[llvm-branch-commits] [cfe-branch] r156683 - in /cfe/branches/release_31: ./ include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp test/SemaCXX/implicit-exception-spec.cpp test/SemaCXX/warn-unreachable.cpp
Bill Wendling
isanbard at gmail.com
Fri May 11 17:29:58 PDT 2012
Author: void
Date: Fri May 11 19:29:58 2012
New Revision: 156683
URL: http://llvm.org/viewvc/llvm-project?rev=156683&view=rev
Log:
Merging r155293:
------------------------------------------------------------------------
r155293 | rsmith | 2012-04-21 11:42:51 -0700 (Sat, 21 Apr 2012) | 4 lines
Fix regression in r154844. If necessary, defer computing adjusted destructor
exception specifications in C++11 until after we've parsed the exception
specifications for nested classes.
------------------------------------------------------------------------
Modified:
cfe/branches/release_31/ (props changed)
cfe/branches/release_31/include/clang/Sema/Sema.h
cfe/branches/release_31/lib/Parse/ParseDeclCXX.cpp
cfe/branches/release_31/lib/Sema/SemaDecl.cpp
cfe/branches/release_31/lib/Sema/SemaDeclCXX.cpp
cfe/branches/release_31/test/SemaCXX/implicit-exception-spec.cpp
cfe/branches/release_31/test/SemaCXX/warn-unreachable.cpp (props changed)
Propchange: cfe/branches/release_31/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 11 19:29:58 2012
@@ -1,3 +1,3 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:155076,155218,155278-155279,155289,155342,155356,155424,155534-155535,155576,155608,155670,155728,155788,155803,155823,155860,155910,155975,156047,156322
+/cfe/trunk:155076,155218,155278-155279,155289,155293,155342,155356,155424,155534-155535,155576,155608,155670,155728,155788,155803,155823,155860,155910,155975,156047,156322
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_31/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_31/include/clang/Sema/Sema.h?rev=156683&r1=156682&r2=156683&view=diff
==============================================================================
--- cfe/branches/release_31/include/clang/Sema/Sema.h (original)
+++ cfe/branches/release_31/include/clang/Sema/Sema.h Fri May 11 19:29:58 2012
@@ -331,6 +331,11 @@
/// cycle detection at the end of the TU.
DelegatingCtorDeclsType DelegatingCtorDecls;
+ /// \brief All the destructors seen during a class definition that had their
+ /// exception spec computation delayed because it depended on an unparsed
+ /// exception spec.
+ SmallVector<CXXDestructorDecl*, 2> DelayedDestructorExceptionSpecs;
+
/// \brief All the overriding destructors seen during a class definition
/// (there could be multiple due to nested classes) that had their exception
/// spec checks delayed, plus the overridden destructor.
@@ -3196,7 +3201,8 @@
/// C++11 says that user-defined destructors with no exception spec get one
/// that looks as if the destructor was implicitly declared.
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl,
- CXXDestructorDecl *Destructor);
+ CXXDestructorDecl *Destructor,
+ bool WasDelayed = false);
/// \brief Declare all inherited constructors for the given class.
///
@@ -4034,6 +4040,7 @@
SourceLocation LBrac,
SourceLocation RBrac,
AttributeList *AttrList);
+ void ActOnFinishCXXMemberDecls();
void ActOnReenterTemplateScope(Scope *S, Decl *Template);
void ActOnReenterDeclaratorTemplateScope(Scope *S, DeclaratorDecl *D);
Modified: cfe/branches/release_31/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_31/lib/Parse/ParseDeclCXX.cpp?rev=156683&r1=156682&r2=156683&view=diff
==============================================================================
--- cfe/branches/release_31/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/branches/release_31/lib/Parse/ParseDeclCXX.cpp Fri May 11 19:29:58 2012
@@ -2369,6 +2369,10 @@
SourceLocation SavedPrevTokLocation = PrevTokLocation;
ParseLexedAttributes(getCurrentClass());
ParseLexedMethodDeclarations(getCurrentClass());
+
+ // We've finished with all pending member declarations.
+ Actions.ActOnFinishCXXMemberDecls();
+
ParseLexedMemberInitializers(getCurrentClass());
ParseLexedMethodDefs(getCurrentClass());
PrevTokLocation = SavedPrevTokLocation;
Modified: cfe/branches/release_31/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_31/lib/Sema/SemaDecl.cpp?rev=156683&r1=156682&r2=156683&view=diff
==============================================================================
--- cfe/branches/release_31/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/release_31/lib/Sema/SemaDecl.cpp Fri May 11 19:29:58 2012
@@ -9784,21 +9784,6 @@
if (!Completed)
Record->completeDefinition();
- // Now that the record is complete, do any delayed exception spec checks
- // we were missing.
- while (!DelayedDestructorExceptionSpecChecks.empty()) {
- const CXXDestructorDecl *Dtor =
- DelayedDestructorExceptionSpecChecks.back().first;
- if (Dtor->getParent() != Record)
- break;
-
- assert(!Dtor->getParent()->isDependentType() &&
- "Should not ever add destructors of templates into the list.");
- CheckOverridingFunctionExceptionSpec(Dtor,
- DelayedDestructorExceptionSpecChecks.back().second);
- DelayedDestructorExceptionSpecChecks.pop_back();
- }
-
} else {
ObjCIvarDecl **ClsFields =
reinterpret_cast<ObjCIvarDecl**>(RecFields.data());
Modified: cfe/branches/release_31/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_31/lib/Sema/SemaDeclCXX.cpp?rev=156683&r1=156682&r2=156683&view=diff
==============================================================================
--- cfe/branches/release_31/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/release_31/lib/Sema/SemaDeclCXX.cpp Fri May 11 19:29:58 2012
@@ -7319,15 +7319,42 @@
}
}
+/// \brief Perform any semantic analysis which needs to be delayed until all
+/// pending class member declarations have been parsed.
+void Sema::ActOnFinishCXXMemberDecls() {
+ // Now we have parsed all exception specifications, determine the implicit
+ // exception specifications for destructors.
+ for (unsigned i = 0, e = DelayedDestructorExceptionSpecs.size();
+ i != e; ++i) {
+ CXXDestructorDecl *Dtor = DelayedDestructorExceptionSpecs[i];
+ AdjustDestructorExceptionSpec(Dtor->getParent(), Dtor, true);
+ }
+ DelayedDestructorExceptionSpecs.clear();
+
+ // Perform any deferred checking of exception specifications for virtual
+ // destructors.
+ for (unsigned i = 0, e = DelayedDestructorExceptionSpecChecks.size();
+ i != e; ++i) {
+ const CXXDestructorDecl *Dtor =
+ DelayedDestructorExceptionSpecChecks[i].first;
+ assert(!Dtor->getParent()->isDependentType() &&
+ "Should not ever add destructors of templates into the list.");
+ CheckOverridingFunctionExceptionSpec(Dtor,
+ DelayedDestructorExceptionSpecChecks[i].second);
+ }
+ DelayedDestructorExceptionSpecChecks.clear();
+}
+
void Sema::AdjustDestructorExceptionSpec(CXXRecordDecl *classDecl,
- CXXDestructorDecl *destructor) {
+ CXXDestructorDecl *destructor,
+ bool WasDelayed) {
// C++11 [class.dtor]p3:
// A declaration of a destructor that does not have an exception-
// specification is implicitly considered to have the same exception-
// specification as an implicit declaration.
const FunctionProtoType *dtorType = destructor->getType()->
getAs<FunctionProtoType>();
- if (dtorType->hasExceptionSpec())
+ if (!WasDelayed && dtorType->hasExceptionSpec())
return;
ImplicitExceptionSpecification exceptSpec =
@@ -7344,6 +7371,14 @@
destructor->setType(ty);
+ // If we can't compute the exception specification for this destructor yet
+ // (because it depends on an exception specification which we have not parsed
+ // yet), make a note that we need to try again when the class is complete.
+ if (epi.ExceptionSpecType == EST_Delayed) {
+ assert(!WasDelayed && "couldn't compute destructor exception spec");
+ DelayedDestructorExceptionSpecs.push_back(destructor);
+ }
+
// FIXME: If the destructor has a body that could throw, and the newly created
// spec doesn't allow exceptions, we should emit a warning, because this
// change in behavior can break conforming C++03 programs at runtime.
Modified: cfe/branches/release_31/test/SemaCXX/implicit-exception-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_31/test/SemaCXX/implicit-exception-spec.cpp?rev=156683&r1=156682&r2=156683&view=diff
==============================================================================
--- cfe/branches/release_31/test/SemaCXX/implicit-exception-spec.cpp (original)
+++ cfe/branches/release_31/test/SemaCXX/implicit-exception-spec.cpp Fri May 11 19:29:58 2012
@@ -57,3 +57,33 @@
} t; // expected-note {{has no default constructor}}
};
}
+
+namespace ImplicitDtorExceptionSpec {
+ struct A {
+ virtual ~A();
+
+ struct Inner {
+ ~Inner() throw();
+ };
+ Inner inner;
+ };
+
+ struct B {
+ virtual ~B() {} // expected-note {{here}}
+ };
+
+ struct C : B {
+ virtual ~C() {}
+ A a;
+ };
+
+ struct D : B {
+ ~D(); // expected-error {{more lax than base}}
+ struct E {
+ ~E();
+ struct F {
+ ~F() throw(A);
+ } f;
+ } e;
+ };
+}
Propchange: cfe/branches/release_31/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 11 19:29:58 2012
@@ -1,2 +1,2 @@
/cfe/branches/type-system-rewrite/test/SemaCXX/warn-unreachable.cpp:134693-134817
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,155076,155218,155278-155279,155289,155342,155356,155424,155534-155535,155576,155608,155670,155728,155788,155803,155823,155860,155910,155975,156047
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,155076,155218,155278-155279,155289,155293,155342,155356,155424,155534-155535,155576,155608,155670,155728,155788,155803,155823,155860,155910,155975,156047
More information about the llvm-branch-commits
mailing list