Author: benlangmuir
Date: Thu Sep 25 15:55:00 2014
New Revision: 218466

URL: http://llvm.org/viewvc/llvm-project?rev=218466&view=rev
Log:
Move calls to ResolveExceptionSpec out of SetDeclDefaulted and into 
DefineImplicit*

This fixes an assertion failure in CodeGen where we were not resolving
an exception specification.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CodeGenCXX/cxx11-special-members.cpp
    cfe/trunk/test/Misc/ast-dump-color.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=218466&r1=218465&r2=218466&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep 25 15:55:00 2014
@@ -8583,6 +8583,11 @@ void Sema::DefineImplicitDefaultConstruc
     return;
   }
 
+  // The exception specification is needed because we are defining the
+  // function.
+  ResolveExceptionSpec(CurrentLocation,
+                       Constructor->getType()->castAs<FunctionProtoType>());
+
   SourceLocation Loc = Constructor->getLocEnd().isValid()
                            ? Constructor->getLocEnd()
                            : Constructor->getLocation();
@@ -9047,6 +9052,11 @@ void Sema::DefineImplicitDestructor(Sour
     return;
   }
 
+  // The exception specification is needed because we are defining the
+  // function.
+  ResolveExceptionSpec(CurrentLocation,
+                       Destructor->getType()->castAs<FunctionProtoType>());
+
   SourceLocation Loc = Destructor->getLocEnd().isValid()
                            ? Destructor->getLocEnd()
                            : Destructor->getLocation();
@@ -9890,6 +9900,11 @@ void Sema::DefineImplicitCopyAssignment(
     }
   }
 
+  // The exception specification is needed because we are defining the
+  // function.
+  ResolveExceptionSpec(CurrentLocation,
+                       
CopyAssignOperator->getType()->castAs<FunctionProtoType>());
+
   if (Invalid) {
     CopyAssignOperator->setInvalidDecl();
     return;
@@ -10312,6 +10327,11 @@ void Sema::DefineImplicitMoveAssignment(
     }
   }
 
+  // The exception specification is needed because we are defining the
+  // function.
+  ResolveExceptionSpec(CurrentLocation,
+                       
MoveAssignOperator->getType()->castAs<FunctionProtoType>());
+
   if (Invalid) {
     MoveAssignOperator->setInvalidDecl();
     return;
@@ -10481,6 +10501,11 @@ void Sema::DefineImplicitCopyConstructor
         ActOnCompoundStmt(Loc, Loc, None, /*isStmtExpr=*/false).getAs<Stmt>());
   }
 
+  // The exception specification is needed because we are defining the
+  // function.
+  ResolveExceptionSpec(CurrentLocation,
+                       
CopyConstructor->getType()->castAs<FunctionProtoType>());
+
   CopyConstructor->markUsed(Context);
   MarkVTableUsed(CurrentLocation, ClassDecl);
 
@@ -10641,6 +10666,11 @@ void Sema::DefineImplicitMoveConstructor
         Loc, Loc, None, /*isStmtExpr=*/ false).getAs<Stmt>());
   }
 
+  // The exception specification is needed because we are defining the
+  // function.
+  ResolveExceptionSpec(CurrentLocation,
+                       
MoveConstructor->getType()->castAs<FunctionProtoType>());
+
   MoveConstructor->markUsed(Context);
   MarkVTableUsed(CurrentLocation, ClassDecl);
 
@@ -12314,11 +12344,6 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
 
     CheckExplicitlyDefaultedSpecialMember(MD);
 
-    // The exception specification is needed because we are defining the
-    // function.
-    ResolveExceptionSpec(DefaultLoc,
-                         MD->getType()->castAs<FunctionProtoType>());
-
     if (MD->isInvalidDecl())
       return;
 

