[cfe-commits] r72474 - in /cfe/trunk/lib/Sema: Sema.h SemaDecl.cpp SemaInit.cpp

Anders Carlsson andersca at mac.com
Wed May 27 09:10:10 PDT 2009


Author: andersca
Date: Wed May 27 11:10:08 2009
New Revision: 72474

URL: http://llvm.org/viewvc/llvm-project?rev=72474&view=rev
Log:
Create CXXConstructExprs when constructing via copy initialization.

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=72474&r1=72473&r2=72474&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed May 27 11:10:08 2009
@@ -2630,9 +2630,12 @@
                                    IdentifierInfo &Comp, SourceLocation CmpLoc);
   
   /// type checking declaration initializers (C99 6.7.8)
+  
+  /// FIXME: The VarDecl parameter should not have a default value,
+  /// and all call sites should be audited.
   bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType,
                              SourceLocation InitLoc,DeclarationName InitEntity,
-                             bool DirectInit);
+                             bool DirectInit, VarDecl *VD = 0);
   bool CheckInitList(InitListExpr *&InitList, QualType &DeclType);
   bool CheckForConstantInitializer(Expr *e, QualType t);
   

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=72474&r1=72473&r2=72474&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 27 11:10:08 2009
@@ -2562,7 +2562,7 @@
       VDecl->setInvalidDecl();
     } else if (!VDecl->isInvalidDecl()) {
       if (CheckInitializerTypes(Init, DclT, VDecl->getLocation(),
-                                VDecl->getDeclName(), DirectInit))
+                                VDecl->getDeclName(), DirectInit, VDecl))
         VDecl->setInvalidDecl();
       
       // C++ 3.6.2p2, allow dynamic initialization of static initializers.

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=72474&r1=72473&r2=72474&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed May 27 11:10:08 2009
@@ -18,6 +18,7 @@
 #include "Sema.h"
 #include "clang/Parse/Designator.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include <map>
 using namespace clang;
@@ -116,7 +117,7 @@
 bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
                                  SourceLocation InitLoc,
                                  DeclarationName InitEntity,
-                                 bool DirectInit) {
+                                 bool DirectInit, VarDecl *VD) {
   if (DeclType->isDependentType() || 
       Init->isTypeDependent() || Init->isValueDependent())
     return false;
@@ -160,7 +161,14 @@
                                              InitLoc, Init->getSourceRange(),
                                              InitEntity, 
                                              DirectInit? IK_Direct : IK_Copy);
-        return Constructor == 0;
+        if (!Constructor)
+          return true;
+        
+        // FIXME: What do do if VD is null here?
+        assert(VD && "Must have a var decl to construct into!");
+        Init = CXXConstructExpr::Create(Context, VD, DeclType, Constructor, 
+                                        false, &Init, 1);
+        return false;
       }
       
       //   -- Otherwise (i.e., for the remaining copy-initialization





More information about the cfe-commits mailing list