[Clang] avoid relying on StringMap iteration order when roundtripping -analyzer-config
authorErik Desjardins <erikdesjardinspublic@gmail.com>
Wed, 1 Feb 2023 21:46:59 +0000 (13:46 -0800)
committerJan Svoboda <jan_svoboda@apple.com>
Wed, 1 Feb 2023 21:54:09 +0000 (13:54 -0800)
commit06be346311b9341d3d11120a631263de863f937c
treec62b2b546ca9080ac70cc44bf87ef83f046c7724
parentaa2943502cf2986948af69681d9b833614645cd0
[Clang] avoid relying on StringMap iteration order when roundtripping -analyzer-config

I am working on another patch that changes StringMap's hash function,
which changes the iteration order here, and breaks some tests,
specifically:

    clang/test/Analysis/NSString.m
    clang/test/Analysis/shallow-mode.m

with errors like:

    generated arguments do not match in round-trip
    generated arguments #1 in round-trip: <...> "-analyzer-config" "ipa=inlining" "-analyzer-config" "max-nodes=75000" <...>
    generated arguments #2 in round-trip: <...> "-analyzer-config" "max-nodes=75000" "-analyzer-config" "ipa=inlining" <...>

To avoid this, sort the options by key, instead of using the default map
iteration order.

Reviewed By: jansvoboda11, MaskRay

Differential Revision: https://reviews.llvm.org/D142861
clang/lib/Frontend/CompilerInvocation.cpp