diff options
| author | Faisal Vali <faisalv@yahoo.com> | 2014-05-30 04:39:37 +0000 |
|---|---|---|
| committer | Faisal Vali <faisalv@yahoo.com> | 2014-05-30 04:39:37 +0000 |
| commit | 2a8b87e5a89a647ed24098e700aab7f59a920064 (patch) | |
| tree | 3cf7a73bad8ea33bfbf0074c0d682066a1983a24 /lib/Serialization/ModuleManager.cpp | |
| parent | fb84f0cf5c1edebbaad4ebc920f310d7754a4861 (diff) | |
| download | clang-2a8b87e5a89a647ed24098e700aab7f59a920064.tar.gz clang-2a8b87e5a89a647ed24098e700aab7f59a920064.tar.bz2 clang-2a8b87e5a89a647ed24098e700aab7f59a920064.tar.xz | |
Fix 'this' capturing Generic lambdas used within default initializers (PR19876)
http://llvm.org/bugs/show_bug.cgi?id=19876
The following C++1y code results in a crash:
struct X {
int m = 10;
int n = [this](auto) { return m; }(20);
};
When implicitly instantiating the generic lambda's call operator specialization body, Sema is unable to determine the current 'this' type when transforming the MemberExpr 'm' - since it looks for the nearest enclosing FunctionDeclDC - which is obviously null.
I considered two ways to fix this:
1) In InstantiateFunctionDefinition, when the context is saved after the lambda scope info is created, retain the 'this' pointer.
2) Teach getCurrentThisType() to recognize it is within a generic lambda within an NSDMI/default-initializer and return the appropriate this type.
I chose to implement #2 (though I confess I do not have a compelling reason for choosing it over #1).
Richard Smith accepted the patch:
http://reviews.llvm.org/D3935
Thank you!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ModuleManager.cpp')
0 files changed, 0 insertions, 0 deletions
