[clang] [llvm] [mlir] [TableGen] Only store direct superclasses in Record (PR #123072)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 03:23:41 PST 2025


================
@@ -1718,15 +1719,30 @@ class Record {
   ArrayRef<AssertionInfo> getAssertions() const { return Assertions; }
   ArrayRef<DumpInfo> getDumps() const { return Dumps; }
 
-  ArrayRef<std::pair<const Record *, SMRange>> getSuperClasses() const {
-    return SuperClasses;
+  /// Append all superclasses in post-order to \p Classes.
+  void getSuperClasses(std::vector<const Record *> &Classes) const {
+    for (const auto &[SC, R] : DirectSuperClasses) {
+      SC->getSuperClasses(Classes);
+      Classes.push_back(SC);
+    }
+  }
+
+  /// Return all superclasses in post-order.
+  std::vector<const Record *> getSuperClasses() const {
+    std::vector<const Record *> Classes;
+    getSuperClasses(Classes);
+    return Classes;
   }
 
   /// Determine whether this record has the specified direct superclass.
-  bool hasDirectSuperClass(const Record *SuperClass) const;
+  bool hasDirectSuperClass(const Record *SuperClass) const {
+    return is_contained(make_first_range(DirectSuperClasses), SuperClass);
+  }
 
-  /// Append the direct superclasses of this record to Classes.
-  void getDirectSuperClasses(SmallVectorImpl<const Record *> &Classes) const;
+  /// Return the direct superclasses of this record.
+  ArrayRef<std::pair<const Record *, SMRange>> getDirectSuperClasses() const {
----------------
s-barannikov wrote:

I'm not sure location should be removed completely as it might be used for diagnostics.
On the other hand, I can't immediately think of a case where the location of a super-class reference in an error message would be useful.


https://github.com/llvm/llvm-project/pull/123072


More information about the llvm-commits mailing list