r214947 - MS ABI: Mangle lambdas which are given the same mangling number
David Majnemer
david.majnemer at gmail.com
Tue Aug 5 20:12:47 PDT 2014
Author: majnemer
Date: Tue Aug 5 22:12:47 2014
New Revision: 214947
URL: http://llvm.org/viewvc/llvm-project?rev=214947&view=rev
Log:
MS ABI: Mangle lambdas which are given the same mangling number
It is possible for lambdas to get the same mangling number because they
may exist in different mangling contexts. To handle this correctly,
mangle the context into the name as well.
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=214947&r1=214946&r2=214947&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Aug 5 22:12:47 2014
@@ -802,10 +802,7 @@ void MicrosoftCXXNameMangler::mangleUnqu
void MicrosoftCXXNameMangler::mangleNestedName(const NamedDecl *ND) {
// <postfix> ::= <unqualified-name> [<postfix>]
// ::= <substitution> [<postfix>]
- if (isLambda(ND))
- return;
-
- const DeclContext *DC = ND->getDeclContext();
+ const DeclContext *DC = getEffectiveDeclContext(ND);
while (!DC->isTranslationUnit()) {
if (isa<TagDecl>(ND) || isa<VarDecl>(ND)) {
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp?rev=214947&r1=214946&r2=214947&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp Tue Aug 5 22:12:47 2014
@@ -98,7 +98,7 @@ namespace PR18022 {
struct { } a;
decltype(a) fun(decltype(a) x, decltype(a)) { return x; }
-// CHECK-DAG: ?fun at PR18022@@YA?AU<unnamed-type-a>@1 at U21@0 at Z
+// CHECK-DAG: @"\01?fun at PR18022@@YA?AU<unnamed-type-a>@1 at U21@0 at Z"
}
@@ -106,17 +106,32 @@ inline int define_lambda() {
static auto lambda = [] { static int local; ++local; return local; };
// First, we have the static local variable of type "<lambda_1>" inside of
// "define_lambda".
-// CHECK-DAG: ?lambda@?1??define_lambda@@YAHXZ at 4V<lambda_1>@@A
+// CHECK-DAG: @"\01?lambda@?1??define_lambda@@YAHXZ at 4V<lambda_1>@?1 at YAHXZ@A"
// Next, we have the "operator()" for "<lambda_1>" which is inside of
// "define_lambda".
-// CHECK-DAG: ??R<lambda_1>@?define_lambda@@YAHXZ at QBEHXZ
+// CHECK-DAG: @"\01??R<lambda_1>@?define_lambda@@YAHXZ at QBEHXZ"
// Finally, we have the local which is inside of "<lambda_1>" which is inside of
// "define_lambda". Hooray.
-// CHECK-DAG: ?local@?2???R<lambda_1>@?define_lambda@@YAHXZ at QBEHXZ@4HA
+// CHECK-DAG: @"\01?local@?2???R<lambda_1>@?define_lambda@@YAHXZ at QBEHXZ@4HA"
return lambda();
}
+template <typename T>
+void use_lambda_arg(T) {}
+
+inline void call_with_lambda_arg1() {
+ use_lambda_arg([]{});
+ // CHECK-DAG: @"\01??$use_lambda_arg at V<lambda_1>@?call_with_lambda_arg1@@YAXXZ@@@YAXV<lambda_1>@?call_with_lambda_arg1@@YAXXZ@@Z"
+}
+
+inline void call_with_lambda_arg2() {
+ use_lambda_arg([]{});
+ // CHECK-DAG: @"\01??$use_lambda_arg at V<lambda_1>@?call_with_lambda_arg2@@YAXXZ@@@YAXV<lambda_1>@?call_with_lambda_arg2@@YAXXZ@@Z"
+}
+
int call_lambda() {
+ call_with_lambda_arg1();
+ call_with_lambda_arg2();
return define_lambda();
}
More information about the cfe-commits
mailing list