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
168
169 const LangOptions &getLangOpts() const { return LangOpts; }
170 const AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
172 assert(PP);
173 return *PP;
174 }
176 return *RegistryData;
177 }
178 DiagnosticsEngine &getDiagnostics() const { return Diags; }
180 assert(Context);
181 return *Context;
182 }
183
184 /// Emits an error through a DiagnosticsEngine about an invalid user supplied
185 /// checker option value.
187 StringRef OptionName,
188 StringRef ExpectedValueDesc) const;
189
191 using CheckerTag = const void *;
192 using CheckerDtor = CheckerFn<void ()>;
193
194//===----------------------------------------------------------------------===//
195// Checker registration.
196//===----------------------------------------------------------------------===//
197
198 /// Used to register checkers.
199 /// All arguments are automatically passed through to the checker
200 /// constructor.
201 ///
202 /// \returns a pointer to the checker object.
203 template <typename CHECKER, typename... AT>
204 CHECKER *registerChecker(AT &&... Args) {
205 CheckerTag tag = getTag<CHECKER>();
206 CheckerRef &ref = CheckerTags[tag];
207 assert(!ref && "Checker already registered, use getChecker!");
208
209 CHECKER *checker = new CHECKER(std::forward<AT>(Args)...);
210 checker->Name = CurrentCheckerName;
211 CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
212 CHECKER::_register(checker, *this);
213 ref = checker;
214 return checker;
215 }
216
217 template <typename CHECKER>
219 CheckerTag tag = getTag<CHECKER>();
220 assert(CheckerTags.count(tag) != 0 &&
221 "Requested checker is not registered! Maybe you should add it as a "
222 "dependency in Checkers.td?");
223 return static_cast<CHECKER *>(CheckerTags[tag]);
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 obj-c messages.
311 const CallEvent &Call, ExprEngine &Eng) {
312 runCheckersForCallEvent(/*isPreVisit=*/true, Dst, Src, Call, Eng);
313 }
314
315 /// Run checkers for post-visiting obj-c messages.
317 const CallEvent &Call, ExprEngine &Eng,
318 bool wasInlined = false) {
319 runCheckersForCallEvent(/*isPreVisit=*/false, Dst, Src, Call, Eng,
320 wasInlined);
321 }
322
323 /// Run checkers for visiting obj-c messages.
324 void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst,
325 const ExplodedNodeSet &Src,
326 const CallEvent &Call, ExprEngine &Eng,
327 bool wasInlined = false);
328
329 /// Run checkers for load/store of a location.
331 const ExplodedNodeSet &Src,
332 SVal location,
333 bool isLoad,
334 const Stmt *NodeEx,
335 const Stmt *BoundEx,
336 ExprEngine &Eng);
337
338 /// Run checkers for binding of a value to a location.
340 const ExplodedNodeSet &Src,
341 SVal location, SVal val,
342 const Stmt *S, ExprEngine &Eng,
343 const ProgramPoint &PP);
344
345 /// Run checkers for end of analysis.
347 ExprEngine &Eng);
348
349 /// Run checkers on beginning of function.
351 const BlockEdge &L,
352 ExplodedNode *Pred,
353 ExprEngine &Eng);
354
355 /// Run checkers on end of function.
357 ExplodedNodeSet &Dst,
358 ExplodedNode *Pred,
359 ExprEngine &Eng,
360 const ReturnStmt *RS);
361
362 /// Run checkers for branch condition.
363 void runCheckersForBranchCondition(const Stmt *condition,
364 ExplodedNodeSet &Dst, ExplodedNode *Pred,
365 ExprEngine &Eng);
366
367 /// Run checkers between C++ operator new and constructor calls.
369 ExplodedNodeSet &Dst, ExplodedNode *Pred,
370 ExprEngine &Eng, bool wasInlined = false);
371
372 /// Run checkers for live symbols.
373 ///
374 /// Allows modifying SymbolReaper object. For example, checkers can explicitly
375 /// register symbols of interest as live. These symbols will not be marked
376 /// dead and removed.
378 SymbolReaper &SymReaper);
379
380 /// Run checkers for dead symbols.
381 ///
382 /// Notifies checkers when symbols become dead. For example, this allows
383 /// checkers to aggressively clean up/reduce the checker state and produce
384 /// precise diagnostics.
386 const ExplodedNodeSet &Src,
387 SymbolReaper &SymReaper, const Stmt *S,
388 ExprEngine &Eng,
390
391 /// Run checkers for region changes.
392 ///
393 /// This corresponds to the check::RegionChanges callback.
394 /// \param state The current program state.
395 /// \param invalidated A set of all symbols potentially touched by the change.
396 /// \param ExplicitRegions The regions explicitly requested for invalidation.
397 /// For example, in the case of a function call, these would be arguments.
398 /// \param Regions The transitive closure of accessible regions,
399 /// i.e. all regions that may have been touched by this change.
400 /// \param Call The call expression wrapper if the regions are invalidated
401 /// by a call.
404 const InvalidatedSymbols *invalidated,
405 ArrayRef<const MemRegion *> ExplicitRegions,
407 const LocationContext *LCtx,
408 const CallEvent *Call);
409
410 /// Run checkers when pointers escape.
411 ///
412 /// This notifies the checkers about pointer escape, which occurs whenever
413 /// the analyzer cannot track the symbol any more. For example, as a
414 /// result of assigning a pointer into a global or when it's passed to a
415 /// function call the analyzer cannot model.
416 ///
417 /// \param State The state at the point of escape.
418 /// \param Escaped The list of escaped symbols.
419 /// \param Call The corresponding CallEvent, if the symbols escape as
420 /// parameters to the given call.
421 /// \param Kind The reason of pointer escape.
422 /// \param ITraits Information about invalidation for a particular
423 /// region/symbol.
424 /// \returns Checkers can modify the state by returning a new one.
427 const InvalidatedSymbols &Escaped,
428 const CallEvent *Call,
431
432 /// Run checkers for handling assumptions on symbolic values.
434 SVal Cond, bool Assumption);
435
436 /// Run checkers for evaluating a call.
437 ///
438 /// Warning: Currently, the CallEvent MUST come from a CallExpr!
440 const CallEvent &CE, ExprEngine &Eng,
441 const EvalCallOptions &CallOpts);
442
443 /// Run checkers for the entire Translation Unit.
445 AnalysisManager &mgr,
446 BugReporter &BR);
447
448 /// Run checkers for debug-printing a ProgramState.
449 ///
450 /// Unlike most other callbacks, any checker can simply implement the virtual
451 /// method CheckerBase::printState if it has custom data to print.
452 ///
453 /// \param Out The output stream
454 /// \param State The state being printed
455 /// \param NL The preferred representation of a newline.
456 /// \param Space The preferred space between the left side and the message.
457 /// \param IsDot Whether the message will be printed in 'dot' format.
458 void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State,
459 const char *NL = "\n",
460 unsigned int Space = 0,
461 bool IsDot = false) const;
462
463 //===----------------------------------------------------------------------===//
464 // Internal registration functions for AST traversing.
465 //===----------------------------------------------------------------------===//
466
467 // Functions used by the registration mechanism, checkers should not touch
468 // these directly.
469
471 CheckerFn<void (const Decl *, AnalysisManager&, BugReporter &)>;
472
473 using HandlesDeclFunc = bool (*)(const Decl *D);
474
475 void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn);
476
477 void _registerForBody(CheckDeclFunc checkfn);
478
479//===----------------------------------------------------------------------===//
480// Internal registration functions for path-sensitive checking.
481//===----------------------------------------------------------------------===//
482
483 using CheckStmtFunc = CheckerFn<void (const Stmt *, CheckerContext &)>;
484
486 CheckerFn<void (const ObjCMethodCall &, CheckerContext &)>;
487
489 CheckerFn<void (const CallEvent &, CheckerContext &)>;
490
491 using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
492 const Stmt *S, CheckerContext &)>;
493
495 CheckerFn<void(SVal location, SVal val, const Stmt *S, CheckerContext &)>;
496
499
501
503 CheckerFn<void (const ReturnStmt *, CheckerContext &)>;
504
506 CheckerFn<void (const Stmt *, CheckerContext &)>;
507
510
513
515
518 const InvalidatedSymbols *symbols,
519 ArrayRef<const MemRegion *> ExplicitRegions,
521 const LocationContext *LCtx,
522 const CallEvent *Call)>;
523
526 const InvalidatedSymbols &Escaped,
529
531 CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;
532
534
537 BugReporter &)>;
538
539 using HandlesStmtFunc = bool (*)(const Stmt *D);
540
542 HandlesStmtFunc isForStmtFn);
544 HandlesStmtFunc isForStmtFn);
545
548
550
553
555
556 void _registerForBind(CheckBindFunc checkfn);
557
559
562
564
566
568
570
572
574
576
578
580
582
583//===----------------------------------------------------------------------===//
584// Internal registration functions for events.
585//===----------------------------------------------------------------------===//
586
587 using EventTag = void *;
588 using CheckEventFunc = CheckerFn<void (const void *event)>;
589
590 template <typename EVENT>
592 EventInfo &info = Events[&EVENT::Tag];
593 info.Checkers.push_back(checkfn);
594 }
595
596 template <typename EVENT>
598 EventInfo &info = Events[&EVENT::Tag];
599 info.HasDispatcher = true;
600 }
601
602 template <typename EVENT>
603 void _dispatchEvent(const EVENT &event) const {
604 EventsTy::const_iterator I = Events.find(&EVENT::Tag);
605 if (I == Events.end())
606 return;
607 const EventInfo &info = I->second;
608 for (const auto &Checker : info.Checkers)
609 Checker(&event);
610 }
611
612//===----------------------------------------------------------------------===//
613// Implementation details.
614//===----------------------------------------------------------------------===//
615
616private:
617 template <typename CHECKER>
618 static void destruct(void *obj) { delete static_cast<CHECKER *>(obj); }
619
620 template <typename T>
621 static void *getTag() { static int tag; return &tag; }
622
623 llvm::DenseMap<CheckerTag, CheckerRef> CheckerTags;
624
625 std::vector<CheckerDtor> CheckerDtors;
626
627 struct DeclCheckerInfo {
628 CheckDeclFunc CheckFn;
629 HandlesDeclFunc IsForDeclFn;
630 };
631 std::vector<DeclCheckerInfo> DeclCheckers;
632
633 std::vector<CheckDeclFunc> BodyCheckers;
634
635 using CachedDeclCheckers = SmallVector<CheckDeclFunc, 4>;
636 using CachedDeclCheckersMapTy = llvm::DenseMap<unsigned, CachedDeclCheckers>;
637 CachedDeclCheckersMapTy CachedDeclCheckersMap;
638
639 struct StmtCheckerInfo {
640 CheckStmtFunc CheckFn;
641 HandlesStmtFunc IsForStmtFn;
642 bool IsPreVisit;
643 };
644 std::vector<StmtCheckerInfo> StmtCheckers;
645
646 using CachedStmtCheckers = SmallVector<CheckStmtFunc, 4>;
647 using CachedStmtCheckersMapTy = llvm::DenseMap<unsigned, CachedStmtCheckers>;
648 CachedStmtCheckersMapTy CachedStmtCheckersMap;
649
650 const CachedStmtCheckers &getCachedStmtCheckersFor(const Stmt *S,
651 bool isPreVisit);
652
653 /// Returns the checkers that have registered for callbacks of the
654 /// given \p Kind.
655 const std::vector<CheckObjCMessageFunc> &
656 getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
657
658 std::vector<CheckObjCMessageFunc> PreObjCMessageCheckers;
659 std::vector<CheckObjCMessageFunc> PostObjCMessageCheckers;
660 std::vector<CheckObjCMessageFunc> ObjCMessageNilCheckers;
661
662 std::vector<CheckCallFunc> PreCallCheckers;
663 std::vector<CheckCallFunc> PostCallCheckers;
664
665 std::vector<CheckLocationFunc> LocationCheckers;
666
667 std::vector<CheckBindFunc> BindCheckers;
668
669 std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
670
671 std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;
672 std::vector<CheckEndFunctionFunc> EndFunctionCheckers;
673
674 std::vector<CheckBranchConditionFunc> BranchConditionCheckers;
675
676 std::vector<CheckNewAllocatorFunc> NewAllocatorCheckers;
677
678 std::vector<CheckLiveSymbolsFunc> LiveSymbolsCheckers;
679
680 std::vector<CheckDeadSymbolsFunc> DeadSymbolsCheckers;
681
682 std::vector<CheckRegionChangesFunc> RegionChangesCheckers;
683
684 std::vector<CheckPointerEscapeFunc> PointerEscapeCheckers;
685
686 std::vector<EvalAssumeFunc> EvalAssumeCheckers;
687
688 std::vector<EvalCallFunc> EvalCallCheckers;
689
690 std::vector<CheckEndOfTranslationUnit> EndOfTranslationUnitCheckers;
691
692 struct EventInfo {
693 SmallVector<CheckEventFunc, 4> Checkers;
694 bool HasDispatcher = false;
695
696 EventInfo() = default;
697 };
698
699 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
700 EventsTy Events;
701};
702
703} // namespace ento
704
705} // namespace clang
706
707#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::@1653::IndirectLocalPathEntry::EntryKind Kind
Defines the clang::LangOptions interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
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:192
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:476
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:137
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3029
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:1112
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:1243
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:55
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.
#define bool
Definition: stdbool.h:24
Hints for figuring out of a call should be inlined during evalCall().
Definition: ExprEngine.h:97