[PATCH] D45194: [Sema] Defer checking constexpr lambda until after we've finished the lambda class.

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 4 13:46:01 PDT 2018


erik.pilkington added inline comments.


================
Comment at: clang/lib/AST/ExprConstant.cpp:4312
+  } else if (MD && isLambdaCallOperator(MD)
+             && !Info.checkingPotentialConstantExpression()) {
     // We're in a lambda; determine the lambda capture field maps.
----------------
faisalv wrote:
> How about we add a comment here along the lines of: Do not attempt to create the variable-reference to closure data member map while 'constexpr' checking a lambda's function call operator (standard reference).  Currently constpexpr checking is done right after the end of the function definition for the syntehsized call operator marked explicitly constexpr - which occurs prior to adding the captures map to the closure object.  Alternatively we could have conditioned the check at the end of the function body to bypass lambda call operators and then invoke the constexpr check once the lambda is completely processed.  
> 
> Between you and me, I'm a little torn about this approach - if you can make an argument to consider your approach over this one - i think i could be swayed (if i'm not already ;) - unless of course richard weighs in as a tie breaker.
Sure, added a version of that comment in the patch. I could go either way here too, but I like your approach because a) it makes the constant evaluator do just the work that is necessary when checkingPotentialConstantExpression(), and b) special-casing here is simpler and more precise than doing it in Sema.


https://reviews.llvm.org/D45194





More information about the cfe-commits mailing list