#include "ErrnoModeling.h"
#include "clang/AST/ParentMapContext.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/FormatVariadic.h"
#include <optional>
usingnamespaceclang;
usingnamespaceento;
namespace {
const char *ErrnoVarName = …;
CallDescriptionSet ErrnoLocationCalls{ … };
class ErrnoModeling
: public Checker<check::ASTDecl<TranslationUnitDecl>, check::BeginFunction,
check::LiveSymbols, eval::Call> { … };
}
REGISTER_TRAIT_WITH_PROGRAMSTATE(…) …
REGISTER_TRAIT_WITH_PROGRAMSTATE(…) …
void ErrnoModeling::checkASTDecl(const TranslationUnitDecl *D,
AnalysisManager &Mgr, BugReporter &BR) const { … }
void ErrnoModeling::checkBeginFunction(CheckerContext &C) const { … }
bool ErrnoModeling::evalCall(const CallEvent &Call, CheckerContext &C) const { … }
void ErrnoModeling::checkLiveSymbols(ProgramStateRef State,
SymbolReaper &SR) const { … }
namespace clang {
namespace ento {
namespace errno_modeling {
std::optional<SVal> getErrnoValue(ProgramStateRef State) { … }
ProgramStateRef setErrnoValue(ProgramStateRef State,
const LocationContext *LCtx, SVal Value,
ErrnoCheckState EState) { … }
ProgramStateRef setErrnoValue(ProgramStateRef State, CheckerContext &C,
uint64_t Value, ErrnoCheckState EState) { … }
std::optional<Loc> getErrnoLoc(ProgramStateRef State) { … }
ErrnoCheckState getErrnoState(ProgramStateRef State) { … }
ProgramStateRef setErrnoState(ProgramStateRef State, ErrnoCheckState EState) { … }
ProgramStateRef clearErrnoState(ProgramStateRef State) { … }
bool isErrnoLocationCall(const CallEvent &CE) { … }
const NoteTag *getErrnoNoteTag(CheckerContext &C, const std::string &Message) { … }
ProgramStateRef setErrnoForStdSuccess(ProgramStateRef State,
CheckerContext &C) { … }
ProgramStateRef setErrnoForStdFailure(ProgramStateRef State, CheckerContext &C,
NonLoc ErrnoSym) { … }
ProgramStateRef setErrnoStdMustBeChecked(ProgramStateRef State,
CheckerContext &C,
const Expr *InvalE) { … }
}
}
}
void ento::registerErrnoModeling(CheckerManager &mgr) { … }
bool ento::shouldRegisterErrnoModeling(const CheckerManager &mgr) { … }