26#include "llvm/ADT/SmallVector.h"
27#include "llvm/Support/ErrorHandling.h"
28#include "llvm/Support/FormatVariadic.h"
29#include "llvm/Support/TimeProfiler.h"
38 const auto IfAnyAreNonEmpty = [](
const auto &...Callbacks) ->
bool {
39 return (!Callbacks.empty() || ...);
41 return IfAnyAreNonEmpty(
42 StmtCheckers, PreObjCMessageCheckers, ObjCMessageNilCheckers,
43 PostObjCMessageCheckers, PreCallCheckers, PostCallCheckers,
44 LifetimeEndCheckers, LocationCheckers, BindCheckers,
45 BlockEntranceCheckers, EndAnalysisCheckers, BeginFunctionCheckers,
46 EndFunctionCheckers, BranchConditionCheckers, NewAllocatorCheckers,
47 LiveSymbolsCheckers, DeadSymbolsCheckers, RegionChangesCheckers,
48 PointerEscapeCheckers, EvalAssumeCheckers, EvalCallCheckers,
49 EndOfTranslationUnitCheckers);
54 StringRef ExpectedValueDesc)
const {
69 unsigned DeclKind = D->
getKind();
70 auto [CCI, Inserted] = CachedDeclCheckersMap.try_emplace(DeclKind);
71 CachedDeclCheckers *checkers = &(CCI->second);
74 for (
const auto &info : DeclCheckers)
75 if (info.IsForDeclFn(D))
76 checkers->push_back(info.CheckFn);
80 for (
const auto &checker : *checkers)
88 for (
const auto &BodyChecker : BodyCheckers)
89 BodyChecker(D, mgr, BR);
96template <
typename CHECK_CTX>
102 typename CHECK_CTX::CheckersTy::const_iterator
103 I = checkCtx.checkers_begin(), E = checkCtx.checkers_end();
112 for (; I != E; ++I) {
117 CurrSet = (PrevSet == &Tmp1) ? &Tmp2 : &Tmp1;
121 CurrSet->
insert(*PrevSet);
122 for (
const auto &NI : *PrevSet)
123 checkCtx.runChecker(*I, NI, *CurrSet);
126 if (CurrSet->
empty())
137 if (!llvm::timeTraceProfilerEnabled())
140 return (Name +
":" + CheckerTag).str();
143 struct CheckStmtContext {
144 using CheckersTy = SmallVectorImpl<CheckerManager::CheckStmtFunc>;
147 const CheckersTy &Checkers;
152 CheckStmtContext(
bool isPreVisit,
const CheckersTy &checkers,
153 const Stmt *s, ExprEngine &eng,
bool wasInlined =
false)
154 : IsPreVisit(isPreVisit), Checkers(checkers), S(s), Eng(eng),
155 WasInlined(wasInlined) {}
157 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
158 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
161 ExplodedNodeSet &Dst) {
162 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Stmt", checkFn.Checker));
168 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
182 CheckStmtContext
C(isPreVisit, getCachedStmtCheckersFor(S, isPreVisit),
184 llvm::TimeTraceScope TimeScope(
185 isPreVisit ?
"CheckerManager::runCheckersForStmt (Pre)"
186 :
"CheckerManager::runCheckersForStmt (Post)");
192 struct CheckObjCMessageContext {
193 using CheckersTy = std::vector<CheckerManager::CheckObjCMessageFunc>;
197 const CheckersTy &Checkers;
202 const CheckersTy &checkers,
205 : Kind(visitKind), WasInlined(wasInlined), Checkers(checkers), Msg(msg),
208 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
209 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
212 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
213 llvm::TimeTraceScope TimeScope(
214 checkerScopeName(
"ObjCMsg", checkFn.Checker));
218 case ObjCMessageVisitKind::Pre:
221 case ObjCMessageVisitKind::MessageNil:
222 case ObjCMessageVisitKind::Post:
228 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
243 const auto &checkers = getObjCMessageCheckers(visitKind);
244 CheckObjCMessageContext
C(visitKind, checkers, msg, Eng, WasInlined);
245 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForObjCMessage");
249const std::vector<CheckerManager::CheckObjCMessageFunc> &
253 return PreObjCMessageCheckers;
256 return PostObjCMessageCheckers;
258 return ObjCMessageNilCheckers;
260 llvm_unreachable(
"Unknown Kind");
267 struct CheckCallContext {
268 using CheckersTy = std::vector<CheckerManager::CheckCallFunc>;
270 bool IsPreVisit, WasInlined;
271 const CheckersTy &Checkers;
275 CheckCallContext(
bool isPreVisit,
const CheckersTy &checkers,
278 : IsPreVisit(isPreVisit), WasInlined(wasInlined), Checkers(checkers),
279 Call(call), Eng(eng) {}
281 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
282 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
285 ExplodedNodeSet &Dst) {
286 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Call", checkFn.Checker));
288 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
303 CheckCallContext
C(isPreVisit,
304 isPreVisit ? PreCallCheckers
306 Call, Eng, WasInlined);
307 llvm::TimeTraceScope TimeScope(
308 isPreVisit ?
"CheckerManager::runCheckersForCallEvent (Pre)"
309 :
"CheckerManager::runCheckersForCallEvent (Post)");
315struct CheckLifetimeEndContext {
316 using CheckersTy = std::vector<CheckerManager::CheckLifetimeEndFunc>;
318 const CheckersTy &Checkers;
322 CheckLifetimeEndContext(
const CheckersTy &checkers,
const VarDecl *
decl,
324 : Checkers(checkers),
Decl(
decl), Eng(eng) {}
326 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
327 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
330 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
333 CheckerContext
C(Eng, Pred, Dst, L);
345 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForLifetimeEnd");
346 CheckLifetimeEndContext
C(LifetimeEndCheckers,
Decl, Eng);
352 struct CheckLocationContext {
353 using CheckersTy = std::vector<CheckerManager::CheckLocationFunc>;
355 const CheckersTy &Checkers;
362 CheckLocationContext(
const CheckersTy &checkers,
366 : Checkers(checkers),
Loc(
loc), IsLoad(isLoad), NodeEx(NodeEx),
367 BoundEx(BoundEx), Eng(eng) {}
369 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
370 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
373 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
374 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Loc", checkFn.Checker));
379 CheckerContext
C(Eng, Pred, Dst, L);
380 checkFn(Loc, IsLoad, BoundEx,
C);
390 SVal location,
bool isLoad,
394 CheckLocationContext
C(LocationCheckers, location, isLoad, NodeEx,
396 llvm::TimeTraceScope TimeScope(
397 isLoad ?
"CheckerManager::runCheckersForLocation (Load)"
398 :
"CheckerManager::runCheckersForLocation (Store)");
404 struct CheckBindContext {
405 using CheckersTy = std::vector<CheckerManager::CheckBindFunc>;
407 const CheckersTy &Checkers;
415 CheckBindContext(
const CheckersTy &checkers,
SVal loc,
SVal val,
418 : Checkers(checkers),
Loc(
loc), Val(val), S(s), Eng(eng), PP(pp),
419 AtDeclInit(AtDeclInit) {}
421 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
422 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
425 ExplodedNodeSet &Dst) {
426 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Bind", checkFn.Checker));
428 CheckerContext
C(Eng, Pred, Dst, L);
430 checkFn(Loc, Val, S, AtDeclInit,
C);
434 llvm::TimeTraceMetadata getTimeTraceBindMetadata(
SVal Val) {
435 assert(llvm::timeTraceProfilerEnabled());
437 llvm::raw_string_ostream
OS(Name);
439 return llvm::TimeTraceMetadata{
OS.str(),
""};
450 CheckBindContext
C(BindCheckers, location, val, S, AtDeclInit, Eng, PP);
451 llvm::TimeTraceScope TimeScope{
452 "CheckerManager::runCheckersForBind",
453 [&val]() {
return getTimeTraceBindMetadata(val); }};
458struct CheckBlockEntranceContext {
460 using CheckersTy = std::vector<CheckBlockEntranceFunc>;
462 const CheckersTy &Checkers;
466 CheckBlockEntranceContext(
const CheckersTy &Checkers,
468 : Checkers(Checkers), Entrance(Entrance), Eng(Eng) {}
470 auto checkers_begin()
const {
return Checkers.begin(); }
471 auto checkers_end()
const {
return Checkers.end(); }
473 void runChecker(CheckBlockEntranceFunc CheckFn, ExplodedNode *Pred,
474 ExplodedNodeSet &Dst) {
475 llvm::TimeTraceScope TimeScope(
476 checkerScopeName(
"BlockEntrance", CheckFn.Checker));
477 CheckerContext
C(Eng, Pred, Dst, Entrance.
withTag(CheckFn.Checker));
478 CheckFn(Entrance,
C);
488 CheckBlockEntranceContext
C(BlockEntranceCheckers, Entrance, Eng);
489 llvm::TimeTraceScope TimeScope{
"CheckerManager::runCheckersForBlockEntrance"};
496 for (
const auto &EndAnalysisChecker : EndAnalysisCheckers)
497 EndAnalysisChecker(G, BR, Eng);
502struct CheckBeginFunctionContext {
503 using CheckersTy = std::vector<CheckerManager::CheckBeginFunctionFunc>;
505 const CheckersTy &Checkers;
509 CheckBeginFunctionContext(
const CheckersTy &Checkers,
ExprEngine &Eng,
511 : Checkers(Checkers), Eng(Eng), PP(PP) {}
513 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
514 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
517 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
518 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Begin", checkFn.Checker));
520 CheckerContext
C(Eng, Pred, Dst, L);
534 CheckBeginFunctionContext
C(BeginFunctionCheckers, Eng, L);
535 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForBeginFunction");
541struct CheckEndFunctionContext {
542 using CheckersTy = std::vector<CheckerManager::CheckEndFunctionFunc>;
544 const CheckersTy &Checkers;
548 CheckEndFunctionContext(
const CheckersTy &Checkers,
const ReturnStmt *RS,
550 : Checkers(Checkers), RS(RS), Eng(Eng) {}
552 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
553 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
556 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
557 llvm::TimeTraceScope TimeScope(checkerScopeName(
"End", checkFn.Checker));
559 FunctionExitPoint(RS, Pred->
getStackFrame(), checkFn.Checker);
560 CheckerContext
C(Eng, Pred, Dst, L);
576 CheckEndFunctionContext
C(EndFunctionCheckers, RS, Eng);
577 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForEndFunction");
583 struct CheckBranchConditionContext {
584 using CheckersTy = std::vector<CheckerManager::CheckBranchConditionFunc>;
586 const CheckersTy &Checkers;
590 CheckBranchConditionContext(
const CheckersTy &checkers,
592 : Checkers(checkers),
Condition(Cond), Eng(eng) {}
594 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
595 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
598 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
599 llvm::TimeTraceScope TimeScope(
600 checkerScopeName(
"BranchCond", checkFn.Checker));
603 CheckerContext
C(Eng, Pred, Dst, L);
617 CheckBranchConditionContext
C(BranchConditionCheckers,
Condition, Eng);
618 llvm::TimeTraceScope TimeScope(
619 "CheckerManager::runCheckersForBranchCondition");
625 struct CheckNewAllocatorContext {
626 using CheckersTy = std::vector<CheckerManager::CheckNewAllocatorFunc>;
628 const CheckersTy &Checkers;
633 CheckNewAllocatorContext(
const CheckersTy &Checkers,
636 : Checkers(Checkers),
Call(
Call), WasInlined(WasInlined), Eng(Eng) {}
638 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
639 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
642 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
643 llvm::TimeTraceScope TimeScope(
644 checkerScopeName(
"Allocator", checkFn.Checker));
647 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
662 CheckNewAllocatorContext
C(NewAllocatorCheckers,
Call, WasInlined, Eng);
663 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForNewAllocator");
670 for (
const auto &LiveSymbolsChecker : LiveSymbolsCheckers)
671 LiveSymbolsChecker(state, SymReaper);
676 struct CheckDeadSymbolsContext {
677 using CheckersTy = std::vector<CheckerManager::CheckDeadSymbolsFunc>;
679 const CheckersTy &Checkers;
685 CheckDeadSymbolsContext(
const CheckersTy &checkers,
SymbolReaper &sr,
688 : Checkers(checkers), SR(sr), S(s), Eng(eng), ProgramPointKind(K) {}
690 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
691 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
694 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
695 llvm::TimeTraceScope TimeScope(
696 checkerScopeName(
"DeadSymbols", checkFn.Checker));
698 S, ProgramPointKind, Pred->
getStackFrame(), checkFn.Checker);
699 CheckerContext
C(Eng, Pred, Dst, L);
717 CheckDeadSymbolsContext
C(DeadSymbolsCheckers, SymReaper, S, Eng, K);
718 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForDeadSymbols");
728 for (
const auto &RegionChangesChecker : RegionChangesCheckers) {
733 state = RegionChangesChecker(state, invalidated, ExplicitRegions, Regions,
746 assert((
Call !=
nullptr ||
749 "Call must not be NULL when escaping on call");
750 for (
const auto &PointerEscapeChecker : PointerEscapeCheckers) {
755 State = PointerEscapeChecker(State, Escaped,
Call, Kind, ETraits);
763 SVal Cond,
bool Assumption) {
764 for (
const auto &EvalAssumeChecker : EvalAssumeCheckers) {
769 state = EvalAssumeChecker(state, Cond, Assumption);
781 for (
auto *
const Pred : Src) {
782 std::optional<StringRef> evaluatorChecker;
790 for (
const auto &EvalCallChecker : EvalCallCheckers) {
798 bool evaluated = EvalCallChecker(*UpdatedCall,
C);
800 if (evaluated && evaluatorChecker) {
803 llvm::raw_string_ostream
OS(Buf);
807 std::string AssertionMessage = llvm::formatv(
808 "The '{0}' call has been already evaluated by the {1} checker, "
809 "while the {2} checker also tried to evaluate the same call. At "
810 "most one checker supposed to evaluate a call.",
812 EvalCallChecker.Checker->getDebugTag());
813 llvm_unreachable(AssertionMessage.c_str());
817 evaluatorChecker = EvalCallChecker.Checker->getDebugTag();
826 if (!evaluatorChecker)
836 for (
const auto &EndOfTranslationUnitChecker : EndOfTranslationUnitCheckers)
837 EndOfTranslationUnitChecker(TU, mgr, BR);
845 Indent(Out, Space, IsDot) <<
"\"checker_messages\": ";
849 llvm::raw_svector_ostream TempOut(TempBuf);
850 unsigned int InnerSpace = Space + 2;
854 llvm::raw_svector_ostream NLOut(NewLine);
855 NLOut <<
"\", " << NL;
856 Indent(NLOut, InnerSpace, IsDot) <<
"\"";
859 bool HasMessage =
false;
862 const void *LastCT =
nullptr;
863 for (
const auto &CT : CheckerTags) {
865 CT.second->printState(TempOut, State, NewLine.c_str(),
"");
879 for (
const auto &CT : CheckerTags) {
881 CT.second->printState(TempOut, State, NewLine.c_str(),
"");
886 Indent(Out, Space, IsDot) <<
"{ \"checker\": \"" << CT.second->getDebugTag()
887 <<
"\", \"messages\": [" << NL;
888 Indent(Out, InnerSpace, IsDot)
889 <<
'\"' << TempBuf.str().trim() <<
'\"' << NL;
890 Indent(Out, Space, IsDot) <<
"]}";
901 Indent(Out, --Space, IsDot) <<
"]";
914 DeclCheckerInfo info = { checkfn, isForDeclFn };
915 DeclCheckers.push_back(info);
919 BodyCheckers.push_back(checkfn);
928 StmtCheckerInfo info = { checkfn, isForStmtFn,
true };
929 StmtCheckers.push_back(info);
934 StmtCheckerInfo info = { checkfn, isForStmtFn,
false };
935 StmtCheckers.push_back(info);
939 PreObjCMessageCheckers.push_back(checkfn);
943 ObjCMessageNilCheckers.push_back(checkfn);
947 PostObjCMessageCheckers.push_back(checkfn);
951 PreCallCheckers.push_back(checkfn);
954 PostCallCheckers.push_back(checkfn);
958 LifetimeEndCheckers.push_back(checkfn);
962 LocationCheckers.push_back(checkfn);
966 BindCheckers.push_back(checkfn);
970 BlockEntranceCheckers.push_back(checkfn);
974 EndAnalysisCheckers.push_back(checkfn);
978 BeginFunctionCheckers.push_back(checkfn);
982 EndFunctionCheckers.push_back(checkfn);
987 BranchConditionCheckers.push_back(checkfn);
991 NewAllocatorCheckers.push_back(checkfn);
995 LiveSymbolsCheckers.push_back(checkfn);
999 DeadSymbolsCheckers.push_back(checkfn);
1003 RegionChangesCheckers.push_back(checkfn);
1007 PointerEscapeCheckers.push_back(checkfn);
1012 PointerEscapeCheckers.push_back(checkfn);
1016 EvalAssumeCheckers.push_back(checkfn);
1020 EvalCallCheckers.push_back(checkfn);
1025 EndOfTranslationUnitCheckers.push_back(checkfn);
1032const CheckerManager::CachedStmtCheckers &
1033CheckerManager::getCachedStmtCheckersFor(
const Stmt *S,
bool isPreVisit) {
1037 auto [CCI, Inserted] = CachedStmtCheckersMap.try_emplace(Key);
1038 CachedStmtCheckers &Checkers = CCI->second;
1041 for (
const auto &Info : StmtCheckers)
1042 if (Info.IsPreVisit == isPreVisit && Info.IsForStmtFn(S))
1043 Checkers.push_back(Info.CheckFn);
static void expandGraphWithCheckers(CHECK_CTX checkCtx, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Decl - This represents one declaration (or definition), e.g.
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const StackFrame *SF, const ProgramPointTag *tag)
ProgramPoint withTag(const ProgramPointTag *tag) const
Create a new ProgramPoint object that is the same as the original except for using the specified tag ...
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
It represents a stack frame of the call stack.
Stmt - This represents one statement.
StmtClass getStmtClass() const
The top declaration context.
Represents a variable declaration or definition.
BugReporter is a utility class for generating PathDiagnostics for analysis.
Represents the memory allocation call in a C++ new-expression.
Represents an abstract call to a function or method along a particular path.
CallEventRef< T > cloneWithState(ProgramStateRef NewState) const
Returns a copy of this CallEvent, but using the given state.
ProgramPoint getProgramPoint(bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
Returns an appropriate ProgramPoint for this call.
CheckerBackend is an abstract base class that serves as the common ancestor of all the Checker<....
StringRef getDebugTag() const override
Attached to nodes created by this checker class when the ExplodedGraph is dumped for debugging.
A CheckerFrontend instance is what the user recognizes as "one checker": it has a public canonical na...
CheckerNameRef getName() const
void _registerForLiveSymbols(CheckLiveSymbolsFunc checkfn)
void _registerForEndOfTranslationUnit(CheckEndOfTranslationUnit checkfn)
ProgramStateRef runCheckersForRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const StackFrame *SF, const CallEvent *Call)
Run checkers for region changes.
void _registerForBeginFunction(CheckBeginFunctionFunc checkfn)
void _registerForNewAllocator(CheckNewAllocatorFunc checkfn)
CheckerFn< void(const Decl *, AnalysisManager &, BugReporter &)> CheckDeclFunc
void _registerForPreCall(CheckCallFunc checkfn)
CheckerFn< ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)> EvalAssumeFunc
void _registerForObjCMessageNil(CheckObjCMessageFunc checkfn)
CheckerFn< ProgramStateRef(ProgramStateRef, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)> CheckPointerEscapeFunc
bool(*)(const Decl *D) HandlesDeclFunc
void runCheckersForObjCMessage(ObjCMessageVisitKind visitKind, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting obj-c messages.
void runCheckersOnASTDecl(const Decl *D, AnalysisManager &mgr, BugReporter &BR)
Run checkers handling Decls.
void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn)
CheckerFn< void(const ReturnStmt *, CheckerContext &)> CheckEndFunctionFunc
CheckerFn< void(const Stmt *, CheckerContext &)> CheckBranchConditionFunc
void _registerForPreObjCMessage(CheckObjCMessageFunc checkfn)
void runCheckersOnEndOfTranslationUnit(const TranslationUnitDecl *TU, AnalysisManager &mgr, BugReporter &BR)
Run checkers for the entire Translation Unit.
CheckerFn< bool(const CallEvent &, CheckerContext &)> EvalCallFunc
CheckerFn< void(CheckerContext &)> CheckBeginFunctionFunc
CheckerFn< void(ExplodedGraph &, BugReporter &, ExprEngine &)> CheckEndAnalysisFunc
void _registerForEvalAssume(EvalAssumeFunc checkfn)
void _registerForEndAnalysis(CheckEndAnalysisFunc checkfn)
void _registerForBody(CheckDeclFunc checkfn)
DiagnosticsEngine & getDiagnostics() const
void runCheckersForLocation(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, bool isLoad, const Stmt *NodeEx, const Stmt *BoundEx, ExprEngine &Eng)
Run checkers for load/store of a location.
CheckerFn< void(const Stmt *, CheckerContext &)> CheckStmtFunc
CheckerFn< void(SVal location, SVal val, const Stmt *S, bool AtDeclInit, CheckerContext &)> CheckBindFunc
void runCheckersForBind(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, SVal val, const Stmt *S, bool AtDeclInit, ExprEngine &Eng, const ProgramPoint &PP)
Run checkers for binding of a value to a location.
void reportInvalidCheckerOptionValue(const CheckerFrontend *Checker, StringRef OptionName, StringRef ExpectedValueDesc) const
Emits an error through a DiagnosticsEngine about an invalid user supplied checker option value.
void runCheckersForEndAnalysis(ExplodedGraph &G, BugReporter &BR, ExprEngine &Eng)
Run checkers for end of analysis.
CheckerFn< void(const CXXAllocatorCall &Call, CheckerContext &)> CheckNewAllocatorFunc
CheckerFn< void(const VarDecl *, CheckerContext &)> CheckLifetimeEndFunc
void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\n", unsigned int Space=0, bool IsDot=false) const
Run checkers for debug-printing a ProgramState.
void _registerForDeadSymbols(CheckDeadSymbolsFunc checkfn)
void runCheckersForDeadSymbols(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SymbolReaper &SymReaper, const Stmt *S, ExprEngine &Eng, ProgramPoint::Kind K)
Run checkers for dead symbols.
void _registerForPostObjCMessage(CheckObjCMessageFunc checkfn)
void _registerForRegionChanges(CheckRegionChangesFunc checkfn)
bool hasPathSensitiveCheckers() const
void runCheckersForEndFunction(ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, const ReturnStmt *RS)
Run checkers on end of function.
void _registerForBind(CheckBindFunc checkfn)
void runCheckersForLiveSymbols(ProgramStateRef state, SymbolReaper &SymReaper)
Run checkers for live symbols.
void _registerForPointerEscape(CheckPointerEscapeFunc checkfn)
CheckerFn< void(const TranslationUnitDecl *, AnalysisManager &, BugReporter &)> CheckEndOfTranslationUnit
void _registerForPreStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void runCheckersForEvalCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &CE, ExprEngine &Eng, const EvalCallOptions &CallOpts)
Run checkers for evaluating a call.
void _registerForPostStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void runCheckersForBeginFunction(ExplodedNodeSet &Dst, const BlockEdge &L, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers on beginning of function.
void runCheckersForNewAllocator(const CXXAllocatorCall &Call, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, bool wasInlined=false)
Run checkers between C++ operator new and constructor calls.
CheckerFn< void(const CallEvent &, CheckerContext &)> CheckCallFunc
void _registerForBranchCondition(CheckBranchConditionFunc checkfn)
CheckerFn< void(SymbolReaper &, CheckerContext &)> CheckDeadSymbolsFunc
CheckerFn< void(SVal location, bool isLoad, const Stmt *S, CheckerContext &)> CheckLocationFunc
void runCheckersForBlockEntrance(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const BlockEntrance &Entrance, ExprEngine &Eng) const
Run checkers after taking a control flow edge.
void runCheckersForStmt(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting Stmts.
void _registerForEvalCall(EvalCallFunc checkfn)
void _registerForEndFunction(CheckEndFunctionFunc checkfn)
void _registerForBlockEntrance(CheckBlockEntranceFunc checkfn)
CheckerFn< ProgramStateRef( ProgramStateRef, const InvalidatedSymbols *symbols, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const StackFrame *SF, const CallEvent *Call)> CheckRegionChangesFunc
void runCheckersForBranchCondition(const Stmt *condition, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers for branch condition.
CheckerFn< void(const ObjCMethodCall &, CheckerContext &)> CheckObjCMessageFunc
void _registerForLocation(CheckLocationFunc checkfn)
ProgramStateRef runCheckersForPointerEscape(ProgramStateRef State, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)
Run checkers when pointers escape.
void _registerForConstPointerEscape(CheckPointerEscapeFunc checkfn)
CheckerFn< void(const BlockEntrance &, CheckerContext &)> CheckBlockEntranceFunc
CheckerFn< void(ProgramStateRef, SymbolReaper &)> CheckLiveSymbolsFunc
void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting function calls (including methods, constructors, destructors etc.
bool(*)(const Stmt *D) HandlesStmtFunc
void _registerForPostCall(CheckCallFunc checkfn)
void runCheckersOnASTBody(const Decl *D, AnalysisManager &mgr, BugReporter &BR)
Run checkers handling Decls containing a Stmt body.
void runCheckersForLifetimeEnd(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const VarDecl *Decl, ExprEngine &Eng)
Run checkers for the end of a variable's lifetime.
void _registerForLifetimeEnd(CheckLifetimeEndFunc checkfn)
ProgramStateRef runCheckersForEvalAssume(ProgramStateRef state, SVal Cond, bool Assumption)
Run checkers for handling assumptions on symbolic values.
Simple checker classes that implement one frontend (i.e.
ExplodedNodeSet is a set of ExplodedNode * elements with the invariant that its elements cannot be nu...
void insert(ExplodedNode *N)
const ProgramStateRef & getState() const
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
const StackFrame * getStackFrame() const
void defaultEvalCall(ExplodedNodeSet &Dst, ExplodedNode *Pred, const CallEvent &Call, const EvalCallOptions &CallOpts={})
Default implementation of call evaluation.
Represents any expression that calls an Objective-C method.
Information about invalidation for a particular region/symbol.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
void dumpToStream(raw_ostream &OS) const
A class responsible for cleaning up unused symbols.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
@ PSK_DirectEscapeOnCall
The pointer has been passed to a function call directly.
@ PSK_IndirectEscapeOnCall
The pointer has been passed to a function indirectly.
llvm::DenseSet< SymbolRef > InvalidatedSymbols
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
Top level wrappers for InstallAPI frontend operations.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
U cast(CodeGen::Address addr)
Hints for figuring out if a call should be inlined during evalCall().