]> granicus.if.org Git - clang/commitdiff
Mangle ::std::allocator as Sa.
authorAnders Carlsson <andersca@mac.com>
Sat, 26 Sep 2009 23:10:05 +0000 (23:10 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 26 Sep 2009 23:10:05 +0000 (23:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82880 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/mangle-subst-std.cpp

index 3db736b7b489686b0c356018e245bd5a70e3ab4b..639d719b79fb4bf08da5ac542ccfb18ff74cb5b7 100644 (file)
@@ -1132,18 +1132,26 @@ bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) {
 
 bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) {
   // <substitution> ::= St # ::std::
+  if (const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
+    if (NS->getParent()->isTranslationUnit() &&
+        NS->getOriginalNamespace()->getIdentifier()->isStr("std")) {
+      Out << "St";
+      return true;
+    }
+  }
+
+  if (const ClassTemplateDecl *TD = dyn_cast<ClassTemplateDecl>(ND)) {
+    if (!isStdNamespace(TD->getDeclContext()))
+      return false;
+    
+    // <substitution> ::= Sa # ::std::allocator
+    if (TD->getIdentifier()->isStr("allocator")) {
+      Out << "Sa";
+      return true;
+    }
+  }
   
-  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;
+  return false;
 }
 
 void CXXNameMangler::addSubstitution(QualType T) {
index a5ba3ab7d08d0850ea87bfced97fedae023f8dd5..0fd5eb1c9b90b4bfd6bbb7ef891ed03f170a9737 100644 (file)
@@ -7,3 +7,12 @@ namespace std {
   // CHECK: define void @_ZNSt1AC2Ev
   A::A() { }
 };
+
+namespace std {
+  template<typename T> struct allocator { allocator(); };
+}
+
+// FIXME: typename is really not allowed here, but it's kept 
+// as a workaround for PR5061.
+// CHECK: define void @_Z1fSaIcESaIiE
+void f(typename std::allocator<char>, typename std::allocator<int>) { }