[llvm] bd55d5b - Change comments about order of classes in superclass list.

Paul C. Anagnostopoulos via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 07:26:45 PDT 2020


Author: Paul C. Anagnostopoulos
Date: 2020-09-21T10:25:44-04:00
New Revision: bd55d5b2a11030dc7a93008275c533bbdb748c72

URL: https://github.com/llvm/llvm-project/commit/bd55d5b2a11030dc7a93008275c533bbdb748c72
DIFF: https://github.com/llvm/llvm-project/commit/bd55d5b2a11030dc7a93008275c533bbdb748c72.diff

LOG: Change comments about order of classes in superclass list.

Added: 
    

Modified: 
    llvm/include/llvm/TableGen/Record.h
    llvm/lib/TableGen/Record.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 3724c2651c06..5e1a04d541ac 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1440,7 +1440,7 @@ class Record {
   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;
 

diff  --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index a56d50b33b21..49e95e22c0a0 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -2112,9 +2112,11 @@ void Record::setName(Init *NewName) {
 
 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);


        


More information about the llvm-commits mailing list