[llvm-branch-commits] [cfe-branch] r286970 - Merging r284229:
Alexey Bataev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Nov 15 06:30:48 PST 2016
Author: abataev
Date: Tue Nov 15 08:30:48 2016
New Revision: 286970
URL: http://llvm.org/viewvc/llvm-project?rev=286970&view=rev
Log:
Merging r284229:
------------------------------------------------------------------------
r284229 | abataev | 2016-10-14 12:43:59 +0000 (Fri, 14 Oct 2016) | 37 lines
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.
------------------------------------------------------------------------
Modified:
cfe/branches/release_39/ (props changed)
cfe/branches/release_39/lib/Sema/SemaLambda.cpp
cfe/branches/release_39/test/CodeGenCXX/captured-statements.cpp
cfe/branches/release_39/test/OpenMP/for_lastprivate_codegen.cpp
cfe/branches/release_39/test/OpenMP/target_map_codegen.cpp
Propchange: cfe/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 15 08:30:48 2016
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763,278786,278988,284110,286103,286106,286129,286584,286944
+/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763,278786,278988,284110,284229,286103,286106,286129,286584,286944,286953
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_39/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Sema/SemaLambda.cpp?rev=286970&r1=286969&r2=286970&view=diff
==============================================================================
--- cfe/branches/release_39/lib/Sema/SemaLambda.cpp (original)
+++ cfe/branches/release_39/lib/Sema/SemaLambda.cpp Tue Nov 15 08:30:48 2016
@@ -314,18 +314,21 @@ Sema::getCurrentMangleNumberContext(cons
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
if ((IsInNonspecializedTemplate &&
!(ManglingContextDecl && isa<ParmVarDecl>(ManglingContextDecl))) ||
isInInlineFunction(CurContext)) {
ManglingContextDecl = nullptr;
+ while (auto *CD = dyn_cast<CapturedDecl>(DC))
+ DC = CD->getParent();
return &Context.getManglingNumberContext(DC);
}
ManglingContextDecl = nullptr;
return nullptr;
+ }
case StaticDataMember:
// -- the initializers of nonspecialized static members of template classes
Modified: cfe/branches/release_39/test/CodeGenCXX/captured-statements.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/CodeGenCXX/captured-statements.cpp?rev=286970&r1=286969&r2=286970&view=diff
==============================================================================
--- cfe/branches/release_39/test/CodeGenCXX/captured-statements.cpp (original)
+++ cfe/branches/release_39/test/CodeGenCXX/captured-statements.cpp Tue Nov 15 08:30:48 2016
@@ -78,6 +78,7 @@ void test3(int x) {
{
x = [=]() { return x + 1; } ();
}
+ x = [=]() { return x + 1; }();
// CHECK-3: %[[Capture:struct\.anon[\.0-9]*]] = type { i32* }
Modified: cfe/branches/release_39/test/OpenMP/for_lastprivate_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/for_lastprivate_codegen.cpp?rev=286970&r1=286969&r2=286970&view=diff
==============================================================================
--- cfe/branches/release_39/test/OpenMP/for_lastprivate_codegen.cpp (original)
+++ cfe/branches/release_39/test/OpenMP/for_lastprivate_codegen.cpp Tue Nov 15 08:30:48 2016
@@ -41,7 +41,7 @@ struct SS {
for (a = 0; a < 2; ++a)
#ifdef LAMBDA
[&]() {
- ++this->a, --b, (this)->c /= 1;
+ --this->a, ++b, (this)->c *= 2;
#pragma omp parallel
#pragma omp for lastprivate(b)
for (b = 0; b < 2; ++b)
@@ -190,7 +190,7 @@ int main() {
// LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void
// LAMBDA: call void @__kmpc_for_static_init_4(
// LAMBDA-NOT: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
- // LAMBDA: call void {{.+}} [[SS_LAMBDA:@[^ ]+]]
+ // LAMBDA: call{{.*}} void [[SS_LAMBDA1:@[^ ]+]]
// LAMBDA: call void @__kmpc_for_static_fini(%
// LAMBDA: ret
@@ -200,7 +200,7 @@ int main() {
// LAMBDA: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 2
// LAMBDA: call void @__kmpc_for_static_init_4(
// LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]*
- // LAMBDA: call{{.*}} void
+ // LAMBDA: call{{.*}} void [[SS_LAMBDA:@[^ ]+]]
// LAMBDA: call void @__kmpc_for_static_fini(
// LAMBDA: br i1
// LAMBDA: [[B_REF:%.+]] = getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 1
@@ -236,6 +236,9 @@ int main() {
// LAMBDA: br label
// LAMBDA: ret void
+ // LAMBDA: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})
+ // LAMBDA: ret void
+
// LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable(4) [[SIVAR:%.+]])
// LAMBDA: alloca i{{[0-9]+}},
// LAMBDA: alloca i{{[0-9]+}},
Modified: cfe/branches/release_39/test/OpenMP/target_map_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/target_map_codegen.cpp?rev=286970&r1=286969&r2=286970&view=diff
==============================================================================
--- cfe/branches/release_39/test/OpenMP/target_map_codegen.cpp (original)
+++ cfe/branches/release_39/test/OpenMP/target_map_codegen.cpp Tue Nov 15 08:30:48 2016
@@ -4074,7 +4074,9 @@ int explicit_maps_with_inner_lambda(int
// CK25: [[VAL1:%.+]] = load i32*, i32** [[VALADDR]],
// CK25: [[VALADDR1:%.+]] = getelementptr inbounds [[CA01]], [[CA01]]* [[CA:%[^,]+]], i32 0, i32 0
// CK25: store i32* [[VAL1]], i32** [[VALADDR1]],
-// CK25: call void {{.*}}[[LAMBDA]]{{.*}}([[CA01]]* [[CA]])
+// CK25: call void {{.*}}[[LAMBDA2:@.+]]{{.*}}([[CA01]]* [[CA]])
+
+// CK25: define {{.+}}[[LAMBDA2]]
#endif
///==========================================================================///
// RUN: %clang_cc1 -DCK26 -std=c++11 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK26 --check-prefix CK26-64
More information about the llvm-branch-commits
mailing list