[clang] 3d62139 - [clang-format][NFC] Reformat clang/lib/Format using 6257832bf94f
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 21 12:03:19 PDT 2022
Author: owenca
Date: 2022-09-21T12:02:49-07:00
New Revision: 3d621398626a972313dfc8c22a7f124c2138f0f5
URL: https://github.com/llvm/llvm-project/commit/3d621398626a972313dfc8c22a7f124c2138f0f5
DIFF: https://github.com/llvm/llvm-project/commit/3d621398626a972313dfc8c22a7f124c2138f0f5.diff
LOG: [clang-format][NFC] Reformat clang/lib/Format using 6257832bf94f
Fix braces and add .clang-format to keep the directory formatted.
Differential Revision: https://reviews.llvm.org/D134329
Added:
clang/lib/Format/.clang-format
Modified:
clang/lib/Format/MacroCallReconstructor.cpp
clang/lib/Format/TokenAnnotator.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/.clang-format b/clang/lib/Format/.clang-format
new file mode 100644
index 0000000000000..0e362770f3537
--- /dev/null
+++ b/clang/lib/Format/.clang-format
@@ -0,0 +1,3 @@
+BasedOnStyle: LLVM
+InsertBraces: true
+RemoveBracesLLVM: true
diff --git a/clang/lib/Format/MacroCallReconstructor.cpp b/clang/lib/Format/MacroCallReconstructor.cpp
index ccff183cf0da1..23b223868c2f0 100644
--- a/clang/lib/Format/MacroCallReconstructor.cpp
+++ b/clang/lib/Format/MacroCallReconstructor.cpp
@@ -35,9 +35,8 @@ void forEachToken(const UnwrappedLine &Line, const T &Call,
for (const auto &N : Line.Tokens) {
Call(N.Tok, Parent, First);
First = false;
- for (const auto &Child : N.Children) {
+ for (const auto &Child : N.Children)
forEachToken(Child, Call, N.Tok);
- }
}
}
@@ -61,7 +60,8 @@ void MacroCallReconstructor::addLine(const UnwrappedLine &Line) {
UnwrappedLine MacroCallReconstructor::takeResult() && {
finalize();
- assert(Result.Tokens.size() == 1 && Result.Tokens.front()->Children.size() == 1);
+ assert(Result.Tokens.size() == 1 &&
+ Result.Tokens.front()->Children.size() == 1);
UnwrappedLine Final =
createUnwrappedLine(*Result.Tokens.front()->Children.front(), Level);
assert(!Final.Tokens.empty());
@@ -194,9 +194,8 @@ FormatToken *MacroCallReconstructor::getParentInResult(FormatToken *Parent) {
FormatToken *Mapped = SpelledParentToReconstructedParent.lookup(Parent);
if (!Mapped)
return Parent;
- for (; Mapped; Mapped = SpelledParentToReconstructedParent.lookup(Parent)) {
+ for (; Mapped; Mapped = SpelledParentToReconstructedParent.lookup(Parent))
Parent = Mapped;
- }
// If we use a
diff erent token than the parent in the expanded token stream
// as parent, mark it as a special parent, so the formatting code knows it
// needs to have its children formatted.
@@ -216,9 +215,8 @@ void MacroCallReconstructor::reconstruct(FormatToken *Token) {
// If the order of tokens in the expanded token stream is not the
// same as the order of tokens in the reconstructed stream, we need
// to reconstruct tokens that arrive later in the stream.
- if (Token->MacroCtx->Role != MR_Hidden) {
+ if (Token->MacroCtx->Role != MR_Hidden)
reconstructActiveCallUntil(Token);
- }
}
assert(!ActiveExpansions.empty());
if (ActiveExpansions.back().SpelledI != ActiveExpansions.back().SpelledE) {
@@ -334,9 +332,8 @@ void MacroCallReconstructor::endReconstruction(FormatToken *Token) {
bool PreviousLevel =
Token->MacroCtx &&
(ActiveExpansions.size() < Token->MacroCtx->ExpandedFrom.size());
- if (!ClosingParen && !TrailingComment && !PreviousLevel) {
+ if (!ClosingParen && !TrailingComment && !PreviousLevel)
llvm::dbgs() << "At token: " << Token->TokenText << "\n";
- }
// In addition to the following cases, we can also run into this
// when a macro call had more arguments than expected; in that case,
// the comma and the remaining tokens in the macro call will potentially
@@ -392,9 +389,8 @@ bool MacroCallReconstructor::processNextReconstructed() {
++ActiveExpansions.back().SpelledI;
if (Token->MacroCtx) {
// Skip tokens that are not part of the macro call.
- if (Token->MacroCtx->Role == MR_Hidden) {
+ if (Token->MacroCtx->Role == MR_Hidden)
return false;
- }
// Skip tokens we already expanded during an inner reconstruction.
// For example, given: #define ID(x) {x}
// And the call: ID(ID(f))
@@ -403,9 +399,8 @@ bool MacroCallReconstructor::processNextReconstructed() {
// ID({f}) -> {{f}}
// We reconstruct f during the first reconstruction, and skip it during the
// second reconstruction.
- if (ActiveExpansions.size() < Token->MacroCtx->ExpandedFrom.size()) {
+ if (ActiveExpansions.size() < Token->MacroCtx->ExpandedFrom.size())
return false;
- }
}
// Tokens that do not have a macro context are tokens in that are part of the
// macro call that have not taken part in expansion.
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 21c2115e7b506..597d7b64625f3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2069,8 +2069,9 @@ class AnnotatingParser {
// type[] a in Java
if (Style.Language == FormatStyle::LK_Java &&
- PreviousNotConst->is(tok::r_square))
+ PreviousNotConst->is(tok::r_square)) {
return true;
+ }
// const a = in JavaScript.
return Style.isJavaScript() && PreviousNotConst->is(tok::kw_const);
@@ -2369,8 +2370,9 @@ class AnnotatingParser {
// case, the matching `{` is on the same unwrapped line, so check for the
// presence of the matching brace to distinguish between those.
if (PrevToken->is(tok::r_brace) && Tok.is(tok::star) &&
- !PrevToken->MatchingParen)
+ !PrevToken->MatchingParen) {
return TT_PointerOrReference;
+ }
if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
return TT_UnaryOperator;
More information about the cfe-commits
mailing list