[clang] 630c736 - [clang-format] Elide unnecessary braces. NFC.

Marek Kurdej via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 2 05:36:15 PST 2022


Author: Marek Kurdej
Date: 2022-02-02T14:36:01+01:00
New Revision: 630c736047a3191a5d3150bcc825064ab84e9fb5

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

LOG: [clang-format] Elide unnecessary braces. NFC.

Added: 
    

Modified: 
    clang/lib/Format/ContinuationIndenter.cpp
    clang/lib/Format/Format.cpp
    clang/lib/Format/MacroExpander.cpp
    clang/lib/Format/TokenAnnotator.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 45a4d23557f7..95cf0a0c2da4 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -197,12 +197,10 @@ RawStringFormatStyleManager::RawStringFormatStyleManager(
       LanguageStyle = PredefinedStyle;
     }
     LanguageStyle->ColumnLimit = CodeStyle.ColumnLimit;
-    for (StringRef Delimiter : RawStringFormat.Delimiters) {
+    for (StringRef Delimiter : RawStringFormat.Delimiters)
       DelimiterStyle.insert({Delimiter, *LanguageStyle});
-    }
-    for (StringRef EnclosingFunction : RawStringFormat.EnclosingFunctions) {
+    for (StringRef EnclosingFunction : RawStringFormat.EnclosingFunctions)
       EnclosingFunctionStyle.insert({EnclosingFunction, *LanguageStyle});
-    }
   }
 }
 

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 3abe569f8770..128196a24df6 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2092,9 +2092,8 @@ class Cleaner : public TokenAnalyzer {
 
 private:
   void cleanupLine(AnnotatedLine *Line) {
-    for (auto *Child : Line->Children) {
+    for (auto *Child : Line->Children)
       cleanupLine(Child);
-    }
 
     if (Line->Affected) {
       cleanupRight(Line->First, tok::comma, tok::comma);
@@ -2120,9 +2119,8 @@ class Cleaner : public TokenAnalyzer {
     std::set<unsigned> DeletedLines;
     for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
       auto &Line = *AnnotatedLines[i];
-      if (Line.startsWithNamespace()) {
+      if (Line.startsWithNamespace())
         checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
-      }
     }
 
     for (auto Line : DeletedLines) {
@@ -2184,9 +2182,8 @@ class Cleaner : public TokenAnalyzer {
             AnnotatedLines[CurrentLine]->Last->Tok.getEndLoc())))
       return false;
 
-    for (unsigned i = InitLine; i <= CurrentLine; ++i) {
+    for (unsigned i = InitLine; i <= CurrentLine; ++i)
       DeletedLines.insert(i);
-    }
 
     return true;
   }

diff  --git a/clang/lib/Format/MacroExpander.cpp b/clang/lib/Format/MacroExpander.cpp
index de96cb24ba1f..9c6bcb8764f4 100644
--- a/clang/lib/Format/MacroExpander.cpp
+++ b/clang/lib/Format/MacroExpander.cpp
@@ -125,9 +125,8 @@ MacroExpander::MacroExpander(
     IdentifierTable &IdentTable)
     : SourceMgr(SourceMgr), Style(Style), Allocator(Allocator),
       IdentTable(IdentTable) {
-  for (const std::string &Macro : Macros) {
+  for (const std::string &Macro : Macros)
     parseDefinition(Macro);
-  }
 }
 
 MacroExpander::~MacroExpander() = default;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 9d130dbb02eb..0bd6dfa5926d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1388,9 +1388,8 @@ class AnnotatingParser {
     }
 
     for (const auto &ctx : Contexts) {
-      if (ctx.InStructArrayInitializer) {
+      if (ctx.InStructArrayInitializer)
         return LT_ArrayOfStructInitializer;
-      }
     }
 
     return LT_Other;


        


More information about the cfe-commits mailing list