[clang] 5b7ea8e - [clang-tblgen] Fix non-determinism in generating AttributeReference.rst

Igor Kudrin via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 9 19:09:46 PST 2021


Author: Igor Kudrin
Date: 2021-11-10T10:08:07+07:00
New Revision: 5b7ea8e62921e53fdea73d948eb0d48c071d4b73

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

LOG: [clang-tblgen] Fix non-determinism in generating AttributeReference.rst

As for now, the categories are printed in an arbitrary order which
depends on the addresses of dynamically allocated objects. The patch
sorts them in an alphabetical order thus making the output stable.

Differential Revision: https://reviews.llvm.org/D113477

Added: 
    

Modified: 
    clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index c692e8b5b6bc..fe05a3466af1 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -4433,7 +4433,13 @@ void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) {
   // Gather the Documentation lists from each of the attributes, based on the
   // category provided.
   std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
-  std::map<const Record *, std::vector<DocumentationData>> SplitDocs;
+  struct CategoryLess {
+    bool operator()(const Record *L, const Record *R) const {
+      return L->getValueAsString("Name") < R->getValueAsString("Name");
+    }
+  };
+  std::map<const Record *, std::vector<DocumentationData>, CategoryLess>
+      SplitDocs;
   for (const auto *A : Attrs) {
     const Record &Attr = *A;
     std::vector<Record *> Docs = Attr.getValueAsListOfDefs("Documentation");


        


More information about the cfe-commits mailing list