diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-26 23:43:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-26 23:43:26 +0000 |
commit | 07d754acf11590af580bcc4b8816105a60ebb8fe (patch) | |
tree | 826faaa9f03a4d583f6fc74cf49b69879832d94a | |
parent | 248388e3131be2fda43387653ced370b6aaf95b2 (diff) | |
download | bcm5719-llvm-07d754acf11590af580bcc4b8816105a60ebb8fe.tar.gz bcm5719-llvm-07d754acf11590af580bcc4b8816105a60ebb8fe.zip |
Remember whether an initlist had a designator in the AST.
llvm-svn: 58218
-rw-r--r-- | clang/Driver/RewriteObjC.cpp | 7 | ||||
-rw-r--r-- | clang/clang.xcodeproj/project.pbxproj | 2 | ||||
-rw-r--r-- | clang/include/clang/AST/Expr.h | 8 | ||||
-rw-r--r-- | clang/lib/AST/Expr.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 3 |
6 files changed, 22 insertions, 13 deletions
diff --git a/clang/Driver/RewriteObjC.cpp b/clang/Driver/RewriteObjC.cpp index 3e8216e6679..b62b5fa2372 100644 --- a/clang/Driver/RewriteObjC.cpp +++ b/clang/Driver/RewriteObjC.cpp @@ -2123,8 +2123,9 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) { // (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 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) { // (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 * diff --git a/clang/clang.xcodeproj/project.pbxproj b/clang/clang.xcodeproj/project.pbxproj index 71fddf561cf..407f193e31b 100644 --- a/clang/clang.xcodeproj/project.pbxproj +++ b/clang/clang.xcodeproj/project.pbxproj @@ -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 */, diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index de4f4f75bb1..e2db4032f83 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -1410,11 +1410,17 @@ public: 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!"); diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index c20ca25f283..f18586fb709 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -204,13 +204,12 @@ const char *BinaryOperator::getOpcodeStr(Opcode Op) { } 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. diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index fee94568b78..5304fd9f7a5 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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 @@ ActOnInitList(SourceLocation LBraceLoc, ExprTy **initlist, unsigned NumInit, // 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; } diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 12ca3820dd4..0e627a1aab4 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -87,7 +87,8 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList, // 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. |