[PATCH] D87967: TableGen: Change comments about superclass order
Paul C. Anagnostopoulos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 19 09:27:29 PDT 2020
Paul-C-Anagnostopoulos created this revision.
Paul-C-Anagnostopoulos added reviewers: lattner, nhaehnle.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Paul-C-Anagnostopoulos requested review of this revision.
The comments about the SuperClasses list in the Record class says that the list is in reverse pre-order. Unless I've gone mad, the list is actually in post-order. Traversing it backward produces reverse pre-order. I fixed the comments.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87967
Files:
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
Index: llvm/lib/TableGen/Record.cpp
===================================================================
--- llvm/lib/TableGen/Record.cpp
+++ llvm/lib/TableGen/Record.cpp
@@ -2112,9 +2112,11 @@
void Record::getDirectSuperClasses(SmallVectorImpl<Record *> &Classes) const {
ArrayRef<std::pair<Record *, SMRange>> SCs = getSuperClasses();
+
+ // Superclasses are in post-order, so the final one is a direct
+ // superclass. All of its transitive superclases immediately precede it,
+ // so we can step through the direct superclasses in reverse order.
while (!SCs.empty()) {
- // Superclasses are in reverse preorder, so 'back' is a direct superclass,
- // and its transitive superclasses are directly preceding it.
Record *SC = SCs.back().first;
SCs = SCs.drop_back(1 + SC->getSuperClasses().size());
Classes.push_back(SC);
Index: llvm/include/llvm/TableGen/Record.h
===================================================================
--- llvm/include/llvm/TableGen/Record.h
+++ llvm/include/llvm/TableGen/Record.h
@@ -1440,7 +1440,7 @@
SmallVector<Init *, 0> TemplateArgs;
SmallVector<RecordVal, 0> Values;
- // All superclasses in the inheritance forest in reverse preorder (yes, it
+ // All superclasses in the inheritance forest in post-order (yes, it
// must be a forest; diamond-shaped inheritance is not allowed).
SmallVector<std::pair<Record *, SMRange>, 0> SuperClasses;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87967.292971.patch
Type: text/x-patch
Size: 1429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200919/e9a89eea/attachment.bin>
More information about the llvm-commits
mailing list