A C++ member function always has either weak linkage (if it's inline or defined inline) or strong linkage (other cases).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71873 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 706a973..2c96615 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -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;