Fix a bug in the mangler where in 'namespace std { extern "C" {X;} }', X would not be seen to be in ::std::.

Migrate two other places where the same logic is used to use the helper function that already exists.

llvm-svn: 152022
This commit is contained in:
James Molloy 2012-03-05 09:59:43 +00:00
parent 5db541304f
commit 7583ccdc1f
2 changed files with 31 additions and 5 deletions

View File

@ -553,8 +553,7 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) {
return;
}
while (isa<LinkageSpecDecl>(DC))
DC = getEffectiveParentContext(DC);
DC = IgnoreLinkageSpecDecls(DC);
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
// Check if we have a template.
@ -594,7 +593,8 @@ void CXXNameMangler::mangleName(const TemplateDecl *TD,
void CXXNameMangler::mangleUnscopedName(const NamedDecl *ND) {
// <unscoped-name> ::= <unqualified-name>
// ::= St <unqualified-name> # ::std::
if (isStdNamespace(getEffectiveDeclContext(ND)))
if (isStdNamespace(IgnoreLinkageSpecDecls(getEffectiveDeclContext(ND))))
Out << "St";
mangleUnqualifiedName(ND);
@ -1393,8 +1393,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
// ::= # empty
// ::= <substitution>
while (isa<LinkageSpecDecl>(DC))
DC = getEffectiveParentContext(DC);
DC = IgnoreLinkageSpecDecls(DC);
if (DC->isTranslationUnit())
return;

View File

@ -0,0 +1,27 @@
// RUN: %clang_cc1 %s -DNS=std -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-STD
// RUN: %clang_cc1 %s -DNS=n -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-N
// _ZNSt1DISt1CE1iE = std::D<std::C>::i
// CHECK-STD: @_ZNSt1DISt1CE1iE =
// _ZN1n1DINS_1CEE1iE == n::D<n::C>::i
// CHECK-N: @_ZN1n1DINS_1CEE1iE =
namespace NS {
extern "C" {
class C {
};
}
template <class T>
class D {
public:
static int i;
};
}
int f() {
return NS::D<NS::C>::i;
}