[clang-tools-extra] a8eb741 - Revert "[clang-tidy] Sort options in --dump-config"

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 27 12:27:37 PDT 2023


Author: Piotr Zegar
Date: 2023-07-27T19:27:25Z
New Revision: a8eb7415a418d878be8a7d6e48f8dff0c401dfc6

URL: https://github.com/llvm/llvm-project/commit/a8eb7415a418d878be8a7d6e48f8dff0c401dfc6
DIFF: https://github.com/llvm/llvm-project/commit/a8eb7415a418d878be8a7d6e48f8dff0c401dfc6.diff

LOG: Revert "[clang-tidy] Sort options in --dump-config"

This reverts commit 2cdb843767529b2be641b93e43d70837900345c1.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index f800e560331016..1efe35a8b8f015 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -16,7 +16,6 @@
 #include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLTraits.h"
-#include <algorithm>
 #include <optional>
 #include <utility>
 
@@ -86,21 +85,14 @@ template <>
 void yamlize(IO &IO, ClangTidyOptions::OptionMap &Options, bool,
              EmptyContext &Ctx) {
   if (IO.outputting()) {
-    // Ensure check options are sorted
-    std::vector<std::pair<StringRef, StringRef>> SortedOptions;
-    SortedOptions.reserve(Options.size());
-    for (auto &Key : Options) {
-      SortedOptions.emplace_back(Key.getKey(), Key.getValue().Value);
-    }
-    std::sort(SortedOptions.begin(), SortedOptions.end());
-
     IO.beginMapping();
     // Only output as a map
-    for (auto &Option : SortedOptions) {
-      bool UseDefault = false;
-      void *SaveInfo = nullptr;
-      IO.preflightKey(Option.first.data(), true, false, UseDefault, SaveInfo);
-      IO.scalarString(Option.second, needsQuotes(Option.second));
+    for (auto &Key : Options) {
+      bool UseDefault;
+      void *SaveInfo;
+      IO.preflightKey(Key.getKey().data(), true, false, UseDefault, SaveInfo);
+      StringRef S = Key.getValue().Value;
+      IO.scalarString(S, needsQuotes(S));
       IO.postflightKey(SaveInfo);
     }
     IO.endMapping();

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index d8c55c17be3e2f..4441473774b2c8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -111,8 +111,6 @@ Improvements to clang-tidy
 - Remove configuration option `AnalyzeTemporaryDestructors`, which was deprecated since
   :program:`clang-tidy` 16.
 
-- Improved `--dump-config` to print check options in alphabetical order.
-
 New checks
 ^^^^^^^^^^
 

diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
index ac71b1846a61ee..6c42bd7f495f78 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -54,6 +54,3 @@
 // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD6
 // CHECK-CHILD6: Checks: {{.*-llvm-qualified-auto'? *$}}
 // CHECK-CHILD6-NOT: modernize-use-using.IgnoreMacros
-
-// Validate that check options are printed in alphabetical order:
-// RUN: clang-tidy --checks="-*,readability-identifier-*" --dump-config | grep readability-identifier-naming | sort --check


        


More information about the cfe-commits mailing list