[clang] 7b02794 - [clang-format] Rename case sorting
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 5 12:43:23 PST 2021
Author: Björn Schäpers
Date: 2021-03-05T21:42:45+01:00
New Revision: 7b02794f0aeb7eaf68d18fffc3057c3c7d975d75
URL: https://github.com/llvm/llvm-project/commit/7b02794f0aeb7eaf68d18fffc3057c3c7d975d75
DIFF: https://github.com/llvm/llvm-project/commit/7b02794f0aeb7eaf68d18fffc3057c3c7d975d75.diff
LOG: [clang-format] Rename case sorting
As discussed in D95017 the names case sensitive and insensitive should
be switched.
This amends a8105b3766e4.
Differential Revision: https://reviews.llvm.org/D97927
Added:
Modified:
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/tools/clang-format/ClangFormat.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/SortIncludesTest.cpp
Removed:
################################################################################
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index a0af61faa143..981fb577f1fa 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3085,8 +3085,8 @@ the configuration (without a prefix: ``Auto``).
#include "A/b.h"
#include "B/a.h"
- * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
- Includes are sorted in an ASCIIbetical or case insensitive fashion.
+ * ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``)
+ Includes are sorted in an ASCIIbetical or case sensitive fashion.
.. code-block:: c++
@@ -3096,8 +3096,8 @@ the configuration (without a prefix: ``Auto``).
#include "B/a.h"
#include "a/b.h"
- * ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``)
- Includes are sorted in an alphabetical or case sensitive fashion.
+ * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
+ Includes are sorted in an alphabetical or case insensitive fashion.
.. code-block:: c++
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 89592606c88c..9b1d76a9c1e0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -170,8 +170,8 @@ clang-format
- Option ``SortIncludes`` has been updated from a ``bool`` to an
``enum`` with backwards compatibility. In addition to the previous
- ``true``/``false`` states (now ``CaseInsensitive``/``Never``), a third
- state has been added (``CaseSensitive``) which causes an alphabetical sort
+ ``true``/``false`` states (now ``CaseSensitive``/``Never``), a third
+ state has been added (``CaseInsensitive``) which causes an alphabetical sort
with case used as a tie-breaker.
.. code-block:: c++
@@ -183,14 +183,14 @@ clang-format
#include "A/b.h"
#include "B/a.h"
- // CaseInsensitive (previously true)
+ // CaseSensitive (previously true)
#include "A/B.h"
#include "A/b.h"
#include "B/A.h"
#include "B/a.h"
#include "a/b.h"
- // CaseSensitive
+ // CaseInsensitive
#include "A/B.h"
#include "A/b.h"
#include "a/b.h"
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 1e8456b0dfd8..c560eff2afa2 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2679,7 +2679,7 @@ struct FormatStyle {
/// #include "B/a.h"
/// \endcode
SI_Never,
- /// Includes are sorted in an ASCIIbetical or case insensitive fashion.
+ /// Includes are sorted in an ASCIIbetical or case sensitive fashion.
/// \code
/// #include "A/B.h"
/// #include "A/b.h"
@@ -2687,8 +2687,8 @@ struct FormatStyle {
/// #include "B/a.h"
/// #include "a/b.h"
/// \endcode
- SI_CaseInsensitive,
- /// Includes are sorted in an alphabetical or case sensitive fashion.
+ SI_CaseSensitive,
+ /// Includes are sorted in an alphabetical or case insensitive fashion.
/// \code
/// #include "A/B.h"
/// #include "A/b.h"
@@ -2696,7 +2696,7 @@ struct FormatStyle {
/// #include "B/A.h"
/// #include "B/a.h"
/// \endcode
- SI_CaseSensitive,
+ SI_CaseInsensitive,
};
/// Controls if and how clang-format will sort ``#includes``.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b815a5255296..674f3e1220f7 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -423,7 +423,7 @@ template <> struct ScalarEnumerationTraits<FormatStyle::SortIncludesOptions> {
// For backward compatibility.
IO.enumCase(Value, "false", FormatStyle::SI_Never);
- IO.enumCase(Value, "true", FormatStyle::SI_CaseInsensitive);
+ IO.enumCase(Value, "true", FormatStyle::SI_CaseSensitive);
}
};
@@ -1047,7 +1047,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.PenaltyIndentedWhitespace = 0;
LLVMStyle.DisableFormat = false;
- LLVMStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
+ LLVMStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
LLVMStyle.SortUsingDeclarations = true;
LLVMStyle.StatementAttributeLikeMacros.push_back("Q_EMIT");
@@ -1250,7 +1250,7 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) {
"java",
"javax",
};
- ChromiumStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
+ ChromiumStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
} else if (Language == FormatStyle::LK_JavaScript) {
ChromiumStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
ChromiumStyle.AllowShortLoopsOnASingleLine = false;
@@ -2248,7 +2248,7 @@ static void sortCppIncludes(const FormatStyle &Style,
Indices.push_back(i);
}
- if (Style.SortIncludes == FormatStyle::SI_CaseSensitive) {
+ if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive) {
llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp
index e59ba663f7f0..c51d9f4ea1f0 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -404,7 +404,7 @@ static bool format(StringRef FileName) {
if (SortIncludes.getNumOccurrences() != 0) {
if (SortIncludes)
- FormatStyle->SortIncludes = FormatStyle::SI_CaseInsensitive;
+ FormatStyle->SortIncludes = FormatStyle::SI_CaseSensitive;
else
FormatStyle->SortIncludes = FormatStyle::SI_Never;
}
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index d8bf3567e38e..85c24eeadf04 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -16007,7 +16007,7 @@ TEST_F(FormatTest, ParsesConfiguration) {
Style.SortIncludes = FormatStyle::SI_Never;
CHECK_PARSE("SortIncludes: true", SortIncludes,
- FormatStyle::SI_CaseInsensitive);
+ FormatStyle::SI_CaseSensitive);
CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);
CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
FormatStyle::SI_CaseInsensitive);
@@ -18131,7 +18131,7 @@ TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
"#include \"b.h\"\n")});
format::FormatStyle Style = format::getLLVMStyle();
- Style.SortIncludes = FormatStyle::SI_CaseInsensitive;
+ Style.SortIncludes = FormatStyle::SI_CaseSensitive;
auto FormattedReplaces = formatReplacements(Code, Replaces, Style);
EXPECT_TRUE(static_cast<bool>(FormattedReplaces))
<< llvm::toString(FormattedReplaces.takeError()) << "\n";
diff --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp
index 240757d9aaea..47ec319294ba 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -599,9 +599,9 @@ TEST_F(SortIncludesTest, MainHeaderIsSeparatedWhenRegroupping) {
}
TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveSorting) {
- EXPECT_FALSE(FmtStyle.SortIncludes == FormatStyle::SI_CaseSensitive);
+ EXPECT_FALSE(FmtStyle.SortIncludes == FormatStyle::SI_CaseInsensitive);
- FmtStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
+ FmtStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
EXPECT_EQ("#include \"A/B.h\"\n"
"#include \"A/b.h\"\n"
More information about the cfe-commits
mailing list