From 2c4de4c31eb1069d76314881d1fb79bdfe98c953 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 6 Feb 2010 04:52:27 +0000 Subject: [PATCH] Only append 'L' for internal variable declarations, not all declarations. (Found by the mangle checker, yay) llvm-svn: 95485 --- clang/lib/CodeGen/Mangle.cpp | 7 ++++--- clang/test/CodeGenCXX/mangle.cpp | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp index 9ac5956a644f..a302225c7f77 100644 --- a/clang/lib/CodeGen/Mangle.cpp +++ b/clang/lib/CodeGen/Mangle.cpp @@ -482,9 +482,10 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, case DeclarationName::Identifier: { if (const IdentifierInfo *II = Name.getAsIdentifierInfo()) { // We must avoid conflicts between internally- and externally- - // linked names in the same TU. This naming convention is the - // same as that followed by GCC, though it shouldn't actually matter. - if (ND && ND->getLinkage() == InternalLinkage && + // 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(ND) && ND->getLinkage() == InternalLinkage && ND->getDeclContext()->isFileContext()) Out << 'L'; diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp index 8f45175ae897..07183782e75e 100644 --- a/clang/test/CodeGenCXX/mangle.cpp +++ b/clang/test/CodeGenCXX/mangle.cpp @@ -372,3 +372,7 @@ namespace test1 { // CHECK: define void @_ZN5test11fINS_1XEiEEvT_IT0_E template void f(X); } + +// CHECK: define internal void @_Z27functionWithInternalLinkagev() +static void functionWithInternalLinkage() { } +void g() { functionWithInternalLinkage(); }