From: Anders Carlsson Date: Sat, 26 Sep 2009 23:10:05 +0000 (+0000) Subject: Mangle ::std::allocator as Sa. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c0315563f05a9face7209221325019e272075fb;p=clang Mangle ::std::allocator as Sa. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82880 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 3db736b7b4..639d719b79 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1132,18 +1132,26 @@ bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) { bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { // ::= St # ::std:: + if (const NamespaceDecl *NS = dyn_cast(ND)) { + if (NS->getParent()->isTranslationUnit() && + NS->getOriginalNamespace()->getIdentifier()->isStr("std")) { + Out << "St"; + return true; + } + } + + if (const ClassTemplateDecl *TD = dyn_cast(ND)) { + if (!isStdNamespace(TD->getDeclContext())) + return false; + + // ::= Sa # ::std::allocator + if (TD->getIdentifier()->isStr("allocator")) { + Out << "Sa"; + return true; + } + } - const NamespaceDecl *NS = dyn_cast(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) { diff --git a/test/CodeGenCXX/mangle-subst-std.cpp b/test/CodeGenCXX/mangle-subst-std.cpp index a5ba3ab7d0..0fd5eb1c9b 100644 --- a/test/CodeGenCXX/mangle-subst-std.cpp +++ b/test/CodeGenCXX/mangle-subst-std.cpp @@ -7,3 +7,12 @@ namespace std { // CHECK: define void @_ZNSt1AC2Ev A::A() { } }; + +namespace std { + template 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, typename std::allocator) { }