summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLambda.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-10-14 12:43:59 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-10-14 12:43:59 +0000
commitbef6aa6ea99b19cbc570a712a4f243398ad7d014 (patch)
treeae038a4f3a52ea27fdd8b71fe9243a0b61dbea8f /clang/lib/Sema/SemaLambda.cpp
parent735f3a26be47c38404608d62eb8c4ace9555e085 (diff)
downloadbcm5719-llvm-bef6aa6ea99b19cbc570a712a4f243398ad7d014.tar.gz
bcm5719-llvm-bef6aa6ea99b19cbc570a712a4f243398ad7d014.zip
Fix for PR30632: Name mangling issue.
There was a bug in the implementation of captured statements. If it has a lambda expression in it and the same lambda expression is used outside the captured region, clang produced an error: ``` error: definition with same mangled name as another definition ``` Here is an example: ``` struct A { template <typename L> void g(const L&) { } }; template<typename T> void f() { { A().g([](){}); } A().g([](){}); } int main() { f<void>(); } ``` Error report: ``` main.cpp:3:10: error: definition with same mangled name as another definition void g(const L&) { } ^ main.cpp:3:10: note: previous definition is here ``` Patch fixes this bug. llvm-svn: 284229
Diffstat (limited to 'clang/lib/Sema/SemaLambda.cpp')
-rw-r--r--clang/lib/Sema/SemaLambda.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index 0de501fc5e4..9be8fe51887 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -311,18 +311,20 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC,
bool IsInNonspecializedTemplate =
!ActiveTemplateInstantiations.empty() || CurContext->isDependentContext();
switch (Kind) {
- case Normal:
+ case Normal: {
// -- the bodies of non-exported nonspecialized template functions
// -- the bodies of inline functions
+ auto *CD = dyn_cast<CapturedDecl>(CurContext);
if ((IsInNonspecializedTemplate &&
!(ManglingContextDecl && isa<ParmVarDecl>(ManglingContextDecl))) ||
- isInInlineFunction(CurContext)) {
+ isInInlineFunction(CurContext) || CD) {
ManglingContextDecl = nullptr;
- return &Context.getManglingNumberContext(DC);
+ return &Context.getManglingNumberContext(CD ? CD->getParent() : DC);
}
ManglingContextDecl = nullptr;
return nullptr;
+ }
case StaticDataMember:
// -- the initializers of nonspecialized static members of template classes
OpenPOWER on IntegriCloud