clang 19.0.0git
Namespaces | Functions
ErrnoModeling.cpp File Reference
#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>

Go to the source code of this file.

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
 
namespace  clang::ento
 
namespace  clang::ento::errno_modeling
 

Functions

static const VarDeclgetErrnoVar (ASTContext &ACtx)
 Store a MemRegion that contains the 'errno' integer value.
 
static const FunctionDeclgetErrnoFunc (ASTContext &ACtx)
 Search for a function with a specific name that is used to return a pointer to "errno".
 
std::optional< SValclang::ento::errno_modeling::getErrnoValue (ProgramStateRef State)
 Returns the value of 'errno', if 'errno' was found in the AST.
 
ProgramStateRef clang::ento::errno_modeling::setErrnoValue (ProgramStateRef State, const LocationContext *LCtx, SVal Value, ErrnoCheckState EState)
 Set value of 'errno' to any SVal, if possible.
 
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.
 
std::optional< Locclang::ento::errno_modeling::getErrnoLoc (ProgramStateRef State)
 Returns the location that points to the MemoryRegion where the 'errno' value is stored.
 
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).
 
ProgramStateRef clang::ento::errno_modeling::setErrnoState (ProgramStateRef State, ErrnoCheckState EState)
 Set the errno check state, do not modify the errno value.
 
ProgramStateRef clang::ento::errno_modeling::clearErrnoState (ProgramStateRef State)
 Clear state of errno (make it irrelevant).
 
bool clang::ento::errno_modeling::isErrno (const Decl *D)
 Determine if a Decl node related to 'errno'.
 
const NoteTagclang::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.
 
ProgramStateRef clang::ento::errno_modeling::setErrnoForStdSuccess (ProgramStateRef State, CheckerContext &C)
 Set errno state for the common case when a standard function is successful.
 
ProgramStateRef clang::ento::errno_modeling::setErrnoForStdFailure (ProgramStateRef State, CheckerContext &C, NonLoc ErrnoSym)
 Set errno state for the common case when a standard function fails.
 
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.
 

Function Documentation

◆ getErrnoFunc()

static const FunctionDecl * getErrnoFunc ( ASTContext ACtx)
static

Search for a function with a specific name that is used to return a pointer to "errno".

Return nullptr if no such function was found.

Definition at line 98 of file ErrnoModeling.cpp.

References clang::IdentifierTable::get(), clang::ASTContext::getPointerType(), clang::ASTContext::getSourceManager(), clang::ASTContext::getTranslationUnitDecl(), clang::ASTContext::Idents, clang::ASTContext::IntTy, clang::SourceManager::isInSystemHeader(), and clang::DeclContext::lookup().

◆ getErrnoVar()

static const VarDecl * getErrnoVar ( ASTContext ACtx)
static

Store a MemRegion that contains the 'errno' integer value.

The value is null if the 'errno' value was not recognized in the AST. Search for a variable called "errno" in the AST. Return nullptr if not found.

Definition at line 79 of file ErrnoModeling.cpp.