Skip to content

Commit e262299

Browse files
committed
Change cycle detection to be based off of a warning flag.
llvm-svn: 130898
1 parent a3d5d16 commit e262299

File tree

7 files changed

+13
-22
lines changed

7 files changed

+13
-22
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ def NonGCC : DiagGroup<"non-gcc",
271271
def CXX0xStaticNonIntegralInitializer :
272272
DiagGroup<"c++0x-static-nonintegral-init">;
273273
def CXX0x : DiagGroup<"c++0x-extensions", [CXX0xStaticNonIntegralInitializer]>;
274+
def DelegatingCtorCycles :
275+
DiagGroup<"delegating-ctor-cycles">;
274276

275277
// A warning group for warnings about GCC extensions.
276278
def GNU : DiagGroup<"gnu", [GNUDesignator, VLA]>;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,16 +1009,15 @@ def err_enum_redeclare_scoped_mismatch : Error<
10091009
// C++0x delegating constructors
10101010
def err_delegation_0x_only : Error<
10111011
"delegating constructors are permitted only in C++0x">;
1012-
def err_delegation_unimplemented : Error<
1013-
"delegating constructors are not fully implemented">;
10141012
def err_delegating_initializer_alone : Error<
10151013
"an initializer for a delegating constructor must appear alone">;
1016-
def err_delegating_ctor_cycle : Error<
1017-
"constructor for %0 creates a delegation cycle">;
1014+
def warn_delegating_ctor_cycle : Warning<
1015+
"constructor for %0 creates a delegation cycle">, DefaultError,
1016+
InGroup<DelegatingCtorCycles>;
10181017
def note_it_delegates_to : Note<
1019-
"it delegates to">;
1018+
"it delegates to">, InGroup<DelegatingCtorCycles>;
10201019
def note_which_delegates_to : Note<
1021-
"which delegates to">;
1020+
"which delegates to">, InGroup<DelegatingCtorCycles>;
10221021
def err_delegating_codegen_not_implemented : Error<
10231022
"code generation for delegating constructors not implemented">;
10241023

clang/include/clang/Basic/LangOptions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ class LangOptions {
134134
unsigned MRTD : 1; // -mrtd calling convention
135135
unsigned DelayedTemplateParsing : 1; // Delayed template parsing
136136

137-
// Do we try to detect cycles in delegating constructors?
138-
unsigned CheckDelegatingCtorCycles : 1;
139-
140137
private:
141138
// We declare multibit enums as unsigned because MSVC insists on making enums
142139
// signed. Set/Query these values using accessors.
@@ -235,8 +232,6 @@ class LangOptions {
235232
MRTD = 0;
236233
DelayedTemplateParsing = 0;
237234
ParseUnknownAnytype = 0;
238-
239-
CheckDelegatingCtorCycles = 1;
240235
}
241236

242237
GCMode getGCMode() const { return (GCMode) GC; }

clang/include/clang/Driver/CC1Options.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,6 @@ def fdeprecated_macro : Flag<"-fdeprecated-macro">,
550550
HelpText<"Defines the __DEPRECATED macro">;
551551
def fno_deprecated_macro : Flag<"-fno-deprecated-macro">,
552552
HelpText<"Undefines the __DEPRECATED macro">;
553-
def fno_check_delegating_ctor_cycles : Flag<"-fno-check-delegating-ctor-cycles">,
554-
HelpText<"Turns off delegating constructor cycle detection">;
555553

556554
//===----------------------------------------------------------------------===//
557555
// Header Search Options

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,6 @@ static void LangOptsToArgs(const LangOptions &Opts,
698698
Res.push_back("-fdelayed-template-parsing");
699699
if (Opts.Deprecated)
700700
Res.push_back("-fdeprecated-macro");
701-
702-
if (Opts.CheckDelegatingCtorCycles)
703-
Res.push_back("-fcheck-delegating-ctor-cycles");
704701
}
705702

706703
static void PreprocessorOptsToArgs(const PreprocessorOptions &Opts,
@@ -1569,8 +1566,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
15691566
Opts.MRTD = Args.hasArg(OPT_mrtd);
15701567
Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
15711568
Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);
1572-
Opts.CheckDelegatingCtorCycles
1573-
= !Args.hasArg(OPT_fno_check_delegating_ctor_cycles);
15741569

15751570
// Record whether the __DEPRECATED define was requested.
15761571
Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,

clang/lib/Sema/Sema.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ void Sema::ActOnEndOfTranslationUnit() {
474474

475475
}
476476

477-
if (LangOpts.CPlusPlus0x && LangOpts.CheckDelegatingCtorCycles)
477+
if (LangOpts.CPlusPlus0x &&
478+
Diags.getDiagnosticLevel(diag::warn_delegating_ctor_cycle,
479+
SourceLocation())
480+
!= Diagnostic::Ignored)
478481
CheckDelegatingCtorCycles();
479482

480483
// If there were errors, disable 'unused' warnings since they will mostly be

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,8 +2085,7 @@ Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
20852085
DiagnoseUseOfDecl(Dtor, Initializer->getSourceLocation());
20862086
}
20872087

2088-
if (LangOpts.CheckDelegatingCtorCycles)
2089-
DelegatingCtorDecls.push_back(Constructor);
2088+
DelegatingCtorDecls.push_back(Constructor);
20902089

20912090
return false;
20922091
}
@@ -7984,7 +7983,7 @@ void DelegatingCycleHelper(CXXConstructorDecl* Ctor,
79847983
// If we haven't diagnosed this cycle yet, do so now.
79857984
if (!Invalid.count(TCanonical)) {
79867985
S.Diag((*Ctor->init_begin())->getSourceLocation(),
7987-
diag::err_delegating_ctor_cycle)
7986+
diag::warn_delegating_ctor_cycle)
79887987
<< Ctor;
79897988

79907989
// Don't add a note for a function delegating directo to itself.

0 commit comments

Comments
 (0)