Fix PR32831 (Try Again): 'this' capture while instantiating generic lambda call opera...
authorFaisal Vali <faisalv@yahoo.com>
Tue, 2 May 2017 20:56:34 +0000 (20:56 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Tue, 2 May 2017 20:56:34 +0000 (20:56 +0000)
commit999f27e3739efbe43edd1baa09dedd9dcea68d6f
treea8917fe0ceede6935aa02b2275b47826e6abab0e
parentc7695a8e4565afb256aad1a705ef292bc3625a36
Fix PR32831 (Try Again): 'this' capture while instantiating generic lambda call operator specialization

When computing the appropriate cv-qualifiers for the 'this' capture, we have to examine each enclosing lambda - but when using the FunctionScopeInfo stack we have to ensure that the lambda below (outer) is the decl-context of the closure-class of the current lambda.

https://bugs.llvm.org/show_bug.cgi?id=32831

This patch was initially committed here: https://reviews.llvm.org/rL301735
Then reverted here: https://reviews.llvm.org/rL301916

The issue with the original patch was a failure to check that the closure type has been created within the LambdaScopeInfo before querying its DeclContext - instead of just assuming it has (silly!).  A reduced example such as this highlights the problem:
  struct X {
     int data;
     auto foo() { return [] { return [] -> decltype(data) { return 0; }; }; }
  };

When 'data' within decltype(data) tries to determine the type of 'this', none of the LambdaScopeInfo's have their closure types created at that point.

llvm-svn: 301972
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/cxx1z-lambda-star-this.cpp