[cfe-commits] r82123 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-subst.cpp

Anders Carlsson andersca at mac.com
Wed Sep 16 21:38:24 PDT 2009


Author: andersca
Date: Wed Sep 16 23:38:23 2009
New Revision: 82123

URL: http://llvm.org/viewvc/llvm-project?rev=82123&view=rev
Log:
Treat an unqualified RecordType as a RecordDecl when substituting.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle-subst.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=82123&r1=82122&r2=82123&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Wed Sep 16 23:38:23 2009
@@ -93,8 +93,8 @@
     void mangleCXXCtorType(CXXCtorType T);
     void mangleCXXDtorType(CXXDtorType T);
 
-    void mangleTemplateArgumentList(const TemplateArgumentList &L);
-    void mangleTemplateArgument(const TemplateArgument &A);
+    void mangleTemplateArgs(const TemplateArgumentList &L);
+    void mangleTemplateArg(const TemplateArgument &A);
   };
 }
 
@@ -252,9 +252,10 @@
   if (ND->getDeclContext()->isTranslationUnit() ||
       isStdNamespace(ND->getDeclContext())) {
     const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
-    if (FD && FD->getPrimaryTemplate()) 
+    if (FD && FD->getPrimaryTemplate()) {
       mangleUnscopedTemplateName(FD);
-    else
+      mangleTemplateArgs(*FD->getTemplateSpecializationArgs());
+    } else
       mangleUnscopedName(ND);
   } else if (isa<FunctionDecl>(ND->getDeclContext()))
     mangleLocalName(ND);
@@ -386,12 +387,6 @@
     assert(false && "Can't mangle a using directive name!");
     break;
   }
-
-  if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
-    if (const TemplateArgumentList *TemplateArgs
-          = Function->getTemplateSpecializationArgs())
-      mangleTemplateArgumentList(*TemplateArgs);
-  }
 }
 
 void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
@@ -715,7 +710,7 @@
   // If this is a class template specialization, mangle the template arguments.
   if (ClassTemplateSpecializationDecl *Spec
       = dyn_cast<ClassTemplateSpecializationDecl>(T->getDecl()))
-    mangleTemplateArgumentList(Spec->getTemplateArgs());
+    mangleTemplateArgs(Spec->getTemplateArgs());
 }
 
 // <type>       ::= <array-type>
@@ -877,20 +872,20 @@
   }
 }
 
-void CXXNameMangler::mangleTemplateArgumentList(const TemplateArgumentList &L) {
+void CXXNameMangler::mangleTemplateArgs(const TemplateArgumentList &L) {
   // <template-args> ::= I <template-arg>+ E
   Out << "I";
 
   for (unsigned i = 0, e = L.size(); i != e; ++i) {
     const TemplateArgument &A = L[i];
 
-    mangleTemplateArgument(A);
+    mangleTemplateArg(A);
   }
 
   Out << "E";
 }
 
-void CXXNameMangler::mangleTemplateArgument(const TemplateArgument &A) {
+void CXXNameMangler::mangleTemplateArg(const TemplateArgument &A) {
   // <template-arg> ::= <type>              # type or template
   //                ::= X <expression> E    # expression
   //                ::= <expr-primary>      # simple expressions
@@ -932,6 +927,11 @@
 }
 
 bool CXXNameMangler::mangleSubstitution(QualType T) {
+  if (!T.getCVRQualifiers()) {
+    if (const RecordType *RT = dyn_cast<RecordType>(T))
+      return mangleSubstitution(RT->getDecl());
+  }
+  
   uintptr_t TypePtr = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
 
   return mangleSubstitution(TypePtr);
@@ -972,6 +972,13 @@
 }
 
 void CXXNameMangler::addSubstitution(QualType T) {
+  if (!T.getCVRQualifiers()) {
+    if (const RecordType *RT = dyn_cast<RecordType>(T)) {
+      addSubstitution(RT->getDecl());
+      return;
+    }
+  }
+  
   uintptr_t TypePtr = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
   addSubstitution(TypePtr);
 }

Modified: cfe/trunk/test/CodeGenCXX/mangle-subst.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-subst.cpp?rev=82123&r1=82122&r2=82123&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-subst.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-subst.cpp Wed Sep 16 23:38:23 2009
@@ -24,3 +24,11 @@
 
 // CHECK: define void @_Z1fN1A1AENS_1BE(
 void f(A::A a, A::B b) { }
+
+struct C { struct D { }; };
+
+// CHECK: define void @_Z1fP1CNS_1DE
+void f(C*, C::D) { }
+
+// CHECK: define void @_Z1fN1C1DEPKS_
+void f(C::D, const C*) { }





More information about the cfe-commits mailing list