]> granicus.if.org Git - clang/commitdiff
[-cxx-abi microsoft] Mangle TemplateArgument::Declaration for references
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 13 Aug 2013 01:25:35 +0000 (01:25 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 13 Aug 2013 01:25:35 +0000 (01:25 +0000)
Summary:
Properly mangle declarations showing up in template arguments that are
reference parameters.  Fun-fact: undname cannot handle these!

Reviewers: rnk, cdavis5x

Reviewed By: rnk

CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1356

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188245 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/MicrosoftMangle.cpp
test/CodeGenCXX/mangle-ms-templates.cpp

index 8d7b76db5e9fbac9587375c36c9b9859cc55ec85..765b14d49e5e4a22288d79ead6988a085e587026 100644 (file)
@@ -886,9 +886,11 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD,
     mangleType(T, SourceRange(), QMM_Escape);
     break;
   }
-  case TemplateArgument::Declaration:
-    mangle(cast<NamedDecl>(TA.getAsDecl()), "$1?");
+  case TemplateArgument::Declaration: {
+    const NamedDecl *ND = cast<NamedDecl>(TA.getAsDecl());
+    mangle(ND, TA.isDeclForReferenceParam() ? "$E?" : "$1?");
     break;
+  }
   case TemplateArgument::Integral:
     mangleIntegerLiteral(TA.getAsIntegral(),
                          TA.getIntegralType()->isBooleanType());
index 25c8b43506de0b05e377b1d75ab5f12a7cd4f558..e65279aa0da8e3185139c9e1cd9f4f25f5f4cc97 100644 (file)
@@ -190,3 +190,14 @@ void template_template_specialization<void (Type<Thing<Second, true>, Second>)>(
 template <decltype(nullptr)> struct S1 {};
 void f(S1<nullptr>) {}
 // CHECK: "\01?f@@YAXU?$S1@$0A@@@@Z"
+
+struct record {
+  int first;
+  int second;
+};
+template <const record &>
+struct type1 {
+};
+extern const record inst;
+void recref(type1<inst>) {}
+// CHECK: "\01?recref@@YAXU?$type1@$E?inst@@3Urecord@@B@@@Z"