[clang-tools-extra] [clang-tidy] fix false positives for bugprone-macro-parentheses in C++ templates (PR #174329)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 5 21:21:46 PST 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results

* 3014 tests passed
* 29 tests skipped
* 1 test failed

## Failed Tests
(click on a test name to see its output)

### Clang Tools
<details>
<summary>Clang Tools.clang-tidy/checkers/bugprone/macro-parentheses.cpp</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
C:/Python312/python.exe C:/_work/llvm-project/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\bugprone\macro-parentheses.cpp bugprone-macro-parentheses C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp
# executed command: C:/Python312/python.exe 'C:/_work/llvm-project/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py' 'C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\bugprone\macro-parentheses.cpp' bugprone-macro-parentheses 'C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp'
# .---command stdout------------
# | Running ['clang-tidy', '--experimental-custom-checks', 'C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\bugprone\\Output\\macro-parentheses.cpp.tmp.cpp', '-fix', '--checks=-*,bugprone-macro-parentheses', '--config={}', '--', '-std=c++11', '-nostdinc++']...
# | ------------------------ clang-tidy output -----------------------
# | 16 warnings generated.
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:3:27: warning: macro replacement list should be enclosed in parentheses [bugprone-macro-parentheses]
# |     3 | #define BAD1              -1
# |       |                           ^ 
# |       |                           ( )
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:3:27: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:3:29: note: FIX-IT applied suggested code changes
# |     3 | #define BAD1              -1
# |       |                             ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:5:28: warning: macro replacement list should be enclosed in parentheses [bugprone-macro-parentheses]
# |     5 | #define BAD2              1+2
# |       |                            ^ 
# |       |                           (  )
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:5:27: note: FIX-IT applied suggested code changes
# |     5 | #define BAD2              1+2
# |       |                           ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:5:30: note: FIX-IT applied suggested code changes
# |     5 | #define BAD2              1+2
# |       |                              ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:7:28: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |     7 | #define BAD3(A)           (A+1)
# |       |                            ^
# |       |                            ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:7:28: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:7:29: note: FIX-IT applied suggested code changes
# |     7 | #define BAD3(A)           (A+1)
# |       |                             ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:9:44: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |     9 | #define BAD4(x)           ((unsigned char)(x & 0xff))
# |       |                                            ^
# |       |                                            ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:9:44: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:9:45: note: FIX-IT applied suggested code changes
# |     9 | #define BAD4(x)           ((unsigned char)(x & 0xff))
# |       |                                             ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:11:35: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    11 | #define BAD5(X)           A*B=(C*)X+2
# |       |                                   ^
# |       |                                   ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:11:35: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:11:36: note: FIX-IT applied suggested code changes
# |    11 | #define BAD5(X)           A*B=(C*)X+2
# |       |                                    ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:13:33: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    13 | #define BAD6(x)           goto *x;
# |       |                                 ^
# |       |                                 ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:13:33: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:13:34: note: FIX-IT applied suggested code changes
# |    13 | #define BAD6(x)           goto *x;
# |       |                                  ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:15:47: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    15 | #define BAD7(x, y)        if (x) goto y; else x;
# |       |                                               ^
# |       |                                               ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:15:47: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:15:48: note: FIX-IT applied suggested code changes
# |    15 | #define BAD7(x, y)        if (x) goto y; else x;
# |       |                                                ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:75:40: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    75 | #define BAD_TEMPLATE1(T)  (std::vector<T*2>)
# |       |                                        ^
# |       |                                        ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:75:40: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:75:41: note: FIX-IT applied suggested code changes
# |    75 | #define BAD_TEMPLATE1(T)  (std::vector<T*2>)
# |       |                                         ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:77:37: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    77 | #define BAD_TEMPLATE2(T)  (std::map<T*2, int>)
# |       |                                     ^
# |       |                                     ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:77:37: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:77:38: note: FIX-IT applied suggested code changes
# |    77 | #define BAD_TEMPLATE2(T)  (std::map<T*2, int>)
# |       |                                      ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:79:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    79 | #define BAD_TEMPLATE3(T)  (std::map<int, T*2>)
# |       |                                          ^
# |       |                                          ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:79:42: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:79:43: note: FIX-IT applied suggested code changes
# |    79 | #define BAD_TEMPLATE3(T)  (std::map<int, T*2>)
# |       |                                           ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:81:40: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    81 | #define BAD_TEMPLATE4(T)  (std::vector<T+1>)
# |       |                                        ^
# |       |                                        ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:81:40: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:81:41: note: FIX-IT applied suggested code changes
# |    81 | #define BAD_TEMPLATE4(T)  (std::vector<T+1>)
# |       |                                         ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:40: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    83 | #define BAD_TEMPLATE5(T)  (std::vector<T*T>)
# |       |                                        ^
# |       |                                        ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:40: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:41: note: FIX-IT applied suggested code changes
# |    83 | #define BAD_TEMPLATE5(T)  (std::vector<T*T>)
# |       |                                         ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    83 | #define BAD_TEMPLATE5(T)  (std::vector<T*T>)
# |       |                                          ^
# |       |                                          ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:42: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:43: note: FIX-IT applied suggested code changes
# |    83 | #define BAD_TEMPLATE5(T)  (std::vector<T*T>)
# |       |                                           ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:86:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    86 | #define BAD_TEMPLATE6(T)  (std::vector<2*T>)
# |       |                                          ^
# |       |                                          ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:86:42: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:86:43: note: FIX-IT applied suggested code changes
# |    86 | #define BAD_TEMPLATE6(T)  (std::vector<2*T>)
# |       |                                           ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:88:45: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    88 | #define BAD_CAST1(T)      (reinterpret_cast<T*2>(0))
# |       |                                             ^
# |       |                                             ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:88:45: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:88:46: note: FIX-IT applied suggested code changes
# |    88 | #define BAD_CAST1(T)      (reinterpret_cast<T*2>(0))
# |       |                                              ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:90:45: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# |    90 | #define BAD_CAST2(T)      (reinterpret_cast<T+1>(0))
# |       |                                             ^
# |       |                                             ()
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:90:45: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:90:46: note: FIX-IT applied suggested code changes
# | clang-tidy applied 32 of 32 suggested fixes.
# | 
# |    90 | #define BAD_CAST2(T)      (reinterpret_cast<T+1>(0))
# |       |                                              ^
# | 
# | ------------------------------------------------------------------
# | diff -u C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.orig C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp failed:
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.orig	2026-01-06 05:20:29.536227100 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp	2026-01-06 05:20:29.589268900 +0000
# | @@ -1,18 +1,18 @@
# |  // RUN: %check_clang_tidy %s bugprone-macro-parentheses %t
# | 
# |  
# | 
# | -#define BAD1              -1
# | 
# | +#define BAD1              (-1)
# | 
# |  //
# | 
# | -#define BAD2              1+2
# | 
# | +#define BAD2              (1+2)
# | 
# |  //
# | 
# | -#define BAD3(A)           (A+1)
# | 
# | +#define BAD3(A)           ((A)+1)
# | 
# |  //
# | 
# | -#define BAD4(x)           ((unsigned char)(x & 0xff))
# | 
# | +#define BAD4(x)           ((unsigned char)((x) & 0xff))
# | 
# |  //
# | 
# | -#define BAD5(X)           A*B=(C*)X+2
# | 
# | +#define BAD5(X)           A*B=(C*)(X)+2
# | 
# |  //
# | 
# | -#define BAD6(x)           goto *x;
# | 
# | +#define BAD6(x)           goto *(x);
# | 
# |  //
# | 
# | -#define BAD7(x, y)        if (x) goto y; else x;
# | 
# | +#define BAD7(x, y)        if (x) goto y; else (x);
# | 
# |  //
# | 
# |  
# | 
# |  #define GOOD1             1
# | 
# | @@ -72,20 +72,20 @@
# |  #define TEMPLATE3(T)      (std::vector<const T*>)
# | 
# |  #define TEMPLATE4(T)      (std::map<T*, T*>)
# | 
# |  
# | 
# | -#define BAD_TEMPLATE1(T)  (std::vector<T*2>)
# | 
# | +#define BAD_TEMPLATE1(T)  (std::vector<(T)*2>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE2(T)  (std::map<T*2, int>)
# | 
# | +#define BAD_TEMPLATE2(T)  (std::map<(T)*2, int>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE3(T)  (std::map<int, T*2>)
# | 
# | +#define BAD_TEMPLATE3(T)  (std::map<int, (T)*2>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE4(T)  (std::vector<T+1>)
# | 
# | +#define BAD_TEMPLATE4(T)  (std::vector<(T)+1>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE5(T)  (std::vector<T*T>)
# | 
# | +#define BAD_TEMPLATE5(T)  (std::vector<(T)*(T)>)
# | 
# |  //
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE6(T)  (std::vector<2*T>)
# | 
# | +#define BAD_TEMPLATE6(T)  (std::vector<2*(T)>)
# | 
# |  //
# | 
# | -#define BAD_CAST1(T)      (reinterpret_cast<T*2>(0))
# | 
# | +#define BAD_CAST1(T)      (reinterpret_cast<(T)*2>(0))
# | 
# |  //
# | 
# | -#define BAD_CAST2(T)      (reinterpret_cast<T+1>(0))
# | 
# | +#define BAD_CAST2(T)      (reinterpret_cast<(T)+1>(0))
# | 
# |  //
# | 
# | 
# | ------------------------------ Fixes -----------------------------
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.orig	2026-01-06 05:20:29.536227100 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp	2026-01-06 05:20:29.589268900 +0000
# | @@ -1,18 +1,18 @@
# |  // RUN: %check_clang_tidy %s bugprone-macro-parentheses %t
# | 
# |  
# | 
# | -#define BAD1              -1
# | 
# | +#define BAD1              (-1)
# | 
# |  //
# | 
# | -#define BAD2              1+2
# | 
# | +#define BAD2              (1+2)
# | 
# |  //
# | 
# | -#define BAD3(A)           (A+1)
# | 
# | +#define BAD3(A)           ((A)+1)
# | 
# |  //
# | 
# | -#define BAD4(x)           ((unsigned char)(x & 0xff))
# | 
# | +#define BAD4(x)           ((unsigned char)((x) & 0xff))
# | 
# |  //
# | 
# | -#define BAD5(X)           A*B=(C*)X+2
# | 
# | +#define BAD5(X)           A*B=(C*)(X)+2
# | 
# |  //
# | 
# | -#define BAD6(x)           goto *x;
# | 
# | +#define BAD6(x)           goto *(x);
# | 
# |  //
# | 
# | -#define BAD7(x, y)        if (x) goto y; else x;
# | 
# | +#define BAD7(x, y)        if (x) goto y; else (x);
# | 
# |  //
# | 
# |  
# | 
# |  #define GOOD1             1
# | 
# | @@ -72,20 +72,20 @@
# |  #define TEMPLATE3(T)      (std::vector<const T*>)
# | 
# |  #define TEMPLATE4(T)      (std::map<T*, T*>)
# | 
# |  
# | 
# | -#define BAD_TEMPLATE1(T)  (std::vector<T*2>)
# | 
# | +#define BAD_TEMPLATE1(T)  (std::vector<(T)*2>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE2(T)  (std::map<T*2, int>)
# | 
# | +#define BAD_TEMPLATE2(T)  (std::map<(T)*2, int>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE3(T)  (std::map<int, T*2>)
# | 
# | +#define BAD_TEMPLATE3(T)  (std::map<int, (T)*2>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE4(T)  (std::vector<T+1>)
# | 
# | +#define BAD_TEMPLATE4(T)  (std::vector<(T)+1>)
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE5(T)  (std::vector<T*T>)
# | 
# | +#define BAD_TEMPLATE5(T)  (std::vector<(T)*(T)>)
# | 
# |  //
# | 
# |  //
# | 
# | -#define BAD_TEMPLATE6(T)  (std::vector<2*T>)
# | 
# | +#define BAD_TEMPLATE6(T)  (std::vector<2*(T)>)
# | 
# |  //
# | 
# | -#define BAD_CAST1(T)      (reinterpret_cast<T*2>(0))
# | 
# | +#define BAD_CAST1(T)      (reinterpret_cast<(T)*2>(0))
# | 
# |  //
# | 
# | -#define BAD_CAST2(T)      (reinterpret_cast<T+1>(0))
# | 
# | +#define BAD_CAST2(T)      (reinterpret_cast<(T)+1>(0))
# | 
# |  //
# | 
# | 
# | ------------------------------------------------------------------
# | FileCheck -input-file=C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp.msg C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\bugprone\macro-parentheses.cpp -check-prefixes=CHECK-MESSAGES -implicit-check-not={{warning|error}}: failed:
# | C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\bugprone\macro-parentheses.cpp:87:20: error: CHECK-MESSAGES: expected string not found in input
# | 
# | // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# | 
# |                    ^
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp.msg:100:230: note: scanning from here
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# | 
# |                                                                                                                                                                                                                                      ^
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp.msg:100:230: note: with "@LINE-1" equal to "86"
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# | 
# |                                                                                                                                                                                                                                      ^
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp.msg:108:138: note: possible intended match here
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:86:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
# | 
# |                                                                                                                                          ^
# | 
# | 
# | 
# | Input file: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp.msg
# | 
# | Check file: C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\bugprone\macro-parentheses.cpp
# | 
# | 
# | 
# | -dump-input=help explains the following input dump.
# | 
# | 
# | 
# | Input was:
# | 
# | <<<<<<
# | 
# |             .
# | 
# |             .
# | 
# |             .
# | 
# |            95:  | () 
# | 
# |            96: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:40: note: FIX-IT applied suggested code changes 
# | 
# |            97: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:41: note: FIX-IT applied suggested code changes 
# | 
# |            98:  83 | #define BAD_TEMPLATE5(T) (std::vector<T*T>) 
# | 
# |            99:  | ^ 
# | 
# |           100: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses] 
# | 
# | check:87'0                                                                                                                                                                                                                                          X error: no match found
# | 
# | check:87'1                                                                                                                                                                                                                                            with "@LINE-1" equal to "86"
# | 
# |           101:  83 | #define BAD_TEMPLATE5(T) (std::vector<T*T>) 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |           102:  | ^ 
# | 
# | check:87'0     ~~~~~
# | 
# |           103:  | () 
# | 
# | check:87'0     ~~~~~~
# | 
# |           104: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:42: note: FIX-IT applied suggested code changes 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |           105: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:83:43: note: FIX-IT applied suggested code changes 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |           106:  83 | #define BAD_TEMPLATE5(T) (std::vector<T*T>) 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |           107:  | ^ 
# | 
# | check:87'0     ~~~~~
# | 
# |           108: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:86:42: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses] 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# | check:87'2                                                                                                                                              ?                                                                                             possible intended match
# | 
# |           109:  86 | #define BAD_TEMPLATE6(T) (std::vector<2*T>) 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |           110:  | ^ 
# | 
# | check:87'0     ~~~~~
# | 
# |           111:  | () 
# | 
# | check:87'0     ~~~~~~
# | 
# |           112: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:86:42: note: FIX-IT applied suggested code changes 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |           113: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\bugprone\Output\macro-parentheses.cpp.tmp.cpp:86:43: note: FIX-IT applied suggested code changes 
# | 
# | check:87'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |             .
# | 
# |             .
# | 
# |             .
# | 
# | >>>>>>
# | 
# | 
# `-----------------------------
# .---command stderr------------
# | Traceback (most recent call last):
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 413, in <module>
# |     main()
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 409, in main
# |     CheckRunner(args, extra_args).run()
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 312, in run
# |     self.check_messages(clang_tidy_output)
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 273, in check_messages
# |     try_run(
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 63, in try_run
# |     process_output = subprocess.check_output(args, stderr=subprocess.STDOUT).decode(
# |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# |   File "c:\python312\Lib\subprocess.py", line 466, in check_output
# |     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
# |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# |   File "c:\python312\Lib\subprocess.py", line 571, in run
# |     raise CalledProcessError(retcode, process.args,
# | subprocess.CalledProcessError: Command '['FileCheck', '-input-file=C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\bugprone\\Output\\macro-parentheses.cpp.tmp.cpp.msg', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\bugprone\\macro-parentheses.cpp', '-check-prefixes=CHECK-MESSAGES', '-implicit-check-not={{warning|error}}:']' returned non-zero exit status 1.
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

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


More information about the cfe-commits mailing list