This revision was automatically updated to reflect the committed changes.
Closed by commit rC337470: [Sema] Add a new warning, -Wmemset-transposed-args
(authored by epilk, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D49112?vs=156178&id=156298#toc
Repository:
rC Clang
h
aaron.ballman accepted this revision.
aaron.ballman added a comment.
LGTM aside from a minor nit.
Comment at: clang/lib/Sema/SemaChecking.cpp:8751
+
+ if (auto *BO = dyn_cast(SizeofExpr)) {
+if (BO->getOpcode() != BO_Mul && BO->getOpcode() != BO_Add)
`cons
erik.pilkington added inline comments.
Comment at: clang/lib/Sema/SemaChecking.cpp:7984
+ if (isa(ThirdArg) &&
+ cast(ThirdArg)->getValue() == 0) {
+WarningKind = 0;
Quuxplusone wrote:
> > Suppress the diagnostic in cases like `memset(ptr, 0xff, PADDING
erik.pilkington updated this revision to Diff 156178.
erik.pilkington marked 5 inline comments as done.
erik.pilkington added a comment.
This revision is now accepted and ready to land.
In this new patch:
- Add support for __builtin_bzero (-Wsuspicious-bzero), improve diagnostics for
platforms t
aaron.ballman added inline comments.
Comment at: clang/lib/Sema/SemaChecking.cpp:7975-7976
+static void CheckMemsetSizeof(Sema &S, unsigned BId, const CallExpr *Call) {
+ if (BId != Builtin::BImemset)
+return;
+
erik.pilkington wrote:
> aaron.ballman wrote:
Quuxplusone added inline comments.
Comment at: clang/lib/Sema/SemaChecking.cpp:7984
+ if (isa(ThirdArg) &&
+ cast(ThirdArg)->getValue() == 0) {
+WarningKind = 0;
> Suppress the diagnostic in cases like `memset(ptr, 0xff, PADDING)`, when
> `PADDING` is
erik.pilkington planned changes to this revision.
erik.pilkington added a comment.
In https://reviews.llvm.org/D49112#1158793, @thakis wrote:
> lgtm assuming you ran this on some large code base to make sure it doesn't
> have false positives.
Sorry for the delay here, I was running this on som
Quuxplusone added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:662
+def note_suspicious_sizeof_memset_silence : Note<
+ "%select{parenthesize the third argument|cast the second argument to 'int'}0
to silence">;
+
aaron.ballman w
aaron.ballman added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:662
+def note_suspicious_sizeof_memset_silence : Note<
+ "%select{parenthesize the third argument|cast the second argument to 'int'}0
to silence">;
+
erik.pilkingt
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.
lgtm assuming you ran this on some large code base to make sure it doesn't have
false positives.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:659
+def warn_s
erik.pilkington added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:662
+def note_suspicious_sizeof_memset_silence : Note<
+ "%select{parenthesize the third argument|cast the second argument to 'int'}0
to silence">;
+
Quuxplusone
erik.pilkington updated this revision to Diff 154833.
erik.pilkington added a comment.
Address @Quuxplusone comments.
https://reviews.llvm.org/D49112
Files:
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
cla
Quuxplusone added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:662
+def note_suspicious_sizeof_memset_silence : Note<
+ "%select{parenthesize the third argument|cast the second argument to 'int'}0
to silence">;
+
If it were my c
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, aaron.ballman, arphaman.
Herald added a subscriber: dexonsmith.
This warning tries to catch programs that incorrectly call memset with the
second and third arguments transposed, ie `memset(ary, sizeof(ary), 0)` instea
14 matches
Mail list logo