From: Charles Davis Date: Sat, 23 Jun 2012 00:27:49 +0000 (+0000) Subject: MicrosoftMangle: Fix mangling of integral constant non-type template arguments in... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3facb626608c99f497cb5b8bfc60d3ed3ba304b6;p=clang MicrosoftMangle: Fix mangling of integral constant non-type template arguments in a class specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159056 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 29319ff417..d2be5e5393 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -744,7 +744,16 @@ MicrosoftCXXNameMangler::mangleTemplateArgs( case TemplateArgument::Integral: mangleIntegerLiteral(TA.getIntegralType(), TA.getAsIntegral()); break; - default: { + case TemplateArgument::Expression: { + // See if this is a constant expression. + Expr *TAE = TA.getAsExpr(); + llvm::APSInt Value; + if (TAE->isIntegerConstantExpr(Value, Context.getASTContext())) { + mangleIntegerLiteral(TAE->getType(), Value); + break; + } + /* fallthrough */ + } default: { // Issue a diagnostic. DiagnosticsEngine &Diags = Context.getDiags(); unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp index 0a011b327e..977ef353da 100644 --- a/test/CodeGenCXX/mangle-ms-templates.cpp +++ b/test/CodeGenCXX/mangle-ms-templates.cpp @@ -23,6 +23,13 @@ class IntTemplate { IntTemplate() {} }; +template<> +class BoolTemplate { + public: + BoolTemplate() {} + template void Foo(T arg) {} +}; + void template_mangling() { Class c1; c1.method(); @@ -36,7 +43,10 @@ void template_mangling() { // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ" BoolTemplate _true; + // PR13158 + _true.Foo(1); // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ" +// CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z" IntTemplate<5> five; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ"