]> granicus.if.org Git - clang/commitdiff
Mangle record types as decls.
authorAnders Carlsson <andersca@mac.com>
Sat, 26 Sep 2009 03:55:37 +0000 (03:55 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 26 Sep 2009 03:55:37 +0000 (03:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82843 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/PR5050-constructor-conversion.cpp
test/CodeGenCXX/constructor-default-arg.cpp
test/CodeGenCXX/copy-assign-synthesis-1.cpp
test/CodeGenCXX/copy-constructor-synthesis.cpp
test/CodeGenCXX/mangle-subst.cpp
test/CodeGenCXX/member-functions.cpp

index f03f029198deb208ded2c7344e248d34f55c59de..629b46bf9449252ae4ec6934aa40483a43df7ca7 100644 (file)
@@ -456,7 +456,7 @@ void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
 void CXXNameMangler::mangleNestedName(const NamedDecl *ND) {
   // <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
   //               ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
-  // FIXME: no class template support
+
   Out << 'N';
   if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND))
     mangleQualifiers(Qualifiers::fromCVRMask(Method->getTypeQualifiers()));
@@ -1077,6 +1077,11 @@ bool CXXNameMangler::mangleSubstitution(const NamedDecl *ND) {
 }
 
 bool CXXNameMangler::mangleSubstitution(QualType T) {
+  if (!T.getCVRQualifiers()) {
+    if (const RecordType *RT = T->getAs<RecordType>())
+      return mangleSubstitution(RT->getDecl());
+  }
+  
   uintptr_t TypePtr = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
 
   return mangleSubstitution(TypePtr);
@@ -1117,6 +1122,13 @@ bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) {
 }
 
 void CXXNameMangler::addSubstitution(QualType T) {
+  if (!T.getCVRQualifiers()) {
+    if (const RecordType *RT = T->getAs<RecordType>()) {
+      addSubstitution(RT->getDecl());
+      return;
+    }
+  }
+  
   uintptr_t TypePtr = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
   addSubstitution(TypePtr);
 }
@@ -1144,6 +1156,10 @@ namespace clang {
     assert(!isa<CXXDestructorDecl>(D) &&
            "Use mangleCXXDtor for destructor decls!");
 
+    PrettyStackTraceDecl CrashInfo(const_cast<NamedDecl *>(D), SourceLocation(),
+                                   Context.getSourceManager(),
+                                   "Mangling declaration");
+    
     CXXNameMangler Mangler(Context, os);
     if (!Mangler.mangle(D))
       return false;
index 7c7068742d5ccf01480168494e91c7aa34987039..e5f722c513de2181a54dc11c19f66f4ad5d925ec 100644 (file)
@@ -12,8 +12,8 @@ A f(const B &b) {
   return b;
 }
 
-// CHECK-LP64: call     __ZN1AC1ERK1Ai
+// CHECK-LP64: call     __ZN1AC1ERKS_i
 
-// CHECK-LP32: call     L__ZN1AC1ERK1Ai
+// CHECK-LP32: call     L__ZN1AC1ERKS_i
 
 
index 6691912b6f7b1876e8c07b8dce1a2c2f387a5eaf..7e6a7cd8f71ab4d97ee7da9c2a02d7c9c27ba42a 100644 (file)
@@ -31,10 +31,10 @@ int main() {
   X d(a, 5, 6);
 }
 
-// CHECK-LP64: call __ZN1XC1ERK1Xiii
-// CHECK-LP64: call __ZN1XC1ERK1Xiii
-// CHECK-LP64: call __ZN1XC1ERK1Xiii
+// CHECK-LP64: call __ZN1XC1ERKS_iii
+// CHECK-LP64: call __ZN1XC1ERKS_iii
+// CHECK-LP64: call __ZN1XC1ERKS_iii
 
-// CHECK-LP32: call L__ZN1XC1ERK1Xiii
-// CHECK-LP32: call L__ZN1XC1ERK1Xiii
-// CHECK-LP32: call L__ZN1XC1ERK1Xiii
+// CHECK-LP32: call L__ZN1XC1ERKS_iii
+// CHECK-LP32: call L__ZN1XC1ERKS_iii
+// CHECK-LP32: call L__ZN1XC1ERKS_iii
index 3c24b12752828011923fd0e6baecb24444ebbd90..d4a93afefbfaef14e7bd96886a34dd013ff6da3d 100644 (file)
@@ -93,17 +93,17 @@ int main() {
   dstY.pr();
 }
 
-// CHECK-LP64: .globl   __ZN1XaSERK1X
-// CHECK-LP64: .weak_definition  __ZN1XaSERK1X
-// CHECK-LP64: __ZN1XaSERK1X:
-// CHECK-LP64: .globl   __ZN1QaSERK1Q
-// CHECK-LP64: .weak_definition  __ZN1QaSERK1Q
-// CHECK-LP64: __ZN1QaSERK1Q:
+// CHECK-LP64: .globl   __ZN1XaSERKS_
+// CHECK-LP64: .weak_definition  __ZN1XaSERKS_
+// CHECK-LP64: __ZN1XaSERKS_:
+// CHECK-LP64: .globl   __ZN1QaSERKS_
+// CHECK-LP64: .weak_definition  __ZN1QaSERKS_
+// CHECK-LP64: __ZN1QaSERKS_:
 
-// CHECK-LP32: .globl   __ZN1XaSERK1X
-// CHECK-LP32: .weak_definition  __ZN1XaSERK1X
-// CHECK-LP32: __ZN1XaSERK1X:
-// CHECK-LP32: .globl   __ZN1QaSERK1Q
-// CHECK-LP32: .weak_definition  __ZN1QaSERK1Q
-// CHECK-LP32: __ZN1QaSERK1Q:
+// CHECK-LP32: .globl   __ZN1XaSERKS_
+// CHECK-LP32: .weak_definition  __ZN1XaSERKS_
+// CHECK-LP32: __ZN1XaSERKS_:
+// CHECK-LP32: .globl   __ZN1QaSERKS_
+// CHECK-LP32: .weak_definition  __ZN1QaSERKS_
+// CHECK-LP32: __ZN1QaSERKS_:
 
index 37550c42193c74961494d3a54474f7f7e98fb186..47971afe61d4c14c86c94b703b00971769674958 100644 (file)
@@ -101,10 +101,10 @@ int main() {
   m1.pr();
 }
 
-// CHECK-LP64: .globl  __ZN1XC1ERK1X
-// CHECK-LP64: .weak_definition __ZN1XC1ERK1X
-// CHECK-LP64: __ZN1XC1ERK1X:
+// CHECK-LP64: .globl  __ZN1XC1ERKS_
+// CHECK-LP64: .weak_definition __ZN1XC1ERKS_
+// CHECK-LP64: __ZN1XC1ERKS_:
 
-// CHECK-LP32: .globl  __ZN1XC1ERK1X
-// CHECK-LP32: .weak_definition __ZN1XC1ERK1X
-// CHECK-LP32: __ZN1XC1ERK1X:
+// CHECK-LP32: .globl  __ZN1XC1ERKS_
+// CHECK-LP32: .weak_definition __ZN1XC1ERKS_
+// CHECK-LP32: __ZN1XC1ERKS_:
index fb0e990902508b8c9e628ada4929e4c73bbf019b..2ff375e711c6f510c60b6459a5ff79577ac3bd41 100644 (file)
@@ -24,3 +24,10 @@ namespace A {
 
 // CHECK: define void @_Z1fN1A1AENS_1BE(
 void f(A::A a, A::B b) { }
+
+struct C {
+  struct D { };
+};
+
+// CHECK: define void @_Z1fN1C1DERS_PS_S1_(
+void f(C::D, C&, C*, C&) { }
index 8ada907117bea0f1aa77b572c637bc2087dbb794..29629d5bf8242040e6c270536e44387bc708c3d1 100644 (file)
@@ -58,6 +58,6 @@ struct T {
 void test3() {
   T t1, t2;
   
-  // RUN: grep "call void @_ZN1TpsERK1T" %t
+  // RUN: grep "call void @_ZN1TpsERKS_" %t
   T result = t1 + t2;
 }