From 4fa53427585ceea6e5e947bc19e7cfbce17bb4fa Mon Sep 17 00:00:00 2001 From: John McCall Date: Thu, 1 Oct 2009 00:25:31 +0000 Subject: Anonymous namespaces, sema + codegen. A lot of semantics are still broken, apparently because using directives aren't quite working correctly. llvm-svn: 83184 --- clang/lib/CodeGen/Mangle.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/Mangle.cpp') diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp index 61555ad19db..7555ae5da46 100644 --- a/clang/lib/CodeGen/Mangle.cpp +++ b/clang/lib/CodeGen/Mangle.cpp @@ -254,7 +254,8 @@ static bool isStdNamespace(const DeclContext *DC) { return false; const NamespaceDecl *NS = cast(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(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) { // ::= St # ::std:: if (const NamespaceDecl *NS = dyn_cast(ND)) { - if (NS->getParent()->isTranslationUnit() && - NS->getOriginalNamespace()->getIdentifier()->isStr("std")) { + if (isStdNamespace(NS)) { Out << "St"; return true; } -- cgit v1.2.3