diff options
author | Anders Carlsson <andersca@mac.com> | 2009-09-26 20:53:44 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-09-26 20:53:44 +0000 |
commit | e7c8cb6b2728aa98258288d221b09bc66cc05543 (patch) | |
tree | 0e66b70fe4ef23340436601bb909a00105b6200b /lib/CodeGen/Mangle.cpp | |
parent | 1668f2062b237ddb137f5d16388b3dea49651f85 (diff) |
Substitute "::std::" as "St".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.cpp')
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index e07c38fd11..c07d9039c0 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -59,6 +59,8 @@ namespace { 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 @@ void CXXNameMangler::mangleTemplateArgument(const TemplateArgument &A) { // <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 @@ bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) { 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>()) { |