[PATCH] D87785: [analyzer][StdLibraryFunctionsChecker] Fix a BufferSize constraint crash
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 16 12:53:28 PDT 2020
steakhal added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:219-226
if (V.isUndef())
- return State;
+ return {State, State};
DefinedOrUnknownSVal L = V.castAs<DefinedOrUnknownSVal>();
if (!L.getAs<Loc>())
- return State;
-
- return State->assume(L, CannotBeNull);
- }
+ return {State, State};
----------------
I suggest the same //simpler// version for the similar code segments as well.
By the same token, why do you return `{State, State}`?
Shouldn't you return `{State, nullptr}` there?
In general, one would not expect the **same** State being returned, IMO it's advised to avoid doing that.
Same applies for the other cases.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:299-300
SvalBuilder.getContext().BoolTy);
if (auto F = Feasible.getAs<DefinedOrUnknownSVal>())
- return State->assume(*F, true);
+ return State->assume(*F);
----------------
Why don't you `castAs`? That also has the corresponding assert inside.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87785/new/
https://reviews.llvm.org/D87785
More information about the cfe-commits
mailing list