#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/Stmt.h"
#include "clang/Analysis/ProgramPoint.h"
#include "clang/Basic/JsonSupport.h"
#include "clang/Basic/LLVM.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
#include <cassert>
#include <optional>
#include <vector>
usingnamespaceclang;
usingnamespaceento;
bool CheckerManager::hasPathSensitiveCheckers() const { … }
void CheckerManager::finishedCheckerRegistration() { … }
void CheckerManager::reportInvalidCheckerOptionValue(
const CheckerBase *C, StringRef OptionName,
StringRef ExpectedValueDesc) const { … }
void CheckerManager::runCheckersOnASTDecl(const Decl *D, AnalysisManager& mgr,
BugReporter &BR) { … }
void CheckerManager::runCheckersOnASTBody(const Decl *D, AnalysisManager& mgr,
BugReporter &BR) { … }
template <typename CHECK_CTX>
static void expandGraphWithCheckers(CHECK_CTX checkCtx,
ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src) { … }
namespace {
struct CheckStmtContext { … };
}
void CheckerManager::runCheckersForStmt(bool isPreVisit,
ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src,
const Stmt *S,
ExprEngine &Eng,
bool WasInlined) { … }
namespace {
struct CheckObjCMessageContext { … };
}
void CheckerManager::runCheckersForObjCMessage(ObjCMessageVisitKind visitKind,
ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src,
const ObjCMethodCall &msg,
ExprEngine &Eng,
bool WasInlined) { … }
const std::vector<CheckerManager::CheckObjCMessageFunc> &
CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) const { … }
namespace {
struct CheckCallContext { … };
}
void CheckerManager::runCheckersForCallEvent(bool isPreVisit,
ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src,
const CallEvent &Call,
ExprEngine &Eng,
bool WasInlined) { … }
namespace {
struct CheckLocationContext { … };
}
void CheckerManager::runCheckersForLocation(ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src,
SVal location, bool isLoad,
const Stmt *NodeEx,
const Stmt *BoundEx,
ExprEngine &Eng) { … }
namespace {
struct CheckBindContext { … };
}
void CheckerManager::runCheckersForBind(ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src,
SVal location, SVal val,
const Stmt *S, ExprEngine &Eng,
const ProgramPoint &PP) { … }
void CheckerManager::runCheckersForEndAnalysis(ExplodedGraph &G,
BugReporter &BR,
ExprEngine &Eng) { … }
namespace {
struct CheckBeginFunctionContext { … };
}
void CheckerManager::runCheckersForBeginFunction(ExplodedNodeSet &Dst,
const BlockEdge &L,
ExplodedNode *Pred,
ExprEngine &Eng) { … }
void CheckerManager::runCheckersForEndFunction(NodeBuilderContext &BC,
ExplodedNodeSet &Dst,
ExplodedNode *Pred,
ExprEngine &Eng,
const ReturnStmt *RS) { … }
namespace {
struct CheckBranchConditionContext { … };
}
void CheckerManager::runCheckersForBranchCondition(const Stmt *Condition,
ExplodedNodeSet &Dst,
ExplodedNode *Pred,
ExprEngine &Eng) { … }
namespace {
struct CheckNewAllocatorContext { … };
}
void CheckerManager::runCheckersForNewAllocator(const CXXAllocatorCall &Call,
ExplodedNodeSet &Dst,
ExplodedNode *Pred,
ExprEngine &Eng,
bool WasInlined) { … }
void CheckerManager::runCheckersForLiveSymbols(ProgramStateRef state,
SymbolReaper &SymReaper) { … }
namespace {
struct CheckDeadSymbolsContext { … };
}
void CheckerManager::runCheckersForDeadSymbols(ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src,
SymbolReaper &SymReaper,
const Stmt *S,
ExprEngine &Eng,
ProgramPoint::Kind K) { … }
ProgramStateRef
CheckerManager::runCheckersForRegionChanges(ProgramStateRef state,
const InvalidatedSymbols *invalidated,
ArrayRef<const MemRegion *> ExplicitRegions,
ArrayRef<const MemRegion *> Regions,
const LocationContext *LCtx,
const CallEvent *Call) { … }
ProgramStateRef
CheckerManager::runCheckersForPointerEscape(ProgramStateRef State,
const InvalidatedSymbols &Escaped,
const CallEvent *Call,
PointerEscapeKind Kind,
RegionAndSymbolInvalidationTraits *ETraits) { … }
ProgramStateRef
CheckerManager::runCheckersForEvalAssume(ProgramStateRef state,
SVal Cond, bool Assumption) { … }
void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet &Dst,
const ExplodedNodeSet &Src,
const CallEvent &Call,
ExprEngine &Eng,
const EvalCallOptions &CallOpts) { … }
void CheckerManager::runCheckersOnEndOfTranslationUnit(
const TranslationUnitDecl *TU,
AnalysisManager &mgr,
BugReporter &BR) { … }
void CheckerManager::runCheckersForPrintStateJson(raw_ostream &Out,
ProgramStateRef State,
const char *NL,
unsigned int Space,
bool IsDot) const { … }
void CheckerManager::_registerForDecl(CheckDeclFunc checkfn,
HandlesDeclFunc isForDeclFn) { … }
void CheckerManager::_registerForBody(CheckDeclFunc checkfn) { … }
void CheckerManager::_registerForPreStmt(CheckStmtFunc checkfn,
HandlesStmtFunc isForStmtFn) { … }
void CheckerManager::_registerForPostStmt(CheckStmtFunc checkfn,
HandlesStmtFunc isForStmtFn) { … }
void CheckerManager::_registerForPreObjCMessage(CheckObjCMessageFunc checkfn) { … }
void CheckerManager::_registerForObjCMessageNil(CheckObjCMessageFunc checkfn) { … }
void CheckerManager::_registerForPostObjCMessage(CheckObjCMessageFunc checkfn) { … }
void CheckerManager::_registerForPreCall(CheckCallFunc checkfn) { … }
void CheckerManager::_registerForPostCall(CheckCallFunc checkfn) { … }
void CheckerManager::_registerForLocation(CheckLocationFunc checkfn) { … }
void CheckerManager::_registerForBind(CheckBindFunc checkfn) { … }
void CheckerManager::_registerForEndAnalysis(CheckEndAnalysisFunc checkfn) { … }
void CheckerManager::_registerForBeginFunction(CheckBeginFunctionFunc checkfn) { … }
void CheckerManager::_registerForEndFunction(CheckEndFunctionFunc checkfn) { … }
void CheckerManager::_registerForBranchCondition(
CheckBranchConditionFunc checkfn) { … }
void CheckerManager::_registerForNewAllocator(CheckNewAllocatorFunc checkfn) { … }
void CheckerManager::_registerForLiveSymbols(CheckLiveSymbolsFunc checkfn) { … }
void CheckerManager::_registerForDeadSymbols(CheckDeadSymbolsFunc checkfn) { … }
void CheckerManager::_registerForRegionChanges(CheckRegionChangesFunc checkfn) { … }
void CheckerManager::_registerForPointerEscape(CheckPointerEscapeFunc checkfn){ … }
void CheckerManager::_registerForConstPointerEscape(
CheckPointerEscapeFunc checkfn) { … }
void CheckerManager::_registerForEvalAssume(EvalAssumeFunc checkfn) { … }
void CheckerManager::_registerForEvalCall(EvalCallFunc checkfn) { … }
void CheckerManager::_registerForEndOfTranslationUnit(
CheckEndOfTranslationUnit checkfn) { … }
const CheckerManager::CachedStmtCheckers &
CheckerManager::getCachedStmtCheckersFor(const Stmt *S, bool isPreVisit) { … }