diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 72ab3732e2d7..a610e157d906 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -562,6 +562,13 @@ isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs) { return Spec->getSpecializedTemplate(); } + // Check if we have a variable template. + if (const VarTemplateSpecializationDecl *Spec = + dyn_cast(ND)) { + TemplateArgs = &Spec->getTemplateArgs(); + return Spec->getSpecializedTemplate(); + } + return 0; } @@ -585,7 +592,6 @@ MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, return; } - // We have a class template. // Here comes the tricky thing: if we need to mangle something like // void foo(A::X, B::X), // the X part is aliased. However, if you need to mangle diff --git a/clang/test/CodeGenCXX/mangle-ms-cxx14.cpp b/clang/test/CodeGenCXX/mangle-ms-cxx14.cpp new file mode 100644 index 000000000000..5bf0e967a79c --- /dev/null +++ b/clang/test/CodeGenCXX/mangle-ms-cxx14.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++1y -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s + +template int x = 0; + +// CHECK: "\01??$x@X@@3HA" +template <> int x; +// CHECK: "\01??$x@H@@3HA" +template <> int x;