github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp 
b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
index 76a14c580..104ce5eee 100644
--- a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
@@ -461,32 +461,30 @@ bool FormatStringConverter::emitIntegerArgument(
     // In cases where `x` or `X` was specified in the format string
     // these will technically have no effect, since the bool can only be zero 
or
     // one. However, it seems best to leave them as-is anyway.
-    switch(ArgKind)
-    {
-      case ConversionSpecifier::Kind::xArg:
-        FormatSpec.push_back('x'); // Not strictly needed
-        break;
-      case ConversionSpecifier::Kind::XArg:
-        FormatSpec.push_back('X');
-        break;
-      default:
-        FormatSpec.push_back('d');
+    switch (ArgKind) {
+    case ConversionSpecifier::Kind::xArg:
+      FormatSpec.push_back('x'); // Not strictly needed
+      break;
+    case ConversionSpecifier::Kind::XArg:
+      FormatSpec.push_back('X');
+      break;
+    default:
+      FormatSpec.push_back('d');
     }
-    
+
   } else if (ArgType->isEnumeralType()) {
 
     // If the format string contained `x` or `X`, then use these
     // format modifiers. Otherwise the default will work.
-    switch(ArgKind)
-    {
-      case ConversionSpecifier::Kind::xArg:
-        FormatSpec.push_back('x');
-        break;
-      case ConversionSpecifier::Kind::XArg:
-        FormatSpec.push_back('X');
-        break;
-      default:
-        break;
+    switch (ArgKind) {
+    case ConversionSpecifier::Kind::xArg:
+      FormatSpec.push_back('x');
+      break;
+    case ConversionSpecifier::Kind::XArg:
+      FormatSpec.push_back('X');
+      break;
+    default:
+      break;
     }
 
     // std::format will try to find a specialization to print the enum
@@ -511,24 +509,21 @@ bool FormatStringConverter::emitIntegerArgument(
     // Even -Wformat doesn't warn for this. std::format will format as
     // unsigned unless we cast it.
     if (const std::optional<std::string> MaybeCastType =
-            castTypeForArgument(ArgKind, ArgType))
-    {
-      switch(ArgKind)
-      {
-        case ConversionSpecifier::Kind::xArg:
-          FormatSpec.push_back('x');
-          break;
-        case ConversionSpecifier::Kind::XArg:
-          FormatSpec.push_back('X');
-          break;
-        default:
-          break;
+            castTypeForArgument(ArgKind, ArgType)) {
+      switch (ArgKind) {
+      case ConversionSpecifier::Kind::xArg:
+        FormatSpec.push_back('x');
+        break;
+      case ConversionSpecifier::Kind::XArg:
+        FormatSpec.push_back('X');
+        break;
+      default:
+        break;
       }
 
       ArgFixes.emplace_back(
           ArgIndex, (Twine("static_cast<") + *MaybeCastType + ">(").str());
-    }
-    else
+    } else
       return conversionNotPossible(
           (Twine("argument ") + Twine(ArgIndex) + " cannot be cast to " +
            Twine(ArgKind == ConversionSpecifier::Kind::uArg ? "unsigned"
@@ -536,18 +531,16 @@ bool FormatStringConverter::emitIntegerArgument(
            " integer type to match format"
            " specifier and StrictMode is enabled")
               .str());
-  } else
-  {
-    switch(ArgKind)
-    {
-      case ConversionSpecifier::Kind::xArg:
-        FormatSpec.push_back('x');
-        break;
-      case ConversionSpecifier::Kind::XArg:
-        FormatSpec.push_back('X');
-        break;
-      default:
-        if (isRealCharType(ArgType) || !ArgType->isIntegerType()) {
+  } else {
+    switch (ArgKind) {
+    case ConversionSpecifier::Kind::xArg:
+      FormatSpec.push_back('x');
+      break;
+    case ConversionSpecifier::Kind::XArg:
+      FormatSpec.push_back('X');
+      break;
+    default:
+      if (isRealCharType(ArgType) || !ArgType->isIntegerType()) {
         // Only specify integer if the argument is of a different type
         FormatSpec.push_back('d');
       }

``````````

</details>


https://github.com/llvm/llvm-project/pull/155200
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to