From: David Majnemer Date: Wed, 30 Jul 2014 08:20:03 +0000 (+0000) Subject: MS ABI: Mangle alias templates used as template-template arguments X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d5f9ab2cc2a76d490ffc6317d9552b05901ff63;p=platform%2Fupstream%2Fllvm.git 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. llvm-svn: 214290 --- diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index e6a6d09..0c80ff8 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -1179,11 +1179,21 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD, } break; } - case TemplateArgument::Template: - mangleType(cast( - TA.getAsTemplate().getAsTemplateDecl()->getTemplatedDecl())); + case TemplateArgument::Template: { + const NamedDecl *ND = + TA.getAsTemplate().getAsTemplateDecl()->getTemplatedDecl(); + if (const auto *TD = dyn_cast(ND)) { + mangleType(TD); + } else if (isa(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, diff --git a/clang/test/CodeGenCXX/mangle-ms-cxx11.cpp b/clang/test/CodeGenCXX/mangle-ms-cxx11.cpp index 373d2b7..cb9c64f 100644 --- a/clang/test/CodeGenCXX/mangle-ms-cxx11.cpp +++ b/clang/test/CodeGenCXX/mangle-ms-cxx11.cpp @@ -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 +struct A {}; + +template +using AliasA = A; + +template