]> granicus.if.org Git - clang/commitdiff
Mangle dependent template names of unknown arity
authorDouglas Gregor <dgregor@apple.com>
Tue, 12 Jul 2011 05:06:05 +0000 (05:06 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 12 Jul 2011 05:06:05 +0000 (05:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134967 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ItaniumMangle.cpp
test/CodeGenCXX/mangle.cpp

index 958b4a26a096b58f20330d398b66f855ae2ba7ad..5a1025fff024df64831dc32974b052fe81fc8d16 100644 (file)
@@ -593,19 +593,13 @@ void CXXNameMangler::mangleUnscopedTemplateName(TemplateName Template) {
   if (mangleSubstitution(Template))
     return;
 
-  // FIXME: How to cope with operators here?
   DependentTemplateName *Dependent = Template.getAsDependentTemplateName();
   assert(Dependent && "Not a dependent template name?");
-  if (!Dependent->isIdentifier()) {
-    // FIXME: We can't possibly know the arity of the operator here!
-    Diagnostic &Diags = Context.getDiags();
-    unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
-                                      "cannot mangle dependent operator name");
-    Diags.Report(DiagID);
-    return;
-  }
+  if (const IdentifierInfo *Id = Dependent->getIdentifier())
+    mangleSourceName(Id);
+  else
+    mangleOperatorName(Dependent->getOperator(), UnknownArity);
   
-  mangleSourceName(Dependent->getIdentifier());
   addSubstitution(Template);
 }
 
index 56e70a2b15126642a4d48818c9e9c106e2589faf..0f4e5c5c38259a56914722f98ca54ea771783c95 100644 (file)
@@ -826,3 +826,16 @@ namespace test34 {
   // CHECK: define weak_odr void @_ZN6test342f3ILy4EEEvRAplT_Ly8E_i
   template void f3<4>(int (&)[4 + sizeof(int*)]);
 }
+
+namespace test35 {
+  // Dependent operator names of unknown arity.
+  struct A { 
+    template<typename U> A operator+(U) const;
+  };
+
+  template<typename T>
+  void f1(decltype(sizeof(&T::template operator+<int>))) {}
+
+  // CHECK: define weak_odr void @_ZN6test352f1INS_1AEEEvDTszadsrT_plIiEE
+  template void f1<A>(__SIZE_TYPE__);
+}