[cfe-commits] r68321 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle.cpp
Anders Carlsson
andersca at mac.com
Thu Apr 2 09:24:45 PDT 2009
Author: andersca
Date: Thu Apr 2 11:24:45 2009
New Revision: 68321
URL: http://llvm.org/viewvc/llvm-project?rev=68321&view=rev
Log:
Implement mangling of declarations inside functions.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=68321&r1=68320&r2=68321&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Thu Apr 2 11:24:45 2009
@@ -42,6 +42,7 @@
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 @@
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 @@
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>
Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=68321&r1=68320&r2=68321&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Thu Apr 2 11:24:45 2009
@@ -39,5 +39,8 @@
// 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; } }
More information about the cfe-commits
mailing list