[clang] 93fc916 - [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 24 01:46:10 PST 2021
Author: mydeveloperday
Date: 2021-11-24T09:45:32Z
New Revision: 93fc91610f427f42b77fa36a65a70b9b86225c37
URL: https://github.com/llvm/llvm-project/commit/93fc91610f427f42b77fa36a65a70b9b86225c37
DIFF: https://github.com/llvm/llvm-project/commit/93fc91610f427f42b77fa36a65a70b9b86225c37.diff
LOG: [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.
The following 2 commits caused files in clang-format to no longer be clang-formatted.
we would lose our "clean" status https://releases.llvm.org/13.0.0/tools/clang/docs/ClangFormattedStatus.html
c2271926a4fc - Make clang-format fuzz through Lexing with asserts enabled (https://github.com/llvm/llvm-project/commit/c2271926a4fc )
84bf5e328664 - Fix various problems found by fuzzing. (https://github.com/llvm/llvm-project/commit/84bf5e328664)
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D114430
Added:
Modified:
clang/lib/Format/Format.cpp
clang/lib/Format/SortJavaScriptImports.cpp
clang/lib/Format/TokenAnalyzer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/WhitespaceManager.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8ae29c54a762..17de1075aeaa 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2988,9 +2988,8 @@ reformat(const FormatStyle &Style, StringRef Code,
// JSON only needs the formatting passing.
if (Style.isJson()) {
std::vector<tooling::Range> Ranges(1, tooling::Range(0, Code.size()));
- auto Env =
- Environment::make(Code, FileName, Ranges, FirstStartColumn,
- NextStartColumn, LastStartColumn);
+ auto Env = Environment::make(Code, FileName, Ranges, FirstStartColumn,
+ NextStartColumn, LastStartColumn);
if (!Env)
return {};
// Perform the actual formatting pass.
@@ -3118,9 +3117,7 @@ tooling::Replacements fixNamespaceEndComments(const FormatStyle &Style,
auto Env = Environment::make(Code, FileName, Ranges);
if (!Env)
return {};
- return NamespaceEndCommentsFixer(*Env, Style)
- .process()
- .first;
+ return NamespaceEndCommentsFixer(*Env, Style).process().first;
}
tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
@@ -3130,9 +3127,7 @@ tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
auto Env = Environment::make(Code, FileName, Ranges);
if (!Env)
return {};
- return UsingDeclarationsSorter(*Env, Style)
- .process()
- .first;
+ return UsingDeclarationsSorter(*Env, Style).process().first;
}
LangOptions getFormattingLangOpts(const FormatStyle &Style) {
diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp
index 515cfce725a4..77dc0d683e5f 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -553,9 +553,7 @@ tooling::Replacements sortJavaScriptImports(const FormatStyle &Style,
auto Env = Environment::make(Code, FileName, Ranges);
if (!Env)
return {};
- return JavaScriptImportSorter(*Env, Style)
- .process()
- .first;
+ return JavaScriptImportSorter(*Env, Style).process().first;
}
} // end namespace format
diff --git a/clang/lib/Format/TokenAnalyzer.cpp b/clang/lib/Format/TokenAnalyzer.cpp
index a619c6d939e9..d83e837ca134 100644
--- a/clang/lib/Format/TokenAnalyzer.cpp
+++ b/clang/lib/Format/TokenAnalyzer.cpp
@@ -37,7 +37,7 @@ namespace format {
// FIXME: Instead of printing the diagnostic we should store it and have a
// better way to return errors through the format APIs.
-class FatalDiagnosticConsumer: public DiagnosticConsumer {
+class FatalDiagnosticConsumer : public DiagnosticConsumer {
public:
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Info) override {
@@ -71,7 +71,8 @@ Environment::make(StringRef Code, StringRef FileName,
}
// Validate that we can get the buffer data without a fatal error.
Env->SM.getBufferData(Env->ID);
- if (Diags.fatalError()) return nullptr;
+ if (Diags.fatalError())
+ return nullptr;
return Env;
}
@@ -80,8 +81,7 @@ Environment::Environment(StringRef Code, StringRef FileName,
unsigned LastStartColumn)
: VirtualSM(new SourceManagerForFile(FileName, Code)), SM(VirtualSM->get()),
ID(VirtualSM->get().getMainFileID()), FirstStartColumn(FirstStartColumn),
- NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {
-}
+ NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {}
TokenAnalyzer::TokenAnalyzer(const Environment &Env, const FormatStyle &Style)
: Style(Style), Env(Env),
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 817bda1780de..2cd57c10425f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2342,16 +2342,15 @@ void TokenAnnotator::setCommentLineLevels(
if (NextNonCommentLine && CommentLine &&
NextNonCommentLine->First->NewlinesBefore <= 1 &&
NextNonCommentLine->First->OriginalColumn ==
- AL->First->OriginalColumn) {
+ AL->First->OriginalColumn) {
// Align comments for preprocessor lines with the # in column 0 if
// preprocessor lines are not indented. Otherwise, align with the next
// line.
- AL->Level =
- (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
- (NextNonCommentLine->Type == LT_PreprocessorDirective ||
- NextNonCommentLine->Type == LT_ImportStatement))
- ? 0
- : NextNonCommentLine->Level;
+ AL->Level = (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
+ (NextNonCommentLine->Type == LT_PreprocessorDirective ||
+ NextNonCommentLine->Type == LT_ImportStatement))
+ ? 0
+ : NextNonCommentLine->Level;
} else {
NextNonCommentLine = AL->First->isNot(tok::r_brace) ? AL : nullptr;
}
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index 7a00e9378919..fae8a1c3fdc6 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -913,7 +913,8 @@ void WhitespaceManager::alignTrailingComments(unsigned Start, unsigned End,
Changes[i].StartOfBlockComment->StartOfTokenColumn -
Changes[i].StartOfTokenColumn;
}
- if (Shift < 0) continue;
+ if (Shift < 0)
+ continue;
Changes[i].Spaces += Shift;
if (i + 1 != Changes.size())
Changes[i + 1].PreviousEndOfTokenColumn += Shift;
@@ -1269,7 +1270,7 @@ void WhitespaceManager::generateChanges() {
for (unsigned i = 0, e = Changes.size(); i != e; ++i) {
const Change &C = Changes[i];
if (i > 0 && Changes[i - 1].OriginalWhitespaceRange.getBegin() ==
- C.OriginalWhitespaceRange.getBegin()) {
+ C.OriginalWhitespaceRange.getBegin()) {
// Do not generate two replacements for the same location.
continue;
}
More information about the cfe-commits
mailing list