[cfe-commits] [PATCH] Sema: have BuildExpressionFromIntegralTemplateArgument produce well-formed IntegerLiterals

Craig Silverstein csilvers at google.com
Fri Nov 26 15:02:12 PST 2010


I'm not at a level where I can ok the patch or not, but I have sitting
in my local tree a similar patch, from alp (below).  But I understand
it wasn't committed yet because there were problems elsewhere caused
by the intermingling of ints and enums, and a 'proper' fix required
fixing all those other places too.  I don't know the details.

Either way, I'm not sure if the differences between these two patches
are meaningful, and if so, which is 'more correct'.

craig

===
--- tools/clang/lib/Sema/SemaTemplate.cpp 2010-11-22 22:11:40.000000000 -0800
+++ tools/clang/lib/Sema/SemaTemplate.cpp 2010-11-22 22:33:40.589728000 -0800
@@ -3455,6 +3455,15 @@
                                             T,
                                             Loc));
 
+  if (const EnumType *Enum = T->getAs<EnumType>()) {
+    QualType IntegerType = Context.getCanonicalType(
+                                            Enum->getDecl()->getIntegerType());
+    Expr *E = IntegerLiteral::Create(Context, *Arg.getAsIntegral(),
+                                     IntegerType, Loc);
+    ImpCastExprToType(E, T, CK_NoOp);
+    return Owned(E);
+  }
+
   return Owned(IntegerLiteral::Create(Context, *Arg.getAsIntegral(),
   T, Loc));
 }



More information about the cfe-commits mailing list