diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2021-04-05 12:15:50 +0200 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-04-06 09:24:42 +0200 |
commit | cc26943313def7a985f72eadc7499ac981daabc6 (patch) | |
tree | 3dbe8324ad8247dc2a748a441527054623fdcec9 /clang | |
parent | 98742e42fc50f58d3f2d3f2cdbbf540288c134b9 (diff) | |
download | llvm-cc26943313def7a985f72eadc7499ac981daabc6.zip llvm-cc26943313def7a985f72eadc7499ac981daabc6.tar.gz llvm-cc26943313def7a985f72eadc7499ac981daabc6.tar.bz2 |
[clang][cli] Ensure plugin args are generated in deterministic order
The '-plugin-arg' command-line arguments are not being generated in deterministic order.
This patch changes the storage from `std::unordered_map` to `std::map` to enforce ordering.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D99879
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Frontend/FrontendOptions.h | 4 | ||||
-rw-r--r-- | clang/unittests/Frontend/CompilerInvocationTest.cpp | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index 5c9a218..d7f9039 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -16,9 +16,9 @@ #include "clang/Serialization/ModuleFileExtension.h" #include "llvm/ADT/StringRef.h" #include <cassert> +#include <map> #include <memory> #include <string> -#include <unordered_map> #include <vector> namespace llvm { @@ -404,7 +404,7 @@ public: std::string ActionName; /// Args to pass to the plugins - std::unordered_map<std::string,std::vector<std::string>> PluginArgs; + std::map<std::string, std::vector<std::string>> PluginArgs; /// The list of plugin actions to run in addition to the normal action. std::vector<std::string> AddPluginActions; diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index b846e6e..066d02b 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -877,4 +877,15 @@ TEST_F(CommandLineTest, RoundTrip) { ShowIncludesDestination::Stdout); ASSERT_TRUE(Invocation.getDependencyOutputOpts().ShowHeaderIncludes); } + +TEST_F(CommandLineTest, PluginArgsRoundTripDeterminism) { + const char *Args[] = { + "-plugin-arg-blink-gc-plugin", "no-members-in-stack-allocated", + "-plugin-arg-find-bad-constructs", "checked-ptr-as-trivial-member", + "-plugin-arg-find-bad-constructs", "check-ipc", + // Enable round-trip to ensure '-plugin-arg' generation is deterministic. + "-round-trip-args"}; + + ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); +} } // anonymous namespace |