aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/MicrosoftMangle.cpp8
-rw-r--r--test/CodeGenCXX/mangle-ms-templates.cpp12
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp
index 40f8730e61..9cd6bac971 100644
--- a/lib/AST/MicrosoftMangle.cpp
+++ b/lib/AST/MicrosoftMangle.cpp
@@ -824,9 +824,13 @@ MicrosoftCXXNameMangler::mangleTemplateArgs(const TemplateDecl *TD,
switch (TA.getKind()) {
case TemplateArgument::Null:
llvm_unreachable("Can't mangle null template arguments!");
- case TemplateArgument::Type:
- mangleType(TA.getAsType(), SourceRange());
+ case TemplateArgument::Type: {
+ QualType T = TA.getAsType();
+ if (T.hasQualifiers())
+ Out << "$$C";
+ mangleType(T, SourceRange());
break;
+ }
case TemplateArgument::Declaration:
mangle(cast<NamedDecl>(TA.getAsDecl()), "$1?");
break;
diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp
index d0e8af4888..7b7f30bb72 100644
--- a/test/CodeGenCXX/mangle-ms-templates.cpp
+++ b/test/CodeGenCXX/mangle-ms-templates.cpp
@@ -35,6 +35,18 @@ void template_mangling() {
c1.method();
// CHECK: call {{.*}} @"\01?method@?$Class@VTypename@@@@QAEXXZ"
+ Class<const Typename> c1_const;
+ Class<volatile Typename> c1_volatile;
+ Class<const volatile Typename> c1_cv;
+ c1_const.method();
+ c1_volatile.method();
+ c1_cv.method();
+// Types with qualifiers have an extra $$C escape when used as template
+// arguments. Not sure why.
+// CHECK: call {{.*}} @"\01?method@?$Class@$$CBVTypename@@@@QAEXXZ"
+// CHECK: call {{.*}} @"\01?method@?$Class@$$CCVTypename@@@@QAEXXZ"
+// CHECK: call {{.*}} @"\01?method@?$Class@$$CDVTypename@@@@QAEXXZ"
+
Class<Nested<Typename> > c2;
c2.method();
// CHECK: call {{.*}} @"\01?method@?$Class@V?$Nested@VTypename@@@@@@QAEXXZ"