]> granicus.if.org Git - clang/commitdiff
[MS ABI] Cleanup emitVTableDefinitions
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 9 Feb 2016 17:27:52 +0000 (17:27 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 9 Feb 2016 17:27:52 +0000 (17:27 +0000)
Use the VFTable components to determine whether or not we should emit
RTTI data instead of duplicating the VFTableBuilder's logic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260238 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MicrosoftCXXABI.cpp

index 4cd4f8533b7f725ddba4721ef5be188f723ecdae..0664381b44f8f69339ae9d7cdf0771b08c6d548e 100644 (file)
@@ -1567,14 +1567,14 @@ void MicrosoftCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT,
     if (VTable->hasInitializer())
       continue;
 
-    llvm::Constant *RTTI = getContext().getLangOpts().RTTIData &&
-                                   VTable->getDLLStorageClass() !=
-                                       llvm::GlobalValue::DLLImportStorageClass
-                               ? getMSCompleteObjectLocator(RD, Info)
-                               : nullptr;
-
     const VTableLayout &VTLayout =
       VFTContext.getVFTableLayout(RD, Info->FullOffsetInMDC);
+
+    llvm::Constant *RTTI = nullptr;
+    if (any_of(VTLayout.vtable_components(),
+               [](const VTableComponent &VTC) { return VTC.isRTTIKind(); }))
+      RTTI = getMSCompleteObjectLocator(RD, Info);
+
     llvm::Constant *Init = CGVT.CreateVTableInitializer(
         RD, VTLayout.vtable_component_begin(),
         VTLayout.getNumVTableComponents(), VTLayout.vtable_thunk_begin(),