[PATCH] D110436: Add %n format specifier warning to clang-tidy

2021-10-21 Thread Jayson Yan via Phabricator via cfe-commits
Jaysonyan added inline comments. Herald added a subscriber: carlosgalvezp. Comment at: clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:89 +Result.Context->getTargetInfo()); +diag(loc, "usage of %%n can lead to unsafe writing to memory"); + } -

[PATCH] D110436: Add %n format specifier warning to clang-tidy

2021-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:43-57 + auto PrintfDecl = functionDecl(hasName("::printf")); + auto FprintfDecl = functionDecl(hasName("::fprintf")); + auto VfprintfDecl = functionDecl(has

[PATCH] D110436: Add %n format specifier warning to clang-tidy

2021-10-21 Thread Jayson Yan via Phabricator via cfe-commits
Jaysonyan added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:43-57 + auto PrintfDecl = functionDecl(hasName("::printf")); + auto FprintfDecl = functionDecl(hasName("::fprintf")); + auto VfprintfDecl = functionDecl(hasName

[PATCH] D110436: Add %n format specifier warning to clang-tidy

2021-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:26-27 + bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS, + const char *startSpecifier, +

[PATCH] D110436: Add %n format specifier warning to clang-tidy

2021-10-20 Thread Jayson Yan via Phabricator via cfe-commits
Jaysonyan updated this revision to Diff 381103. Jaysonyan retitled this revision from "Add %n format specifier warning" to "Add %n format specifier warning to clang-tidy". Jaysonyan added a comment. Herald added a subscriber: mgorny. Herald added a project: clang-tools-extra. Move check for `%n`

[PATCH] D110436: Add %n format specifier warning

2021-10-05 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230 +def warn_printf_n_specifier : Warning< + "usage of '%%n' can lead to unsafe writing to memory">, InGroup; def warn_printf_data_arg_not_used : Warning< Jaysony

[PATCH] D110436: Add %n format specifier warning

2021-10-05 Thread Jayson Yan via Phabricator via cfe-commits
Jaysonyan added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230 +def warn_printf_n_specifier : Warning< + "usage of '%%n' can lead to unsafe writing to memory">, InGroup; def warn_printf_data_arg_not_used : Warning< aaron.bal

[PATCH] D110436: Add %n format specifier warning

2021-10-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230 +def warn_printf_n_specifier : Warning< + "usage of '%%n' can lead to unsafe writing to memory">, InGroup; def warn_printf_data_arg_not_used : Warning< Quuxp

[PATCH] D110436: Add %n format specifier warning

2021-10-05 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230 +def warn_printf_n_specifier : Warning< + "usage of '%%n' can lead to unsafe writing to memory">, InGroup; def warn_printf_data_arg_not_used : Warning< FWIW, I

[PATCH] D110436: Add %n format specifier warning

2021-10-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. The trouble with this diagnostic is that it throws the baby out with the bathwater. It is possible to securely use `%n`, so we can't have this warning be on by default because it will have too high of a false positive rate. However, we typically don't introduce ne

[PATCH] D110436: Add %n format specifier warning

2021-10-05 Thread Jayson Yan via Phabricator via cfe-commits
Jaysonyan added a comment. Since no discussion came out of the RFC I'll leave the warning under the `-Wformat-n-specifier` flag under `-Wformat` unless there's other ideas brought up. Would appreciate any reviews at this points! :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTI