forked from OSchip/llvm-project
A C++ member function always has either weak linkage (if it's inline or defined inline) or strong linkage (other cases).
llvm-svn: 71873
This commit is contained in:
parent
82049e6bdd
commit
37604a0984
|
@ -241,6 +241,14 @@ void CodeGenModule::EmitAnnotations() {
|
|||
|
||||
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;
|
||||
|
|
|
@ -26,14 +26,21 @@ struct S {
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue