[cfe-commits] r79976 - in /cfe/trunk/lib/Sema: Sema.h SemaDecl.cpp SemaDeclCXX.cpp
Anders Carlsson
andersca at mac.com
Mon Aug 24 22:18:01 PDT 2009
Author: andersca
Date: Tue Aug 25 00:18:00 2009
New Revision: 79976
URL: http://llvm.org/viewvc/llvm-project?rev=79976&view=rev
Log:
InitializeVarWithConstructor now returns true on failure.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=79976&r1=79975&r2=79976&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Aug 25 00:18:00 2009
@@ -1747,7 +1747,7 @@
/// 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);
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=79976&r1=79975&r2=79976&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug 25 00:18:00 2009
@@ -3257,8 +3257,11 @@
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);
}
}
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=79976&r1=79975&r2=79976&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Aug 25 00:18:00 2009
@@ -2467,18 +2467,21 @@
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 @@
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;
More information about the cfe-commits
mailing list