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));
}
// <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));
}
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>()) {
--- /dev/null
+// 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() { }
+};