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

Anders Carlsson andersca at mac.com
Sat Sep 26 13:53:44 PDT 2009


Author: andersca
Date: Sat Sep 26 15:53:44 2009
New Revision: 82874

URL: http://llvm.org/viewvc/llvm-project?rev=82874&view=rev
Log:
Substitute "::std::" as "St".

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

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

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sat Sep 26 15:53:44 2009
@@ -59,6 +59,8 @@
     bool mangleSubstitution(QualType T);
     bool mangleSubstitution(uintptr_t Ptr);
     
+    bool mangleStandardSubstitution(const NamedDecl *ND);
+    
     void addSubstitution(const NamedDecl *ND) {
       addSubstitution(reinterpret_cast<uintptr_t>(ND));
     }
@@ -1070,8 +1072,11 @@
 
 // <substitution> ::= S <seq-id> _
 //                ::= S_
-
 bool CXXNameMangler::mangleSubstitution(const NamedDecl *ND) {
+  // Try one of the standard substitutions first.
+  if (mangleStandardSubstitution(ND))
+    return true;
+  
   return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
 }
 
@@ -1120,6 +1125,22 @@
   return true;
 }
 
+bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) {
+  // <substitution> ::= St # ::std::
+  
+  const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND);
+  if (!NS)
+    return false;
+  if (!NS->getParent()->isTranslationUnit())
+    return false;
+  
+  if (!NS->getOriginalNamespace()->getIdentifier()->isStr("std"))
+    return false;
+  
+  Out << "St";
+  return true;
+}
+
 void CXXNameMangler::addSubstitution(QualType T) {
   if (!T.getCVRQualifiers()) {
     if (const RecordType *RT = T->getAs<RecordType>()) {

Added: cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp?rev=82874&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp Sat Sep 26 15:53:44 2009
@@ -0,0 +1,9 @@
+// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+namespace std {
+  struct A { A(); };
+  
+  // CHECK: define void @_ZNSt1AC1Ev
+  // CHECK: define void @_ZNSt1AC2Ev
+  A::A() { }
+};





More information about the cfe-commits mailing list