[PATCH] D11441: Generating available_externally vtables for classes without inline virtual functions

Richard Smith richard at metafoo.co.uk
Wed Jul 22 17:50:35 PDT 2015


rsmith added inline comments.

================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:309
@@ +308,3 @@
+ private:
+  /// Checks if function have any virtual inline function.
+  bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
----------------
function have -> RD has

================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:320
@@ +319,3 @@
+      const auto &method = vtableComponent.getFunctionDecl();
+      if (method->getMostRecentDecl()->isInlined()) return true;
+    }
----------------
majnemer wrote:
> Would we want to use `getCanonicalDecl` instead?
That would give the wrong answer in some cases. The `isInlined` flag is monotonically increasing across the redeclaration chain (at least until we reach a definition, at which point it can't change any more), so checking it on the most recent declaration at end of TU gives the correct answer. The canonical declaration may lie to you.

================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1510-1511
@@ +1509,4 @@
+  // can emit definition of the inline functions.
+  if (!CGM.getCodeGenOpts().OptimizationLevel || CGM.getLangOpts().AppleKext)
+    return false;
+
----------------
I think the `OptimizationLevel` check belongs in the caller, not here. (We can emit `available_externally` vtables even at -O0, we just usually don't want to do so.)


http://reviews.llvm.org/D11441







More information about the cfe-commits mailing list