[cfe-commits] r71873 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/member-functions.cpp
Anders Carlsson
andersca at mac.com
Fri May 15 11:35:49 PDT 2009
Author: andersca
Date: Fri May 15 13:35:39 2009
New Revision: 71873
URL: http://llvm.org/viewvc/llvm-project?rev=71873&view=rev
Log:
A C++ member function always has either weak linkage (if it's inline or defined inline) or strong linkage (other cases).
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/member-functions.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=71873&r1=71872&r2=71873&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 15 13:35:39 2009
@@ -241,6 +241,14 @@
static CodeGenModule::GVALinkage
GetLinkageForFunction(const FunctionDecl *FD, const LangOptions &Features) {
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
+ // C++ member functions defined inside the class are always inline.
+ if (MD->isInline() || !MD->isOutOfLineDefinition())
+ return CodeGenModule::GVA_CXXInline;
+
+ return CodeGenModule::GVA_StrongExternal;
+ }
+
// "static" functions get internal linkage.
if (FD->getStorageClass() == FunctionDecl::Static)
return CodeGenModule::GVA_Internal;
Modified: cfe/trunk/test/CodeGenCXX/member-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/member-functions.cpp?rev=71873&r1=71872&r2=71873&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/member-functions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/member-functions.cpp Fri May 15 13:35:39 2009
@@ -26,14 +26,21 @@
inline ~S() { }
+ // RUN: grep "define linkonce_odr void @_ZN1S9f_inline1Ev" %t &&
void f_inline1() { }
// RUN: grep "define linkonce_odr void @_ZN1S9f_inline2Ev" %t &&
inline void f_inline2() { }
- // RUN: grep "define internal void @_ZN1S1gEv" %t
+ // RUN: grep "define linkonce_odr void @_ZN1S1gEv" %t &&
static void g() { }
+
+ static void f();
};
+// RUN: grep "define void @_ZN1S1fEv" %t
+void S::f() {
+}
+
void test2() {
S s;
More information about the cfe-commits
mailing list