clang 23.0.0git
CheckerManager.h
Go to the documentation of this file.
1//===- CheckerManager.h - Static Analyzer Checker Manager -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Defines the Static Analyzer Checker Manager.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
14#define LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
15
21#include "llvm/ADT/ArrayRef.h"
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/SmallVector.h"
24#include "llvm/ADT/StringRef.h"
25#include <vector>
26
27namespace clang {
28
29class AnalyzerOptions;
30class CallExpr;
31class Decl;
32class Stmt;
34
35namespace ento {
36
37class AnalysisManager;
39class BugReporter;
40class CallEvent;
41class CheckerFrontend;
42class CheckerBackend;
43class CheckerContext;
44class CheckerRegistry;
46class ExplodedGraph;
47class ExplodedNode;
48class ExplodedNodeSet;
49class ExprEngine;
50struct EvalCallOptions;
51class MemRegion;
53class ObjCMethodCall;
55class SVal;
56class SymbolReaper;
57
58template <typename T> class CheckerFn;
59
60template <typename RET, typename... Ps>
61class CheckerFn<RET(Ps...)> {
62 using Func = RET (*)(void *, Ps...);
63
64 Func Fn;
65
66public:
68
69 CheckerFn(CheckerBackend *checker, Func fn) : Fn(fn), Checker(checker) {}
70
71 RET operator()(Ps... ps) const {
72 return Fn(Checker, ps...);
73 }
74};
75
76/// Describes the different reasons a pointer escapes
77/// during analysis.
79 /// A pointer escapes due to binding its value to a location
80 /// that the analyzer cannot track.
82
83 /// The pointer has been passed to a function call directly.
85
86 /// The pointer has been passed to a function indirectly.
87 /// For example, the pointer is accessible through an
88 /// argument to a function.
90
91
92 /// Escape for a new symbol that was generated into a region
93 /// that the analyzer cannot follow during a conservative call.
95
96 /// The reason for pointer escape is unknown. For example,
97 /// a region containing this pointer is invalidated.
99};
100
101/// This wrapper is used to ensure that only StringRefs originating from the
102/// CheckerRegistry are used as check names. We want to make sure all checker
103/// name strings have a lifetime that keeps them alive at least until the path
104/// diagnostics have been processed, since they are expected to be constexpr
105/// string literals (most likely generated by TblGen).
106class CheckerNameRef {
107 friend class ::clang::ento::CheckerRegistry;
108
109 StringRef Name;
110
111 explicit CheckerNameRef(StringRef Name) : Name(Name) {}
112
113public:
114 CheckerNameRef() = default;
115
116 operator StringRef() const { return Name; }
117};
118
124
126 ASTContext *Context = nullptr;
127 const LangOptions LangOpts;
128 const AnalyzerOptions &AOptions;
129 const Preprocessor *PP = nullptr;
130 CheckerNameRef CurrentCheckerName;
131 DiagnosticsEngine &Diags;
132 std::unique_ptr<CheckerRegistryData> RegistryData;
133
134public:
135 // These constructors are defined in the Frontend library, because
136 // CheckerRegistry, a crucial component of the initialization is in there.
137 // CheckerRegistry cannot be moved to the Core library, because the checker
138 // registration functions are defined in the Checkers library, and the library
139 // dependencies look like this: Core -> Checkers -> Frontend.
140
142 ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP,
143 ArrayRef<std::string> plugins,
144 ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns);
145
146 /// Constructs a CheckerManager that ignores all non TblGen-generated
147 /// checkers. Useful for unit testing, unless the checker infrastructure
148 /// itself is tested.
150 const Preprocessor &PP)
151 : CheckerManager(Context, AOptions, PP, {}, {}) {}
152
153 /// Constructs a CheckerManager without requiring an AST. No checker
154 /// registration will take place. Only useful when one needs to print the
155 /// help flags through CheckerRegistryData, and the AST is unavailable.
156 CheckerManager(AnalyzerOptions &AOptions, const LangOptions &LangOpts,
157 DiagnosticsEngine &Diags, ArrayRef<std::string> plugins);
158
160
161 void setCurrentCheckerName(CheckerNameRef name) { CurrentCheckerName = name; }
162 CheckerNameRef getCurrentCheckerName() const { return CurrentCheckerName; }
163
164 bool hasPathSensitiveCheckers() const;
165
166 const LangOptions &getLangOpts() const { return LangOpts; }
167 const AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
169 assert(PP);
170 return *PP;
171 }
173 return *RegistryData;
174 }
175 DiagnosticsEngine &getDiagnostics() const { return Diags; }
177 assert(Context);
178 return *Context;
179 }
180
181 /// Emits an error through a DiagnosticsEngine about an invalid user supplied
182 /// checker option value.
184 StringRef OptionName,
185 StringRef ExpectedValueDesc) const;
186
187 using CheckerTag = const void *;
188
189 //===--------------------------------------------------------------------===//
190 // Checker registration.
191 //===--------------------------------------------------------------------===//
192
193 /// If the the singleton instance of a checker class is not yet constructed,
194 /// then construct it (with the supplied arguments), register it for the
195 /// callbacks that are supported by it, and return it. Otherwise, just return
196 /// a pointer to the existing instance.
197 template <typename CHECKER, typename... AT>
198 CHECKER *getChecker(AT &&...Args) {
199 CheckerTag Tag = getTag<CHECKER>();
200
201 std::unique_ptr<CheckerBackend> &Ref = CheckerTags[Tag];
202 if (!Ref) {
203 std::unique_ptr<CHECKER> Checker =
204 std::make_unique<CHECKER>(std::forward<AT>(Args)...);
205 CHECKER::_register(Checker.get(), *this);
206 Ref = std::move(Checker);
207 }
208
209 return static_cast<CHECKER *>(Ref.get());
210 }
211
212 /// Register a single-part checker (derived from `Checker`): construct its
213 /// singleton instance, register it for the supported callbacks and record
214 /// its name (with `CheckerFrontend::enable`). Calling this multiple times
215 /// triggers an assertion failure.
216 template <typename CHECKER, typename... AT>
217 CHECKER *registerChecker(AT &&...Args) {
218 CHECKER *Chk = getChecker<CHECKER>(std::forward<AT>(Args)...);
219 Chk->enable(*this);
220 return Chk;
221 }
222
223 template <typename CHECKER> bool isRegisteredChecker() {
224 return CheckerTags.contains(getTag<CHECKER>());
225 }
226
227//===----------------------------------------------------------------------===//
228// Functions for running checkers for AST traversing.
229//===----------------------------------------------------------------------===//
230
231 /// Run checkers handling Decls.
232 void runCheckersOnASTDecl(const Decl *D, AnalysisManager& mgr,
233 BugReporter &BR);
234
235 /// Run checkers handling Decls containing a Stmt body.
236 void runCheckersOnASTBody(const Decl *D, AnalysisManager& mgr,
237 BugReporter &BR);
238
239//===----------------------------------------------------------------------===//
240// Functions for running checkers for path-sensitive checking.
241//===----------------------------------------------------------------------===//
242
243 /// Run checkers for pre-visiting Stmts.
244 ///
245 /// The notification is performed for every explored CFGElement, which does
246 /// not include the control flow statements such as IfStmt.
247 ///
248 /// \sa runCheckersForBranchCondition, runCheckersForPostStmt
250 const ExplodedNodeSet &Src,
251 const Stmt *S,
252 ExprEngine &Eng) {
253 runCheckersForStmt(/*isPreVisit=*/true, Dst, Src, S, Eng);
254 }
255
256 /// Run checkers for post-visiting Stmts.
257 ///
258 /// The notification is performed for every explored CFGElement, which does
259 /// not include the control flow statements such as IfStmt.
260 ///
261 /// \sa runCheckersForBranchCondition, runCheckersForPreStmt
263 const ExplodedNodeSet &Src,
264 const Stmt *S,
265 ExprEngine &Eng,
266 bool wasInlined = false) {
267 runCheckersForStmt(/*isPreVisit=*/false, Dst, Src, S, Eng, wasInlined);
268 }
269
270 /// Run checkers for visiting Stmts.
271 void runCheckersForStmt(bool isPreVisit,
272 ExplodedNodeSet &Dst, const ExplodedNodeSet &Src,
273 const Stmt *S, ExprEngine &Eng,
274 bool wasInlined = false);
275
276 /// Run checkers for pre-visiting obj-c messages.
278 const ExplodedNodeSet &Src,
279 const ObjCMethodCall &msg,
280 ExprEngine &Eng) {
282 }
283
284 /// Run checkers for post-visiting obj-c messages.
286 const ExplodedNodeSet &Src,
287 const ObjCMethodCall &msg,
288 ExprEngine &Eng,
289 bool wasInlined = false) {
291 wasInlined);
292 }
293
294 /// Run checkers for visiting an obj-c message to nil.
296 const ExplodedNodeSet &Src,
297 const ObjCMethodCall &msg,
298 ExprEngine &Eng) {
300 Eng);
301 }
302
303 /// Run checkers for visiting obj-c messages.
305 ExplodedNodeSet &Dst,
306 const ExplodedNodeSet &Src,
307 const ObjCMethodCall &msg, ExprEngine &Eng,
308 bool wasInlined = false);
309
310 /// Run checkers for pre-visiting function calls (including methods,
311 /// constructors, destructors etc. but excluding obj-c messages).
313 const CallEvent &Call, ExprEngine &Eng) {
314 runCheckersForCallEvent(/*isPreVisit=*/true, Dst, Src, Call, Eng);
315 }
316
317 /// Run checkers for post-visiting function calls (including methods,
318 /// constructors, destructors etc. but excluding obj-c messages).
320 const CallEvent &Call, ExprEngine &Eng,
321 bool wasInlined = false) {
322 runCheckersForCallEvent(/*isPreVisit=*/false, Dst, Src, Call, Eng,
323 wasInlined);
324 }
325
326 /// Run checkers for visiting function calls (including methods,
327 /// constructors, destructors etc. but excluding obj-c messages).
328 void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst,
329 const ExplodedNodeSet &Src,
330 const CallEvent &Call, ExprEngine &Eng,
331 bool wasInlined = false);
332
333 /// Run checkers for the end of a variable's lifetime.
335 const ExplodedNodeSet &Src,
336 const VarDecl *Decl, ExprEngine &Eng);
337
338 /// Run checkers for load/store of a location.
340 const ExplodedNodeSet &Src,
341 SVal location,
342 bool isLoad,
343 const Stmt *NodeEx,
344 const Stmt *BoundEx,
345 ExprEngine &Eng);
346
347 /// Run checkers for binding of a value to a location.
349 SVal location, SVal val, const Stmt *S,
350 bool AtDeclInit, ExprEngine &Eng,
351 const ProgramPoint &PP);
352
353 /// Run checkers after taking a control flow edge.
355 const ExplodedNodeSet &Src,
356 const BlockEntrance &Entrance,
357 ExprEngine &Eng) const;
358
359 /// Run checkers for end of analysis.
361 ExprEngine &Eng);
362
363 /// Run checkers on beginning of function.
365 const BlockEdge &L,
366 ExplodedNode *Pred,
367 ExprEngine &Eng);
368
369 /// Run checkers on end of function.
371 ExprEngine &Eng, const ReturnStmt *RS);
372
373 /// Run checkers for branch condition.
375 ExplodedNodeSet &Dst, ExplodedNode *Pred,
376 ExprEngine &Eng);
377
378 /// Run checkers between C++ operator new and constructor calls.
380 ExplodedNodeSet &Dst, ExplodedNode *Pred,
381 ExprEngine &Eng, bool wasInlined = false);
382
383 /// Run checkers for live symbols.
384 ///
385 /// Allows modifying SymbolReaper object. For example, checkers can explicitly
386 /// register symbols of interest as live. These symbols will not be marked
387 /// dead and removed.
389 SymbolReaper &SymReaper);
390
391 /// Run checkers for dead symbols.
392 ///
393 /// Notifies checkers when symbols become dead. For example, this allows
394 /// checkers to aggressively clean up/reduce the checker state and produce
395 /// precise diagnostics.
397 const ExplodedNodeSet &Src,
398 SymbolReaper &SymReaper, const Stmt *S,
399 ExprEngine &Eng,
401
402 /// Run checkers for region changes.
403 ///
404 /// This corresponds to the check::RegionChanges callback.
405 /// \param state The current program state.
406 /// \param invalidated A set of all symbols potentially touched by the change.
407 /// \param ExplicitRegions The regions explicitly requested for invalidation.
408 /// For example, in the case of a function call, these would be arguments.
409 /// \param Regions The transitive closure of accessible regions,
410 /// i.e. all regions that may have been touched by this change.
411 /// \param Call The call expression wrapper if the regions are invalidated
412 /// by a call.
415 const InvalidatedSymbols *invalidated,
416 ArrayRef<const MemRegion *> ExplicitRegions,
418 const StackFrame *SF, const CallEvent *Call);
419
420 /// Run checkers when pointers escape.
421 ///
422 /// This notifies the checkers about pointer escape, which occurs whenever
423 /// the analyzer cannot track the symbol any more. For example, as a
424 /// result of assigning a pointer into a global or when it's passed to a
425 /// function call the analyzer cannot model.
426 ///
427 /// \param State The state at the point of escape.
428 /// \param Escaped The list of escaped symbols.
429 /// \param Call The corresponding CallEvent, if the symbols escape as
430 /// parameters to the given call.
431 /// \param Kind The reason of pointer escape.
432 /// \param ITraits Information about invalidation for a particular
433 /// region/symbol.
434 /// \returns Checkers can modify the state by returning a new one.
437 const InvalidatedSymbols &Escaped,
438 const CallEvent *Call,
441
442 /// Run checkers for handling assumptions on symbolic values.
444 SVal Cond, bool Assumption);
445
446 /// Run checkers for evaluating a call.
447 ///
448 /// Warning: Currently, the CallEvent MUST come from a CallExpr!
450 const CallEvent &CE, ExprEngine &Eng,
451 const EvalCallOptions &CallOpts);
452
453 /// Run checkers for the entire Translation Unit.
455 AnalysisManager &mgr,
456 BugReporter &BR);
457
458 /// Run checkers for debug-printing a ProgramState.
459 ///
460 /// Unlike most other callbacks, any checker can simply implement the virtual
461 /// method CheckerBackend::printState if it has custom data to print.
462 ///
463 /// \param Out The output stream
464 /// \param State The state being printed
465 /// \param NL The preferred representation of a newline.
466 /// \param Space The preferred space between the left side and the message.
467 /// \param IsDot Whether the message will be printed in 'dot' format.
468 void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State,
469 const char *NL = "\n",
470 unsigned int Space = 0,
471 bool IsDot = false) const;
472
473 //===--------------------------------------------------------------------===//
474 // Internal registration functions for AST traversing.
475 //===--------------------------------------------------------------------===//
476
477 // Functions used by the registration mechanism, checkers should not touch
478 // these directly.
479
481 CheckerFn<void (const Decl *, AnalysisManager&, BugReporter &)>;
482
483 using HandlesDeclFunc = bool (*)(const Decl *D);
484
485 void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn);
486
487 void _registerForBody(CheckDeclFunc checkfn);
488
489 //===--------------------------------------------------------------------===//
490 // Internal registration functions for path-sensitive checking.
491 //===--------------------------------------------------------------------===//
492
493 using CheckStmtFunc = CheckerFn<void (const Stmt *, CheckerContext &)>;
494
496 CheckerFn<void (const ObjCMethodCall &, CheckerContext &)>;
497
499 CheckerFn<void (const CallEvent &, CheckerContext &)>;
500
502 CheckerFn<void(const VarDecl *, CheckerContext &)>;
503
504 using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
505 const Stmt *S, CheckerContext &)>;
506
507 using CheckBindFunc = CheckerFn<void(SVal location, SVal val, const Stmt *S,
508 bool AtDeclInit, CheckerContext &)>;
509
511 CheckerFn<void(const BlockEntrance &, CheckerContext &)>;
512
515
517
519 CheckerFn<void (const ReturnStmt *, CheckerContext &)>;
520
522 CheckerFn<void (const Stmt *, CheckerContext &)>;
523
526
529
531
533 ProgramStateRef, const InvalidatedSymbols *symbols,
534 ArrayRef<const MemRegion *> ExplicitRegions,
535 ArrayRef<const MemRegion *> Regions, const StackFrame *SF,
536 const CallEvent *Call)>;
537
540 const InvalidatedSymbols &Escaped,
541 const CallEvent *Call, PointerEscapeKind Kind,
543
545 CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;
546
548
551 BugReporter &)>;
552
553 using HandlesStmtFunc = bool (*)(const Stmt *D);
554
556 HandlesStmtFunc isForStmtFn);
558 HandlesStmtFunc isForStmtFn);
559
562
564
567
569
571
572 void _registerForBind(CheckBindFunc checkfn);
573
575
577
580
582
584
586
588
590
592
594
596
598
600
601 //===--------------------------------------------------------------------===//
602 // Internal registration functions for events.
603 //===--------------------------------------------------------------------===//
604
605 using EventTag = void *;
606 using CheckEventFunc = CheckerFn<void (const void *event)>;
607
608 template <typename EVENT>
610 EventInfo &info = Events[&EVENT::Tag];
611 info.Checkers.push_back(checkfn);
612 }
613
614 template <typename EVENT>
616 EventInfo &info = Events[&EVENT::Tag];
617 info.HasDispatcher = true;
618 }
619
620 template <typename EVENT>
621 void _dispatchEvent(const EVENT &event) const {
622 EventsTy::const_iterator I = Events.find(&EVENT::Tag);
623 if (I == Events.end())
624 return;
625 const EventInfo &info = I->second;
626 for (const auto &Checker : info.Checkers)
627 Checker(&event);
628 }
629
630 //===--------------------------------------------------------------------===//
631 // Implementation details.
632 //===--------------------------------------------------------------------===//
633
634private:
635 template <typename T>
636 static void *getTag() { static int tag; return &tag; }
637
638 llvm::DenseMap<CheckerTag, std::unique_ptr<CheckerBackend>> CheckerTags;
639
640 struct DeclCheckerInfo {
641 CheckDeclFunc CheckFn;
642 HandlesDeclFunc IsForDeclFn;
643 };
644 std::vector<DeclCheckerInfo> DeclCheckers;
645
646 std::vector<CheckDeclFunc> BodyCheckers;
647
648 using CachedDeclCheckers = SmallVector<CheckDeclFunc, 4>;
649 using CachedDeclCheckersMapTy = llvm::DenseMap<unsigned, CachedDeclCheckers>;
650 CachedDeclCheckersMapTy CachedDeclCheckersMap;
651
652 struct StmtCheckerInfo {
653 CheckStmtFunc CheckFn;
654 HandlesStmtFunc IsForStmtFn;
655 bool IsPreVisit;
656 };
657 std::vector<StmtCheckerInfo> StmtCheckers;
658
659 using CachedStmtCheckers = SmallVector<CheckStmtFunc, 4>;
660 using CachedStmtCheckersMapTy = llvm::DenseMap<unsigned, CachedStmtCheckers>;
661 CachedStmtCheckersMapTy CachedStmtCheckersMap;
662
663 const CachedStmtCheckers &getCachedStmtCheckersFor(const Stmt *S,
664 bool isPreVisit);
665
666 /// Returns the checkers that have registered for callbacks of the
667 /// given \p Kind.
668 const std::vector<CheckObjCMessageFunc> &
669 getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
670
671 std::vector<CheckObjCMessageFunc> PreObjCMessageCheckers;
672 std::vector<CheckObjCMessageFunc> PostObjCMessageCheckers;
673 std::vector<CheckObjCMessageFunc> ObjCMessageNilCheckers;
674
675 std::vector<CheckCallFunc> PreCallCheckers;
676 std::vector<CheckCallFunc> PostCallCheckers;
677
678 std::vector<CheckLifetimeEndFunc> LifetimeEndCheckers;
679
680 std::vector<CheckLocationFunc> LocationCheckers;
681
682 std::vector<CheckBindFunc> BindCheckers;
683
684 std::vector<CheckBlockEntranceFunc> BlockEntranceCheckers;
685
686 std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
687
688 std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;
689 std::vector<CheckEndFunctionFunc> EndFunctionCheckers;
690
691 std::vector<CheckBranchConditionFunc> BranchConditionCheckers;
692
693 std::vector<CheckNewAllocatorFunc> NewAllocatorCheckers;
694
695 std::vector<CheckLiveSymbolsFunc> LiveSymbolsCheckers;
696
697 std::vector<CheckDeadSymbolsFunc> DeadSymbolsCheckers;
698
699 std::vector<CheckRegionChangesFunc> RegionChangesCheckers;
700
701 std::vector<CheckPointerEscapeFunc> PointerEscapeCheckers;
702
703 std::vector<EvalAssumeFunc> EvalAssumeCheckers;
704
705 std::vector<EvalCallFunc> EvalCallCheckers;
706
707 std::vector<CheckEndOfTranslationUnit> EndOfTranslationUnitCheckers;
708
709 struct EventInfo {
710 SmallVector<CheckEventFunc, 4> Checkers;
711 bool HasDispatcher = false;
712
713 EventInfo() = default;
714 };
715
716 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
717 EventsTy Events;
718};
719
720} // namespace ento
721
722} // namespace clang
723
724#endif // LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
Defines the Diagnostic-related interfaces.
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN)
Defines the clang::LangOptions interface.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a an optional score condition
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:223
Stores options for the analyzer from the command line.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:233
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3170
It represents a stack frame of the call stack.
Stmt - This represents one statement.
Definition Stmt.h:86
The top declaration context.
Definition Decl.h:105
Represents a variable declaration or definition.
Definition Decl.h:924
BugReporter is a utility class for generating PathDiagnostics for analysis.
Represents the memory allocation call in a C++ new-expression.
Definition CallEvent.h:1122
Represents an abstract call to a function or method along a particular path.
Definition CallEvent.h:152
CheckerBackend is an abstract base class that serves as the common ancestor of all the Checker<....
Definition Checker.h:544
CheckerFn(CheckerBackend *checker, Func fn)
A CheckerFrontend instance is what the user recognizes as "one checker": it has a public canonical na...
Definition Checker.h:526
void _registerForLiveSymbols(CheckLiveSymbolsFunc checkfn)
void _registerForEndOfTranslationUnit(CheckEndOfTranslationUnit checkfn)
const AnalyzerOptions & getAnalyzerOptions() const
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 runCheckersForPreObjCMessage(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for pre-visiting obj-c messages.
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
ASTContext & getASTContext() const
CheckerFn< void(const void *event)> CheckEventFunc
void _registerListenerForEvent(CheckEventFunc checkfn)
CheckerFn< void(ExplodedGraph &, BugReporter &, ExprEngine &)> CheckEndAnalysisFunc
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
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.
const CheckerRegistryData & getCheckerRegistryData() const
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.
CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP)
Constructs a CheckerManager that ignores all non TblGen-generated checkers.
void runCheckersForPreCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng)
Run checkers for pre-visiting function calls (including methods, constructors, destructors etc.
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)
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 runCheckersForPostObjCMessage(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting obj-c messages.
void runCheckersForBeginFunction(ExplodedNodeSet &Dst, const BlockEdge &L, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers on beginning of function.
void runCheckersForPostStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting Stmts.
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 runCheckersForPreStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng)
Run checkers for pre-visiting Stmts.
void _registerForBranchCondition(CheckBranchConditionFunc checkfn)
CheckerFn< void(SymbolReaper &, CheckerContext &)> CheckDeadSymbolsFunc
CheckerFn< void(SVal location, bool isLoad, const Stmt *S, CheckerContext &)> CheckLocationFunc
void runCheckersForObjCMessageNil(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for visiting an obj-c message to nil.
void runCheckersForBlockEntrance(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const BlockEntrance &Entrance, ExprEngine &Eng) const
Run checkers after taking a control flow edge.
void _dispatchEvent(const EVENT &event) const
void runCheckersForStmt(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting Stmts.
CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP, ArrayRef< std::string > plugins, ArrayRef< std::function< void(CheckerRegistry &)> > checkerRegistrationFns)
const LangOptions & getLangOpts() const
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.
CheckerNameRef getCurrentCheckerName() const
CheckerFn< void(const ObjCMethodCall &, CheckerContext &)> CheckObjCMessageFunc
CHECKER * getChecker(AT &&...Args)
If the the singleton instance of a checker class is not yet constructed, then construct it (with the ...
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 runCheckersForPostCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting function calls (including methods, constructors, destructors etc.
void _registerForLifetimeEnd(CheckLifetimeEndFunc checkfn)
void setCurrentCheckerName(CheckerNameRef name)
ProgramStateRef runCheckersForEvalAssume(ProgramStateRef state, SVal Cond, bool Assumption)
Run checkers for handling assumptions on symbolic values.
const Preprocessor & getPreprocessor() const
This wrapper is used to ensure that only StringRefs originating from the CheckerRegistry are used as ...
Manages a set of available checkers for running a static analysis.
Simple checker classes that implement one frontend (i.e.
Definition Checker.h:565
ExplodedNodeSet is a set of ExplodedNode * elements with the invariant that its elements cannot be nu...
MemRegion - The root abstract class for all memory regions.
Definition MemRegion.h:97
Represents any expression that calls an Objective-C method.
Definition CallEvent.h:1251
Information about invalidation for a particular region/symbol.
Definition MemRegion.h:1656
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition SVals.h:56
A class responsible for cleaning up unused symbols.
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
@ PSK_DirectEscapeOnCall
The pointer has been passed to a function call directly.
@ PSK_EscapeOnBind
A pointer escapes due to binding its value to a location that the analyzer cannot track.
@ PSK_IndirectEscapeOnCall
The pointer has been passed to a function indirectly.
@ PSK_EscapeOther
The reason for pointer escape is unknown.
@ PSK_EscapeOutParameters
Escape for a new symbol that was generated into a region that the analyzer cannot follow during a con...
llvm::DenseSet< SymbolRef > InvalidatedSymbols
Definition Store.h:50
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
The JSON file list parser is used to communicate input to InstallAPI.
Expr * Cond
};
int const char * function
Definition c++config.h:31
Hints for figuring out if a call should be inlined during evalCall().
Definition ExprEngine.h:93