aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/Mangle.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-10-01 00:25:31 +0000
committerJohn McCall <rjmccall@apple.com>2009-10-01 00:25:31 +0000
commit9aeed32282fe8a775c24c01c923717ca86695685 (patch)
tree3cfd3627388904cf806cc552f6b3585fedbb6565 /lib/CodeGen/Mangle.cpp
parent4a5c15f75f76b95e1c2ceb6fa2737dcadd5f4be1 (diff)
Anonymous namespaces, sema + codegen. A lot of semantics are still broken,
apparently because using directives aren't quite working correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83184 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.cpp')
-rw-r--r--lib/CodeGen/Mangle.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 61555ad19d..7555ae5da4 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -254,7 +254,8 @@ static bool isStdNamespace(const DeclContext *DC) {
return false;
const NamespaceDecl *NS = cast<NamespaceDecl>(DC);
- return NS->getOriginalNamespace()->getIdentifier()->isStr("std");
+ const IdentifierInfo *II = NS->getOriginalNamespace()->getIdentifier();
+ return II && II->isStr("std");
}
static const TemplateDecl *
@@ -403,6 +404,14 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) {
DeclarationName Name = ND->getDeclName();
switch (Name.getNameKind()) {
case DeclarationName::Identifier:
+ if (const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND))
+ if (NS->isAnonymousNamespace()) {
+ // This is how gcc mangles these names. It's apparently
+ // always '1', no matter how many different anonymous
+ // namespaces appear in a context.
+ Out << "12_GLOBAL__N_1";
+ break;
+ }
mangleSourceName(Name.getAsIdentifierInfo());
break;
@@ -1204,8 +1213,7 @@ static bool isCharSpecialization(QualType T, const char *Name) {
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")) {
+ if (isStdNamespace(NS)) {
Out << "St";
return true;
}