forked from OSchip/llvm-project
Implement mangling of declarations inside functions.
llvm-svn: 68321
This commit is contained in:
parent
f2125a02db
commit
4eca109941
|
@ -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<FunctionDecl>(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) {
|
||||
// <local-name> := Z <function encoding> E <entity name> [<discriminator>]
|
||||
// := Z <function encoding> E s [<discriminator>]
|
||||
// <discriminator> := _ <non-negative number>
|
||||
Out << 'Z';
|
||||
mangleFunctionEncoding(cast<FunctionDecl>(ND->getDeclContext()));
|
||||
Out << 'E';
|
||||
mangleSourceName(ND->getIdentifier());
|
||||
}
|
||||
|
||||
void CXXNameMangler::manglePrefix(const DeclContext *DC) {
|
||||
// <prefix> ::= <prefix> <unqualified-name>
|
||||
// ::= <template-prefix> <template-args>
|
||||
|
|
|
@ -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; } }
|
||||
|
|
Loading…
Reference in New Issue