[cfe-commits] r79149 - in /cfe/trunk/lib/Sema: Sema.h SemaDeclCXX.cpp SemaExprCXX.cpp SemaInit.cpp TreeTransform.h

Anders Carlsson andersca at mac.com
Sat Aug 15 16:41:37 PDT 2009


Author: andersca
Date: Sat Aug 15 18:41:35 2009
New Revision: 79149

URL: http://llvm.org/viewvc/llvm-project?rev=79149&view=rev
Log:
BuildCXXConstructExpr doesn't need to take an ASTContext.

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/lib/Sema/TreeTransform.h

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sat Aug 15 18:41:35 2009
@@ -1692,12 +1692,13 @@
   
   /// BuildCXXConstructExpr - Creates a complete call to a constructor,
   /// including handling of its default argument expressions.
-  Expr * BuildCXXConstructExpr(ASTContext &C,
-                               QualType DeclInitType,
-                               CXXConstructorDecl *Constructor,
-                               bool Elidable,
-                               Expr **Exprs, unsigned NumExprs);
+  Expr *BuildCXXConstructExpr(QualType DeclInitType,
+                              CXXConstructorDecl *Constructor,
+                              bool Elidable,
+                              Expr **Exprs, unsigned NumExprs);
 
+  Expr *BuildCXXCopyConstructExpr(Expr *Expr);
+  
   /// FinalizeVarWithDestructor - Prepare for calling destructor on the
   /// constructed variable.
   void FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Aug 15 18:41:35 2009
@@ -2379,12 +2379,11 @@
 
 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
 /// including handling of its default argument expressions.
-Expr *Sema::BuildCXXConstructExpr(ASTContext &C,
-                                  QualType DeclInitType, 
+Expr *Sema::BuildCXXConstructExpr(QualType DeclInitType, 
                                   CXXConstructorDecl *Constructor,
                                   bool Elidable,
                                   Expr **Exprs, unsigned NumExprs) {
-  CXXConstructExpr *Temp = CXXConstructExpr::Create(C, DeclInitType, 
+  CXXConstructExpr *Temp = CXXConstructExpr::Create(Context, DeclInitType, 
                                                     Constructor, 
                                                     Elidable, Exprs, NumExprs);
   // default arguments must be added to constructor call expression.
@@ -2403,7 +2402,7 @@
       for (unsigned I = 0, N = E->getNumTemporaries(); I != N; ++I)
         ExprTemporaries.push_back(E->getTemporary(I));
     }
-    Expr *Arg = CXXDefaultArgExpr::Create(C, FDecl->getParamDecl(j));
+    Expr *Arg = CXXDefaultArgExpr::Create(Context, FDecl->getParamDecl(j));
     Temp->setArg(j, Arg);
   }
   return Temp;
@@ -2413,8 +2412,7 @@
                                         CXXConstructorDecl *Constructor,
                                         QualType DeclInitType, 
                                         Expr **Exprs, unsigned NumExprs) {
-  Expr *Temp = BuildCXXConstructExpr(Context,
-                                     DeclInitType, Constructor, 
+  Expr *Temp = BuildCXXConstructExpr(DeclInitType, Constructor, 
                                      false, Exprs, NumExprs);  
   MarkDeclarationReferenced(VD->getLocation(), Constructor);
   Temp = MaybeCreateCXXExprWithTemporaries(Temp, /*DestroyTemps=*/true);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sat Aug 15 18:41:35 2009
@@ -905,8 +905,8 @@
     // FIXME: Keep track of whether the copy constructor is elidable or not.
     bool Elidable = (isa<CallExpr>(From) || 
                      isa<CXXTemporaryObjectExpr>(From));
-    From = BuildCXXConstructExpr(Context, ToType, 
-                                 SCS.CopyConstructor, Elidable, &From, 1);
+    From = BuildCXXConstructExpr(ToType, SCS.CopyConstructor, 
+                                 Elidable, &From, 1);
     return false;
   }
 
@@ -1558,6 +1558,9 @@
 }
 
 Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) {
+  if (!Context.getLangOptions().CPlusPlus)
+    return Owned(E);
+  
   const RecordType *RT = E->getType()->getAs<RecordType>();
   if (!RT)
     return Owned(E);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sat Aug 15 18:41:35 2009
@@ -178,8 +178,7 @@
           return true;
         bool Elidable = (isa<CallExpr>(Init) || 
                          isa<CXXTemporaryObjectExpr>(Init));
-        Init = BuildCXXConstructExpr(Context,
-                                     DeclType, Constructor, Elidable, &Init, 1);
+        Init = BuildCXXConstructExpr(DeclType, Constructor, Elidable, &Init, 1);
         Init = MaybeCreateCXXExprWithTemporaries(Init, /*DestroyTemps=*/true);
         return false;
       }

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

==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Sat Aug 15 18:41:35 2009
@@ -1173,8 +1173,7 @@
                                            MultiExprArg Args) {
     unsigned NumArgs = Args.size();
     Expr **ArgsExprs = (Expr **)Args.release();
-    return getSema().Owned(SemaRef.BuildCXXConstructExpr(getSema().Context, T,
-                                                         Constructor,
+    return getSema().Owned(SemaRef.BuildCXXConstructExpr(T, Constructor,
                                                          IsElidable,
                                                          ArgsExprs,
                                                          NumArgs));





More information about the cfe-commits mailing list