diff options
author | Anders Carlsson <andersca@mac.com> | 2009-12-06 00:23:49 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-12-06 00:23:49 +0000 |
commit | 0911ae8ef20f0251d51cb840cbe41b4255565351 (patch) | |
tree | 16119fee7e3c33cd3f92757363d9e1fcc79d30e2 /clang | |
parent | 58eea20f47c54ff0f230234cddac70dec44da16c (diff) | |
download | bcm5719-llvm-0911ae8ef20f0251d51cb840cbe41b4255565351.tar.gz bcm5719-llvm-0911ae8ef20f0251d51cb840cbe41b4255565351.zip |
Pass the desired vtable linkage to GenerateVtable directly. Only call MaybeMarkVirtualImplicitMembersReferenced for non-inline functions.
llvm-svn: 90686
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGVtable.cpp | 26 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVtable.h | 13 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 4 |
3 files changed, 16 insertions, 27 deletions
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp index b52e5739d59..6f8f9ebd834 100644 --- a/clang/lib/CodeGen/CGVtable.cpp +++ b/clang/lib/CodeGen/CGVtable.cpp @@ -1112,7 +1112,8 @@ createGlobalVariable(CodeGenModule &CGM, const CXXRecordDecl *RD, } llvm::GlobalVariable * -CGVtableInfo::GenerateVtable(const CXXRecordDecl *LayoutClass, +CGVtableInfo::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage, + const CXXRecordDecl *LayoutClass, const CXXRecordDecl *RD, uint64_t Offset) { llvm::SmallString<256> OutName; if (LayoutClass != RD) @@ -1133,21 +1134,7 @@ CGVtableInfo::GenerateVtable(const CXXRecordDecl *LayoutClass, if (AddressPoint == 0) AddressPoint = 1; } else { - bool CreateDefinition = true; - if (LayoutClass != RD) - CreateDefinition = true; - else { - const ASTRecordLayout &Layout = - CGM.getContext().getASTRecordLayout(LayoutClass); - - if (const CXXMethodDecl *KeyFunction = Layout.getKeyFunction()) { - if (!KeyFunction->getBody()) { - // If there is a KeyFunction, and it isn't defined, just build a - // reference to the vtable. - CreateDefinition = false; - } - } - } + bool CreateDefinition = Linkage != llvm::GlobalVariable::ExternalLinkage; VtableBuilder b(RD, LayoutClass, Offset, CGM, CreateDefinition); @@ -1383,7 +1370,7 @@ llvm::Constant *CodeGenModule::GenerateVTT(const CXXRecordDecl *RD) { } void CGVtableInfo::GenerateClassData(const CXXRecordDecl *RD) { - Vtables[RD] = GenerateVtable(RD, RD, 0); + Vtables[RD] = GenerateVtable(llvm::GlobalValue::WeakODRLinkage, RD, RD, 0); CGM.GenerateRTTI(RD); CGM.GenerateVTT(RD); } @@ -1392,7 +1379,7 @@ llvm::GlobalVariable *CGVtableInfo::getVtable(const CXXRecordDecl *RD) { llvm::GlobalVariable *Vtable = Vtables[RD]; if (!Vtable) - Vtable = GenerateVtable(RD, RD, 0); + Vtable = GenerateVtable(llvm::GlobalValue::ExternalLinkage, RD, RD, 0); return Vtable; } @@ -1400,7 +1387,8 @@ llvm::GlobalVariable *CGVtableInfo::getVtable(const CXXRecordDecl *RD) { llvm::GlobalVariable * CGVtableInfo::getCtorVtable(const CXXRecordDecl *LayoutClass, const CXXRecordDecl *RD, uint64_t Offset) { - return GenerateVtable(LayoutClass, RD, Offset); + return GenerateVtable(llvm::GlobalValue::InternalLinkage, + LayoutClass, RD, Offset); } void CGVtableInfo::MaybeEmitVtable(GlobalDecl GD) { diff --git a/clang/lib/CodeGen/CGVtable.h b/clang/lib/CodeGen/CGVtable.h index bfffb673aef..37fa1230f69 100644 --- a/clang/lib/CodeGen/CGVtable.h +++ b/clang/lib/CodeGen/CGVtable.h @@ -15,12 +15,9 @@ #define CLANG_CODEGEN_CGVTABLE_H #include "llvm/ADT/DenseMap.h" +#include "llvm/GlobalVariable.h" #include "GlobalDecl.h" -namespace llvm { - class GlobalVariable; -} - namespace clang { class CXXRecordDecl; @@ -97,9 +94,11 @@ class CGVtableInfo { /// rtti data structure and the VTT. void GenerateClassData(const CXXRecordDecl *RD); - llvm::GlobalVariable *GenerateVtable(const CXXRecordDecl *LayoutClass, - const CXXRecordDecl *RD, - uint64_t Offset); + llvm::GlobalVariable * + + GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage, + const CXXRecordDecl *LayoutClass, const CXXRecordDecl *RD, + uint64_t Offset); public: CGVtableInfo(CodeGenModule &CGM) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c5bebcc9516..d05340a4267 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4120,7 +4120,9 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, if (Method->isVirtual() && !Method->isPure()) MarkDeclarationReferenced(Method->getLocation(), Method); - MaybeMarkVirtualImplicitMembersReferenced(Method->getLocation(), Method); + if (!Method->isInlined()) + MaybeMarkVirtualImplicitMembersReferenced(Method->getLocation(), + Method); } assert(FD == getCurFunctionDecl() && "Function parsing confused"); } else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) { |