[llvm] [TableGen] Only store direct superclasses in Record (PR #123072)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 03:32:10 PST 2025
================
@@ -1718,15 +1719,23 @@ class Record {
ArrayRef<AssertionInfo> getAssertions() const { return Assertions; }
ArrayRef<DumpInfo> getDumps() const { return Dumps; }
- ArrayRef<std::pair<const Record *, SMRange>> getSuperClasses() const {
- return SuperClasses;
+ void getSuperClasses(
----------------
s-barannikov wrote:
> I assume it is safe to iterate over a temporary returned from this function:
It is safe, the lifetime of the vector is extended by a [reference](https://eel.is/c++draft/stmt.ranged#1.sentence-1).
Something like this won't work though (note `reverse`):
```
for (const Record *SC : reverse(Def->getSuperClasses())) { ... }
```
This was fixed in C++23. http://wg21.link/cwg900
https://github.com/llvm/llvm-project/pull/123072
More information about the llvm-commits
mailing list