From cc26943313def7a985f72eadc7499ac981daabc6 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Mon, 5 Apr 2021 12:15:50 +0200 Subject: [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 --- clang/unittests/Frontend/CompilerInvocationTest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp') 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 -- cgit v1.1