[PATCH] D44934: [analyzer] Improve the modeling of `memset()`.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 15 15:07:07 PDT 2018
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.
Thanks! This looks great now.
================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1055
+ std::tie(StateNullChar, StateNonNullChar) =
+ assumeZero(C, State, CharVal, Ctx.UnsignedCharTy);
+
----------------
MTC wrote:
> NoQ wrote:
> > I think this should use `IntTy` here. Because that's the type of the `memset`'s argument, and that's what `assumeZero()` expects.
> I confirmed again that `memset()` will convert the value to `unsigned char` first, see http://en.cppreference.com/w/c/string/byte/memset.
>
> In the next update, I will `evalCast(value, UnsignedCharTy, IntTy)` first, therefore, I will continue to use `UnsignedCharTy`.
Aha, yup, it does convert to `unsigned char`, but `assumeZero()` doesn't. The new code looks correct.
Repository:
rC Clang
https://reviews.llvm.org/D44934
More information about the cfe-commits
mailing list