Issue |
143326
|
Summary |
[clang-tidy] Check request: portability-minmax-macro-defensive
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
denzor200
|
Needs a check that will find `std::min` and `std::max` invocations without surrounding parentheses over the name. The check will suggest to insert parentheses around the name.
BEFORE:
```
int result = std::min(a, b);
```
AFTER:
```
int result = (std::min)(a, b);
```
Without parentheses the code that uses `std::min` and `std::max` might lead to compilation error in MSVC:
```
#include <algorithm> // std::min
#include <windows.h> // min macro
int main() {
int a = 5, b = 10;
// Compilation error in MSVC:
// "error C2589: '(': illegal token on right side of '::'"
int result = std::min(a, b);
return 0;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs