[cfe-dev] Adding type source info to CompoundLiteralExpr.

John McCall rjmccall at apple.com
Mon Jan 18 11:36:35 PST 2010


On Jan 17, 2010, at 11:36 AM, Enea Zaffanella wrote:
> The attached patch adds type source info to compound literals.

Looks good!  Committed as r93752, with one tweak:

@@ -3849,15 +3849,17 @@
 template<typename Derived>
 Sema::OwningExprResult
 TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) {
-  QualType T;
+  TypeSourceInfo *OldT;
+  TypeSourceInfo *NewT;
   {
     // FIXME: Source location isn't quite accurate.
     SourceLocation FakeTypeLoc
       = SemaRef.PP.getLocForEndOfToken(E->getLParenLoc());
     TemporaryBase Rebase(*this, FakeTypeLoc, DeclarationName());
 
-    T = getDerived().TransformType(E->getType());
-    if (T.isNull())
+    OldT = E->getTypeSourceInfo();
+    NewT = getDerived().TransformType(OldT);
+    if (!NewT)
       return SemaRef.ExprError();
   }
 
This rebase is being done purely to give slightly better locations when rebuilding the type, so you can kill it since you're rebuilding an actual TypeSourceInfo.

John.



More information about the cfe-dev mailing list