r253590 - Change the expression evaluation context from Unevaluated to ConstantEvaluated while substituting into non-type template argument defaults.

Faisal Vali via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 19 11:20:17 PST 2015


Author: faisalv
Date: Thu Nov 19 13:20:17 2015
New Revision: 253590

URL: http://llvm.org/viewvc/llvm-project?rev=253590&view=rev
Log:
Change the expression evaluation context from Unevaluated to ConstantEvaluated while substituting into non-type template argument defaults.

Also address a typo from a prior patch that performed a similar fix during Parsing of default non-type template arguments.  I left the RAII ExpressionEvaluationContext variable Name as Unevaluated though we had switched the context to ConstantEvaluated.

There should be no functionality change here - since when expression evaluation context is popped off, for the most part these two contexts currently behave similarly in regards to lambda diagnostics and odr-use tracking.

Like its parsing counterpart, this patch presages the advent of constexpr lambda patches...

Modified:
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=253590&r1=253589&r2=253590&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu Nov 19 13:20:17 2015
@@ -695,8 +695,8 @@ Parser::ParseNonTypeTemplateParameter(un
     //   end of the template-parameter-list rather than a greater-than
     //   operator.
     GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
-    EnterExpressionEvaluationContext Unevaluated(Actions,
-                                                 Sema::ConstantEvaluated);
+    EnterExpressionEvaluationContext ConstantEvaluated(Actions,
+                                                       Sema::ConstantEvaluated);
 
     DefaultArg = Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
     if (DefaultArg.isInvalid())

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=253590&r1=253589&r2=253590&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Nov 19 13:20:17 2015
@@ -3280,7 +3280,8 @@ SubstDefaultTemplateArgument(Sema &SemaR
     TemplateArgLists.addOuterTemplateArguments(None);
 
   Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
-  EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
+  EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+                                                     Sema::ConstantEvaluated);
   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
 }
 




More information about the cfe-commits mailing list