[cfe-commits] r45504 - in /cfe/trunk: AST/StmtSerialization.cpp Driver/RewriteTest.cpp Sema/SemaExpr.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Expr.h

Chris Lattner sabre at nondot.org
Wed Jan 2 13:46:27 PST 2008


Author: lattner
Date: Wed Jan  2 15:46:24 2008
New Revision: 45504

URL: http://llvm.org/viewvc/llvm-project?rev=45504&view=rev
Log:
Compute the proper sourcerange for an CompoundLiteralExpr.

Modified:
    cfe/trunk/AST/StmtSerialization.cpp
    cfe/trunk/Driver/RewriteTest.cpp
    cfe/trunk/Sema/SemaExpr.cpp
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtSerialization.cpp?rev=45504&r1=45503&r2=45504&view=diff

==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Wed Jan  2 15:46:24 2008
@@ -387,13 +387,15 @@
 
 void CompoundLiteralExpr::EmitImpl(Serializer& S) const {
   S.Emit(getType());
+  S.Emit(getLParenLoc());
   S.EmitOwnedPtr(Init);
 }
 
 CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D) {
   QualType Q = QualType::ReadVal(D);
+  SourceLocation L = SourceLocation::ReadVal(D);
   Expr* Init = D.ReadOwnedPtr<Expr>();
-  return new CompoundLiteralExpr(Q,Init);
+  return new CompoundLiteralExpr(L, Q, Init);
 }
 
 void CompoundStmt::EmitImpl(Serializer& S) const {

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=45504&r1=45503&r2=45504&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Jan  2 15:46:24 2008
@@ -1454,7 +1454,8 @@
       InitListExpr *ILE = new InitListExpr(SourceLocation(), 
                                            &InitExprs[0], InitExprs.size(), 
                                            SourceLocation());
-      CompoundLiteralExpr *SuperRep = new CompoundLiteralExpr(superType, ILE);
+      CompoundLiteralExpr *SuperRep = new CompoundLiteralExpr(SourceLocation(),
+                                                              superType, ILE);
       // struct objc_super *
       Expr *Unop = new UnaryOperator(SuperRep, UnaryOperator::AddrOf,
                                Context->getPointerType(SuperRep->getType()), 
@@ -1506,7 +1507,8 @@
       InitListExpr *ILE = new InitListExpr(SourceLocation(), 
                                            &InitExprs[0], InitExprs.size(), 
                                            SourceLocation());
-      CompoundLiteralExpr *SuperRep = new CompoundLiteralExpr(superType, ILE);
+      CompoundLiteralExpr *SuperRep = new CompoundLiteralExpr(SourceLocation(),
+                                                              superType, ILE);
       // struct objc_super *
       Expr *Unop = new UnaryOperator(SuperRep, UnaryOperator::AddrOf,
                                Context->getPointerType(SuperRep->getType()), 

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

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Wed Jan  2 15:46:24 2008
@@ -704,7 +704,7 @@
   if (CheckInitializer(literalExpr, literalType, false))
     return 0;
 
-  return new CompoundLiteralExpr(literalType, literalExpr);
+  return new CompoundLiteralExpr(LParenLoc, literalType, literalExpr);
 }
 
 Action::ExprResult Sema::
@@ -1982,7 +1982,7 @@
   
   // Otherwise, create a compound literal expression as the base, and
   // iteratively process the offsetof designators.
-  Expr *Res = new CompoundLiteralExpr(ArgTy, 0);
+  Expr *Res = new CompoundLiteralExpr(SourceLocation(), ArgTy, 0);
   
   // offsetof with non-identifier designators (e.g. "offsetof(x, a.b[c])") are a
   // GCC extension, diagnose them.

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

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Wed Jan  2 15:46:24 2008
@@ -796,7 +796,6 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
-			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
 			projectDirPath = "";

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Jan  2 15:46:24 2008
@@ -723,18 +723,27 @@
 /// CompoundLiteralExpr - [C99 6.5.2.5] 
 ///
 class CompoundLiteralExpr : public Expr {
+  /// LParenLoc - If non-null, this is the location of the left paren in a
+  /// compound literal like "(int){4}".  This can be null if this is a
+  /// synthesized compound expression.
+  SourceLocation LParenLoc;
   Expr *Init;
 public:
-  CompoundLiteralExpr(QualType ty, Expr *init) : 
-    Expr(CompoundLiteralExprClass, ty), Init(init) {}
+  CompoundLiteralExpr(SourceLocation lparenloc, QualType ty, Expr *init) : 
+    Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init) {}
   
   const Expr *getInitializer() const { return Init; }
   Expr *getInitializer() { return Init; }
   
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+  
   virtual SourceRange getSourceRange() const {
-    if (Init)
+    // FIXME: Init should never be null.
+    if (!Init)
+      return SourceRange();
+    if (LParenLoc.isInvalid())
       return Init->getSourceRange();
-    return SourceRange();
+    return SourceRange(LParenLoc, Init->getLocEnd());
   }
 
   static bool classof(const Stmt *T) { 





More information about the cfe-commits mailing list