aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ItaniumMangle.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-03-22 06:34:45 +0000
committerJohn McCall <rjmccall@apple.com>2011-03-22 06:34:45 +0000
commit74990f45b0bc57fca81f908efb13d2b6c6350f03 (patch)
tree50a10cf5ec55dd718a51b008505c34dce1aa3433 /lib/AST/ItaniumMangle.cpp
parent5fff46b65389f7e7eb576e47c7bc3ca67326a206 (diff)
File-scope static functions need to be mangled with 'L' so that
they don't collide with file-scope extern functions from the same translation unit. This is basically a matter of applying the same logic to FunctionDecls as we were previously applying to VarDecls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ItaniumMangle.cpp')
-rw-r--r--lib/AST/ItaniumMangle.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index bceed08137..bb274a96f1 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -695,10 +695,12 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
case DeclarationName::Identifier: {
if (const IdentifierInfo *II = Name.getAsIdentifierInfo()) {
// We must avoid conflicts between internally- and externally-
- // linked variable declaration names in the same TU.
- // This naming convention is the same as that followed by GCC, though it
- // shouldn't actually matter.
- if (ND && isa<VarDecl>(ND) && ND->getLinkage() == InternalLinkage &&
+ // linked variable and function declaration names in the same TU:
+ // void test() { extern void foo(); }
+ // static void foo();
+ // This naming convention is the same as that followed by GCC,
+ // though it shouldn't actually matter.
+ if (ND && ND->getLinkage() == InternalLinkage &&
ND->getDeclContext()->isFileContext())
Out << 'L';