[clang] [llvm] [mlir] [TableGen] Only store direct superclasses in Record (PR #123072)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 09:37:28 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 {
----------------
mshockwave 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.
Though unfortunately we're not doing it at this moment, I think we _should_ make good uses of this location (where the superclass was reference) to show a nice backtrace. Personally I feel like if it doesn't take a lot of efforts we should probably keep the location.
https://github.com/llvm/llvm-project/pull/123072
More information about the llvm-commits
mailing list