24using namespace errno_modeling;
28class ErrnoTesterChecker :
public Checker<eval::Call> {
73 {{CDM::SimpleFunc, {
"ErrnoTesterChecker_setErrno"}, 1},
74 &ErrnoTesterChecker::evalSetErrno},
75 {{CDM::SimpleFunc, {
"ErrnoTesterChecker_getErrno"}, 0},
76 &ErrnoTesterChecker::evalGetErrno},
77 {{CDM::SimpleFunc, {
"ErrnoTesterChecker_setErrnoIfError"}, 0},
78 &ErrnoTesterChecker::evalSetErrnoIfError},
79 {{CDM::SimpleFunc, {
"ErrnoTesterChecker_setErrnoIfErrorRange"}, 0},
80 &ErrnoTesterChecker::evalSetErrnoIfErrorRange},
81 {{CDM::SimpleFunc, {
"ErrnoTesterChecker_setErrnoCheckState"}, 0},
82 &ErrnoTesterChecker::evalSetErrnoCheckState}};
98 assert(ErrnoVal &&
"Errno value should be available.");
100 State->BindExpr(
Call.getOriginExpr(),
C.getLocationContext(), *ErrnoVal);
102 C.addTransition(State);
111 Call.getOriginExpr(),
C.getLocationContext(), SVB.
makeIntVal(0,
true));
115 Call.getOriginExpr(),
C.getLocationContext(), SVB.
makeIntVal(1,
true));
118 C.addTransition(StateSuccess);
119 C.addTransition(StateFailure);
128 Call.getOriginExpr(),
C.getLocationContext(), SVB.
makeIntVal(0,
true));
132 Call.getOriginExpr(),
C.getLocationContext(), SVB.
makeIntVal(1,
true));
134 nullptr,
Call.getOriginExpr(),
C.getLocationContext(),
C.blockCount());
135 StateFailure = StateFailure->assume(ErrnoVal,
true);
136 assert(StateFailure &&
"Failed to assume on an initial value.");
140 C.addTransition(StateSuccess);
141 C.addTransition(StateFailure);
150 Call.getOriginExpr(),
C.getLocationContext(), SVB.
makeIntVal(0,
true));
154 Call.getOriginExpr(),
C.getLocationContext(), SVB.
makeIntVal(1,
true));
158 Call.getOriginExpr(),
C.getLocationContext(), SVB.
makeIntVal(2,
true));
161 C.addTransition(StateSuccess,
163 "sets 'errno' to an unspecified value."));
164 C.addTransition(StateFailure1);
168 "should be checked to test for failure."));
173 const EvalFn *
Fn = TestCalls.lookup(
Call);
176 return C.isDifferent();
185bool ento::shouldRegisterErrnoTesterChecker(
const CheckerManager &Mgr) {
An immutable map from CallDescriptions to arbitrary data.
Represents an abstract call to a function or method along a particular path.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, const Expr *expr, const LocationContext *LCtx, unsigned count)
Create a new symbol with a unique 'name'.
ProgramStateRef setErrnoValue(ProgramStateRef State, const LocationContext *LCtx, SVal Value, ErrnoCheckState EState)
Set value of 'errno' to any SVal, if possible.
ProgramStateRef setErrnoState(ProgramStateRef State, ErrnoCheckState EState)
Set the errno check state, do not modify the errno value.
const NoteTag * getErrnoNoteTag(CheckerContext &C, const std::string &Message)
Create a NoteTag that displays the message if the 'errno' memory region is marked as interesting,...
std::optional< SVal > getErrnoValue(ProgramStateRef State)
Returns the value of 'errno', if 'errno' was found in the AST.
@ MustBeChecked
Value of 'errno' should be checked to find out if a previous function call has failed.
@ Irrelevant
We do not know anything about 'errno'.
@ MustNotBeChecked
Value of 'errno' is not allowed to be read, it can contain an unspecified value.
The JSON file list parser is used to communicate input to InstallAPI.