From b135f0f2d893121ed2cc46d4d6c5bd5ab87d872f Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 2 Jul 2012 21:05:30 +0000 Subject: [PATCH] When we're looking for redeclarations which might provide a definition in CodeGen, make sure we examine all the redeclarations. PR13252. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159586 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 1 + test/CodeGenCXX/inline-functions.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 25053b91a4..ef20cf4556 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1111,6 +1111,7 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName, } else if (getLangOpts().CPlusPlus && D.getDecl()) { // Look for a declaration that's lexically in a record. const FunctionDecl *FD = cast(D.getDecl()); + FD = FD->getMostRecentDecl(); do { if (isa(FD->getLexicalDeclContext())) { if (FD->isImplicit() && !ForVTable) { diff --git a/test/CodeGenCXX/inline-functions.cpp b/test/CodeGenCXX/inline-functions.cpp index 69dfe0db98..8c011de28a 100644 --- a/test/CodeGenCXX/inline-functions.cpp +++ b/test/CodeGenCXX/inline-functions.cpp @@ -53,3 +53,17 @@ namespace test1 { c.func(); } } + +// PR13252 +namespace test2 { + struct A; + void f(const A& a); + struct A { + friend void f(const A& a) { } + }; + void g() { + A a; + f(a); + } + // CHECK: define linkonce_odr void @_ZN5test21fERKNS_1AE +} -- 2.40.0