[PATCH] D68099: [MS ABI]: Fix mangling function arguments for template types to be compatible with MSVC

Adam Folwarczny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 26 12:34:07 PDT 2019


adamf created this revision.
adamf added reviewers: rnk, thakis.
adamf added a project: clang.
Herald added a subscriber: cfe-commits.

MS name mangling supports cache for first 10 distinct function arguments.
The error was when non cached template type occurred twice (e.g. 11th and 12th).
For such case there is another cache table TemplateArgStrings.
Then one '@' character at the end of the mangled name taken from this table was missing.
For other cases the missing '@' character was added in mangleSourceName function.


Repository:
  rC Clang

https://reviews.llvm.org/D68099

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-back-references.cpp


Index: clang/test/CodeGenCXX/mangle-ms-back-references.cpp
===================================================================
--- clang/test/CodeGenCXX/mangle-ms-back-references.cpp
+++ clang/test/CodeGenCXX/mangle-ms-back-references.cpp
@@ -66,3 +66,20 @@
 void foo() { }
 // CHECK: "?foo at 0@YAXXZ"
 }
+
+class T01;
+class T02;
+class T03;
+class T04;
+class T05;
+class T06;
+class T07;
+class T08;
+class T09;
+class T10;
+class T11;
+template <typename T>
+class H;
+
+void ManyParams(T01 &, T02 &, T03 &, T04 &, T05 &, T06 &, T07 &, T08 &, T09 &, T10 &, H<T11> &, H<T11> &) {}
+// CHECK: "?ManyParams@@YAXAAVT01@@AAVT02@@AAVT03@@AAVT04@@AAVT05@@AAVT06@@AAVT07@@AAVT08@@AAVT09@@AAVT10@@AAV?$H at VT11@@@@AAV?$H at VT11@@@@@Z"
Index: clang/lib/AST/MicrosoftMangle.cpp
===================================================================
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -846,7 +846,7 @@
               TemplateArgStringStorage.save(TemplateMangling.str());
         }
       } else {
-        Out << Found->second; // Outputs a StringRef.
+        Out << Found->second << '@'; // Outputs a StringRef.
       }
     } else {
       Out << Found->second; // Outputs a back reference (an int).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68099.222005.patch
Type: text/x-patch
Size: 1233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190926/349eb6f8/attachment-0001.bin>


More information about the cfe-commits mailing list