clang 19.0.0git
|
Enumerations | |
enum | ErrnoCheckState : unsigned { Irrelevant = 0 , MustBeChecked = 1 , MustNotBeChecked = 2 } |
Describe how reads and writes of errno are handled by the checker. More... | |
Functions | |
std::optional< SVal > | getErrnoValue (ProgramStateRef State) |
Returns the value of 'errno', if 'errno' was found in the AST. | |
ProgramStateRef | setErrnoValue (ProgramStateRef State, const LocationContext *LCtx, SVal Value, ErrnoCheckState EState) |
Set value of 'errno' to any SVal, if possible. | |
ProgramStateRef | setErrnoValue (ProgramStateRef State, CheckerContext &C, uint64_t Value, ErrnoCheckState EState) |
Set value of 'errno' to a concrete (signed) integer, if possible. | |
std::optional< Loc > | getErrnoLoc (ProgramStateRef State) |
Returns the location that points to the MemoryRegion where the 'errno' value is stored. | |
ErrnoCheckState | getErrnoState (ProgramStateRef State) |
Returns the errno check state, Errno_Irrelevant if 'errno' was not found (this is not the only case for that value). | |
ProgramStateRef | setErrnoState (ProgramStateRef State, ErrnoCheckState EState) |
Set the errno check state, do not modify the errno value. | |
ProgramStateRef | clearErrnoState (ProgramStateRef State) |
Clear state of errno (make it irrelevant). | |
bool | isErrno (const Decl *D) |
Determine if a Decl node related to 'errno'. | |
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, and resets the interestingness. | |
ProgramStateRef | setErrnoForStdSuccess (ProgramStateRef State, CheckerContext &C) |
Set errno state for the common case when a standard function is successful. | |
ProgramStateRef | setErrnoForStdFailure (ProgramStateRef State, CheckerContext &C, NonLoc ErrnoSym) |
Set errno state for the common case when a standard function fails. | |
ProgramStateRef | setErrnoStdMustBeChecked (ProgramStateRef State, CheckerContext &C, const Expr *InvalE) |
Set errno state for the common case when a standard function indicates failure only by errno . | |
Describe how reads and writes of errno
are handled by the checker.
Enumerator | |
---|---|
Irrelevant | We do not know anything about 'errno'. Read and write is always allowed. |
MustBeChecked | Value of 'errno' should be checked to find out if a previous function call has failed. When this state is set |
MustNotBeChecked | Value of 'errno' is not allowed to be read, it can contain an unspecified value. When this state is set |
Definition at line 26 of file ErrnoModeling.h.
ProgramStateRef clang::ento::errno_modeling::clearErrnoState | ( | ProgramStateRef | State | ) |
Clear state of errno (make it irrelevant).
Definition at line 259 of file ErrnoModeling.cpp.
References Irrelevant, and setErrnoState().
std::optional< Loc > clang::ento::errno_modeling::getErrnoLoc | ( | ProgramStateRef | State | ) |
Returns the location that points to the MemoryRegion
where the 'errno' value is stored.
Returns std::nullopt
if 'errno' was not found. Otherwise it always returns a valid memory region in the system global memory space.
Definition at line 244 of file ErrnoModeling.cpp.
const NoteTag * clang::ento::errno_modeling::getErrnoNoteTag | ( | CheckerContext & | C, |
const std::string & | Message | ||
) |
Create a NoteTag that displays the message if the 'errno' memory region is marked as interesting, and resets the interestingness.
Definition at line 273 of file ErrnoModeling.cpp.
References clang::C, clang::ento::PathSensitiveBugReport::getErrorNode(), and clang::ento::PathSensitiveBugReport::isInteresting().
ErrnoCheckState clang::ento::errno_modeling::getErrnoState | ( | ProgramStateRef | State | ) |
Returns the errno check state, Errno_Irrelevant
if 'errno' was not found (this is not the only case for that value).
Definition at line 251 of file ErrnoModeling.cpp.
std::optional< SVal > clang::ento::errno_modeling::getErrnoValue | ( | ProgramStateRef | State | ) |
Returns the value of 'errno', if 'errno' was found in the AST.
Definition at line 212 of file ErrnoModeling.cpp.
Determine if a Decl
node related to 'errno'.
This is true if the declaration is the errno variable or a function that returns a pointer to the 'errno' value (usually the 'errno' macro is defined with this function). D
is not required to be a canonical declaration.
Definition at line 263 of file ErrnoModeling.cpp.
ProgramStateRef clang::ento::errno_modeling::setErrnoForStdFailure | ( | ProgramStateRef | State, |
CheckerContext & | C, | ||
NonLoc | ErrnoSym | ||
) |
Set errno state for the common case when a standard function fails.
Set errno
value to be not equal to zero and ErrnoCheckState
to Irrelevant
. The irrelevant errno state ensures that no related bug report is emitted later and no note tag is needed.
ErrnoSym
Value to be used for errno
and constrained to be non-zero. Definition at line 289 of file ErrnoModeling.cpp.
References clang::C, clang::ento::SVal::castAs(), clang::ento::SValBuilder::evalBinOp(), clang::ento::SValBuilder::getConditionType(), Irrelevant, clang::ento::SValBuilder::makeZeroVal(), and setErrnoValue().
ProgramStateRef clang::ento::errno_modeling::setErrnoForStdSuccess | ( | ProgramStateRef | State, |
CheckerContext & | C | ||
) |
Set errno state for the common case when a standard function is successful.
Set ErrnoCheckState
to MustNotBeChecked
(the errno
value is not affected).
Definition at line 284 of file ErrnoModeling.cpp.
References MustNotBeChecked, and setErrnoState().
ProgramStateRef clang::ento::errno_modeling::setErrnoState | ( | ProgramStateRef | State, |
ErrnoCheckState | EState | ||
) |
Set the errno check state, do not modify the errno value.
Definition at line 255 of file ErrnoModeling.cpp.
Referenced by clearErrnoState(), setErrnoForStdSuccess(), setErrnoStateIrrelevant(), and setErrnoStdMustBeChecked().
ProgramStateRef clang::ento::errno_modeling::setErrnoStdMustBeChecked | ( | ProgramStateRef | State, |
CheckerContext & | C, | ||
const Expr * | InvalE | ||
) |
Set errno state for the common case when a standard function indicates failure only by errno
.
Sets ErrnoCheckState
to MustBeChecked
, and invalidates the errno region (clear of previous value).
InvalE
Expression that causes invalidation of errno
. Definition at line 302 of file ErrnoModeling.cpp.
References clang::C, MustBeChecked, and setErrnoState().
ProgramStateRef clang::ento::errno_modeling::setErrnoValue | ( | ProgramStateRef | State, |
CheckerContext & | C, | ||
uint64_t | Value, | ||
ErrnoCheckState | EState | ||
) |
Set value of 'errno' to a concrete (signed) integer, if possible.
The errno check state is set always when the 'errno' value is set.
Definition at line 232 of file ErrnoModeling.cpp.
References clang::C.
ProgramStateRef clang::ento::errno_modeling::setErrnoValue | ( | ProgramStateRef | State, |
const LocationContext * | LCtx, | ||
SVal | Value, | ||
ErrnoCheckState | EState | ||
) |
Set value of 'errno' to any SVal, if possible.
The errno check state is set always when the 'errno' value is set.
Definition at line 220 of file ErrnoModeling.cpp.
Referenced by setErrnoForStdFailure().