[clang] 40a5d79 - [clang-format][NFC] Format lib/Format and unittests/Format in clang

via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 02:26:27 PDT 2022


Author: owenca
Date: 2022-06-09T02:25:06-07:00
New Revision: 40a5d79a5cb4edc7343349f17e59377eb9362c4a

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

LOG: [clang-format][NFC] Format lib/Format and unittests/Format in clang

Reformat these directories with InsertBraces and RemoveBracesLLVM.

Differential Revision: https://reviews.llvm.org/D127366

Added: 
    

Modified: 
    clang/lib/Format/BreakableToken.cpp
    clang/lib/Format/WhitespaceManager.cpp
    clang/unittests/Format/FormatTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index 6ae112b86ebb6..db82018a4c83c 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -705,11 +705,9 @@ void BreakableBlockComment::adaptStartOfLine(
       // contain a trailing whitespace.
       Prefix = Prefix.substr(0, 1);
     }
-  } else {
-    if (ContentColumn[LineIndex] == 1) {
-      // This line starts immediately after the decorating *.
-      Prefix = Prefix.substr(0, 1);
-    }
+  } else if (ContentColumn[LineIndex] == 1) {
+    // This line starts immediately after the decorating *.
+    Prefix = Prefix.substr(0, 1);
   }
   // This is the offset of the end of the last line relative to the start of the
   // token text in the token.

diff  --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index fe43981e27d00..6ec788ad23c66 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -230,12 +230,10 @@ void WhitespaceManager::calculateLineBreakInformation() {
     if (Change.Tok->is(tok::comment)) {
       if (Change.Tok->is(TT_LineComment) || !Change.IsInsideToken) {
         LastBlockComment = &Change;
-      } else {
-        if ((Change.StartOfBlockComment = LastBlockComment)) {
-          Change.IndentationOffset =
-              Change.StartOfTokenColumn -
-              Change.StartOfBlockComment->StartOfTokenColumn;
-        }
+      } else if ((Change.StartOfBlockComment = LastBlockComment)) {
+        Change.IndentationOffset =
+            Change.StartOfTokenColumn -
+            Change.StartOfBlockComment->StartOfTokenColumn;
       }
     } else {
       LastBlockComment = nullptr;

diff  --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index ffc7e941398a1..14b169ebe5869 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -25439,8 +25439,7 @@ TEST_F(FormatTest, RemoveBraces) {
   verifyFormat("do {\n"
                "  ++I;\n"
                "} while (hasMore() && Filter(*I));",
-               "do { ++I; } while (hasMore() && Filter(*I));",
-               Style);
+               "do { ++I; } while (hasMore() && Filter(*I));", Style);
 
   verifyFormat("if (a)\n"
                "  if (b)\n"


        


More information about the cfe-commits mailing list