[cfe-commits] r91882 - in /cfe/trunk/lib/Sema: SemaExpr.cpp SemaInit.cpp

Eli Friedman eli.friedman at gmail.com
Mon Dec 21 18:35:53 PST 2009


Author: efriedma
Date: Mon Dec 21 20:35:53 2009
New Revision: 91882

URL: http://llvm.org/viewvc/llvm-project?rev=91882&view=rev
Log:
Switch compound literals over to InitializationSequence.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Dec 21 20:35:53 2009
@@ -3478,15 +3478,22 @@
   InitializationKind Kind
     = InitializationKind::CreateCast(SourceRange(LParenLoc, RParenLoc), 
                                      /*IsCStyleCast=*/true);
-  if (CheckInitializerTypes(literalExpr, literalType, Entity, Kind))
+  InitializationSequence InitSeq(*this, Entity, Kind, &literalExpr, 1);
+  OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
+                                   MultiExprArg(*this, (void**)&literalExpr, 1),
+                                            &literalType);
+  if (Result.isInvalid())
     return ExprError();
+  InitExpr.release();
+  literalExpr = static_cast<Expr*>(Result.get());
 
   bool isFileScope = getCurFunctionOrMethodDecl() == 0;
   if (isFileScope) { // 6.5.2.5p3
     if (CheckForConstantInitializer(literalExpr, literalType))
       return ExprError();
   }
-  InitExpr.release();
+
+  Result.release();
   
   // FIXME: Store the TInfo to preserve type information better.
   return Owned(new (Context) CompoundLiteralExpr(LParenLoc, literalType,

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Dec 21 20:35:53 2009
@@ -3186,7 +3186,7 @@
       }
     }
 
-    if (Kind.getKind() == InitializationKind::IK_Copy)
+    if (Kind.getKind() == InitializationKind::IK_Copy || Kind.isExplicitCast())
       return Sema::OwningExprResult(S, Args.release()[0]);
 
     unsigned NumArgs = Args.size();





More information about the cfe-commits mailing list