r214290 - MS ABI: Mangle alias templates used as template-template arguments

David Majnemer david.majnemer at gmail.com
Wed Jul 30 01:20:03 PDT 2014


Author: majnemer
Date: Wed Jul 30 03:20:03 2014
New Revision: 214290

URL: http://llvm.org/viewvc/llvm-project?rev=214290&view=rev
Log:
MS ABI: Mangle alias templates used as template-template arguments

A templated using declaration may be used as a template-template
argument.

Unfortunately, the VS "14" chooses '?' as the sole marker for the
argument.  This is problematic because it presupposes the possibility of
using more than one template-aliases as arguments to the same template.

This fixes PR20047.

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=214290&r1=214289&r2=214290&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Jul 30 03:20:03 2014
@@ -1179,11 +1179,21 @@ void MicrosoftCXXNameMangler::mangleTemp
     }
     break;
   }
-  case TemplateArgument::Template:
-    mangleType(cast<TagDecl>(
-        TA.getAsTemplate().getAsTemplateDecl()->getTemplatedDecl()));
+  case TemplateArgument::Template: {
+    const NamedDecl *ND =
+        TA.getAsTemplate().getAsTemplateDecl()->getTemplatedDecl();
+    if (const auto *TD = dyn_cast<TagDecl>(ND)) {
+      mangleType(TD);
+    } else if (isa<TypeAliasDecl>(ND)) {
+      // FIXME: The mangling, while compatible with VS "14", is horribly
+      // broken.  Update this when they release their next compiler.
+      Out << '?';
+    } else {
+      llvm_unreachable("unexpected template template NamedDecl!");
+    }
     break;
   }
+  }
 }
 
 void MicrosoftCXXNameMangler::mangleQualifiers(Qualifiers Quals,

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=214290&r1=214289&r2=214290&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp Wed Jul 30 03:20:03 2014
@@ -139,3 +139,17 @@ void templ_fun_with_pack() {}
 
 template void templ_fun_with_pack<>();
 // CHECK-DAG: @"\01??$templ_fun_with_pack@$S@@YAXXZ"
+
+namespace PR20047 {
+template <typename T>
+struct A {};
+
+template <typename T>
+using AliasA = A<T>;
+
+template <template <typename> class>
+void f() {}
+
+template void f<AliasA>();
+// CHECK-DAG: @"\01??$f@?@PR20047@@YAXXZ"
+}





More information about the cfe-commits mailing list