[cfe-commits] r90686 - in /cfe/trunk/lib: CodeGen/CGVtable.cpp CodeGen/CGVtable.h Sema/SemaDecl.cpp
Anders Carlsson
andersca at mac.com
Sat Dec 5 16:23:49 PST 2009
Author: andersca
Date: Sat Dec 5 18:23:49 2009
New Revision: 90686
URL: http://llvm.org/viewvc/llvm-project?rev=90686&view=rev
Log:
Pass the desired vtable linkage to GenerateVtable directly. Only call MaybeMarkVirtualImplicitMembersReferenced for non-inline functions.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/lib/CodeGen/CGVtable.h
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=90686&r1=90685&r2=90686&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Sat Dec 5 18:23:49 2009
@@ -1112,7 +1112,8 @@
}
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 @@
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 @@
}
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 *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::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) {
Modified: cfe/trunk/lib/CodeGen/CGVtable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.h?rev=90686&r1=90685&r2=90686&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.h (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.h Sat Dec 5 18:23:49 2009
@@ -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 @@
/// 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)
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=90686&r1=90685&r2=90686&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Dec 5 18:23:49 2009
@@ -4120,7 +4120,9 @@
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)) {
More information about the cfe-commits
mailing list