26#include "llvm/ADT/STLExtras.h"
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/Support/ErrorHandling.h"
29#include "llvm/Support/FormatVariadic.h"
30#include "llvm/Support/TimeProfiler.h"
39 const auto IfAnyAreNonEmpty = [](
const auto &...Callbacks) ->
bool {
40 return (!Callbacks.empty() || ...);
42 return IfAnyAreNonEmpty(
43 StmtCheckers, PreObjCMessageCheckers, ObjCMessageNilCheckers,
44 PostObjCMessageCheckers, PreCallCheckers, PostCallCheckers,
45 LifetimeEndCheckers, LocationCheckers, BindCheckers,
46 BlockEntranceCheckers, EndAnalysisCheckers, BeginFunctionCheckers,
47 EndFunctionCheckers, BranchConditionCheckers, NewAllocatorCheckers,
48 LiveSymbolsCheckers, DeadSymbolsCheckers, RegionChangesCheckers,
49 PointerEscapeCheckers, EvalAssumeCheckers, EvalCallCheckers,
50 EndOfTranslationUnitCheckers);
55 StringRef ExpectedValueDesc)
const {
70 unsigned DeclKind = D->
getKind();
71 auto [CCI, Inserted] = CachedDeclCheckersMap.try_emplace(DeclKind);
72 CachedDeclCheckers *checkers = &(CCI->second);
75 for (
const auto &info : DeclCheckers)
76 if (info.IsForDeclFn(D))
77 checkers->push_back(info.CheckFn);
81 for (
const auto &checker : *checkers)
89 for (
const auto &BodyChecker : BodyCheckers)
90 BodyChecker(D, mgr, BR);
97template <
typename CHECK_CTX>
103 typename CHECK_CTX::CheckersTy::const_iterator
104 I = checkCtx.checkers_begin(), E = checkCtx.checkers_end();
113 for (; I != E; ++I) {
118 CurrSet = (PrevSet == &Tmp1) ? &Tmp2 : &Tmp1;
122 CurrSet->
insert(*PrevSet);
123 for (
const auto &NI : *PrevSet)
124 checkCtx.runChecker(*I, NI, *CurrSet);
127 if (CurrSet->
empty())
138 if (!llvm::timeTraceProfilerEnabled())
141 return (Name +
":" + CheckerTag).str();
144 struct CheckStmtContext {
145 using CheckersTy = SmallVectorImpl<CheckerManager::CheckStmtFunc>;
148 const CheckersTy &Checkers;
153 CheckStmtContext(
bool isPreVisit,
const CheckersTy &checkers,
154 const Stmt *s, ExprEngine &eng,
bool wasInlined =
false)
155 : IsPreVisit(isPreVisit), Checkers(checkers), S(s), Eng(eng),
156 WasInlined(wasInlined) {}
158 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
159 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
162 ExplodedNodeSet &Dst) {
163 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Stmt", checkFn.Checker));
169 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
183 CheckStmtContext
C(isPreVisit, getCachedStmtCheckersFor(S, isPreVisit),
185 llvm::TimeTraceScope TimeScope(
186 isPreVisit ?
"CheckerManager::runCheckersForStmt (Pre)"
187 :
"CheckerManager::runCheckersForStmt (Post)");
193 struct CheckObjCMessageContext {
194 using CheckersTy = std::vector<CheckerManager::CheckObjCMessageFunc>;
198 const CheckersTy &Checkers;
203 const CheckersTy &checkers,
206 : Kind(visitKind), WasInlined(wasInlined), Checkers(checkers), Msg(msg),
209 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
210 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
213 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
214 llvm::TimeTraceScope TimeScope(
215 checkerScopeName(
"ObjCMsg", checkFn.Checker));
219 case ObjCMessageVisitKind::Pre:
222 case ObjCMessageVisitKind::MessageNil:
223 case ObjCMessageVisitKind::Post:
229 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
244 const auto &checkers = getObjCMessageCheckers(visitKind);
245 CheckObjCMessageContext
C(visitKind, checkers, msg, Eng, WasInlined);
246 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForObjCMessage");
250const std::vector<CheckerManager::CheckObjCMessageFunc> &
254 return PreObjCMessageCheckers;
257 return PostObjCMessageCheckers;
259 return ObjCMessageNilCheckers;
261 llvm_unreachable(
"Unknown Kind");
268 struct CheckCallContext {
269 using CheckersTy = std::vector<CheckerManager::CheckCallFunc>;
271 bool IsPreVisit, WasInlined;
272 const CheckersTy &Checkers;
276 CheckCallContext(
bool isPreVisit,
const CheckersTy &checkers,
279 : IsPreVisit(isPreVisit), WasInlined(wasInlined), Checkers(checkers),
280 Call(call), Eng(eng) {}
282 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
283 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
286 ExplodedNodeSet &Dst) {
287 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Call", checkFn.Checker));
289 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
304 CheckCallContext
C(isPreVisit,
305 isPreVisit ? PreCallCheckers
307 Call, Eng, WasInlined);
308 llvm::TimeTraceScope TimeScope(
309 isPreVisit ?
"CheckerManager::runCheckersForCallEvent (Pre)"
310 :
"CheckerManager::runCheckersForCallEvent (Post)");
316struct CheckLifetimeEndContext {
317 using CheckersTy = std::vector<CheckerManager::CheckLifetimeEndFunc>;
319 const CheckersTy &Checkers;
323 CheckLifetimeEndContext(
const CheckersTy &checkers,
const VarDecl *
decl,
325 : Checkers(checkers),
Decl(
decl), Eng(eng) {}
327 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
328 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
331 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
334 CheckerContext
C(Eng, Pred, Dst, L);
346 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForLifetimeEnd");
347 CheckLifetimeEndContext
C(LifetimeEndCheckers,
Decl, Eng);
353 struct CheckLocationContext {
354 using CheckersTy = std::vector<CheckerManager::CheckLocationFunc>;
356 const CheckersTy &Checkers;
363 CheckLocationContext(
const CheckersTy &checkers,
367 : Checkers(checkers),
Loc(
loc), IsLoad(isLoad), NodeEx(NodeEx),
368 BoundEx(BoundEx), Eng(eng) {}
370 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
371 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
374 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
375 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Loc", checkFn.Checker));
380 CheckerContext
C(Eng, Pred, Dst, L);
381 checkFn(Loc, IsLoad, BoundEx,
C);
391 SVal location,
bool isLoad,
395 CheckLocationContext
C(LocationCheckers, location, isLoad, NodeEx,
397 llvm::TimeTraceScope TimeScope(
398 isLoad ?
"CheckerManager::runCheckersForLocation (Load)"
399 :
"CheckerManager::runCheckersForLocation (Store)");
405 struct CheckBindContext {
406 using CheckersTy = std::vector<CheckerManager::CheckBindFunc>;
408 const CheckersTy &Checkers;
416 CheckBindContext(
const CheckersTy &checkers,
SVal loc,
SVal val,
419 : Checkers(checkers),
Loc(
loc), Val(val), S(s), Eng(eng), PP(pp),
420 AtDeclInit(AtDeclInit) {}
422 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
423 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
426 ExplodedNodeSet &Dst) {
427 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Bind", checkFn.Checker));
429 CheckerContext
C(Eng, Pred, Dst, L);
431 checkFn(Loc, Val, S, AtDeclInit,
C);
435 llvm::TimeTraceMetadata getTimeTraceBindMetadata(
SVal Val) {
436 assert(llvm::timeTraceProfilerEnabled());
438 llvm::raw_string_ostream
OS(Name);
440 return llvm::TimeTraceMetadata{
OS.str(),
""};
451 CheckBindContext
C(BindCheckers, location, val, S, AtDeclInit, Eng, PP);
452 llvm::TimeTraceScope TimeScope{
453 "CheckerManager::runCheckersForBind",
454 [&val]() {
return getTimeTraceBindMetadata(val); }};
459struct CheckBlockEntranceContext {
461 using CheckersTy = std::vector<CheckBlockEntranceFunc>;
463 const CheckersTy &Checkers;
467 CheckBlockEntranceContext(
const CheckersTy &Checkers,
469 : Checkers(Checkers), Entrance(Entrance), Eng(Eng) {}
471 auto checkers_begin()
const {
return Checkers.begin(); }
472 auto checkers_end()
const {
return Checkers.end(); }
474 void runChecker(CheckBlockEntranceFunc CheckFn, ExplodedNode *Pred,
475 ExplodedNodeSet &Dst) {
476 llvm::TimeTraceScope TimeScope(
477 checkerScopeName(
"BlockEntrance", CheckFn.Checker));
478 CheckerContext
C(Eng, Pred, Dst, Entrance.
withTag(CheckFn.Checker));
479 CheckFn(Entrance,
C);
489 CheckBlockEntranceContext
C(BlockEntranceCheckers, Entrance, Eng);
490 llvm::TimeTraceScope TimeScope{
"CheckerManager::runCheckersForBlockEntrance"};
497 for (
const auto &EndAnalysisChecker : EndAnalysisCheckers)
498 EndAnalysisChecker(G, BR, Eng);
503struct CheckBeginFunctionContext {
504 using CheckersTy = std::vector<CheckerManager::CheckBeginFunctionFunc>;
506 const CheckersTy &Checkers;
510 CheckBeginFunctionContext(
const CheckersTy &Checkers,
ExprEngine &Eng,
512 : Checkers(Checkers), Eng(Eng), PP(PP) {}
514 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
515 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
518 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
519 llvm::TimeTraceScope TimeScope(checkerScopeName(
"Begin", checkFn.Checker));
521 CheckerContext
C(Eng, Pred, Dst, L);
535 CheckBeginFunctionContext
C(BeginFunctionCheckers, Eng, L);
536 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForBeginFunction");
542struct CheckEndFunctionContext {
543 using CheckersTy = std::vector<CheckerManager::CheckEndFunctionFunc>;
545 const CheckersTy &Checkers;
549 CheckEndFunctionContext(
const CheckersTy &Checkers,
const ReturnStmt *RS,
551 : Checkers(Checkers), RS(RS), Eng(Eng) {}
553 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
554 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
557 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
558 llvm::TimeTraceScope TimeScope(checkerScopeName(
"End", checkFn.Checker));
560 FunctionExitPoint(RS, Pred->
getStackFrame(), checkFn.Checker);
561 CheckerContext
C(Eng, Pred, Dst, L);
577 CheckEndFunctionContext
C(EndFunctionCheckers, RS, Eng);
578 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForEndFunction");
584 struct CheckBranchConditionContext {
585 using CheckersTy = std::vector<CheckerManager::CheckBranchConditionFunc>;
587 const CheckersTy &Checkers;
591 CheckBranchConditionContext(
const CheckersTy &checkers,
593 : Checkers(checkers),
Condition(Cond), Eng(eng) {}
595 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
596 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
599 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
600 llvm::TimeTraceScope TimeScope(
601 checkerScopeName(
"BranchCond", checkFn.Checker));
604 CheckerContext
C(Eng, Pred, Dst, L);
618 CheckBranchConditionContext
C(BranchConditionCheckers,
Condition, Eng);
619 llvm::TimeTraceScope TimeScope(
620 "CheckerManager::runCheckersForBranchCondition");
626 struct CheckNewAllocatorContext {
627 using CheckersTy = std::vector<CheckerManager::CheckNewAllocatorFunc>;
629 const CheckersTy &Checkers;
634 CheckNewAllocatorContext(
const CheckersTy &Checkers,
637 : Checkers(Checkers),
Call(
Call), WasInlined(WasInlined), Eng(Eng) {}
639 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
640 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
643 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
644 llvm::TimeTraceScope TimeScope(
645 checkerScopeName(
"Allocator", checkFn.Checker));
648 CheckerContext
C(Eng, Pred, Dst, L, WasInlined);
663 CheckNewAllocatorContext
C(NewAllocatorCheckers,
Call, WasInlined, Eng);
664 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForNewAllocator");
671 for (
const auto &LiveSymbolsChecker : LiveSymbolsCheckers)
672 LiveSymbolsChecker(state, SymReaper);
677 struct CheckDeadSymbolsContext {
678 using CheckersTy = std::vector<CheckerManager::CheckDeadSymbolsFunc>;
680 const CheckersTy &Checkers;
686 CheckDeadSymbolsContext(
const CheckersTy &checkers,
SymbolReaper &sr,
689 : Checkers(checkers), SR(sr), S(s), Eng(eng), ProgramPointKind(K) {}
691 CheckersTy::const_iterator checkers_begin() {
return Checkers.begin(); }
692 CheckersTy::const_iterator checkers_end() {
return Checkers.end(); }
695 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
696 llvm::TimeTraceScope TimeScope(
697 checkerScopeName(
"DeadSymbols", checkFn.Checker));
699 S, ProgramPointKind, Pred->
getStackFrame(), checkFn.Checker);
700 CheckerContext
C(Eng, Pred, Dst, L);
718 CheckDeadSymbolsContext
C(DeadSymbolsCheckers, SymReaper, S, Eng, K);
719 llvm::TimeTraceScope TimeScope(
"CheckerManager::runCheckersForDeadSymbols");
729 for (
const auto &RegionChangesChecker : RegionChangesCheckers) {
734 state = RegionChangesChecker(state, invalidated, ExplicitRegions, Regions,
747 assert((
Call !=
nullptr ||
750 "Call must not be NULL when escaping on call");
751 for (
const auto &PointerEscapeChecker : PointerEscapeCheckers) {
756 State = PointerEscapeChecker(State, Escaped,
Call, Kind, ETraits);
764 SVal Cond,
bool Assumption) {
765 for (
const auto &EvalAssumeChecker : EvalAssumeCheckers) {
770 state = EvalAssumeChecker(state, Cond, Assumption);
782 for (
auto *
const Pred : Src) {
783 std::optional<StringRef> evaluatorChecker;
791 for (
const auto &EvalCallChecker : EvalCallCheckers) {
799 bool evaluated = EvalCallChecker(*UpdatedCall,
C);
801 if (evaluated && evaluatorChecker) {
804 llvm::raw_string_ostream
OS(Buf);
808 std::string AssertionMessage = llvm::formatv(
809 "The '{0}' call has been already evaluated by the {1} checker, "
810 "while the {2} checker also tried to evaluate the same call. At "
811 "most one checker supposed to evaluate a call.",
813 EvalCallChecker.Checker->getDebugTag());
814 llvm_unreachable(AssertionMessage.c_str());
818 evaluatorChecker = EvalCallChecker.Checker->getDebugTag();
827 if (!evaluatorChecker)
837 for (
const auto &EndOfTranslationUnitChecker : EndOfTranslationUnitCheckers)
838 EndOfTranslationUnitChecker(TU, mgr, BR);
846 Indent(Out, Space, IsDot) <<
"\"checker_messages\": ";
850 llvm::raw_svector_ostream TempOut(TempBuf);
851 unsigned int InnerSpace = Space + 2;
855 llvm::raw_svector_ostream NLOut(NewLine);
856 NLOut <<
"\", " << NL;
857 Indent(NLOut, InnerSpace, IsDot) <<
"\"";
861 std::vector<std::pair<std::string, std::string>> CheckerMsgs;
862 for (
const auto &CT : CheckerTags) {
863 CT.second->printState(TempOut, State, NewLine.c_str(),
"");
864 const std::string Msg = TempBuf.str().trim().str();
868 CheckerMsgs.push_back({CT.second->getDebugTag().str(), Msg});
870 llvm::sort(CheckerMsgs);
872 if (!CheckerMsgs.empty())
877 [&](
const std::pair<std::string, std::string> &CM) {
879 <<
"{ \"checker\": \"" << CM.first <<
"\", \"messages\": [" << NL;
880 Indent(Out, InnerSpace, IsDot) <<
'\"' << CM.second <<
'\"' << NL;
881 Indent(Out, Space, IsDot) <<
"]}";
883 [&] { Out <<
',' << NL; });
886 if (!CheckerMsgs.empty()) {
888 Indent(Out, --Space, IsDot) <<
"]";
902 DeclCheckerInfo info = { checkfn, isForDeclFn };
903 DeclCheckers.push_back(info);
907 BodyCheckers.push_back(checkfn);
916 StmtCheckerInfo info = { checkfn, isForStmtFn,
true };
917 StmtCheckers.push_back(info);
922 StmtCheckerInfo info = { checkfn, isForStmtFn,
false };
923 StmtCheckers.push_back(info);
927 PreObjCMessageCheckers.push_back(checkfn);
931 ObjCMessageNilCheckers.push_back(checkfn);
935 PostObjCMessageCheckers.push_back(checkfn);
939 PreCallCheckers.push_back(checkfn);
942 PostCallCheckers.push_back(checkfn);
946 LifetimeEndCheckers.push_back(checkfn);
950 LocationCheckers.push_back(checkfn);
954 BindCheckers.push_back(checkfn);
958 BlockEntranceCheckers.push_back(checkfn);
962 EndAnalysisCheckers.push_back(checkfn);
966 BeginFunctionCheckers.push_back(checkfn);
970 EndFunctionCheckers.push_back(checkfn);
975 BranchConditionCheckers.push_back(checkfn);
979 NewAllocatorCheckers.push_back(checkfn);
983 LiveSymbolsCheckers.push_back(checkfn);
987 DeadSymbolsCheckers.push_back(checkfn);
991 RegionChangesCheckers.push_back(checkfn);
995 PointerEscapeCheckers.push_back(checkfn);
1000 PointerEscapeCheckers.push_back(checkfn);
1004 EvalAssumeCheckers.push_back(checkfn);
1008 EvalCallCheckers.push_back(checkfn);
1013 EndOfTranslationUnitCheckers.push_back(checkfn);
1020const CheckerManager::CachedStmtCheckers &
1021CheckerManager::getCachedStmtCheckersFor(
const Stmt *S,
bool isPreVisit) {
1025 auto [CCI, Inserted] = CachedStmtCheckersMap.try_emplace(Key);
1026 CachedStmtCheckers &Checkers = CCI->second;
1029 for (
const auto &Info : StmtCheckers)
1030 if (Info.IsPreVisit == isPreVisit && Info.IsForStmtFn(S))
1031 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 *NewTag) 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().