[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-09-06 Thread 方程 via Phabricator via cfe-commits
Yoorkin added a comment. I want to enable this check in both c and c++, but didn't find option `LangOpt.C`. For c++, we have option `LangOpt.CPlusPlus`. There is only some specific c standard option like `C99` `C11` `C17` and `C2X` defined in `LangOptions.def`. Could you tell me how to do this?

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-09-06 Thread 方程 via Phabricator via cfe-commits
Yoorkin updated this revision to Diff 458155. Yoorkin marked 5 inline comments as done. Yoorkin added a comment. Maybe renamed to bugprone-sprintf-with-fixed-size-buffer would be better. I add another option `FlagAllCalls` to flag all calls to `sprintf` and `vsprintf`. CHANGES SINCE LAST ACTION

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. Should this check be renamed to bugprone-sprintf-with-fixed-size-buffer? Have you thought about an option to flag all calls to sprintf as they are typically not recommended by a lot of coding practice guides. Obviously we couldn't generate a fix-it as the buffer size ma

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-23 Thread 方程 via Phabricator via cfe-commits
Yoorkin updated this revision to Diff 454724. Yoorkin added a comment. I forgot to update comments in `PrintfWithFixedSizeBufferCheck.h`, sorry CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132294/new/ https://reviews.llvm.org/D132294 Files: clang-tools-extra/clang-tidy/bugprone/Bugp

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-23 Thread 方程 via Phabricator via cfe-commits
Yoorkin updated this revision to Diff 454722. Yoorkin added a comment. Now it can find usage of both `sprintf` and `vsprintf`, and then change a small piece of code. Here is an option `PreferSafe`, when value is true, the check prefers `snprintf_s` `vsnprintf_s` over `snprintf` `vsnprintf`. CH

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. Why are we only targeting sprintf, vsprintf would also suffer from the same pitfalls. Is there any hard reason that this check always suggests `snprintf` instead of `sprintf_s`, maybe have that dynamically controlled with an option. Comment at: clan

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin updated this revision to Diff 454228. Yoorkin added a comment. I fixed it. Thanks CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132294/new/ https://reviews.llvm.org/D132294 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp clang-tools-extra/clang-tidy/bugp

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst:6 + +Find usage of ``sprintf``, which write output string into a fixed-size array. It +will suggest ``snprintf`` instead. Sho

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin updated this revision to Diff 454226. Yoorkin marked 10 inline comments as done. Yoorkin added a comment. I fixed them all CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132294/new/ https://reviews.llvm.org/D132294 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModul

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h:29 + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + Yoorkin wrote: > Eugene.Zelenko wrote: > > Please add

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h:29 + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + Eugene.Zelenko wrote: > Please add `isLanguageVersionSupport

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp:13 +#include "clang/ASTMatchers/ASTMatchFinder.h" + +#include "clang/Lex/Lexer.h" Unnecessary newline. Comment at: cla

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin created this revision. Yoorkin added a reviewer: clang-tools-extra. Yoorkin added a project: clang-tools-extra. Herald added subscribers: carlosgalvezp, xazax.hun, mgorny. Herald added a project: All. Yoorkin requested review of this revision. Herald added a subscriber: cfe-commits. Hi, I