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");
+ }
-
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
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`
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
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
Jaysonyan updated this revision to Diff 375887.
Jaysonyan added a comment.
- Add more verbose warning message
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110436/new/
https://reviews.llvm.org/D110436
Files:
clang/include/clang/Basic/DiagnosticG
Jaysonyan created this revision.
Jaysonyan added reviewers: leonardchan, phosek.
Jaysonyan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This warning is to dissuade developers from using the potentially unsafe %n
format specifier. Current