]> granicus.if.org Git - clang/commitdiff
Pass the desired vtable linkage to GenerateVtable directly. Only call MaybeMarkVirtua...
authorAnders Carlsson <andersca@mac.com>
Sun, 6 Dec 2009 00:23:49 +0000 (00:23 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 6 Dec 2009 00:23:49 +0000 (00:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90686 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.cpp
lib/CodeGen/CGVtable.h
lib/Sema/SemaDecl.cpp

index b52e5739d599676199a3f47b4168087f1f6356b1..6f8f9ebd834c6d11b0fa6a58a9e0c53e4170665f 100644 (file)
@@ -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) {
index bfffb673aef1d200e5c069887932111f4f9d63d0..37fa1230f69e4a5d4f1a7f7ec0d21649d0cd54ff 100644 (file)
 #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)
index c5bebcc9516da7b2e3fea9f1648498e04162259a..d05340a42674d7477219d8f19cc514ed536b6803 100644 (file)
@@ -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)) {