clang 24.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;
52class ObjCMethodCall;
54class SVal;
55class SymbolReaper;
56
57template <typename T> class CheckerFn;
58
59template <typename RET, typename... Ps>
60class CheckerFn<RET(Ps...)> {
61 using Func = RET (*)(void *, Ps...);
62
63 Func Fn;
64
65public:
67
68 CheckerFn(CheckerBackend *checker, Func fn) : Fn(fn), Checker(checker) {}
69
70 RET operator()(Ps... ps) const {
71 return Fn(Checker, ps...);
72 }
73};
74
75/// Describes the different reasons a pointer escapes
76/// during analysis.
78 /// A pointer escapes due to binding its value to a location
79 /// that the analyzer cannot track.
81
82 /// The pointer has been passed to a function call directly.
84
85 /// The pointer has been passed to a function indirectly.
86 /// For example, the pointer is accessible through an
87 /// argument to a function.
89
90
91 /// Escape for a new symbol that was generated into a region
92 /// that the analyzer cannot follow during a conservative call.
94
95 /// The reason for pointer escape is unknown. For example,
96 /// a region containing this pointer is invalidated.
98};
99
100/// This wrapper is used to ensure that only StringRefs originating from the
101/// CheckerRegistry are used as check names. We want to make sure all checker
102/// name strings have a lifetime that keeps them alive at least until the path
103/// diagnostics have been processed, since they are expected to be constexpr
104/// string literals (most likely generated by TblGen).
105class CheckerNameRef {
106 friend class ::clang::ento::CheckerRegistry;
107
108 StringRef Name;
109
110 explicit CheckerNameRef(StringRef Name) : Name(Name) {}
111
112public:
113 CheckerNameRef() = default;
114
115 operator StringRef() const { return Name; }
116};
117
123
125 ASTContext *Context = nullptr;
126 const LangOptions LangOpts;
127 const AnalyzerOptions &AOptions;
128 const Preprocessor *PP = nullptr;
129 CheckerNameRef CurrentCheckerName;
130 DiagnosticsEngine &Diags;
131 std::unique_ptr<CheckerRegistryData> RegistryData;
132
133public:
134 // These constructors are defined in the Frontend library, because
135 // CheckerRegistry, a crucial component of the initialization is in there.
136 // CheckerRegistry cannot be moved to the Core library, because the checker
137 // registration functions are defined in the Checkers library, and the library
138 // dependencies look like this: Core -> Checkers -> Frontend.
139
141 ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP,
142 ArrayRef<std::string> plugins,
143 ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns);
144
145 /// Constructs a CheckerManager that ignores all non TblGen-generated
146 /// checkers. Useful for unit testing, unless the checker infrastructure
147 /// itself is tested.
149 const Preprocessor &PP)
150 : CheckerManager(Context, AOptions, PP, {}, {}) {}
151
152 /// Constructs a CheckerManager without requiring an AST. No checker
153 /// registration will take place. Only useful when one needs to print the
154 /// help flags through CheckerRegistryData, and the AST is unavailable.
155 CheckerManager(AnalyzerOptions &AOptions, const LangOptions &LangOpts,
156 DiagnosticsEngine &Diags, ArrayRef<std::string> plugins);
157
159
160 void setCurrentCheckerName(CheckerNameRef name) { CurrentCheckerName = name; }
161 CheckerNameRef getCurrentCheckerName() const { return CurrentCheckerName; }
162
163 bool hasPathSensitiveCheckers() const;
164
165 const LangOptions &getLangOpts() const { return LangOpts; }
166 const AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
168 assert(PP);
169 return *PP;
170 }
172 return *RegistryData;
173 }
174 DiagnosticsEngine &getDiagnostics() const { return Diags; }
176 assert(Context);
177 return *Context;
178 }
179
180 /// Emits an error through a DiagnosticsEngine about an invalid user supplied
181 /// checker option value.
183 StringRef OptionName,
184 StringRef ExpectedValueDesc) const;
185
186 using CheckerTag = const void *;
187
188 //===--------------------------------------------------------------------===//
189 // Checker registration.
190 //===--------------------------------------------------------------------===//
191
192 /// If the the singleton instance of a checker class is not yet constructed,
193 /// then construct it (with the supplied arguments), register it for the
194 /// callbacks that are supported by it, and return it. Otherwise, just return
195 /// a pointer to the existing instance.
196 template <typename CHECKER, typename... AT>
197 CHECKER *getChecker(AT &&...Args) {
198 CheckerTag Tag = getTag<CHECKER>();
199
200 std::unique_ptr<CheckerBackend> &Ref = CheckerTags[Tag];
201 if (!Ref) {
202 std::unique_ptr<CHECKER> Checker =
203 std::make_unique<CHECKER>(std::forward<AT>(Args)...);
204 CHECKER::_register(Checker.get(), *this);
205 Ref = std::move(Checker);
206 }
207
208 return static_cast<CHECKER *>(Ref.get());
209 }
210
211 /// Register a single-part checker (derived from `Checker`): construct its
212 /// singleton instance, register it for the supported callbacks and record
213 /// its name (with `CheckerFrontend::enable`). Calling this multiple times
214 /// triggers an assertion failure.
215 template <typename CHECKER, typename... AT>
216 CHECKER *registerChecker(AT &&...Args) {
217 CHECKER *Chk = getChecker<CHECKER>(std::forward<AT>(Args)...);
218 Chk->enable(*this);
219 return Chk;
220 }
221
222 template <typename CHECKER> bool isRegisteredChecker() {
223 return CheckerTags.contains(getTag<CHECKER>());
224 }
225
226//===----------------------------------------------------------------------===//
227// Functions for running checkers for AST traversing.
228//===----------------------------------------------------------------------===//
229
230 /// Run checkers handling Decls.
231 void runCheckersOnASTDecl(const Decl *D, AnalysisManager& mgr,
232 BugReporter &BR);
233
234 /// Run checkers handling Decls containing a Stmt body.
235 void runCheckersOnASTBody(const Decl *D, AnalysisManager& mgr,
236 BugReporter &BR);
237
238//===----------------------------------------------------------------------===//
239// Functions for running checkers for path-sensitive checking.
240//===----------------------------------------------------------------------===//
241
242 /// Run checkers for pre-visiting Stmts.
243 ///
244 /// The notification is performed for every explored CFGElement, which does
245 /// not include the control flow statements such as IfStmt.
246 ///
247 /// \sa runCheckersForBranchCondition, runCheckersForPostStmt
249 const ExplodedNodeSet &Src,
250 const Stmt *S,
251 ExprEngine &Eng) {
252 runCheckersForStmt(/*isPreVisit=*/true, Dst, Src, S, Eng);
253 }
254
255 /// Run checkers for post-visiting Stmts.
256 ///
257 /// The notification is performed for every explored CFGElement, which does
258 /// not include the control flow statements such as IfStmt.
259 ///
260 /// \sa runCheckersForBranchCondition, runCheckersForPreStmt
262 const ExplodedNodeSet &Src,
263 const Stmt *S,
264 ExprEngine &Eng,
265 bool wasInlined = false) {
266 runCheckersForStmt(/*isPreVisit=*/false, Dst, Src, S, Eng, wasInlined);
267 }
268
269 /// Run checkers for visiting Stmts.
270 void runCheckersForStmt(bool isPreVisit,
271 ExplodedNodeSet &Dst, const ExplodedNodeSet &Src,
272 const Stmt *S, ExprEngine &Eng,
273 bool wasInlined = false);
274
275 /// Run checkers for pre-visiting obj-c messages.
277 const ExplodedNodeSet &Src,
278 const ObjCMethodCall &msg,
279 ExprEngine &Eng) {
281 }
282
283 /// Run checkers for post-visiting obj-c messages.
285 const ExplodedNodeSet &Src,
286 const ObjCMethodCall &msg,
287 ExprEngine &Eng,
288 bool wasInlined = false) {
290 wasInlined);
291 }
292
293 /// Run checkers for visiting an obj-c message to nil.
295 const ExplodedNodeSet &Src,
296 const ObjCMethodCall &msg,
297 ExprEngine &Eng) {
299 Eng);
300 }
301
302 /// Run checkers for visiting obj-c messages.
304 ExplodedNodeSet &Dst,
305 const ExplodedNodeSet &Src,
306 const ObjCMethodCall &msg, ExprEngine &Eng,
307 bool wasInlined = false);
308
309 /// Run checkers for pre-visiting function calls (including methods,
310 /// constructors, destructors etc. but excluding obj-c messages).
312 const CallEvent &Call, ExprEngine &Eng) {
313 runCheckersForCallEvent(/*isPreVisit=*/true, Dst, Src, Call, Eng);
314 }
315
316 /// Run checkers for post-visiting function calls (including methods,
317 /// constructors, destructors etc. but excluding obj-c messages).
319 const CallEvent &Call, ExprEngine &Eng,
320 bool wasInlined = false) {
321 runCheckersForCallEvent(/*isPreVisit=*/false, Dst, Src, Call, Eng,
322 wasInlined);
323 }
324
325 /// Run checkers for visiting function calls (including methods,
326 /// constructors, destructors etc. but excluding obj-c messages).
327 void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst,
328 const ExplodedNodeSet &Src,
329 const CallEvent &Call, ExprEngine &Eng,
330 bool wasInlined = false);
331
332 /// Run checkers for the end of a variable's lifetime.
334 const ExplodedNodeSet &Src,
335 const VarDecl *Decl, ExprEngine &Eng);
336
337 /// Run checkers for load/store of a location.
339 const ExplodedNodeSet &Src,
340 SVal location,
341 bool isLoad,
342 const Stmt *NodeEx,
343 const Stmt *BoundEx,
344 ExprEngine &Eng);
345
346 /// Run checkers for binding of a value to a location.
348 SVal location, SVal val, const Stmt *S,
349 bool AtDeclInit, ExprEngine &Eng,
350 const ProgramPoint &PP);
351
352 /// Run checkers after taking a control flow edge.
354 const ExplodedNodeSet &Src,
355 const BlockEntrance &Entrance,
356 ExprEngine &Eng) const;
357
358 /// Run checkers for end of analysis.
360 ExprEngine &Eng);
361
362 /// Run checkers on beginning of function.
364 const BlockEdge &L,
365 ExplodedNode *Pred,
366 ExprEngine &Eng);
367
368 /// Run checkers on end of function.
370 ExprEngine &Eng, const ReturnStmt *RS);
371
372 /// Run checkers for branch condition.
374 ExplodedNodeSet &Dst, ExplodedNode *Pred,
375 ExprEngine &Eng);
376
377 /// Run checkers between C++ operator new and constructor calls.
379 ExplodedNodeSet &Dst, ExplodedNode *Pred,
380 ExprEngine &Eng, bool wasInlined = false);
381
382 /// Run checkers for live symbols.
383 ///
384 /// Allows modifying SymbolReaper object. For example, checkers can explicitly
385 /// register symbols of interest as live. These symbols will not be marked
386 /// dead and removed.
388 SymbolReaper &SymReaper);
389
390 /// Run checkers for dead symbols.
391 ///
392 /// Notifies checkers when symbols become dead. For example, this allows
393 /// checkers to aggressively clean up/reduce the checker state and produce
394 /// precise diagnostics.
396 const ExplodedNodeSet &Src,
397 SymbolReaper &SymReaper, const Stmt *S,
398 ExprEngine &Eng,
400
401 /// Run checkers for region changes.
402 ///
403 /// This corresponds to the check::RegionChanges callback.
404 /// \param state The current program state.
405 /// \param invalidated A set of all symbols potentially touched by the change.
406 /// \param ExplicitRegions The regions explicitly requested for invalidation.
407 /// For example, in the case of a function call, these would be arguments.
408 /// \param Regions The transitive closure of accessible regions,
409 /// i.e. all regions that may have been touched by this change.
410 /// \param Call The call expression wrapper if the regions are invalidated
411 /// by a call.
414 const InvalidatedSymbols *invalidated,
415 ArrayRef<const MemRegion *> ExplicitRegions,
417 const StackFrame *SF, const CallEvent *Call);
418
419 /// Run checkers when pointers escape.
420 ///
421 /// This notifies the checkers about pointer escape, which occurs whenever
422 /// the analyzer cannot track the symbol any more. For example, as a
423 /// result of assigning a pointer into a global or when it's passed to a
424 /// function call the analyzer cannot model.
425 ///
426 /// \param State The state at the point of escape.
427 /// \param Escaped The list of escaped symbols.
428 /// \param Call The corresponding CallEvent, if the symbols escape as
429 /// parameters to the given call.
430 /// \param Kind The reason of pointer escape.
431 /// \param ITraits Information about invalidation for a particular
432 /// region/symbol.
433 /// \returns Checkers can modify the state by returning a new one.
436 const InvalidatedSymbols &Escaped,
437 const CallEvent *Call,
440
441 /// Run checkers for handling assumptions on symbolic values.
443 SVal Cond, bool Assumption);
444
445 /// Run checkers for evaluating a call.
446 ///
447 /// Warning: Currently, the CallEvent MUST come from a CallExpr!
449 const CallEvent &CE, ExprEngine &Eng,
450 const EvalCallOptions &CallOpts);
451
452 /// Run checkers for the entire Translation Unit.
454 AnalysisManager &mgr,
455 BugReporter &BR);
456
457 /// Run checkers for debug-printing a ProgramState.
458 ///
459 /// Unlike most other callbacks, any checker can simply implement the virtual
460 /// method CheckerBackend::printState if it has custom data to print.
461 ///
462 /// \param Out The output stream
463 /// \param State The state being printed
464 /// \param NL The preferred representation of a newline.
465 /// \param Space The preferred space between the left side and the message.
466 /// \param IsDot Whether the message will be printed in 'dot' format.
467 void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State,
468 const char *NL = "\n",
469 unsigned int Space = 0,
470 bool IsDot = false) const;
471
472 //===--------------------------------------------------------------------===//
473 // Internal registration functions for AST traversing.
474 //===--------------------------------------------------------------------===//
475
476 // Functions used by the registration mechanism, checkers should not touch
477 // these directly.
478
480 CheckerFn<void (const Decl *, AnalysisManager&, BugReporter &)>;
481
482 using HandlesDeclFunc = bool (*)(const Decl *D);
483
484 void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn);
485
486 void _registerForBody(CheckDeclFunc checkfn);
487
488 //===--------------------------------------------------------------------===//
489 // Internal registration functions for path-sensitive checking.
490 //===--------------------------------------------------------------------===//
491
492 using CheckStmtFunc = CheckerFn<void (const Stmt *, CheckerContext &)>;
493
495 CheckerFn<void (const ObjCMethodCall &, CheckerContext &)>;
496
498 CheckerFn<void (const CallEvent &, CheckerContext &)>;
499
501 CheckerFn<void(const VarDecl *, CheckerContext &)>;
502
503 using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
504 const Stmt *S, CheckerContext &)>;
505
506 using CheckBindFunc = CheckerFn<void(SVal location, SVal val, const Stmt *S,
507 bool AtDeclInit, CheckerContext &)>;
508
510 CheckerFn<void(const BlockEntrance &, CheckerContext &)>;
511
514
516
518 CheckerFn<void (const ReturnStmt *, CheckerContext &)>;
519
521 CheckerFn<void (const Stmt *, CheckerContext &)>;
522
525
528
530
532 ProgramStateRef, const InvalidatedSymbols *symbols,
533 ArrayRef<const MemRegion *> ExplicitRegions,
534 ArrayRef<const MemRegion *> Regions, const StackFrame *SF,
535 const CallEvent *Call)>;
536
539 const InvalidatedSymbols &Escaped,
540 const CallEvent *Call, PointerEscapeKind Kind,
542
544 CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;
545
547
550 BugReporter &)>;
551
552 using HandlesStmtFunc = bool (*)(const Stmt *D);
553
555 HandlesStmtFunc isForStmtFn);
557 HandlesStmtFunc isForStmtFn);
558
561
563
566
568
570
571 void _registerForBind(CheckBindFunc checkfn);
572
574
576
579
581
583
585
587
589
591
593
595
597
599
600 //===--------------------------------------------------------------------===//
601 // Internal registration functions for events.
602 //===--------------------------------------------------------------------===//
603
604 using EventTag = void *;
605 using CheckEventFunc = CheckerFn<void (const void *event)>;
606
607 template <typename EVENT>
609 EventInfo &info = Events[&EVENT::Tag];
610 info.Checkers.push_back(checkfn);
611 }
612
613 template <typename EVENT>
615 EventInfo &info = Events[&EVENT::Tag];
616 info.HasDispatcher = true;
617 }
618
619 template <typename EVENT>
620 void _dispatchEvent(const EVENT &event) const {
621 EventsTy::const_iterator I = Events.find(&EVENT::Tag);
622 if (I == Events.end())
623 return;
624 const EventInfo &info = I->second;
625 for (const auto &Checker : info.Checkers)
626 Checker(&event);
627 }
628
629 //===--------------------------------------------------------------------===//
630 // Implementation details.
631 //===--------------------------------------------------------------------===//
632
633private:
634 template <typename T>
635 static void *getTag() { static int tag; return &tag; }
636
637 llvm::DenseMap<CheckerTag, std::unique_ptr<CheckerBackend>> CheckerTags;
638
639 struct DeclCheckerInfo {
640 CheckDeclFunc CheckFn;
641 HandlesDeclFunc IsForDeclFn;
642 };
643 std::vector<DeclCheckerInfo> DeclCheckers;
644
645 std::vector<CheckDeclFunc> BodyCheckers;
646
647 using CachedDeclCheckers = SmallVector<CheckDeclFunc, 4>;
648 using CachedDeclCheckersMapTy = llvm::DenseMap<unsigned, CachedDeclCheckers>;
649 CachedDeclCheckersMapTy CachedDeclCheckersMap;
650
651 struct StmtCheckerInfo {
652 CheckStmtFunc CheckFn;
653 HandlesStmtFunc IsForStmtFn;
654 bool IsPreVisit;
655 };
656 std::vector<StmtCheckerInfo> StmtCheckers;
657
658 using CachedStmtCheckers = SmallVector<CheckStmtFunc, 4>;
659 using CachedStmtCheckersMapTy = llvm::DenseMap<unsigned, CachedStmtCheckers>;
660 CachedStmtCheckersMapTy CachedStmtCheckersMap;
661
662 const CachedStmtCheckers &getCachedStmtCheckersFor(const Stmt *S,
663 bool isPreVisit);
664
665 /// Returns the checkers that have registered for callbacks of the
666 /// given \p Kind.
667 const std::vector<CheckObjCMessageFunc> &
668 getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
669
670 std::vector<CheckObjCMessageFunc> PreObjCMessageCheckers;
671 std::vector<CheckObjCMessageFunc> PostObjCMessageCheckers;
672 std::vector<CheckObjCMessageFunc> ObjCMessageNilCheckers;
673
674 std::vector<CheckCallFunc> PreCallCheckers;
675 std::vector<CheckCallFunc> PostCallCheckers;
676
677 std::vector<CheckLifetimeEndFunc> LifetimeEndCheckers;
678
679 std::vector<CheckLocationFunc> LocationCheckers;
680
681 std::vector<CheckBindFunc> BindCheckers;
682
683 std::vector<CheckBlockEntranceFunc> BlockEntranceCheckers;
684
685 std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
686
687 std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;
688 std::vector<CheckEndFunctionFunc> EndFunctionCheckers;
689
690 std::vector<CheckBranchConditionFunc> BranchConditionCheckers;
691
692 std::vector<CheckNewAllocatorFunc> NewAllocatorCheckers;
693
694 std::vector<CheckLiveSymbolsFunc> LiveSymbolsCheckers;
695
696 std::vector<CheckDeadSymbolsFunc> DeadSymbolsCheckers;
697
698 std::vector<CheckRegionChangesFunc> RegionChangesCheckers;
699
700 std::vector<CheckPointerEscapeFunc> PointerEscapeCheckers;
701
702 std::vector<EvalAssumeFunc> EvalAssumeCheckers;
703
704 std::vector<EvalCallFunc> EvalCallCheckers;
705
706 std::vector<CheckEndOfTranslationUnit> EndOfTranslationUnitCheckers;
707
708 struct EventInfo {
709 SmallVector<CheckEventFunc, 4> Checkers;
710 bool HasDispatcher = false;
711
712 EventInfo() = default;
713 };
714
715 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
716 EventsTy Events;
717};
718
719} // namespace ento
720
721} // namespace clang
722
723#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:2987
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:234
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:3172
It represents a stack frame of the call stack.
Stmt - This represents one statement.
Definition Stmt.h:85
The top declaration context.
Definition Decl.h:105
Represents a variable declaration or definition.
Definition Decl.h:932
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:1663
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition SVals.h:57
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
Top level wrappers for InstallAPI frontend operations.
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:92