Modified: cfe/trunk/test/CodeGenCXX/cxx11-special-members.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-special-members.cpp?rev=218466&r1=218465&r2=218466&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/cxx11-special-members.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx11-special-members.cpp Thu Sep 25 15:55:00 2014
@@ -28,5 +28,19 @@ void f2(B &x, B &y) {
 // CHECK: define {{.*}} @_ZN1BaSEOS_(
 // CHECK: call {{.*}} @_ZN1AaSERKS_(
 
+// rdar://18309639 {
+template<int> struct C { C() = default; };
+struct D {
+  C<0> c;
+  D() { }
+};
+template struct C<0>; // was asserting
+void f3() {
+  C<0> a;
+  D b;
+}
+// CHECK: define {{.*}} @_ZN1CILi0EEC1Ev
+// CHECK: define {{.*}} @_ZN1DC1Ev
+
 // CHECK: define {{.*}} @_ZN1BC2EOS_(
 // CHECK: call {{.*}} @_ZN1AC1ERKS_(

Modified: cfe/trunk/test/Misc/ast-dump-color.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-color.cpp?rev=218466&r1=218465&r2=218466&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-dump-color.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-color.cpp Thu Sep 25 15:55:00 2014
@@ -75,16 +75,16 @@ struct Invalid {
 //CHECK: {{^}}[[Blue]]| |   | 
`-[[RESET]][[Blue]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] 
<[[Yellow]]col:6[[RESET]], [[Yellow]]col:22[[RESET]]> Text=" Another 
variable"{{$}}
 //CHECK: {{^}}[[Blue]]| |   
`-[[RESET]][[Blue]]ParagraphComment[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:23:6[[RESET]], 
[[Yellow]]col:44[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| |     
`-[[RESET]][[Blue]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] 
<[[Yellow]]col:6[[RESET]], [[Yellow]]col:44[[RESET]]> Text=" Like the other 
variable, but different"{{$}}
-//CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:33[[RESET]]> 
[[Yellow]]col:33[[RESET]] implicit used[[CYAN]] Mutex[[RESET]] [[Green]]'void 
(void)'[[RESET]] inline{{.*$}}
+//CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:33[[RESET]]> 
[[Yellow]]col:33[[RESET]] implicit used[[CYAN]] Mutex[[RESET]] [[Green]]'void 
(void) noexcept'[[RESET]] inline{{.*$}}
 //CHECK: {{^}}[[Blue]]| | 
`-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> 
[[Yellow]]col:33[[RESET]] implicit[[CYAN]] Mutex[[RESET]] [[Green]]'void (const 
class Mutex &)'[[RESET]] inline{{ .*$}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> 
[[Yellow]]col:33[[RESET]] [[Green]]'const class Mutex &'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| 
`-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> 
[[Yellow]]col:33[[RESET]] implicit[[CYAN]] Mutex[[RESET]] [[Green]]'void (class 
Mutex &&)'[[RESET]] inline{{ .*$}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> 
[[Yellow]]col:33[[RESET]] [[Green]]'class Mutex &&'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], 
[[Yellow]]line:25:3[[RESET]]> [[Yellow]]col:3[[RESET]] referenced[[CYAN]] 
mu1[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]
-//CHECK: {{^}}[[Blue]]| 
`-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'class 
Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void 
(void)'[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]| 
`-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'class 
Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void 
(void) noexcept'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:1[[RESET]], 
[[Yellow]]line:25:8[[RESET]]> [[Yellow]]col:8[[RESET]][[CYAN]] mu2[[RESET]] 
[[Green]]'class Mutex':'class Mutex'[[RESET]]
-//CHECK: {{^}}[[Blue]]| 
`-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'class 
Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void 
(void)'[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]| 
`-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'class 
Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void 
(void) noexcept'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:26:1[[RESET]], 
[[Yellow]]col:5[[RESET]]> [[Yellow]]col:5[[RESET]][[CYAN]] TestExpr[[RESET]] 
[[Green]]'int'[[RESET]]
 //CHECK: {{^}}[[Blue]]| `-[[RESET]][[BLUE]]GuardedByAttr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:29[[RESET]], 
[[Yellow]]col:43[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[MAGENTA]]DeclRefExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:40[[RESET]]> [[Green]]'class 
Mutex':'class Mutex'[[RESET]][[Cyan]] lvalue[[RESET]][[Cyan]][[RESET]] 
[[GREEN]]Var[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]][[CYAN]] 
'mu1'[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]{{$}}
@@ -93,11 +93,11 @@ struct Invalid {
 //CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:29:3[[RESET]], 
[[Yellow]]col:42[[RESET]]> [[Yellow]]col:29[[RESET]] invalid[[CYAN]] 
Invalid[[RESET]] [[Green]]'void (int)'[[RESET]]
 //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:37[[RESET]], [[Yellow]]<invalid 
sloc>[[RESET]]> [[Yellow]]col:42[[RESET]] invalid [[Green]]'int'[[RESET]]
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[BLUE]]NoInlineAttr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:18[[RESET]]>
-//CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:28:8[[RESET]]> 
[[Yellow]]col:8[[RESET]] implicit used[[CYAN]] Invalid[[RESET]] [[Green]]'void 
(void)'[[RESET]] inline noexcept-unevaluated 0x{{[0-9a-fA-F]*}}
+//CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:28:8[[RESET]]> 
[[Yellow]]col:8[[RESET]] implicit used[[CYAN]] Invalid[[RESET]] [[Green]]'void 
(void) noexcept'[[RESET]] inline
 //CHECK: {{^}}[[Blue]]| | 
`-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]>
 //CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] 
implicit[[CYAN]] Invalid[[RESET]] [[Green]]'void (const struct Invalid 
&)'[[RESET]] inline noexcept-unevaluated 0x{{[0-9a-fA-F]*}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] 
[[Green]]'const struct Invalid &'[[RESET]]
 //CHECK: {{^}}[[Blue]]| 
`-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] 
implicit[[CYAN]] Invalid[[RESET]] [[Green]]'void (struct Invalid &&)'[[RESET]] 
inline noexcept-unevaluated 0x{{[0-9a-fA-F]*}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] 
[[Green]]'struct Invalid &&'[[RESET]]
 //CHECK: {{^}}[[Blue]]`-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], 
[[Yellow]]line:30:3[[RESET]]> [[Yellow]]col:3[[RESET]][[CYAN]] Invalid[[RESET]] 
[[Green]]'struct Invalid':'struct Invalid'[[RESET]]
-//CHECK: {{^}}[[Blue]]  
`-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'struct 
Invalid':'struct Invalid'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] 
[[Green]]'void (void)'[[RESET]]
+//CHECK: {{^}}[[Blue]]  
`-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'struct 
Invalid':'struct Invalid'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] 
[[Green]]'void (void) noexcept'[[RESET]]


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to