clang 22.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 CheckerFrontend;
43class CheckerBackend;
44class CheckerContext;
45class CheckerRegistry;
46struct CheckerRegistryData;
47class ExplodedGraph;
48class ExplodedNode;
49class ExplodedNodeSet;
50class ExprEngine;
51struct EvalCallOptions;
52class MemRegion;
53class NodeBuilderContext;
54class ObjCMethodCall;
55class RegionAndSymbolInvalidationTraits;
56class SVal;
57class SymbolReaper;
58
59template <typename T> class CheckerFn;
60
61template <typename RET, typename... Ps>
62class CheckerFn<RET(Ps...)> {
63 using Func = RET (*)(void *, Ps...);
64
65 Func Fn;
66
67public:
69
70 CheckerFn(CheckerBackend *checker, Func fn) : Fn(fn), Checker(checker) {}
71
72 RET operator()(Ps... ps) const {
73 return Fn(Checker, ps...);
74 }
75};
76
77/// Describes the different reasons a pointer escapes
78/// during analysis.
80 /// A pointer escapes due to binding its value to a location
81 /// that the analyzer cannot track.
83
84 /// The pointer has been passed to a function call directly.
86
87 /// The pointer has been passed to a function indirectly.
88 /// For example, the pointer is accessible through an
89 /// argument to a function.
91
92
93 /// Escape for a new symbol that was generated into a region
94 /// that the analyzer cannot follow during a conservative call.
96
97 /// The reason for pointer escape is unknown. For example,
98 /// a region containing this pointer is invalidated.
101
102/// This wrapper is used to ensure that only StringRefs originating from the
103/// CheckerRegistry are used as check names. We want to make sure all checker
104/// name strings have a lifetime that keeps them alive at least until the path
105/// diagnostics have been processed, since they are expected to be constexpr
106/// string literals (most likely generated by TblGen).
108 friend class ::clang::ento::CheckerRegistry;
109
110 StringRef Name;
111
112 explicit CheckerNameRef(StringRef Name) : Name(Name) {}
113
114public:
115 CheckerNameRef() = default;
116
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
188 using CheckerTag = const void *;
189
190 //===--------------------------------------------------------------------===//
191 // Checker registration.
192 //===--------------------------------------------------------------------===//
193
194 /// If the the singleton instance of a checker class is not yet constructed,
195 /// then construct it (with the supplied arguments), register it for the
196 /// callbacks that are supported by it, and return it. Otherwise, just return
197 /// a pointer to the existing instance.
198 template <typename CHECKER, typename... AT>
199 CHECKER *getChecker(AT &&...Args) {
200 CheckerTag Tag = getTag<CHECKER>();
201
202 std::unique_ptr<CheckerBackend> &Ref = CheckerTags[Tag];
203 if (!Ref) {
204 std::unique_ptr<CHECKER> Checker =
205 std::make_unique<CHECKER>(std::forward<AT>(Args)...);
206 CHECKER::_register(Checker.get(), *this);
207 Ref = std::move(Checker);
208 }
209
210 return static_cast<CHECKER *>(Ref.get());
211 }
212
213 /// Register a single-part checker (derived from `Checker`): construct its
214 /// singleton instance, register it for the supported callbacks and record
215 /// its name (with `CheckerFrontend::enable`). Calling this multiple times
216 /// triggers an assertion failure.
217 template <typename CHECKER, typename... AT>
218 CHECKER *registerChecker(AT &&...Args) {
219 CHECKER *Chk = getChecker<CHECKER>(std::forward<AT>(Args)...);
220 Chk->enable(*this);
221 return Chk;
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 SVal location, SVal val, const Stmt *S,
343 bool AtDeclInit, ExprEngine &Eng,
344 const ProgramPoint &PP);
345
346 /// Run checkers after taking a control flow edge.
348 const ExplodedNodeSet &Src,
349 const BlockEntrance &Entrance,
350 ExprEngine &Eng) const;
351
352 /// Run checkers for end of analysis.
354 ExprEngine &Eng);
355
356 /// Run checkers on beginning of function.
358 const BlockEdge &L,
359 ExplodedNode *Pred,
360 ExprEngine &Eng);
361
362 /// Run checkers on end of function.
364 ExplodedNodeSet &Dst,
365 ExplodedNode *Pred,
366 ExprEngine &Eng,
367 const ReturnStmt *RS);
368
369 /// Run checkers for branch condition.
370 void runCheckersForBranchCondition(const Stmt *condition,
371 ExplodedNodeSet &Dst, ExplodedNode *Pred,
372 ExprEngine &Eng);
373
374 /// Run checkers between C++ operator new and constructor calls.
376 ExplodedNodeSet &Dst, ExplodedNode *Pred,
377 ExprEngine &Eng, bool wasInlined = false);
378
379 /// Run checkers for live symbols.
380 ///
381 /// Allows modifying SymbolReaper object. For example, checkers can explicitly
382 /// register symbols of interest as live. These symbols will not be marked
383 /// dead and removed.
385 SymbolReaper &SymReaper);
386
387 /// Run checkers for dead symbols.
388 ///
389 /// Notifies checkers when symbols become dead. For example, this allows
390 /// checkers to aggressively clean up/reduce the checker state and produce
391 /// precise diagnostics.
393 const ExplodedNodeSet &Src,
394 SymbolReaper &SymReaper, const Stmt *S,
395 ExprEngine &Eng,
397
398 /// Run checkers for region changes.
399 ///
400 /// This corresponds to the check::RegionChanges callback.
401 /// \param state The current program state.
402 /// \param invalidated A set of all symbols potentially touched by the change.
403 /// \param ExplicitRegions The regions explicitly requested for invalidation.
404 /// For example, in the case of a function call, these would be arguments.
405 /// \param Regions The transitive closure of accessible regions,
406 /// i.e. all regions that may have been touched by this change.
407 /// \param Call The call expression wrapper if the regions are invalidated
408 /// by a call.
411 const InvalidatedSymbols *invalidated,
412 ArrayRef<const MemRegion *> ExplicitRegions,
414 const LocationContext *LCtx,
415 const CallEvent *Call);
416
417 /// Run checkers when pointers escape.
418 ///
419 /// This notifies the checkers about pointer escape, which occurs whenever
420 /// the analyzer cannot track the symbol any more. For example, as a
421 /// result of assigning a pointer into a global or when it's passed to a
422 /// function call the analyzer cannot model.
423 ///
424 /// \param State The state at the point of escape.
425 /// \param Escaped The list of escaped symbols.
426 /// \param Call The corresponding CallEvent, if the symbols escape as
427 /// parameters to the given call.
428 /// \param Kind The reason of pointer escape.
429 /// \param ITraits Information about invalidation for a particular
430 /// region/symbol.
431 /// \returns Checkers can modify the state by returning a new one.
434 const InvalidatedSymbols &Escaped,
435 const CallEvent *Call,
438
439 /// Run checkers for handling assumptions on symbolic values.
441 SVal Cond, bool Assumption);
442
443 /// Run checkers for evaluating a call.
444 ///
445 /// Warning: Currently, the CallEvent MUST come from a CallExpr!
447 const CallEvent &CE, ExprEngine &Eng,
448 const EvalCallOptions &CallOpts);
449
450 /// Run checkers for the entire Translation Unit.
452 AnalysisManager &mgr,
453 BugReporter &BR);
454
455 /// Run checkers for debug-printing a ProgramState.
456 ///
457 /// Unlike most other callbacks, any checker can simply implement the virtual
458 /// method CheckerBackend::printState if it has custom data to print.
459 ///
460 /// \param Out The output stream
461 /// \param State The state being printed
462 /// \param NL The preferred representation of a newline.
463 /// \param Space The preferred space between the left side and the message.
464 /// \param IsDot Whether the message will be printed in 'dot' format.
465 void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State,
466 const char *NL = "\n",
467 unsigned int Space = 0,
468 bool IsDot = false) const;
469
470 //===--------------------------------------------------------------------===//
471 // Internal registration functions for AST traversing.
472 //===--------------------------------------------------------------------===//
473
474 // Functions used by the registration mechanism, checkers should not touch
475 // these directly.
476
478 CheckerFn<void (const Decl *, AnalysisManager&, BugReporter &)>;
479
480 using HandlesDeclFunc = bool (*)(const Decl *D);
481
482 void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn);
483
484 void _registerForBody(CheckDeclFunc checkfn);
485
486 //===--------------------------------------------------------------------===//
487 // Internal registration functions for path-sensitive checking.
488 //===--------------------------------------------------------------------===//
489
490 using CheckStmtFunc = CheckerFn<void (const Stmt *, CheckerContext &)>;
491
493 CheckerFn<void (const ObjCMethodCall &, CheckerContext &)>;
494
496 CheckerFn<void (const CallEvent &, CheckerContext &)>;
497
498 using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
499 const Stmt *S, CheckerContext &)>;
500
501 using CheckBindFunc = CheckerFn<void(SVal location, SVal val, const Stmt *S,
502 bool AtDeclInit, CheckerContext &)>;
503
505 CheckerFn<void(const BlockEntrance &, CheckerContext &)>;
506
509
511
513 CheckerFn<void (const ReturnStmt *, CheckerContext &)>;
514
516 CheckerFn<void (const Stmt *, CheckerContext &)>;
517
520
523
525
528 const InvalidatedSymbols *symbols,
529 ArrayRef<const MemRegion *> ExplicitRegions,
531 const LocationContext *LCtx,
532 const CallEvent *Call)>;
533
536 const InvalidatedSymbols &Escaped,
539
541 CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;
542
544
547 BugReporter &)>;
548
549 using HandlesStmtFunc = bool (*)(const Stmt *D);
550
552 HandlesStmtFunc isForStmtFn);
554 HandlesStmtFunc isForStmtFn);
555
558
560
563
565
566 void _registerForBind(CheckBindFunc checkfn);
567
569
571
574
576
578
580
582
584
586
588
590
592
594
595 //===--------------------------------------------------------------------===//
596 // Internal registration functions for events.
597 //===--------------------------------------------------------------------===//
598
599 using EventTag = void *;
600 using CheckEventFunc = CheckerFn<void (const void *event)>;
601
602 template <typename EVENT>
604 EventInfo &info = Events[&EVENT::Tag];
605 info.Checkers.push_back(checkfn);
606 }
607
608 template <typename EVENT>
610 EventInfo &info = Events[&EVENT::Tag];
611 info.HasDispatcher = true;
612 }
613
614 template <typename EVENT>
615 void _dispatchEvent(const EVENT &event) const {
616 EventsTy::const_iterator I = Events.find(&EVENT::Tag);
617 if (I == Events.end())
618 return;
619 const EventInfo &info = I->second;
620 for (const auto &Checker : info.Checkers)
621 Checker(&event);
622 }
623
624 //===--------------------------------------------------------------------===//
625 // Implementation details.
626 //===--------------------------------------------------------------------===//
627
628private:
629 template <typename T>
630 static void *getTag() { static int tag; return &tag; }
631
632 llvm::DenseMap<CheckerTag, std::unique_ptr<CheckerBackend>> CheckerTags;
633
634 struct DeclCheckerInfo {
635 CheckDeclFunc CheckFn;
636 HandlesDeclFunc IsForDeclFn;
637 };
638 std::vector<DeclCheckerInfo> DeclCheckers;
639
640 std::vector<CheckDeclFunc> BodyCheckers;
641
642 using CachedDeclCheckers = SmallVector<CheckDeclFunc, 4>;
643 using CachedDeclCheckersMapTy = llvm::DenseMap<unsigned, CachedDeclCheckers>;
644 CachedDeclCheckersMapTy CachedDeclCheckersMap;
645
646 struct StmtCheckerInfo {
647 CheckStmtFunc CheckFn;
648 HandlesStmtFunc IsForStmtFn;
649 bool IsPreVisit;
650 };
651 std::vector<StmtCheckerInfo> StmtCheckers;
652
653 using CachedStmtCheckers = SmallVector<CheckStmtFunc, 4>;
654 using CachedStmtCheckersMapTy = llvm::DenseMap<unsigned, CachedStmtCheckers>;
655 CachedStmtCheckersMapTy CachedStmtCheckersMap;
656
657 const CachedStmtCheckers &getCachedStmtCheckersFor(const Stmt *S,
658 bool isPreVisit);
659
660 /// Returns the checkers that have registered for callbacks of the
661 /// given \p Kind.
662 const std::vector<CheckObjCMessageFunc> &
663 getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
664
665 std::vector<CheckObjCMessageFunc> PreObjCMessageCheckers;
666 std::vector<CheckObjCMessageFunc> PostObjCMessageCheckers;
667 std::vector<CheckObjCMessageFunc> ObjCMessageNilCheckers;
668
669 std::vector<CheckCallFunc> PreCallCheckers;
670 std::vector<CheckCallFunc> PostCallCheckers;
671
672 std::vector<CheckLocationFunc> LocationCheckers;
673
674 std::vector<CheckBindFunc> BindCheckers;
675
676 std::vector<CheckBlockEntranceFunc> BlockEntranceCheckers;
677
678 std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
679
680 std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;
681 std::vector<CheckEndFunctionFunc> EndFunctionCheckers;
682
683 std::vector<CheckBranchConditionFunc> BranchConditionCheckers;
684
685 std::vector<CheckNewAllocatorFunc> NewAllocatorCheckers;
686
687 std::vector<CheckLiveSymbolsFunc> LiveSymbolsCheckers;
688
689 std::vector<CheckDeadSymbolsFunc> DeadSymbolsCheckers;
690
691 std::vector<CheckRegionChangesFunc> RegionChangesCheckers;
692
693 std::vector<CheckPointerEscapeFunc> PointerEscapeCheckers;
694
695 std::vector<EvalAssumeFunc> EvalAssumeCheckers;
696
697 std::vector<EvalCallFunc> EvalCallCheckers;
698
699 std::vector<CheckEndOfTranslationUnit> EndOfTranslationUnitCheckers;
700
701 struct EventInfo {
702 SmallVector<CheckEventFunc, 4> Checkers;
703 bool HasDispatcher = false;
704
705 EventInfo() = default;
706 };
707
708 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
709 EventsTy Events;
710};
711
712} // namespace ento
713
714} // namespace clang
715
716#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::@1840::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: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:434
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:145
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3160
Stmt - This represents one statement.
Definition: Stmt.h:85
The top declaration context.
Definition: Decl.h:104
BugReporter is a utility class for generating PathDiagnostics for analysis.
Definition: BugReporter.h:586
Represents the memory allocation call in a C++ new-expression.
Definition: CallEvent.h:1119
Represents an abstract call to a function or method along a particular path.
Definition: CallEvent.h:153
CheckerBackend is an abstract base class that serves as the common ancestor of all the Checker<....
Definition: Checker.h:532
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:514
void _registerForLiveSymbols(CheckLiveSymbolsFunc checkfn)
void _registerForEndOfTranslationUnit(CheckEndOfTranslationUnit checkfn)
const AnalyzerOptions & getAnalyzerOptions() const
void _registerForBeginFunction(CheckBeginFunctionFunc checkfn)
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)
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)
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)
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
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 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 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.
const LangOptions & getLangOpts() const
void _registerForEvalCall(EvalCallFunc checkfn)
void _registerForEndFunction(CheckEndFunctionFunc checkfn)
void _registerForBlockEntrance(CheckBlockEntranceFunc checkfn)
void runCheckersForBranchCondition(const Stmt *condition, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers for branch condition.
CheckerNameRef getCurrentCheckerName() const
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)
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.
Simple checker classes that implement one frontend (i.e.
Definition: Checker.h:553
Represents any expression that calls an Objective-C method.
Definition: CallEvent.h:1250
Information about invalidation for a particular region/symbol.
Definition: MemRegion.h:1657
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.
#define bool
Definition: gpuintrin.h:32
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
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Definition: ModuleMapFile.h:36
The JSON file list parser is used to communicate input to InstallAPI.
int const char * function
Definition: c++config.h:31
Hints for figuring out of a call should be inlined during evalCall().
Definition: ExprEngine.h:97