[llvm] [Support] Use macro var args to allow templates within DEBUG_WITH_TYPE (PR #117614)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 11:31:34 PST 2024


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 7e3187e12a2cef8b2552e08ce9423aca9c09d813 6c40a0993a5b5e868384da72b549fd0badc32607 --extensions cpp,h -- llvm/include/llvm/Support/Debug.h llvm/unittests/Support/DebugTest.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/include/llvm/Support/Debug.h b/llvm/include/llvm/Support/Debug.h
index c16327033e..23c54ac9bb 100644
--- a/llvm/include/llvm/Support/Debug.h
+++ b/llvm/include/llvm/Support/Debug.h
@@ -61,15 +61,20 @@ void setCurrentDebugTypes(const char **Types, unsigned Count);
 ///
 /// This will emit the debug information if -debug is present, and -debug-only
 /// is not specified, or is specified as "bitset".
-#define DEBUG_WITH_TYPE(TYPE, ...)                                        \
-  do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)) { __VA_ARGS__; } \
+#define DEBUG_WITH_TYPE(TYPE, ...)                                             \
+  do {                                                                         \
+    if (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)) {               \
+      __VA_ARGS__;                                                             \
+    }                                                                          \
   } while (false)
 
 #else
 #define isCurrentDebugType(X) (false)
 #define setCurrentDebugType(X) do { (void)(X); } while (false)
 #define setCurrentDebugTypes(X, N) do { (void)(X); (void)(N); } while (false)
-#define DEBUG_WITH_TYPE(TYPE, ...) do { } while (false)
+#define DEBUG_WITH_TYPE(TYPE, ...)                                             \
+  do {                                                                         \
+  } while (false)
 #endif
 
 /// This boolean is set to true if the '-debug' command line option
diff --git a/llvm/unittests/Support/DebugTest.cpp b/llvm/unittests/Support/DebugTest.cpp
index 9e4b6e8665..e8b754892a 100644
--- a/llvm/unittests/Support/DebugTest.cpp
+++ b/llvm/unittests/Support/DebugTest.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/ADT/MapVector.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include "gtest/gtest.h"
@@ -36,14 +36,14 @@ TEST(DebugTest, Basic) {
 TEST(DebugTest, CommaInDebugBlock) {
   std::string s1, s2;
   raw_string_ostream os1(s1), os2(s2);
-  static const char *DT[] = {"A", "B"};  
-  static const char Letters[] = {'X', 'Y', 'Z'};  
-  
+  static const char *DT[] = {"A", "B"};
+  static const char Letters[] = {'X', 'Y', 'Z'};
+
   llvm::DebugFlag = true;
   setCurrentDebugTypes(DT, 2);
   DEBUG_WITH_TYPE("A", {
-    SmallMapVector <int, char, 4> map;
-    for (int i = 0; i < 3; i++) 
+    SmallMapVector<int, char, 4> map;
+    for (int i = 0; i < 3; i++)
       map[i] = Letters[i];
     for (int i = 2; i >= 0; i--)
       os1 << map[i];

``````````

</details>


https://github.com/llvm/llvm-project/pull/117614


More information about the llvm-commits mailing list