[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
This commit is contained in:
Igor Kudrin 2021-11-10 10:07:20 +07:00
parent 7352f42cdc
commit 5b7ea8e629
1 changed files with 7 additions and 1 deletions

View File

@ -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");