]> granicus.if.org Git - clang/commitdiff
InitializeVarWithConstructor now returns true on failure.
authorAnders Carlsson <andersca@mac.com>
Tue, 25 Aug 2009 05:18:00 +0000 (05:18 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 25 Aug 2009 05:18:00 +0000 (05:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79976 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp

index a60c60c4e158167bdc7162aa1c4f84533e4bae26..363f3ade7901dc32aa0fe60c2d448e138d66e6e1 100644 (file)
@@ -1747,7 +1747,7 @@ public:
 
   /// InitializeVarWithConstructor - Creates an CXXConstructExpr
   /// and sets it as the initializer for the the passed in VarDecl.
-  void InitializeVarWithConstructor(VarDecl *VD, 
+  bool InitializeVarWithConstructor(VarDecl *VD, 
                                     CXXConstructorDecl *Constructor,
                                     QualType DeclInitType, 
                                     Expr **Exprs, unsigned NumExprs);
index 6668aeaac559f3a5ef284ab73375f71bc0176b3a..99c1338fbae21ba5e21db605327199ab791d2e79 100644 (file)
@@ -3257,8 +3257,11 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
         if (!Constructor)
           Var->setInvalidDecl();
         else { 
-          if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor())
-            InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0);
+          if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor()) {
+            if (InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0))
+              Var->setInvalidDecl();
+          }
+          
           FinalizeVarWithDestructor(Var, InitType);
         }
       }
index 17e88b3512e67fa9ec26f5dc60c2397000bda34e..f4b5a57ed532a91c70962f8e8435e048bcf76e0d 100644 (file)
@@ -2467,18 +2467,21 @@ Sema::BuildCXXConstructExpr(QualType DeclInitType,
   return Owned(Temp);
 }
 
-void Sema::InitializeVarWithConstructor(VarDecl *VD, 
+bool Sema::InitializeVarWithConstructor(VarDecl *VD, 
                                         CXXConstructorDecl *Constructor,
                                         QualType DeclInitType, 
                                         Expr **Exprs, unsigned NumExprs) {
   OwningExprResult TempResult = BuildCXXConstructExpr(DeclInitType, Constructor, 
                                                       Exprs, NumExprs);
-  assert(!TempResult.isInvalid() && "FIXME: Error handling");
+  if (TempResult.isInvalid())
+    return true;
   
   Expr *Temp = TempResult.takeAs<Expr>();
   MarkDeclarationReferenced(VD->getLocation(), Constructor);
   Temp = MaybeCreateCXXExprWithTemporaries(Temp, /*DestroyTemps=*/true);
   VD->setInit(Context, Temp);
+  
+  return false;
 }
 
 void Sema::FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType)
@@ -2555,8 +2558,9 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
       RealDecl->setInvalidDecl();
     else {
       VDecl->setCXXDirectInitializer(true);
-      InitializeVarWithConstructor(VDecl, Constructor, DeclInitType, 
-                                   (Expr**)Exprs.release(), NumExprs);
+      if (InitializeVarWithConstructor(VDecl, Constructor, DeclInitType, 
+                                       (Expr**)Exprs.release(), NumExprs))
+        RealDecl->setInvalidDecl();
       FinalizeVarWithDestructor(VDecl, DeclInitType);
     }
     return;