diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp index 6e62fcfc2e67..3e685e6b1722 100644 --- a/clang/lib/CodeGen/Mangle.cpp +++ b/clang/lib/CodeGen/Mangle.cpp @@ -42,6 +42,7 @@ namespace { void mangleName(const NamedDecl *ND); void mangleUnqualifiedName(const NamedDecl *ND); void mangleSourceName(const IdentifierInfo *II); + void mangleLocalName(const NamedDecl *ND); void mangleNestedName(const NamedDecl *ND); void manglePrefix(const DeclContext *DC); void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity); @@ -149,9 +150,10 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) { else if (isStdNamespace(ND->getDeclContext())) { Out << "St"; mangleUnqualifiedName(ND); - } else { + } else if (isa(ND->getDeclContext())) + mangleLocalName(ND); + else mangleNestedName(ND); - } } void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) { @@ -226,6 +228,16 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND) { Out << 'E'; } +void CXXNameMangler::mangleLocalName(const NamedDecl *ND) { + // := Z E [] + // := Z E s [] + // := _ + Out << 'Z'; + mangleFunctionEncoding(cast(ND->getDeclContext())); + Out << 'E'; + mangleSourceName(ND->getIdentifier()); +} + void CXXNameMangler::manglePrefix(const DeclContext *DC) { // ::= // ::= diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp index e9a76c93f08e..f608a22f0323 100644 --- a/clang/test/CodeGenCXX/mangle.cpp +++ b/clang/test/CodeGenCXX/mangle.cpp @@ -39,5 +39,8 @@ extern "C" { namespace N { void unmangled_function() { } } } // RUN: grep unmangled_variable %t | count 1 && extern "C" { namespace N { int unmangled_variable; } } -// RUN: grep _ZN1N1iE %t | count 1 +// RUN: grep _ZN1N1iE %t | count 1 && namespace N { int i; } + +// RUN: grep _ZZN1N1fEiiE1b %t | count 2 +namespace N { int f(int, int) { static int b; return b; } }