aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
diff options
context:
space:
mode:
authorBalázs Kéri <balazs.keri@ericsson.com>2023-07-18 08:47:40 +0200
committerBalázs Kéri <balazs.keri@ericsson.com>2023-07-18 09:29:15 +0200
commitf12808ab20369c85ddb602e5a78bab40d16bb83f (patch)
tree1d10edc97c27f5e7cb2a5e9116154157aa126da4 /clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
parent39670ae3b93470b2d29fe78e6d40c5d82a05e4a1 (diff)
downloadllvm-f12808ab20369c85ddb602e5a78bab40d16bb83f.zip
llvm-f12808ab20369c85ddb602e5a78bab40d16bb83f.tar.gz
llvm-f12808ab20369c85ddb602e5a78bab40d16bb83f.tar.bz2
[clang][analyzer] Display notes in StdLibraryFunctionsChecker only if interesting
The note tag that was previously added in all cases when a standard function call is found is displayed now only if the function call (return value) is "interesting". This results in less unneeded notes but some of the previously good notes disappear too. This is because interestingness is not always set as it should be. Reviewed By: donat.nagy Differential Revision: https://reviews.llvm.org/D153776
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 8d4fb12..1fb248b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -835,6 +835,7 @@ private:
for (ArgNo ArgN : VC->getArgsToTrack()) {
bugreporter::trackExpressionValue(N, Call.getArgExpr(ArgN), *R);
+ R->markInteresting(Call.getArgSVal(ArgN));
// All tracked arguments are important, highlight them.
R->addRange(Call.getArgSourceRange(ArgN));
}
@@ -1298,6 +1299,7 @@ void StdLibraryFunctionsChecker::checkPostCall(const CallEvent &Call,
// StdLibraryFunctionsChecker.
ExplodedNode *Pred = Node;
if (!Case.getNote().empty()) {
+ const SVal RV = Call.getReturnValue();
// If there is a description for this execution branch (summary case),
// use it as a note tag.
std::string Note =
@@ -1305,7 +1307,7 @@ void StdLibraryFunctionsChecker::checkPostCall(const CallEvent &Call,
cast<NamedDecl>(Call.getDecl())->getDeclName());
if (Summary.getInvalidationKd() == EvalCallAsPure) {
const NoteTag *Tag = C.getNoteTag(
- [Node, Note](PathSensitiveBugReport &BR) -> std::string {
+ [Node, Note, RV](PathSensitiveBugReport &BR) -> std::string {
// Try to omit the note if we know in advance which branch is
// taken (this means, only one branch exists).
// This check is performed inside the lambda, after other
@@ -1316,18 +1318,22 @@ void StdLibraryFunctionsChecker::checkPostCall(const CallEvent &Call,
// split that was performed by another checker (and can not find
// the successors). This is why this check is only used in the
// EvalCallAsPure case.
- if (Node->succ_size() > 1)
+ if (BR.isInteresting(RV) && Node->succ_size() > 1)
return Note;
return "";
- },
- /*IsPrunable=*/true);
+ });
Pred = C.addTransition(NewState, Pred, Tag);
} else {
- const NoteTag *Tag = C.getNoteTag(Note, /*IsPrunable=*/true);
+ const NoteTag *Tag =
+ C.getNoteTag([Note, RV](PathSensitiveBugReport &BR) -> std::string {
+ if (BR.isInteresting(RV))
+ return Note;
+ return "";
+ });
Pred = C.addTransition(NewState, Pred, Tag);
}
if (!Pred)
- break;
+ continue;
}
// If we can get a note tag for the errno change, add this additionally to