[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 24 06:13:56 PST 2020
martong updated this revision to Diff 246193.
martong marked 7 inline comments as done.
martong added a comment.
- Use StringRef for Msg
- Remove superfluous addTransition
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73898/new/
https://reviews.llvm.org/D73898
Files:
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-arg-constraints.c
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===================================================================
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -37,10 +37,8 @@
y = 0;
clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
- if (x > 255) { // This path is no longer feasible.
- ret = isalnum(x);
+ if (x > 255) // This path is no longer feasible.
ret = x / y; // No warning here
- }
ret = x / y; // expected-warning{{Division by zero}}
}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -404,7 +404,7 @@
if (!ChecksEnabled[CK_StdCLibraryFunctionArgsChecker])
return;
// FIXME Add detailed diagnostic.
- std::string Msg = "Function argument constraint is not satisfied";
+ StringRef Msg = "Function argument constraint is not satisfied";
auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, N);
bugreporter::trackExpressionValue(N, Call.getArgExpr(0), *R);
C.emitReport(std::move(R));
@@ -415,8 +415,7 @@
ProgramStateRef FailureSt = VR.negate().apply(State, Call, Summary);
// The argument constraint is not satisfied.
if (FailureSt && !SuccessSt) {
- C.addTransition(FailureSt);
- if (ExplodedNode *N = C.generateErrorNode(FailureSt))
+ if (ExplodedNode *N = C.generateErrorNode(State))
Report(N);
break;
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73898.246193.patch
Type: text/x-patch
Size: 1737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200224/89e6683b/attachment.bin>
More information about the cfe-commits
mailing list