[clang] e408cba - [AST] Mangle LambdaContextDecl for top level decl
Zequan Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 10 09:45:54 PDT 2020
Author: Zequan Wu
Date: 2020-06-10T09:44:09-07:00
New Revision: e408cba84f8a9471bb26deca8d9aac049a924847
URL: https://github.com/llvm/llvm-project/commit/e408cba84f8a9471bb26deca8d9aac049a924847
DIFF: https://github.com/llvm/llvm-project/commit/e408cba84f8a9471bb26deca8d9aac049a924847.diff
LOG: [AST] Mangle LambdaContextDecl for top level decl
Summary:
Bug filed here: https://bugs.llvm.org/show_bug.cgi?id=45213
To resolve it, we let the checks for mangling LambdaContextDecl to be analogous to ItaniumMangle strategy: https://github.com/llvm/llvm-project/blob/master/clang/lib/AST/ItaniumMangle.cpp#L1829
Differential Revision: https://reviews.llvm.org/D80153
Added:
Modified:
clang/lib/AST/MicrosoftMangle.cpp
clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index ca628b3501f6..529f301e4696 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,12 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
mangleSourceName(Name);
- // If the context of a closure type is an initializer for a class
- // member (static or nonstatic), it is encoded in a qualified name.
+ // If the context is a variable or a class member and not a parameter,
+ // it is encoded in a qualified name.
if (LambdaManglingNumber && LambdaContextDecl) {
if ((isa<VarDecl>(LambdaContextDecl) ||
isa<FieldDecl>(LambdaContextDecl)) &&
- LambdaContextDecl->getDeclContext()->isRecord()) {
+ !isa<ParmVarDecl>(LambdaContextDecl)) {
mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl));
}
}
diff --git a/clang/test/CodeGenCXX/mangle-ms-cxx17.cpp b/clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
index 897f0d6c9b17..751fcc46a7ce 100644
--- a/clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -19,3 +19,11 @@ double b;
// CHECK-DAG: "?$S4@@3US@@B"
const auto [x2, y2] = f();
+
+// CHECK-DAG: "?i1@@3V<lambda_1>@0 at B"
+inline const auto i1 = [](auto x) { return 0; };
+// CHECK-DAG: "?i2@@3V<lambda_1>@0 at B"
+inline const auto i2 = [](auto x) { return 1; };
+// CHECK-DAG: "??$?RH@<lambda_1>@i1@@QBE?A?<auto>@@H at Z"
+// CHECK-DAG: "??$?RH@<lambda_1>@i2@@QBE?A?<auto>@@H at Z"
+int g() {return i1(1) + i2(1); }
More information about the cfe-commits
mailing list