[PATCH] D28310: Add virtual functions getter

2017-01-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This is a potentially significant pessimization.  Can you turn this into a 
range iterator of some sort?


https://reviews.llvm.org/D28310



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28310: Add virtual functions getter

2017-01-04 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek created this revision.
Prazek added a reviewer: rjmccall.
Prazek added a subscriber: cfe-commits.

Small refactor


https://reviews.llvm.org/D28310

Files:
  include/clang/AST/VTableBuilder.h
  lib/CodeGen/ItaniumCXXABI.cpp


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -367,19 +367,12 @@
 
  private:
bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
-const auto &VtableLayout =
-CGM.getItaniumVTableContext().getVTableLayout(RD);
-
-for (const auto &VtableComponent : VtableLayout.vtable_components()) {
-  // Skip empty slot.
-  if (!VtableComponent.isUsedFunctionPointerKind())
-continue;
-
-  const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
-  if (Method->getCanonicalDecl()->isInlined())
-return true;
-}
-return false;
+ const auto &VTableLayout =
+ CGM.getItaniumVTableContext().getVTableLayout(RD);
+ for (const auto *VFunction : VTableLayout.virtualFunctions())
+   if (VFunction->getCanonicalDecl()->isInlined())
+ return true;
+ return false;
   }
 
   bool isVTableHidden(const CXXRecordDecl *RD) const {
Index: include/clang/AST/VTableBuilder.h
===
--- include/clang/AST/VTableBuilder.h
+++ include/clang/AST/VTableBuilder.h
@@ -254,6 +254,17 @@
 return VTableThunks;
   }
 
+  llvm::SmallVector virtualFunctions() const {
+llvm::SmallVector VFunctions;
+for (const auto &VtableComponent : vtable_components()) {
+  // Skip everything except functions.
+  if (!VtableComponent.isUsedFunctionPointerKind())
+continue;
+  VFunctions.push_back(VtableComponent.getFunctionDecl());
+}
+return VFunctions;
+  }
+
   AddressPointLocation getAddressPoint(BaseSubobject Base) const {
 assert(AddressPoints.count(Base) && "Did not find address point!");
 return AddressPoints.find(Base)->second;


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -367,19 +367,12 @@
 
  private:
bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
-const auto &VtableLayout =
-CGM.getItaniumVTableContext().getVTableLayout(RD);
-
-for (const auto &VtableComponent : VtableLayout.vtable_components()) {
-  // Skip empty slot.
-  if (!VtableComponent.isUsedFunctionPointerKind())
-continue;
-
-  const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
-  if (Method->getCanonicalDecl()->isInlined())
-return true;
-}
-return false;
+ const auto &VTableLayout =
+ CGM.getItaniumVTableContext().getVTableLayout(RD);
+ for (const auto *VFunction : VTableLayout.virtualFunctions())
+   if (VFunction->getCanonicalDecl()->isInlined())
+ return true;
+ return false;
   }
 
   bool isVTableHidden(const CXXRecordDecl *RD) const {
Index: include/clang/AST/VTableBuilder.h
===
--- include/clang/AST/VTableBuilder.h
+++ include/clang/AST/VTableBuilder.h
@@ -254,6 +254,17 @@
 return VTableThunks;
   }
 
+  llvm::SmallVector virtualFunctions() const {
+llvm::SmallVector VFunctions;
+for (const auto &VtableComponent : vtable_components()) {
+  // Skip everything except functions.
+  if (!VtableComponent.isUsedFunctionPointerKind())
+continue;
+  VFunctions.push_back(VtableComponent.getFunctionDecl());
+}
+return VFunctions;
+  }
+
   AddressPointLocation getAddressPoint(BaseSubobject Base) const {
 assert(AddressPoints.count(Base) && "Did not find address point!");
 return AddressPoints.find(Base)->second;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits