[PATCH] D31588: Fix PR25627: Certain constant local variables must be usable as template arguments (without being odr-used)

Richard Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 16 13:57:33 PDT 2017


rsmith added inline comments.


================
Comment at: lib/Parse/ParseExpr.cpp:203-222
+  // Create the ExpressionEvaluationContext on the stack - but only if asked to.
+  struct EnterExpressionEvaluationContextConditionalRAII {
+    llvm::AlignedCharArray<alignof(EnterExpressionEvaluationContext),
+                           sizeof(EnterExpressionEvaluationContext)>
+        MyStackStorage;
+    const EnterExpressionEvaluationContext *const ConstantEvaluatedContext;
+    EnterExpressionEvaluationContextConditionalRAII(bool CreateIt,
----------------
This seems more complexity than we need. How about factoring out a `ParseConstantExpressionInExprEvalContext` function that doesn't create a context, and then calling it from this function after creating the context?


================
Comment at: lib/Parse/ParseTemplate.cpp:1208-1233
   if (isCXXTypeId(TypeIdAsTemplateArgument)) {
     SourceLocation Loc = Tok.getLocation();
-    TypeResult TypeArg = ParseTypeName(/*Range=*/nullptr,
-                                       Declarator::TemplateTypeArgContext);
+    TypeResult TypeArg =
+        ParseTypeName(/*Range=*/nullptr, Declarator::TemplateTypeArgContext);
     if (TypeArg.isInvalid())
       return ParsedTemplateArgument();
+
----------------
There's a bunch of whitespace changes here. I have no objection to them but they should be handled separately rather than mixed into this change.


https://reviews.llvm.org/D31588





More information about the cfe-commits mailing list