From b217c1b9d2225521f4021984ad5a424784fa22bb Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 6 Oct 2009 21:58:01 +0000 Subject: [PATCH] When mangling names, always use the canonical decl. Fixes PR5144. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83420 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 2 +- test/CodeGenCXX/mangle.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 7555ae5da4..702edf05a9 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1303,7 +1303,7 @@ namespace clang { "Mangling declaration"); CXXNameMangler Mangler(Context, os); - if (!Mangler.mangle(D)) + if (!Mangler.mangle(cast(D->getCanonicalDecl()))) return false; os.flush(); diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index 86f5fb0d5b..a881a710d4 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -198,3 +198,12 @@ template typename __enable_if<__is_scalar::__value, void>::__type template void ft7(); // CHECK: @_Z3ft7IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv template void ft7(); + +// PR5144 +extern "C" { +void extern_f(void); +}; + +// CHECK: @extern_f +void extern_f(void) { } +