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?
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
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
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
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
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
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
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
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
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
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
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
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
13 matches
Mail list logo