[cfe-commits] r58218 - in /cfe/trunk: Driver/RewriteObjC.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Expr.h lib/AST/Expr.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaInit.cpp

Chris Lattner sabre at nondot.org
Sun Oct 26 16:43:27 PDT 2008


Author: lattner
Date: Sun Oct 26 18:43:26 2008
New Revision: 58218

URL: http://llvm.org/viewvc/llvm-project?rev=58218&view=rev
Log:
Remember whether an initlist had a designator in the AST.

Modified:
    cfe/trunk/Driver/RewriteObjC.cpp
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=58218&r1=58217&r2=58218&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Sun Oct 26 18:43:26 2008
@@ -2123,8 +2123,9 @@
         // (struct objc_super) { <exprs from above> }
         InitListExpr *ILE = new InitListExpr(SourceLocation(), 
                                              &InitExprs[0], InitExprs.size(), 
-                                             SourceLocation());
-        SuperRep = new CompoundLiteralExpr(SourceLocation(), superType, ILE, false);
+                                             SourceLocation(), false);
+        SuperRep = new CompoundLiteralExpr(SourceLocation(), superType, ILE,
+                                           false);
       }
       // struct objc_super *
       Expr *Unop = new UnaryOperator(SuperRep, UnaryOperator::AddrOf,
@@ -2189,7 +2190,7 @@
         // (struct objc_super) { <exprs from above> }
         InitListExpr *ILE = new InitListExpr(SourceLocation(), 
                                              &InitExprs[0], InitExprs.size(), 
-                                             SourceLocation());
+                                             SourceLocation(), false);
         SuperRep = new CompoundLiteralExpr(SourceLocation(), superType, ILE, false);
       }
       // struct objc_super *

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=58218&r1=58217&r2=58218&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sun Oct 26 18:43:26 2008
@@ -900,7 +900,6 @@
 		DEAEECAE0A5AF0FA0045101B /* Driver */ = {
 			isa = PBXGroup;
 			children = (
-				35A057E60EAE2DDD0069249F /* CacheTokens.cpp */,
 				DE5932CD0AD60FF400BC794C /* clang.cpp */,
 				DE5932CE0AD60FF400BC794C /* clang.h */,
 				359DBBE20E1ACD4700F43FA0 /* AnalysisConsumer.h */,
@@ -908,6 +907,7 @@
 				352028460E2C16820096ADE0 /* Analyses.def */,
 				DE3985780CB8ADC800223765 /* ASTConsumers.h */,
 				DE39857A0CB8ADCB00223765 /* ASTConsumers.cpp */,
+				35A057E60EAE2DDD0069249F /* CacheTokens.cpp */,
 				DE38CF150D8C9DE000A273B6 /* DiagChecker.cpp */,
 				72D16C210D9975EA00E6DA4A /* HTMLPrint.cpp */,
 				DE5932CF0AD60FF400BC794C /* PrintParserCallbacks.cpp */,

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=58218&r1=58217&r2=58218&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Oct 26 18:43:26 2008
@@ -1410,11 +1410,17 @@
 class InitListExpr : public Expr {
   std::vector<Stmt *> InitExprs;
   SourceLocation LBraceLoc, RBraceLoc;
+  
+  /// HadDesignators - Return true if there were any designators in this
+  /// init list expr.  FIXME: this should be replaced by storing the designators
+  /// somehow and updating codegen.
+  bool HadDesignators;
 public:
   InitListExpr(SourceLocation lbraceloc, Expr **initexprs, unsigned numinits,
-               SourceLocation rbraceloc);
+               SourceLocation rbraceloc, bool HadDesignators);
   
   unsigned getNumInits() const { return InitExprs.size(); }
+  bool hadDesignators() const { return HadDesignators; }
   
   const Expr* getInit(unsigned Init) const { 
     assert(Init < getNumInits() && "Initializer access out of range!");

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=58218&r1=58217&r2=58218&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun Oct 26 18:43:26 2008
@@ -204,13 +204,12 @@
 }
 
 InitListExpr::InitListExpr(SourceLocation lbraceloc, 
-                           Expr **initexprs, unsigned numinits,
-                           SourceLocation rbraceloc)
+                           Expr **initExprs, unsigned numInits,
+                           SourceLocation rbraceloc, bool hadDesignators)
   : Expr(InitListExprClass, QualType()),
-    LBraceLoc(lbraceloc), RBraceLoc(rbraceloc)
-{
-  for (unsigned i = 0; i != numinits; i++)
-    InitExprs.push_back(initexprs[i]);
+    LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), HadDesignators(hadDesignators) {
+
+  InitExprs.insert(InitExprs.end(), initExprs, initExprs+numInits);
 }
 
 /// getFunctionType - Return the underlying function type for this block.

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Oct 26 18:43:26 2008
@@ -22,6 +22,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Parse/DeclSpec.h"
+#include "clang/Parse/Designator.h"
 #include "clang/Parse/Scope.h"
 using namespace clang;
 
@@ -1260,7 +1261,8 @@
   // Semantic analysis for initializers is done by ActOnDeclarator() and
   // CheckInitializer() - it requires knowledge of the object being intialized. 
   
-  InitListExpr *E = new InitListExpr(LBraceLoc, InitList, NumInit, RBraceLoc);
+  InitListExpr *E = new InitListExpr(LBraceLoc, InitList, NumInit, RBraceLoc,
+                                     Designators.hasAnyDesignators());
   E->setType(Context.VoidTy); // FIXME: just a place holder for now.
   return E;
 }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sun Oct 26 18:43:26 2008
@@ -87,7 +87,8 @@
   // Synthesize an "implicit" InitListExpr (marked by the invalid source locs).
   InitListExpr *ILE = new InitListExpr(SourceLocation(), 
                                        &InitExprs[0], InitExprs.size(), 
-                                       SourceLocation());
+                                       SourceLocation(),
+                                       ParentIList->hadDesignators());
   ILE->setType(T);
 
   // Modify the parent InitListExpr to point to the implicit InitListExpr.





More information about the cfe-commits mailing list