[clang][analyzer] No new nodes when bug is detected in StdLibraryFunctionsChecker.
authorBalázs Kéri <1.int32@gmail.com>
Wed, 14 Dec 2022 08:25:06 +0000 (09:25 +0100)
committerBalázs Kéri <1.int32@gmail.com>
Wed, 14 Dec 2022 08:51:43 +0000 (09:51 +0100)
commitda0660691f74b0350dee8e15f4ac942457e397e4
tree6c3dd062e1747a5f65cec6f595af237d47ed90ce
parentc86a878e8995d54a5b950098e81f0d3bf153aded
[clang][analyzer] No new nodes when bug is detected in StdLibraryFunctionsChecker.

The checker applies constraints in a sequence and adds new nodes for these states.
If a constraint violation is found this sequence should be stopped with a sink
(error) node. Instead the `generateErrorNode` did add a new error node as a new
branch that is parallel to the other node sequence, the other branch was not
stopped and analysis was continuing on that invalid branch.
To add an error node after any previous node a new version of `generateErrorNode`
is needed, this function is added here and used by `StdLibraryFunctionsChecker`.
The added test executes a situation where the checker adds a number of
constraints before it finds a constraint violation.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D137722
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-arg-constraints.c