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

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


Author: andersca
Date: Wed Sep 16 23:16:28 2009
New Revision: 82122

URL: http://llvm.org/viewvc/llvm-project?rev=82122&view=rev
Log:
Substitution for prefixes.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle-extreme.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=82122&r1=82121&r2=82122&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Wed Sep 16 23:16:28 2009
@@ -55,9 +55,7 @@
     void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type);
 
   private:
-    bool mangleSubstitution(const NamedDecl *ND) {
-      return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
-    }
+    bool mangleSubstitution(const NamedDecl *ND);
     bool mangleSubstitution(QualType T);
     bool mangleSubstitution(uintptr_t Ptr);
     
@@ -432,6 +430,10 @@
   //           ::= # empty
   //           ::= <substitution>
   // FIXME: We only handle mangling of namespaces and classes at the moment.
+
+  if (mangleSubstitution(cast<NamedDecl>(DC)))
+    return;
+  
   if (!DC->getParent()->isTranslationUnit())
     manglePrefix(DC->getParent());
 
@@ -444,6 +446,8 @@
     } else
       mangleSourceName(Record->getIdentifier());
   }
+  
+  addSubstitution(cast<NamedDecl>(DC));
 }
 
 void
@@ -922,6 +926,11 @@
 
 // <substitution> ::= S <seq-id> _
 //                ::= S_
+
+bool CXXNameMangler::mangleSubstitution(const NamedDecl *ND) {
+  return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
+}
+
 bool CXXNameMangler::mangleSubstitution(QualType T) {
   uintptr_t TypePtr = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
 

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

==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-extreme.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-extreme.cpp Wed Sep 16 23:16:28 2009
@@ -1,8 +1,8 @@
-// RUN: clang-cc -emit-llvm %s -o %t -triple=x86_64-apple-darwin10 && 
+// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
 
 struct X { };
 
-// RUN: grep "define void @_Z1fPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_SI_SH_SG_SF_SE_SD_SC_SB_SA_S9_S8_S7_S6_S5_S4_S3_S2_S1_S0_S_(" %t &&
+// CHECK: define void @_Z1fPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_SI_SH_SG_SF_SE_SD_SC_SB_SA_S9_S8_S7_S6_S5_S4_S3_S2_S1_S0_S_(
 void f(X****************************************,
        X****************************************,
        X***************************************,
@@ -45,5 +45,3 @@
        X**,
        X*,
        X) { }
-       
-// RUN: true

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

==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-subst.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-subst.cpp Wed Sep 16 23:16:28 2009
@@ -2,19 +2,25 @@
 
 struct X {};
 
-// CHECK: define void @_Z1f1XS_
+// CHECK: define void @_Z1f1XS_(
 void f(X, X) { }
 
-// CHECK: define void @_Z1fR1XS0_
+// CHECK: define void @_Z1fR1XS0_(
 void f(X&, X&) { }
 
-// CHECK: define void @_Z1fRK1XS1_
+// CHECK: define void @_Z1fRK1XS1_(
 void f(const X&, const X&) { }
 
 typedef void T();
 struct S {};
 
-// CHECK: define void @_Z1fPFvvEM1SFvvE
+// CHECK: define void @_Z1fPFvvEM1SFvvE(
 void f(T*, T (S::*)) {}
 
-// RUN: true
+namespace A {
+  struct A { };
+  struct B { };
+};
+
+// CHECK: define void @_Z1fN1A1AENS_1BE(
+void f(A::A a, A::B b) { }





More information about the cfe-commits mailing list