diff options
author | Charles Davis <cdavis@mines.edu> | 2012-06-23 00:27:49 +0000 |
---|---|---|
committer | Charles Davis <cdavis@mines.edu> | 2012-06-23 00:27:49 +0000 |
commit | de2e5ed4aa22b33f003938fa961edf1519d8bb5b (patch) | |
tree | ee3f4530648ff4c84b516ad97d32b404a29fc284 | |
parent | de8c6fb24f79c670badcb2ec7426796386a7f1c7 (diff) | |
download | bcm5719-llvm-de2e5ed4aa22b33f003938fa961edf1519d8bb5b.tar.gz bcm5719-llvm-de2e5ed4aa22b33f003938fa961edf1519d8bb5b.zip |
MicrosoftMangle: Fix mangling of integral constant non-type template arguments in a class specialization.
llvm-svn: 159056
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 11 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/mangle-ms-templates.cpp | 10 |
2 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 29319ff417f..d2be5e53939 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/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/clang/test/CodeGenCXX/mangle-ms-templates.cpp b/clang/test/CodeGenCXX/mangle-ms-templates.cpp index 0a011b327e0..977ef353dab 100644 --- a/clang/test/CodeGenCXX/mangle-ms-templates.cpp +++ b/clang/test/CodeGenCXX/mangle-ms-templates.cpp @@ -23,6 +23,13 @@ class IntTemplate { IntTemplate() {} }; +template<> +class BoolTemplate<true> { + public: + BoolTemplate() {} + template<class T> void Foo(T arg) {} +}; + void template_mangling() { Class<Typename> c1; c1.method(); @@ -36,7 +43,10 @@ void template_mangling() { // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ" BoolTemplate<true> _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" |