[PATCH] D80153: [AST] Mangle LambdaContextDecl for top level decl

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 19 14:53:50 PDT 2020


zequanwu updated this revision to Diff 265046.
zequanwu added a comment.

Update test cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80153/new/

https://reviews.llvm.org/D80153

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx17.cpp


Index: clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
===================================================================
--- clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -19,3 +19,11 @@
 
 // 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); }
Index: clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
===================================================================
--- clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
@@ -337,10 +337,10 @@
   }();
   using FPtrTy = void(void);
   static void default_args(FPtrTy x = [] {}, FPtrTy y = [] {}, int z = [] { return 1; }() + [] { return 2; }()) {}
-  // CHECK-DAG: @"??R<lambda_1_1>@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
-  // CHECK-DAG: @"??R<lambda_1_2>@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
-  // CHECK-DAG: @"??R<lambda_2_1>@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
-  // CHECK-DAG: @"??R<lambda_3_1>@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
+  // CHECK-DAG: @"??R<lambda_1_1>@z@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
+  // CHECK-DAG: @"??R<lambda_1_2>@z@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
+  // CHECK-DAG: @"??R<lambda_2_1>@y@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
+  // CHECK-DAG: @"??R<lambda_3_1>@x@?0??default_args at A@PR31197@@SAXP6AXXZ0H at Z@QBE at XZ"(
 };
 A a;
 
Index: clang/lib/AST/MicrosoftMangle.cpp
===================================================================
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,11 @@
 
           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, it is encoded
+          // in a qualified name.
           if (LambdaManglingNumber && LambdaContextDecl) {
             if ((isa<VarDecl>(LambdaContextDecl) ||
-                 isa<FieldDecl>(LambdaContextDecl)) &&
-                LambdaContextDecl->getDeclContext()->isRecord()) {
+                 isa<FieldDecl>(LambdaContextDecl))) {
               mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl));
             }
           }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80153.265046.patch
Type: text/x-patch
Size: 2617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200519/474fb354/attachment-0001.bin>


More information about the cfe-commits mailing list