[cfe-commits] r134227 - in /cfe/trunk: lib/AST/ItaniumMangle.cpp test/CodeGenCXX/mangle.cpp

John McCall rjmccall at apple.com
Thu Jun 30 19:19:08 PDT 2011


Author: rjmccall
Date: Thu Jun 30 21:19:08 2011
New Revision: 134227

URL: http://llvm.org/viewvc/llvm-project?rev=134227&view=rev
Log:
Just mangle substituted template parameter types as unresolved types.
This is kindof questionable but seems to do more-or-less the right thing.
This is not a particularly friendly part of the ABI.


Modified:
    cfe/trunk/lib/AST/ItaniumMangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=134227&r1=134226&r2=134227&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Jun 30 21:19:08 2011
@@ -818,28 +818,21 @@
     case Type::Decltype:
     case Type::TemplateTypeParm:
     case Type::UnaryTransform:
+    case Type::SubstTemplateTypeParm:
     unresolvedType:
       assert(!qualifier->getPrefix());
 
       // We only get here recursively if we're followed by identifiers.
       if (recursive) Out << 'N';
 
-      // This seems to do everything we want.
+      // This seems to do everything we want.  It's not really
+      // sanctioned for a substituted template parameter, though.
       mangleType(QualType(type, 0));
 
       // We never want to print 'E' directly after an unresolved-type,
       // so we return directly.
       return;
 
-    // Substituted template type parameters should only come up with
-    // enclosing templates.
-    // <unresolved-type> ::= <existing-substitution> [ <template-args> ]
-    case Type::SubstTemplateTypeParm: {
-      if (recursive) Out << 'N';
-      mangleExistingSubstitution(QualType(type, 0));
-      return;
-    }
-
     case Type::Typedef:
       mangleSourceName(cast<TypedefType>(type)->getDecl()->getIdentifier());
       break;

Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=134227&r1=134226&r2=134227&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Thu Jun 30 21:19:08 2011
@@ -770,3 +770,35 @@
   // CHECK: define weak_odr void @_ZN6test312f3IiEEDTcl1gfp_EET_
   template void f3(int);
 }
+
+// PR10205
+namespace test32 {
+  template<typename T, int=T::value> struct A {
+    typedef int type;
+  };
+  struct B { enum { value = 4 }; };
+
+  template <class T> typename A<T>::type foo() { return 0; }
+  void test() {
+    foo<B>();
+    // CHECK: call i32 @_ZN6test323fooINS_1BEEENS_1AIT_XsrS3_5valueEE4typeEv()
+  }
+}
+
+namespace test33 {
+  template <class T> struct X {
+    enum { value = T::value };
+  };
+
+  template<typename T, int=X<T>::value> struct A {
+    typedef int type;
+  };
+  struct B { enum { value = 4 }; };
+
+  template <class T> typename A<T>::type foo() { return 0; }
+
+  void test() {
+    foo<B>();
+    // CHECK: call i32 @_ZN6test333fooINS_1BEEENS_1AIT_Xsr1XIS3_EE5valueEE4typeEv()
+  }
+}





More information about the cfe-commits mailing list