[PATCH] D77012: [analyzer] Fix StdLibraryFunctionsChecker NotNull Constraint Check
Vince Bridgers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 29 07:59:32 PDT 2020
vabridgers updated this revision to Diff 253419.
vabridgers added a comment.
fix pre-merge lint checks
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77012/new/
https://reviews.llvm.org/D77012
Files:
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions.c
Index: clang/test/Analysis/std-c-library-functions.c
===================================================================
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -89,6 +89,14 @@
clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
}
+void test_fread_uninitialized(void) {
+ void *ptr;
+ size_t sz;
+ size_t nmem;
+ FILE *fp;
+ (void) fread(ptr, sz, nmem, fp); // expected-warning {{1st function call argument is an uninitialized value}}
+}
+
ssize_t getline(char **, size_t *, FILE *);
void test_getline(FILE *fp) {
char *line = 0;
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -190,6 +190,9 @@
ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
const Summary &Summary) const override {
SVal V = getArgSVal(Call, getArgNo());
+ if (V.isUndef())
+ return State;
+
DefinedOrUnknownSVal L = V.castAs<DefinedOrUnknownSVal>();
if (!L.getAs<Loc>())
return State;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77012.253419.patch
Type: text/x-patch
Size: 1265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200329/da3fe6a4/attachment-0001.bin>
More information about the cfe-commits
mailing list