[PATCH] D127827: [clang-format][NFC] Fix braces in ClangFormat.cpp

2022-06-15 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d82c9ccf32c: [clang-format][NFC] Fix braces in 
ClangFormat.cpp (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127827/new/

https://reviews.llvm.org/D127827

Files:
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -358,9 +358,10 @@
   if (!Status.FormatComplete)
 outs() << " line='" << Status.Line << "'";
   outs() << ">\n";
-  if (Cursor.getNumOccurrences() != 0)
+  if (Cursor.getNumOccurrences() != 0) {
 outs() << "" << 
FormatChanges.getShiftedCodePosition(CursorPosition)
<< "\n";
+  }
 
   outputReplacementsXML(Replaces);
   outs() << "\n";
@@ -436,11 +437,11 @@
   .Case("left", FormatStyle::QAS_Left)
   .Default(FormatStyle->QualifierAlignment);
 
-  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left)
+  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left) {
 FormatStyle->QualifierOrder = {"const", "volatile", "type"};
-  else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right)
+  } else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right) {
 FormatStyle->QualifierOrder = {"type", "const", "volatile"};
-  else if (QualifierAlignmentOrder.contains("type")) {
+  } else if (QualifierAlignmentOrder.contains("type")) {
 FormatStyle->QualifierAlignment = FormatStyle::QAS_Custom;
 SmallVector Qualifiers;
 QualifierAlignmentOrder.split(Qualifiers, " ", /*MaxSplit=*/-1,
@@ -463,9 +464,8 @@
   if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
 auto Err = Replaces.add(tooling::Replacement(
 tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
-if (Err) {
+if (Err)
   llvm::errs() << "Bad Json variable insertion\n";
-}
   }
 
   auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), 
Replaces);
@@ -480,11 +480,10 @@
   reformat(*FormatStyle, *ChangedCode, Ranges, AssumedFileName, );
   Replaces = Replaces.merge(FormatChanges);
   if (OutputXML || DryRun) {
-if (DryRun) {
+if (DryRun)
   return emitReplacementWarnings(Replaces, AssumedFileName, Code);
-} else {
+else
   outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
-}
   } else {
 IntrusiveRefCntPtr InMemoryFileSystem(
 new llvm::vfs::InMemoryFileSystem);
@@ -579,9 +578,8 @@
 return 0;
   }
 
-  if (DumpConfig) {
+  if (DumpConfig)
 return dumpConfig();
-  }
 
   if (!Files.empty()) {
 std::ifstream ExternalFileOfFiles{std::string(Files)};
@@ -608,9 +606,10 @@
 
   unsigned FileNo = 1;
   for (const auto  : FileNames) {
-if (Verbose)
+if (Verbose) {
   errs() << "Formatting [" << FileNo++ << "/" << FileNames.size() << "] "
  << FileName << "\n";
+}
 Error |= clang::format::format(FileName);
   }
   return Error ? 1 : 0;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -358,9 +358,10 @@
   if (!Status.FormatComplete)
 outs() << " line='" << Status.Line << "'";
   outs() << ">\n";
-  if (Cursor.getNumOccurrences() != 0)
+  if (Cursor.getNumOccurrences() != 0) {
 outs() << "" << FormatChanges.getShiftedCodePosition(CursorPosition)
<< "\n";
+  }
 
   outputReplacementsXML(Replaces);
   outs() << "\n";
@@ -436,11 +437,11 @@
   .Case("left", FormatStyle::QAS_Left)
   .Default(FormatStyle->QualifierAlignment);
 
-  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left)
+  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left) {
 FormatStyle->QualifierOrder = {"const", "volatile", "type"};
-  else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right)
+  } else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right) {
 FormatStyle->QualifierOrder = {"type", "const", "volatile"};
-  else if (QualifierAlignmentOrder.contains("type")) {
+  } else if (QualifierAlignmentOrder.contains("type")) {
 FormatStyle->QualifierAlignment = FormatStyle::QAS_Custom;
 SmallVector Qualifiers;
 QualifierAlignmentOrder.split(Qualifiers, " ", /*MaxSplit=*/-1,
@@ -463,9 +464,8 @@
   if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
 auto Err = Replaces.add(tooling::Replacement(
 tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
-if (Err) {
+if (Err)
   llvm::errs() << "Bad Json variable insertion\n";
-}
   }
 
   auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces);
@@ -480,11 +480,10 @@
   

[PATCH] D127827: [clang-format][NFC] Fix braces in ClangFormat.cpp

2022-06-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127827

Files:
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -358,9 +358,10 @@
   if (!Status.FormatComplete)
 outs() << " line='" << Status.Line << "'";
   outs() << ">\n";
-  if (Cursor.getNumOccurrences() != 0)
+  if (Cursor.getNumOccurrences() != 0) {
 outs() << "" << 
FormatChanges.getShiftedCodePosition(CursorPosition)
<< "\n";
+  }
 
   outputReplacementsXML(Replaces);
   outs() << "\n";
@@ -436,11 +437,11 @@
   .Case("left", FormatStyle::QAS_Left)
   .Default(FormatStyle->QualifierAlignment);
 
-  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left)
+  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left) {
 FormatStyle->QualifierOrder = {"const", "volatile", "type"};
-  else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right)
+  } else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right) {
 FormatStyle->QualifierOrder = {"type", "const", "volatile"};
-  else if (QualifierAlignmentOrder.contains("type")) {
+  } else if (QualifierAlignmentOrder.contains("type")) {
 FormatStyle->QualifierAlignment = FormatStyle::QAS_Custom;
 SmallVector Qualifiers;
 QualifierAlignmentOrder.split(Qualifiers, " ", /*MaxSplit=*/-1,
@@ -463,9 +464,8 @@
   if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
 auto Err = Replaces.add(tooling::Replacement(
 tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
-if (Err) {
+if (Err)
   llvm::errs() << "Bad Json variable insertion\n";
-}
   }
 
   auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), 
Replaces);
@@ -480,11 +480,10 @@
   reformat(*FormatStyle, *ChangedCode, Ranges, AssumedFileName, );
   Replaces = Replaces.merge(FormatChanges);
   if (OutputXML || DryRun) {
-if (DryRun) {
+if (DryRun)
   return emitReplacementWarnings(Replaces, AssumedFileName, Code);
-} else {
+else
   outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
-}
   } else {
 IntrusiveRefCntPtr InMemoryFileSystem(
 new llvm::vfs::InMemoryFileSystem);
@@ -579,9 +578,8 @@
 return 0;
   }
 
-  if (DumpConfig) {
+  if (DumpConfig)
 return dumpConfig();
-  }
 
   if (!Files.empty()) {
 std::ifstream ExternalFileOfFiles{std::string(Files)};
@@ -608,9 +606,10 @@
 
   unsigned FileNo = 1;
   for (const auto  : FileNames) {
-if (Verbose)
+if (Verbose) {
   errs() << "Formatting [" << FileNo++ << "/" << FileNames.size() << "] "
  << FileName << "\n";
+}
 Error |= clang::format::format(FileName);
   }
   return Error ? 1 : 0;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -358,9 +358,10 @@
   if (!Status.FormatComplete)
 outs() << " line='" << Status.Line << "'";
   outs() << ">\n";
-  if (Cursor.getNumOccurrences() != 0)
+  if (Cursor.getNumOccurrences() != 0) {
 outs() << "" << FormatChanges.getShiftedCodePosition(CursorPosition)
<< "\n";
+  }
 
   outputReplacementsXML(Replaces);
   outs() << "\n";
@@ -436,11 +437,11 @@
   .Case("left", FormatStyle::QAS_Left)
   .Default(FormatStyle->QualifierAlignment);
 
-  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left)
+  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left) {
 FormatStyle->QualifierOrder = {"const", "volatile", "type"};
-  else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right)
+  } else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right) {
 FormatStyle->QualifierOrder = {"type", "const", "volatile"};
-  else if (QualifierAlignmentOrder.contains("type")) {
+  } else if (QualifierAlignmentOrder.contains("type")) {
 FormatStyle->QualifierAlignment = FormatStyle::QAS_Custom;
 SmallVector Qualifiers;
 QualifierAlignmentOrder.split(Qualifiers, " ", /*MaxSplit=*/-1,
@@ -463,9 +464,8 @@
   if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
 auto Err = Replaces.add(tooling::Replacement(
 tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
-if (Err) {
+if (Err)
   llvm::errs() << "Bad Json variable insertion\n";
-}
   }
 
   auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces);
@@ -480,11 +480,10 @@
   reformat(*FormatStyle, *ChangedCode,