clang 20.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 LocationContext;
33class Stmt;
34class TranslationUnitDecl;
35
36namespace ento {
37
38class AnalysisManager;
39class CXXAllocatorCall;
40class BugReporter;
41class CallEvent;
42class CheckerBase;
43class CheckerContext;
44class CheckerRegistry;
45struct CheckerRegistryData;
46class ExplodedGraph;
47class ExplodedNode;
48class ExplodedNodeSet;
49class ExprEngine;
50struct EvalCallOptions;
51class MemRegion;
52class NodeBuilderContext;
53class ObjCMethodCall;
54class RegionAndSymbolInvalidationTraits;
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(CheckerBase *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).
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 StringRef getName() const { return Name; }
117 operator StringRef() const { return Name; }
118};
119
121 Pre,
122 Post,
124};
125
127 ASTContext *Context = nullptr;
128 const LangOptions LangOpts;
129 const AnalyzerOptions &AOptions;
130 const Preprocessor *PP = nullptr;
131 CheckerNameRef CurrentCheckerName;
132 DiagnosticsEngine &Diags;
133 std::unique_ptr<CheckerRegistryData> RegistryData;
134
135public:
136 // These constructors are defined in the Frontend library, because
137 // CheckerRegistry, a crucial component of the initialization is in there.
138 // CheckerRegistry cannot be moved to the Core library, because the checker
139 // registration functions are defined in the Checkers library, and the library
140 // dependencies look like this: Core -> Checkers -> Frontend.
141
143 ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP,
144 ArrayRef<std::string> plugins,
145 ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns);
146
147 /// Constructs a CheckerManager that ignores all non TblGen-generated
148 /// checkers. Useful for unit testing, unless the checker infrastructure
149 /// itself is tested.
151 const Preprocessor &PP)
152 : CheckerManager(Context, AOptions, PP, {}, {}) {}
153
154 /// Constructs a CheckerManager without requiring an AST. No checker
155 /// registration will take place. Only useful when one needs to print the
156 /// help flags through CheckerRegistryData, and the AST is unavailable.
157 CheckerManager(AnalyzerOptions &AOptions, const LangOptions &LangOpts,
158 DiagnosticsEngine &Diags, ArrayRef<std::string> plugins);
159
161
162 void setCurrentCheckerName(CheckerNameRef name) { CurrentCheckerName = name; }
163 CheckerNameRef getCurrentCheckerName() const { return CurrentCheckerName; }
164
165 bool hasPathSensitiveCheckers() const;
166
167 const LangOptions &getLangOpts() const { return LangOpts; }
168 const AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
170 assert(PP);
171 return *PP;
172 }
174 return *RegistryData;
175 }
176 DiagnosticsEngine &getDiagnostics() const { return Diags; }
178 assert(Context);
179 return *Context;
180 }
181
182 /// Emits an error through a DiagnosticsEngine about an invalid user supplied
183 /// checker option value.
185 StringRef OptionName,
186 StringRef ExpectedValueDesc) const;
187
189 using CheckerTag = const void *;
190 using CheckerDtor = CheckerFn<void ()>;
191
192//===----------------------------------------------------------------------===//
193// Checker registration.
194//===----------------------------------------------------------------------===//
195
196 /// Used to register checkers.
197 /// All arguments are automatically passed through to the checker
198 /// constructor.
199 ///
200 /// \returns a pointer to the checker object.
201 template <typename CHECKER, typename... AT>
202 CHECKER *registerChecker(AT &&... Args) {
203 CheckerTag tag = getTag<CHECKER>();
204 CheckerRef &ref = CheckerTags[tag];
205 assert(!ref && "Checker already registered, use getChecker!");
206
207 CHECKER *checker = new CHECKER(std::forward<AT>(Args)...);
208 checker->Name = CurrentCheckerName;
209 CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
210 CHECKER::_register(checker, *this);
211 ref = checker;
212 return checker;
213 }
214
215 template <typename CHECKER>
217 CheckerTag tag = getTag<CHECKER>();
218 assert(CheckerTags.count(tag) != 0 &&
219 "Requested checker is not registered! Maybe you should add it as a "
220 "dependency in Checkers.td?");
221 return static_cast<CHECKER *>(CheckerTags[tag]);
222 }
223
224 template <typename CHECKER> bool isRegisteredChecker() {
225 return CheckerTags.contains(getTag<CHECKER>());
226 }
227
228//===----------------------------------------------------------------------===//
229// Functions for running checkers for AST traversing.
230//===----------------------------------------------------------------------===//
231
232 /// Run checkers handling Decls.
233 void runCheckersOnASTDecl(const Decl *D, AnalysisManager& mgr,
234 BugReporter &BR);
235
236 /// Run checkers handling Decls containing a Stmt body.
237 void runCheckersOnASTBody(const Decl *D, AnalysisManager& mgr,
238 BugReporter &BR);
239
240//===----------------------------------------------------------------------===//
241// Functions for running checkers for path-sensitive checking.
242//===----------------------------------------------------------------------===//
243
244 /// Run checkers for pre-visiting Stmts.
245 ///
246 /// The notification is performed for every explored CFGElement, which does
247 /// not include the control flow statements such as IfStmt.
248 ///
249 /// \sa runCheckersForBranchCondition, runCheckersForPostStmt
251 const ExplodedNodeSet &Src,
252 const Stmt *S,
253 ExprEngine &Eng) {
254 runCheckersForStmt(/*isPreVisit=*/true, Dst, Src, S, Eng);
255 }
256
257 /// Run checkers for post-visiting Stmts.
258 ///
259 /// The notification is performed for every explored CFGElement, which does
260 /// not include the control flow statements such as IfStmt.
261 ///
262 /// \sa runCheckersForBranchCondition, runCheckersForPreStmt
264 const ExplodedNodeSet &Src,
265 const Stmt *S,
266 ExprEngine &Eng,
267 bool wasInlined = false) {
268 runCheckersForStmt(/*isPreVisit=*/false, Dst, Src, S, Eng, wasInlined);
269 }
270
271 /// Run checkers for visiting Stmts.
272 void runCheckersForStmt(bool isPreVisit,
273 ExplodedNodeSet &Dst, const ExplodedNodeSet &Src,
274 const Stmt *S, ExprEngine &Eng,
275 bool wasInlined = false);
276
277 /// Run checkers for pre-visiting obj-c messages.
279 const ExplodedNodeSet &Src,
280 const ObjCMethodCall &msg,
281 ExprEngine &Eng) {
283 }
284
285 /// Run checkers for post-visiting obj-c messages.
287 const ExplodedNodeSet &Src,
288 const ObjCMethodCall &msg,
289 ExprEngine &Eng,
290 bool wasInlined = false) {
292 wasInlined);
293 }
294
295 /// Run checkers for visiting an obj-c message to nil.
297 const ExplodedNodeSet &Src,
298 const ObjCMethodCall &msg,
299 ExprEngine &Eng) {
301 Eng);
302 }
303
304 /// Run checkers for visiting obj-c messages.
306 ExplodedNodeSet &Dst,
307 const ExplodedNodeSet &Src,
308 const ObjCMethodCall &msg, ExprEngine &Eng,
309 bool wasInlined = false);
310
311 /// Run checkers for pre-visiting 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 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 obj-c messages.
326 void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst,
327 const ExplodedNodeSet &Src,
328 const CallEvent &Call, ExprEngine &Eng,
329 bool wasInlined = false);
330
331 /// Run checkers for load/store of a location.
333 const ExplodedNodeSet &Src,
334 SVal location,
335 bool isLoad,
336 const Stmt *NodeEx,
337 const Stmt *BoundEx,
338 ExprEngine &Eng);
339
340 /// Run checkers for binding of a value to a location.
342 const ExplodedNodeSet &Src,
343 SVal location, SVal val,
344 const Stmt *S, ExprEngine &Eng,
345 const ProgramPoint &PP);
346
347 /// Run checkers for end of analysis.
349 ExprEngine &Eng);
350
351 /// Run checkers on beginning of function.
353 const BlockEdge &L,
354 ExplodedNode *Pred,
355 ExprEngine &Eng);
356
357 /// Run checkers on end of function.
359 ExplodedNodeSet &Dst,
360 ExplodedNode *Pred,
361 ExprEngine &Eng,
362 const ReturnStmt *RS);
363
364 /// Run checkers for branch condition.
365 void runCheckersForBranchCondition(const Stmt *condition,
366 ExplodedNodeSet &Dst, ExplodedNode *Pred,
367 ExprEngine &Eng);
368
369 /// Run checkers between C++ operator new and constructor calls.
371 ExplodedNodeSet &Dst, ExplodedNode *Pred,
372 ExprEngine &Eng, bool wasInlined = false);
373
374 /// Run checkers for live symbols.
375 ///
376 /// Allows modifying SymbolReaper object. For example, checkers can explicitly
377 /// register symbols of interest as live. These symbols will not be marked
378 /// dead and removed.
380 SymbolReaper &SymReaper);
381
382 /// Run checkers for dead symbols.
383 ///
384 /// Notifies checkers when symbols become dead. For example, this allows
385 /// checkers to aggressively clean up/reduce the checker state and produce
386 /// precise diagnostics.
388 const ExplodedNodeSet &Src,
389 SymbolReaper &SymReaper, const Stmt *S,
390 ExprEngine &Eng,
392
393 /// Run checkers for region changes.
394 ///
395 /// This corresponds to the check::RegionChanges callback.
396 /// \param state The current program state.
397 /// \param invalidated A set of all symbols potentially touched by the change.
398 /// \param ExplicitRegions The regions explicitly requested for invalidation.
399 /// For example, in the case of a function call, these would be arguments.
400 /// \param Regions The transitive closure of accessible regions,
401 /// i.e. all regions that may have been touched by this change.
402 /// \param Call The call expression wrapper if the regions are invalidated
403 /// by a call.
406 const InvalidatedSymbols *invalidated,
407 ArrayRef<const MemRegion *> ExplicitRegions,
409 const LocationContext *LCtx,
410 const CallEvent *Call);
411
412 /// Run checkers when pointers escape.
413 ///
414 /// This notifies the checkers about pointer escape, which occurs whenever
415 /// the analyzer cannot track the symbol any more. For example, as a
416 /// result of assigning a pointer into a global or when it's passed to a
417 /// function call the analyzer cannot model.
418 ///
419 /// \param State The state at the point of escape.
420 /// \param Escaped The list of escaped symbols.
421 /// \param Call The corresponding CallEvent, if the symbols escape as
422 /// parameters to the given call.
423 /// \param Kind The reason of pointer escape.
424 /// \param ITraits Information about invalidation for a particular
425 /// region/symbol.
426 /// \returns Checkers can modify the state by returning a new one.
429 const InvalidatedSymbols &Escaped,
430 const CallEvent *Call,
433
434 /// Run checkers for handling assumptions on symbolic values.
436 SVal Cond, bool Assumption);
437
438 /// Run checkers for evaluating a call.
439 ///
440 /// Warning: Currently, the CallEvent MUST come from a CallExpr!
442 const CallEvent &CE, ExprEngine &Eng,
443 const EvalCallOptions &CallOpts);
444
445 /// Run checkers for the entire Translation Unit.
447 AnalysisManager &mgr,
448 BugReporter &BR);
449
450 /// Run checkers for debug-printing a ProgramState.
451 ///
452 /// Unlike most other callbacks, any checker can simply implement the virtual
453 /// method CheckerBase::printState if it has custom data to print.
454 ///
455 /// \param Out The output stream
456 /// \param State The state being printed
457 /// \param NL The preferred representation of a newline.
458 /// \param Space The preferred space between the left side and the message.
459 /// \param IsDot Whether the message will be printed in 'dot' format.
460 void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State,
461 const char *NL = "\n",
462 unsigned int Space = 0,
463 bool IsDot = false) const;
464
465 //===----------------------------------------------------------------------===//
466 // Internal registration functions for AST traversing.
467 //===----------------------------------------------------------------------===//
468
469 // Functions used by the registration mechanism, checkers should not touch
470 // these directly.
471
473 CheckerFn<void (const Decl *, AnalysisManager&, BugReporter &)>;
474
475 using HandlesDeclFunc = bool (*)(const Decl *D);
476
477 void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn);
478
479 void _registerForBody(CheckDeclFunc checkfn);
480
481//===----------------------------------------------------------------------===//
482// Internal registration functions for path-sensitive checking.
483//===----------------------------------------------------------------------===//
484
485 using CheckStmtFunc = CheckerFn<void (const Stmt *, CheckerContext &)>;
486
488 CheckerFn<void (const ObjCMethodCall &, CheckerContext &)>;
489
491 CheckerFn<void (const CallEvent &, CheckerContext &)>;
492
493 using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
494 const Stmt *S, CheckerContext &)>;
495
497 CheckerFn<void(SVal location, SVal val, const Stmt *S, CheckerContext &)>;
498
501
503
505 CheckerFn<void (const ReturnStmt *, CheckerContext &)>;
506
508 CheckerFn<void (const Stmt *, CheckerContext &)>;
509
512
515
517
520 const InvalidatedSymbols *symbols,
521 ArrayRef<const MemRegion *> ExplicitRegions,
523 const LocationContext *LCtx,
524 const CallEvent *Call)>;
525
528 const InvalidatedSymbols &Escaped,
531
533 CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;
534
536
539 BugReporter &)>;
540
541 using HandlesStmtFunc = bool (*)(const Stmt *D);
542
544 HandlesStmtFunc isForStmtFn);
546 HandlesStmtFunc isForStmtFn);
547
550
552
555
557
558 void _registerForBind(CheckBindFunc checkfn);
559
561
564
566
568
570
572
574
576
578
580
582
584
585//===----------------------------------------------------------------------===//
586// Internal registration functions for events.
587//===----------------------------------------------------------------------===//
588
589 using EventTag = void *;
590 using CheckEventFunc = CheckerFn<void (const void *event)>;
591
592 template <typename EVENT>
594 EventInfo &info = Events[&EVENT::Tag];
595 info.Checkers.push_back(checkfn);
596 }
597
598 template <typename EVENT>
600 EventInfo &info = Events[&EVENT::Tag];
601 info.HasDispatcher = true;
602 }
603
604 template <typename EVENT>
605 void _dispatchEvent(const EVENT &event) const {
606 EventsTy::const_iterator I = Events.find(&EVENT::Tag);
607 if (I == Events.end())
608 return;
609 const EventInfo &info = I->second;
610 for (const auto &Checker : info.Checkers)
611 Checker(&event);
612 }
613
614//===----------------------------------------------------------------------===//
615// Implementation details.
616//===----------------------------------------------------------------------===//
617
618private:
619 template <typename CHECKER>
620 static void destruct(void *obj) { delete static_cast<CHECKER *>(obj); }
621
622 template <typename T>
623 static void *getTag() { static int tag; return &tag; }
624
625 llvm::DenseMap<CheckerTag, CheckerRef> CheckerTags;
626
627 std::vector<CheckerDtor> CheckerDtors;
628
629 struct DeclCheckerInfo {
630 CheckDeclFunc CheckFn;
631 HandlesDeclFunc IsForDeclFn;
632 };
633 std::vector<DeclCheckerInfo> DeclCheckers;
634
635 std::vector<CheckDeclFunc> BodyCheckers;
636
637 using CachedDeclCheckers = SmallVector<CheckDeclFunc, 4>;
638 using CachedDeclCheckersMapTy = llvm::DenseMap<unsigned, CachedDeclCheckers>;
639 CachedDeclCheckersMapTy CachedDeclCheckersMap;
640
641 struct StmtCheckerInfo {
642 CheckStmtFunc CheckFn;
643 HandlesStmtFunc IsForStmtFn;
644 bool IsPreVisit;
645 };
646 std::vector<StmtCheckerInfo> StmtCheckers;
647
648 using CachedStmtCheckers = SmallVector<CheckStmtFunc, 4>;
649 using CachedStmtCheckersMapTy = llvm::DenseMap<unsigned, CachedStmtCheckers>;
650 CachedStmtCheckersMapTy CachedStmtCheckersMap;
651
652 const CachedStmtCheckers &getCachedStmtCheckersFor(const Stmt *S,
653 bool isPreVisit);
654
655 /// Returns the checkers that have registered for callbacks of the
656 /// given \p Kind.
657 const std::vector<CheckObjCMessageFunc> &
658 getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
659
660 std::vector<CheckObjCMessageFunc> PreObjCMessageCheckers;
661 std::vector<CheckObjCMessageFunc> PostObjCMessageCheckers;
662 std::vector<CheckObjCMessageFunc> ObjCMessageNilCheckers;
663
664 std::vector<CheckCallFunc> PreCallCheckers;
665 std::vector<CheckCallFunc> PostCallCheckers;
666
667 std::vector<CheckLocationFunc> LocationCheckers;
668
669 std::vector<CheckBindFunc> BindCheckers;
670
671 std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
672
673 std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;
674 std::vector<CheckEndFunctionFunc> EndFunctionCheckers;
675
676 std::vector<CheckBranchConditionFunc> BranchConditionCheckers;
677
678 std::vector<CheckNewAllocatorFunc> NewAllocatorCheckers;
679
680 std::vector<CheckLiveSymbolsFunc> LiveSymbolsCheckers;
681
682 std::vector<CheckDeadSymbolsFunc> DeadSymbolsCheckers;
683
684 std::vector<CheckRegionChangesFunc> RegionChangesCheckers;
685
686 std::vector<CheckPointerEscapeFunc> PointerEscapeCheckers;
687
688 std::vector<EvalAssumeFunc> EvalAssumeCheckers;
689
690 std::vector<EvalCallFunc> EvalCallCheckers;
691
692 std::vector<CheckEndOfTranslationUnit> EndOfTranslationUnitCheckers;
693
694 struct EventInfo {
695 SmallVector<CheckEventFunc, 4> Checkers;
696 bool HasDispatcher = false;
697
698 EventInfo() = default;
699 };
700
701 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
702 EventsTy Events;
703};
704
705} // namespace ento
706
707} // namespace clang
708
709#endif // LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
Defines the Diagnostic-related interfaces.
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN)
const Decl * D
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
Defines the clang::LangOptions interface.
#define bool
Definition: amdgpuintrin.h:20
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
Stores options for the analyzer from the command line.
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:231
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:138
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3046
Stmt - This represents one statement.
Definition: Stmt.h:84
The top declaration context.
Definition: Decl.h:84
BugReporter is a utility class for generating PathDiagnostics for analysis.
Definition: BugReporter.h:585
Represents the memory allocation call in a C++ new-expression.
Definition: CallEvent.h:1117
Represents an abstract call to a function or method along a particular path.
Definition: CallEvent.h:153
CheckerFn(CheckerBase *checker, Func fn)
void _registerForLiveSymbols(CheckLiveSymbolsFunc checkfn)
void _registerForEndOfTranslationUnit(CheckEndOfTranslationUnit checkfn)
const AnalyzerOptions & getAnalyzerOptions() const
void _registerForBeginFunction(CheckBeginFunctionFunc checkfn)
void runCheckersForBind(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, SVal val, const Stmt *S, ExprEngine &Eng, const ProgramPoint &PP)
Run checkers for binding of a value to a location.
void _registerForNewAllocator(CheckNewAllocatorFunc checkfn)
void runCheckersForPreObjCMessage(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for pre-visiting obj-c messages.
void _registerForPreCall(CheckCallFunc checkfn)
void _registerForObjCMessageNil(CheckObjCMessageFunc checkfn)
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
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 reportInvalidCheckerOptionValue(const CheckerBase *C, StringRef OptionName, StringRef ExpectedValueDesc) const
Emits an error through a DiagnosticsEngine about an invalid user supplied checker option value.
void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn)
void _registerForPreObjCMessage(CheckObjCMessageFunc checkfn)
void runCheckersOnEndOfTranslationUnit(const TranslationUnitDecl *TU, AnalysisManager &mgr, BugReporter &BR)
Run checkers for the entire Translation Unit.
void runCheckersForEndFunction(NodeBuilderContext &BC, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, const ReturnStmt *RS)
Run checkers on end of function.
ASTContext & getASTContext() const
void _registerListenerForEvent(CheckEventFunc checkfn)
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
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 obj-c messages.
CheckerFn< void(const Decl *, AnalysisManager &, BugReporter &)> CheckDeclFunc
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.
ProgramStateRef runCheckersForRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const LocationContext *LCtx, const CallEvent *Call)
Run checkers for region changes.
void _registerForPostObjCMessage(CheckObjCMessageFunc checkfn)
void _registerForRegionChanges(CheckRegionChangesFunc checkfn)
void _registerForBind(CheckBindFunc checkfn)
void runCheckersForLiveSymbols(ProgramStateRef state, SymbolReaper &SymReaper)
Run checkers for live symbols.
void _registerForPointerEscape(CheckPointerEscapeFunc checkfn)
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.
void runCheckersForPreStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng)
Run checkers for pre-visiting Stmts.
void _registerForBranchCondition(CheckBranchConditionFunc checkfn)
void runCheckersForObjCMessageNil(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for visiting an obj-c message to nil.
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.
const LangOptions & getLangOpts() const
void _registerForEvalCall(EvalCallFunc checkfn)
void _registerForEndFunction(CheckEndFunctionFunc checkfn)
void runCheckersForBranchCondition(const Stmt *condition, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers for branch condition.
CheckerNameRef getCurrentCheckerName() const
CheckerFn< void()> CheckerDtor
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)
void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting obj-c messages.
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 runCheckersForPostCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting obj-c messages.
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.
Represents any expression that calls an Objective-C method.
Definition: CallEvent.h:1248
Information about invalidation for a particular region/symbol.
Definition: MemRegion.h:1629
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.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
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...
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
llvm::DenseSet< SymbolRef > InvalidatedSymbols
Definition: Store.h:51
The JSON file list parser is used to communicate input to InstallAPI.
Hints for figuring out of a call should be inlined during evalCall().
Definition: ExprEngine.h:97