[cfe-commits] r128072 - in /cfe/trunk: lib/AST/ItaniumMangle.cpp test/CodeGenCXX/mangle.cpp
John McCall
rjmccall at apple.com
Mon Mar 21 23:34:45 PDT 2011
Author: rjmccall
Date: Tue Mar 22 01:34:45 2011
New Revision: 128072
URL: http://llvm.org/viewvc/llvm-project?rev=128072&view=rev
Log:
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.
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=128072&r1=128071&r2=128072&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Mar 22 01:34:45 2011
@@ -695,10 +695,12 @@
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';
Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=128072&r1=128071&r2=128072&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Tue Mar 22 01:34:45 2011
@@ -373,7 +373,7 @@
template void f(X<int>);
}
-// CHECK: define internal void @_Z27functionWithInternalLinkagev()
+// CHECK: define internal void @_ZL27functionWithInternalLinkagev()
static void functionWithInternalLinkage() { }
void g() { functionWithInternalLinkage(); }
@@ -647,3 +647,17 @@
void f(vpca5 volatile (&)[10]) {}
// CHECK: define void @_ZN6test231fERA10_A5_VKPv(
}
+
+namespace test24 {
+ void test0() {
+ extern int foo();
+ // CHECK: call i32 @_ZN6test243fooEv()
+ foo();
+ }
+
+ static char foo() {}
+ void test1() {
+ // CHECK: call signext i8 @_ZN6test24L3fooEv()
+ foo();
+ }
+}
More information about the cfe-commits
mailing list