Issue |
91155
|
Summary |
wrong fix of clang-tidy bugprone-macro-parentheses
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
jackua22
|
In this program
```
#define my_cast(type, p) reinterpret_cast<type*>(p)
void foo(void *p)
{
(void)my_cast(int, p);
}
```
This command
` % /grid/common/test/llvm-v17.0.6d1rh74_lnx86/bin/clang-tidy --fix --checks=bugprone-macro-parentheses bugprone-macro-parentheses.cpp -- -std=c++17 -stdlib=libc++`
converts the macro to
`#define my_cast(type, p) (reinterpret_cast<(type)*>(p))
`
And then the compilation fails
```
% /grid/common/test/llvm-v17.0.6d1rh74_lnx86/bin/clang++ -c -std=c++17 -stdlib=libc++ bugprone-macro-parentheses.cpp
bugprone-macro-parentheses.cpp:10:11: error: expected a type
5 | (void)my_cast(int, p);
| ^
bugprone-macro-parentheses.cpp:6:44: note: expanded from macro 'my_cast'
1 | #define my_cast(type, p) (reinterpret_cast<(type)*>(p))
| ^
bugprone-macro-parentheses.cpp:10:11: error: expected '>'
bugprone-macro-parentheses.cpp:6:50: note: expanded from macro 'my_cast'
1 | #define my_cast(type, p) (reinterpret_cast<(type)*>(p))
| ^
bugprone-macro-parentheses.cpp:10:11: note: to match this '<'
bugprone-macro-parentheses.cpp:6:43: note: expanded from macro 'my_cast'
1 | #define my_cast(type, p) (reinterpret_cast<(type)*>(p))
| ^
bugprone-macro-parentheses.cpp:10:11: error: expected _expression_
5 | (void)my_cast(int, p);
| ^
bugprone-macro-parentheses.cpp:6:51: note: expanded from macro 'my_cast'
1 | #define my_cast(type, p) (reinterpret_cast<(type)*>(p))
| ^
3 errors generated.
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs