aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/Mangle.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-04-02 16:24:45 +0000
committerAnders Carlsson <andersca@mac.com>2009-04-02 16:24:45 +0000
commit1b42c794481f6f958267e4ba913d74fef43161f6 (patch)
treeff591a927f5ddbc0bbee2d6fd71327fdd392376a /lib/CodeGen/Mangle.cpp
parent329749c1ec1ead3c41af52260f1203e4991b4e83 (diff)
Implement mangling of declarations inside functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.cpp')
-rw-r--r--lib/CodeGen/Mangle.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 6e62fcfc2e..3e685e6b17 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/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<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>