llvm::MapVector, compared to std::map, guarantees the same iteration order in different runs.
Details
Diff Detail
Event Timeline
I'd like to understand the motivation behind the change a bit more. What problems stem from generating the parsing helpers in a different order? Why do we not need the same changes when generating documentation (see EmitClangAttrDocs())?
We've noticed binary differences in clang in several builds on our local build bots, and the patch fixed that.
As for generating the documentation, the issue can be seen, for example, in Clang-12 and Clang-13 documentation, where the section "Nullable Attributes" is placed differently. Maybe it'll be better to sort the categories alphabetically. Anyway, that is a similar but still a different issue.
FWIW, I consider the documentation issue to be more of a problem than the one being fixed here. The fix for this means code we generate will be generated in the same order every time, which has nice properties in terms of doing incremental builds, but is largely unimportant as far as users are concerned. The documentation is user facing, so there's more of a chance to notice positional changes there.
I'm happy enough with the changes, but please fix the other nondeterminism at the same time so that we don't have to play whack-a-mole in this file.
The compiler has to be deterministic and one way to check that is to recompile a relatively large project several times. For clang, that large project is usually clang itself, so it has to be compiled in a stable way.
Anyway, I've prepared a fix for generating the documentation, D113477. Please, take a look.