Issue |
131936
|
Summary |
[clang-tidy] Check request: bugprone-avoid-invalid-format-string
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
denzor200
|
Needs a check that will find incorrect format strings and point them out. This check will not provide fix-it hints.
```
int number = 42;
printf("Value: %s\n", number); // BAD - expected string but an integer was passed
printf("Numbers: %d, %d\n", 42); // BAD - wrong number of arguments
printf("String: %.*s\n", "Hello world"); // BAD - %.*s requires two arguments
const char* user_input = get_user_input();
printf(user_input); // BAD - format string vulnerability
printf("Numbers: %d, %d\n", 100, 200); // OK
constexpr const char* no_user_input = get_format();
printf(no_user_input); // OK
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs