[PATCH] D21145: [Sema] Fix crash on valid where instantiation of lambda cannot access type of 'this'

Faisal Vali via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 11 06:49:19 PDT 2016


faisalv added inline comments.

================
Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3922
@@ -3920,1 +3921,3 @@
+          *this, Var->getDeclContext(),
+          /*NewThisContext=*/!isLambdaCallOperator(getCurLexicalContext()));
       Init = SubstInitializer(OldVar->getInit(), TemplateArgs,
----------------
I don't think this is the right fix.  In my opinion, the fix should be to teach getCurrentThisType to recognize that we are in a context where a  lambda is being 'transformed' and correctly return the type of 'this', regardless of the containing-context of the lambda.  Also see the Richard-inspired FIXME to attempt to comprehensively handle such cases.

getCurrentThisType is broken though in some other ways currently (handling the cv qualification of lambda 'this' captures by value) - and i'm going to commit my patch to fix that later today.  Let me know if you'd like me to work on this next, or would prefer to take a crack at it yourself.

Thanks for looking into this - apologies for the delay in feedback.



http://reviews.llvm.org/D21145





More information about the cfe-commits mailing list