[PATCH] D99879: [clang][cli] Ensure plugin args are generated in deterministic order

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 6 00:24:59 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc26943313de: [clang][cli] Ensure plugin args are generated in deterministic order (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99879/new/

https://reviews.llvm.org/D99879

Files:
  clang/include/clang/Frontend/FrontendOptions.h
  clang/unittests/Frontend/CompilerInvocationTest.cpp


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===================================================================
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -877,4 +877,15 @@
             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
Index: clang/include/clang/Frontend/FrontendOptions.h
===================================================================
--- clang/include/clang/Frontend/FrontendOptions.h
+++ 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 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99879.335419.patch
Type: text/x-patch
Size: 1699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210406/0c039296/attachment.bin>


More information about the cfe-commits mailing list