clang 24.0.0git
CheckerManager.h
Go to the documentation of this file.
1//===- CheckerManager.h - Static Analyzer Checker Manager -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Defines the Static Analyzer Checker Manager.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
14#define LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
15
21#include "llvm/ADT/ArrayRef.h"
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/SmallVector.h"
24#include "llvm/ADT/StringRef.h"
25#include <vector>
26
27namespace clang {
28
29class AnalyzerOptions;
30class CallExpr;
31class Decl;
32class Stmt;
34
35namespace ento {
36
37class AnalysisManager;
39class BugReporter;
40class CallEvent;
41class CheckerFrontend;
42class CheckerBackend;
43class CheckerContext;
44class CheckerRegistry;
46class ExplodedGraph;
47class ExplodedNode;
48class ExplodedNodeSet;
49class ExprEngine;
50struct EvalCallOptions;
51class MemRegion;
52class ObjCMethodCall;
54class SVal;
55class SymbolReaper;
56
57template <typename T> class CheckerFn;
58
59template <typename RET, typename... Ps>
60class CheckerFn<RET(Ps...)> {
61 using Func = RET (*)(void *, Ps...);
62
63 Func Fn;
64
65public:
67
68 CheckerFn(CheckerBackend *checker, Func fn) : Fn(fn), Checker(checker) {}
69
70 RET operator()(Ps... ps) const {
71 return Fn(Checker, ps...);
72 }
73};
74
75/// Describes the different reasons a pointer escapes
76/// during analysis.
78 /// A pointer escapes due to binding its value to a location
79 /// that the analyzer cannot track.
81
82 /// The pointer has been passed to a function call directly.
84
85 /// The pointer has been passed to a function indirectly.
86 /// For example, the pointer is accessible through an
87 /// argument to a function.
89
90
91 /// Escape for a new symbol that was generated into a region
92 /// that the analyzer cannot follow during a conservative call.
94
95 /// The reason for pointer escape is unknown. For example,
96 /// a region containing this pointer is invalidated.
98};
99
100/// This wrapper is used to ensure that only StringRefs originating from the
101/// CheckerRegistry are used as check names. We want to make sure all checker
102/// name strings have a lifetime that keeps them alive at least until the path
103/// diagnostics have been processed, since they are expected to be constexpr
104/// string literals (most likely generated by TblGen).
105class CheckerNameRef {
106 friend class ::clang::ento::CheckerRegistry;
107
108 StringRef Name;
109
110 explicit CheckerNameRef(StringRef Name) : Name(Name) {}
111
112public:
113 CheckerNameRef() = default;
114
115 operator StringRef() const { return Name; }
116};
117
123
125 ASTContext *Context = nullptr;
126 const LangOptions LangOpts;
127 const AnalyzerOptions &AOptions;
128 const Preprocessor *PP = nullptr;
129 CheckerNameRef CurrentCheckerName;
130 DiagnosticsEngine &Diags;
131 std::unique_ptr<CheckerRegistryData> RegistryData;
132 /// Whether -ftime-trace is enabled. It cannot change during the analysis,
133 /// and caching it avoids querying the thread-local profiler instance for
134 /// every checker callback.
135 const bool TimeTraceEnabled;
136
137public:
138 // These constructors are defined in the Frontend library, because
139 // CheckerRegistry, a crucial component of the initialization is in there.
140 // CheckerRegistry cannot be moved to the Core library, because the checker
141 // registration functions are defined in the Checkers library, and the library
142 // dependencies look like this: Core -> Checkers -> Frontend.
143
145 ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP,
146 ArrayRef<std::string> plugins,
147 ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns);
148
149 /// Constructs a CheckerManager that ignores all non TblGen-generated
150 /// checkers. Useful for unit testing, unless the checker infrastructure
151 /// itself is tested.
153 const Preprocessor &PP)
154 : CheckerManager(Context, AOptions, PP, {}, {}) {}
155
156 /// Constructs a CheckerManager without requiring an AST. No checker
157 /// registration will take place. Only useful when one needs to print the
158 /// help flags through CheckerRegistryData, and the AST is unavailable.
159 CheckerManager(AnalyzerOptions &AOptions, const LangOptions &LangOpts,
160 DiagnosticsEngine &Diags, ArrayRef<std::string> plugins);
161
163
164 void setCurrentCheckerName(CheckerNameRef name) { CurrentCheckerName = name; }
165 CheckerNameRef getCurrentCheckerName() const { return CurrentCheckerName; }
166
167 bool isTimeTraceEnabled() const { return TimeTraceEnabled; }
168
169 bool hasPathSensitiveCheckers() const;
170
171 const LangOptions &getLangOpts() const { return LangOpts; }
172 const AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
174 assert(PP);
175 return *PP;
176 }
178 return *RegistryData;
179 }
180 DiagnosticsEngine &getDiagnostics() const { return Diags; }
182 assert(Context);
183 return *Context;
184 }
185
186 /// Emits an error through a DiagnosticsEngine about an invalid user supplied
187 /// checker option value.
189 StringRef OptionName,
190 StringRef ExpectedValueDesc) const;
191
192 using CheckerTag = const void *;
193
194 //===--------------------------------------------------------------------===//
195 // Checker registration.
196 //===--------------------------------------------------------------------===//
197
198 /// If the the singleton instance of a checker class is not yet constructed,
199 /// then construct it (with the supplied arguments), register it for the
200 /// callbacks that are supported by it, and return it. Otherwise, just return
201 /// a pointer to the existing instance.
202 template <typename CHECKER, typename... AT>
203 CHECKER *getChecker(AT &&...Args) {
204 CheckerTag Tag = getTag<CHECKER>();
205
206 std::unique_ptr<CheckerBackend> &Ref = getCheckerSlot(Tag);
207 if (!Ref) {
208 std::unique_ptr<CHECKER> Checker =
209 std::make_unique<CHECKER>(std::forward<AT>(Args)...);
210 CHECKER::_register(Checker.get(), *this);
211 Ref = std::move(Checker);
212 }
213
214 return static_cast<CHECKER *>(Ref.get());
215 }
216
217 /// Register a single-part checker (derived from `Checker`): construct its
218 /// singleton instance, register it for the supported callbacks and record
219 /// its name (with `CheckerFrontend::enable`). Calling this multiple times
220 /// triggers an assertion failure.
221 template <typename CHECKER, typename... AT>
222 CHECKER *registerChecker(AT &&...Args) {
223 CHECKER *Chk = getChecker<CHECKER>(std::forward<AT>(Args)...);
224 Chk->enable(*this);
225 return Chk;
226 }
227
228 template <typename CHECKER> bool isRegisteredChecker() {
229 return hasCheckerWithTag(getTag<CHECKER>());
230 }
231
232//===----------------------------------------------------------------------===//
233// Functions for running checkers for AST traversing.
234//===----------------------------------------------------------------------===//
235
236 /// Run checkers handling Decls.
237 void runCheckersOnASTDecl(const Decl *D, AnalysisManager& mgr,
238 BugReporter &BR);
239
240 /// Run checkers handling Decls containing a Stmt body.
241 void runCheckersOnASTBody(const Decl *D, AnalysisManager& mgr,
242 BugReporter &BR);
243
244//===----------------------------------------------------------------------===//
245// Functions for running checkers for path-sensitive checking.
246//===----------------------------------------------------------------------===//
247
248 /// Run checkers for pre-visiting Stmts.
249 ///
250 /// The notification is performed for every explored CFGElement, which does
251 /// not include the control flow statements such as IfStmt.
252 ///
253 /// \sa runCheckersForBranchCondition, runCheckersForPostStmt
255 const ExplodedNodeSet &Src,
256 const Stmt *S,
257 ExprEngine &Eng) {
258 runCheckersForStmt(/*isPreVisit=*/true, Dst, Src, S, Eng);
259 }
260
261 /// Run checkers for post-visiting Stmts.
262 ///
263 /// The notification is performed for every explored CFGElement, which does
264 /// not include the control flow statements such as IfStmt.
265 ///
266 /// \sa runCheckersForBranchCondition, runCheckersForPreStmt
268 const ExplodedNodeSet &Src,
269 const Stmt *S,
270 ExprEngine &Eng,
271 bool wasInlined = false) {
272 runCheckersForStmt(/*isPreVisit=*/false, Dst, Src, S, Eng, wasInlined);
273 }
274
275 /// Run checkers for visiting Stmts.
276 void runCheckersForStmt(bool isPreVisit,
277 ExplodedNodeSet &Dst, const ExplodedNodeSet &Src,
278 const Stmt *S, ExprEngine &Eng,
279 bool wasInlined = false);
280
281 /// Run checkers for pre-visiting obj-c messages.
283 const ExplodedNodeSet &Src,
284 const ObjCMethodCall &msg,
285 ExprEngine &Eng) {
287 }
288
289 /// Run checkers for post-visiting obj-c messages.
291 const ExplodedNodeSet &Src,
292 const ObjCMethodCall &msg,
293 ExprEngine &Eng,
294 bool wasInlined = false) {
296 wasInlined);
297 }
298
299 /// Run checkers for visiting an obj-c message to nil.
301 const ExplodedNodeSet &Src,
302 const ObjCMethodCall &msg,
303 ExprEngine &Eng) {
305 Eng);
306 }
307
308 /// Run checkers for visiting obj-c messages.
310 ExplodedNodeSet &Dst,
311 const ExplodedNodeSet &Src,
312 const ObjCMethodCall &msg, ExprEngine &Eng,
313 bool wasInlined = false);
314
315 /// Run checkers for pre-visiting function calls (including methods,
316 /// constructors, destructors etc. but excluding obj-c messages).
318 const CallEvent &Call, ExprEngine &Eng) {
319 runCheckersForCallEvent(/*isPreVisit=*/true, Dst, Src, Call, Eng);
320 }
321
322 /// Run checkers for post-visiting function calls (including methods,
323 /// constructors, destructors etc. but excluding obj-c messages).
325 const CallEvent &Call, ExprEngine &Eng,
326 bool wasInlined = false) {
327 runCheckersForCallEvent(/*isPreVisit=*/false, Dst, Src, Call, Eng,
328 wasInlined);
329 }
330
331 /// Run checkers for visiting function calls (including methods,
332 /// constructors, destructors etc. but excluding obj-c messages).
333 void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst,
334 const ExplodedNodeSet &Src,
335 const CallEvent &Call, ExprEngine &Eng,
336 bool wasInlined = false);
337
338 /// Run checkers for the end of a variable's lifetime.
340 const ExplodedNodeSet &Src,
341 const VarDecl *Decl, ExprEngine &Eng);
342
343 /// Run checkers for load/store of a location.
345 const ExplodedNodeSet &Src,
346 SVal location,
347 bool isLoad,
348 const Stmt *NodeEx,
349 const Stmt *BoundEx,
350 ExprEngine &Eng);
351
352 /// Run checkers for binding of a value to a location.
354 SVal location, SVal val, const Stmt *S,
355 bool AtDeclInit, ExprEngine &Eng,
356 const ProgramPoint &PP);
357
358 /// Run checkers after taking a control flow edge.
360 const ExplodedNodeSet &Src,
361 const BlockEntrance &Entrance,
362 ExprEngine &Eng) const;
363
364 /// Run checkers for end of analysis.
366 ExprEngine &Eng);
367
368 /// Run checkers on beginning of function.
370 const BlockEdge &L,
371 ExplodedNode *Pred,
372 ExprEngine &Eng);
373
374 /// Run checkers on end of function.
376 ExprEngine &Eng, const ReturnStmt *RS);
377
378 /// Run checkers for branch condition.
380 ExplodedNodeSet &Dst, ExplodedNode *Pred,
381 ExprEngine &Eng);
382
383 /// Run checkers between C++ operator new and constructor calls.
385 ExplodedNodeSet &Dst, ExplodedNode *Pred,
386 ExprEngine &Eng, bool wasInlined = false);
387
388 /// Run checkers for live symbols.
389 ///
390 /// Allows modifying SymbolReaper object. For example, checkers can explicitly
391 /// register symbols of interest as live. These symbols will not be marked
392 /// dead and removed.
394 SymbolReaper &SymReaper);
395
396 /// Run checkers for dead symbols.
397 ///
398 /// Notifies checkers when symbols become dead. For example, this allows
399 /// checkers to aggressively clean up/reduce the checker state and produce
400 /// precise diagnostics.
402 const ExplodedNodeSet &Src,
403 SymbolReaper &SymReaper, const Stmt *S,
404 ExprEngine &Eng,
406
407 /// Run checkers for region changes.
408 ///
409 /// This corresponds to the check::RegionChanges callback.
410 /// \param state The current program state.
411 /// \param invalidated A set of all symbols potentially touched by the change.
412 /// \param ExplicitRegions The regions explicitly requested for invalidation.
413 /// For example, in the case of a function call, these would be arguments.
414 /// \param Regions The transitive closure of accessible regions,
415 /// i.e. all regions that may have been touched by this change.
416 /// \param Call The call expression wrapper if the regions are invalidated
417 /// by a call.
420 const InvalidatedSymbols *invalidated,
421 ArrayRef<const MemRegion *> ExplicitRegions,
423 const StackFrame *SF, const CallEvent *Call);
424
425 /// Run checkers when pointers escape.
426 ///
427 /// This notifies the checkers about pointer escape, which occurs whenever
428 /// the analyzer cannot track the symbol any more. For example, as a
429 /// result of assigning a pointer into a global or when it's passed to a
430 /// function call the analyzer cannot model.
431 ///
432 /// \param State The state at the point of escape.
433 /// \param Escaped The list of escaped symbols.
434 /// \param Call The corresponding CallEvent, if the symbols escape as
435 /// parameters to the given call.
436 /// \param Kind The reason of pointer escape.
437 /// \param ITraits Information about invalidation for a particular
438 /// region/symbol.
439 /// \returns Checkers can modify the state by returning a new one.
442 const InvalidatedSymbols &Escaped,
443 const CallEvent *Call,
446
447 /// Run checkers for handling assumptions on symbolic values.
449 SVal Cond, bool Assumption);
450
451 /// Run checkers for evaluating a call.
452 ///
453 /// Warning: Currently, the CallEvent MUST come from a CallExpr!
455 const CallEvent &CE, ExprEngine &Eng,
456 const EvalCallOptions &CallOpts);
457
458 /// Run checkers for the entire Translation Unit.
460 AnalysisManager &mgr,
461 BugReporter &BR);
462
463 /// Run checkers for debug-printing a ProgramState.
464 ///
465 /// Unlike most other callbacks, any checker can simply implement the virtual
466 /// method CheckerBackend::printState if it has custom data to print.
467 ///
468 /// \param Out The output stream
469 /// \param State The state being printed
470 /// \param NL The preferred representation of a newline.
471 /// \param Space The preferred space between the left side and the message.
472 /// \param IsDot Whether the message will be printed in 'dot' format.
473 void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State,
474 const char *NL = "\n",
475 unsigned int Space = 0,
476 bool IsDot = false) const;
477
478 //===--------------------------------------------------------------------===//
479 // Internal registration functions for AST traversing.
480 //===--------------------------------------------------------------------===//
481
482 // Functions used by the registration mechanism, checkers should not touch
483 // these directly.
484
486 CheckerFn<void (const Decl *, AnalysisManager&, BugReporter &)>;
487
488 using HandlesDeclFunc = bool (*)(const Decl *D);
489
490 void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn);
491
492 void _registerForBody(CheckDeclFunc checkfn);
493
494 //===--------------------------------------------------------------------===//
495 // Internal registration functions for path-sensitive checking.
496 //===--------------------------------------------------------------------===//
497
498 using CheckStmtFunc = CheckerFn<void (const Stmt *, CheckerContext &)>;
499
501 CheckerFn<void (const ObjCMethodCall &, CheckerContext &)>;
502
504 CheckerFn<void (const CallEvent &, CheckerContext &)>;
505
507 CheckerFn<void(const VarDecl *, CheckerContext &)>;
508
509 using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
510 const Stmt *S, CheckerContext &)>;
511
512 using CheckBindFunc = CheckerFn<void(SVal location, SVal val, const Stmt *S,
513 bool AtDeclInit, CheckerContext &)>;
514
516 CheckerFn<void(const BlockEntrance &, CheckerContext &)>;
517
520
522
524 CheckerFn<void (const ReturnStmt *, CheckerContext &)>;
525
527 CheckerFn<void (const Stmt *, CheckerContext &)>;
528
531
534
536
538 ProgramStateRef, const InvalidatedSymbols *symbols,
539 ArrayRef<const MemRegion *> ExplicitRegions,
540 ArrayRef<const MemRegion *> Regions, const StackFrame *SF,
541 const CallEvent *Call)>;
542
545 const InvalidatedSymbols &Escaped,
546 const CallEvent *Call, PointerEscapeKind Kind,
548
550 CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;
551
553
556 BugReporter &)>;
557
558 using HandlesStmtFunc = bool (*)(const Stmt *D);
559
561 HandlesStmtFunc isForStmtFn);
563 HandlesStmtFunc isForStmtFn);
564
567
569
572
574
576
577 void _registerForBind(CheckBindFunc checkfn);
578
580
582
585
587
589
591
593
595
597
599
601
603
605
606 //===--------------------------------------------------------------------===//
607 // Internal registration functions for events.
608 //===--------------------------------------------------------------------===//
609
610 using EventTag = void *;
611 using CheckEventFunc = CheckerFn<void (const void *event)>;
612
613 template <typename EVENT>
615 EventInfo &info = Events[&EVENT::Tag];
616 info.Checkers.push_back(checkfn);
617 }
618
619 template <typename EVENT>
621 EventInfo &info = Events[&EVENT::Tag];
622 info.HasDispatcher = true;
623 }
624
625 template <typename EVENT>
626 void _dispatchEvent(const EVENT &event) const {
627 EventsTy::const_iterator I = Events.find(&EVENT::Tag);
628 if (I == Events.end())
629 return;
630 const EventInfo &info = I->second;
631 for (const auto &Checker : info.Checkers)
632 Checker(&event);
633 }
634
635 //===--------------------------------------------------------------------===//
636 // Implementation details.
637 //===--------------------------------------------------------------------===//
638
639private:
640 /// Out-of-line accessors of `CheckerTags`, so that the `DenseMap`
641 /// instantiations are not repeated in every checker's translation unit.
642 std::unique_ptr<CheckerBackend> &getCheckerSlot(CheckerTag Tag);
643 bool hasCheckerWithTag(CheckerTag Tag) const;
644
645 template <typename T>
646 static void *getTag() { static int tag; return &tag; }
647
648 llvm::DenseMap<CheckerTag, std::unique_ptr<CheckerBackend>> CheckerTags;
649
650 /// The checkers registered for each kind of callback. They live in a
651 /// separate struct, defined in CheckerManager.cpp, because every checker
652 /// translation unit includes this header, and instantiating that many
653 /// distinct std::vector<CheckerFn<...>> types is expensive.
654 struct CallbackLists;
655 struct CallbackListsDeleter {
656 void operator()(CallbackLists *Lists) const;
657 };
658 static CallbackLists *createCallbackLists();
659 std::unique_ptr<CallbackLists, CallbackListsDeleter> Lists{
660 createCallbackLists()};
661
662 struct EventInfo {
663 SmallVector<CheckEventFunc, 4> Checkers;
664 bool HasDispatcher = false;
665
666 EventInfo() = default;
667 };
668
669 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
670 EventsTy Events;
671};
672
673} // namespace ento
674
675} // namespace clang
676
677#endif // LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
Defines the Diagnostic-related interfaces.
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN)
Defines the clang::LangOptions interface.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a an optional score condition
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:246
Stores options for the analyzer from the command line.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:3012
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:240
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3173
It represents a stack frame of the call stack.
Stmt - This represents one statement.
Definition Stmt.h:85
The top declaration context.
Definition Decl.h:107
Represents a variable declaration or definition.
Definition Decl.h:934
BugReporter is a utility class for generating PathDiagnostics for analysis.
Represents the memory allocation call in a C++ new-expression.
Definition CallEvent.h:1098
Represents an abstract call to a function or method along a particular path.
Definition CallEvent.h:151
CheckerBackend is an abstract base class that serves as the common ancestor of all the Checker<....
Definition Checker.h:544
CheckerFn(CheckerBackend *checker, Func fn)
A CheckerFrontend instance is what the user recognizes as "one checker": it has a public canonical na...
Definition Checker.h:526
void _registerForLiveSymbols(CheckLiveSymbolsFunc checkfn)
void _registerForEndOfTranslationUnit(CheckEndOfTranslationUnit checkfn)
const AnalyzerOptions & getAnalyzerOptions() const
ProgramStateRef runCheckersForRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const StackFrame *SF, const CallEvent *Call)
Run checkers for region changes.
void _registerForBeginFunction(CheckBeginFunctionFunc checkfn)
void _registerForNewAllocator(CheckNewAllocatorFunc checkfn)
CheckerFn< void(const Decl *, AnalysisManager &, BugReporter &)> CheckDeclFunc
void runCheckersForPreObjCMessage(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for pre-visiting obj-c messages.
void _registerForPreCall(CheckCallFunc checkfn)
CheckerFn< ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)> EvalAssumeFunc
void _registerForObjCMessageNil(CheckObjCMessageFunc checkfn)
CheckerFn< ProgramStateRef(ProgramStateRef, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)> CheckPointerEscapeFunc
bool(*)(const Decl *D) HandlesDeclFunc
void runCheckersForObjCMessage(ObjCMessageVisitKind visitKind, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting obj-c messages.
void runCheckersOnASTDecl(const Decl *D, AnalysisManager &mgr, BugReporter &BR)
Run checkers handling Decls.
void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn)
CheckerFn< void(const ReturnStmt *, CheckerContext &)> CheckEndFunctionFunc
CheckerFn< void(const Stmt *, CheckerContext &)> CheckBranchConditionFunc
void _registerForPreObjCMessage(CheckObjCMessageFunc checkfn)
void runCheckersOnEndOfTranslationUnit(const TranslationUnitDecl *TU, AnalysisManager &mgr, BugReporter &BR)
Run checkers for the entire Translation Unit.
CheckerFn< bool(const CallEvent &, CheckerContext &)> EvalCallFunc
CheckerFn< void(CheckerContext &)> CheckBeginFunctionFunc
ASTContext & getASTContext() const
CheckerFn< void(const void *event)> CheckEventFunc
void _registerListenerForEvent(CheckEventFunc checkfn)
CheckerFn< void(ExplodedGraph &, BugReporter &, ExprEngine &)> CheckEndAnalysisFunc
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
void _registerForEvalAssume(EvalAssumeFunc checkfn)
void _registerForEndAnalysis(CheckEndAnalysisFunc checkfn)
void _registerForBody(CheckDeclFunc checkfn)
DiagnosticsEngine & getDiagnostics() const
void runCheckersForLocation(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, bool isLoad, const Stmt *NodeEx, const Stmt *BoundEx, ExprEngine &Eng)
Run checkers for load/store of a location.
const CheckerRegistryData & getCheckerRegistryData() const
CheckerFn< void(const Stmt *, CheckerContext &)> CheckStmtFunc
CheckerFn< void(SVal location, SVal val, const Stmt *S, bool AtDeclInit, CheckerContext &)> CheckBindFunc
void runCheckersForBind(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, SVal val, const Stmt *S, bool AtDeclInit, ExprEngine &Eng, const ProgramPoint &PP)
Run checkers for binding of a value to a location.
void reportInvalidCheckerOptionValue(const CheckerFrontend *Checker, StringRef OptionName, StringRef ExpectedValueDesc) const
Emits an error through a DiagnosticsEngine about an invalid user supplied checker option value.
void runCheckersForEndAnalysis(ExplodedGraph &G, BugReporter &BR, ExprEngine &Eng)
Run checkers for end of analysis.
CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP)
Constructs a CheckerManager that ignores all non TblGen-generated checkers.
void runCheckersForPreCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng)
Run checkers for pre-visiting function calls (including methods, constructors, destructors etc.
CheckerFn< void(const CXXAllocatorCall &Call, CheckerContext &)> CheckNewAllocatorFunc
CheckerFn< void(const VarDecl *, CheckerContext &)> CheckLifetimeEndFunc
void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\n", unsigned int Space=0, bool IsDot=false) const
Run checkers for debug-printing a ProgramState.
void _registerForDeadSymbols(CheckDeadSymbolsFunc checkfn)
void runCheckersForDeadSymbols(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SymbolReaper &SymReaper, const Stmt *S, ExprEngine &Eng, ProgramPoint::Kind K)
Run checkers for dead symbols.
void _registerForPostObjCMessage(CheckObjCMessageFunc checkfn)
void _registerForRegionChanges(CheckRegionChangesFunc checkfn)
void runCheckersForEndFunction(ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, const ReturnStmt *RS)
Run checkers on end of function.
void _registerForBind(CheckBindFunc checkfn)
void runCheckersForLiveSymbols(ProgramStateRef state, SymbolReaper &SymReaper)
Run checkers for live symbols.
void _registerForPointerEscape(CheckPointerEscapeFunc checkfn)
CheckerFn< void(const TranslationUnitDecl *, AnalysisManager &, BugReporter &)> CheckEndOfTranslationUnit
void _registerForPreStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void runCheckersForEvalCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &CE, ExprEngine &Eng, const EvalCallOptions &CallOpts)
Run checkers for evaluating a call.
void _registerForPostStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void runCheckersForPostObjCMessage(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting obj-c messages.
void runCheckersForBeginFunction(ExplodedNodeSet &Dst, const BlockEdge &L, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers on beginning of function.
void runCheckersForPostStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting Stmts.
void runCheckersForNewAllocator(const CXXAllocatorCall &Call, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, bool wasInlined=false)
Run checkers between C++ operator new and constructor calls.
CheckerFn< void(const CallEvent &, CheckerContext &)> CheckCallFunc
void runCheckersForPreStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng)
Run checkers for pre-visiting Stmts.
void _registerForBranchCondition(CheckBranchConditionFunc checkfn)
CheckerFn< void(SymbolReaper &, CheckerContext &)> CheckDeadSymbolsFunc
CheckerFn< void(SVal location, bool isLoad, const Stmt *S, CheckerContext &)> CheckLocationFunc
void runCheckersForObjCMessageNil(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for visiting an obj-c message to nil.
void runCheckersForBlockEntrance(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const BlockEntrance &Entrance, ExprEngine &Eng) const
Run checkers after taking a control flow edge.
void _dispatchEvent(const EVENT &event) const
void runCheckersForStmt(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting Stmts.
CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP, ArrayRef< std::string > plugins, ArrayRef< std::function< void(CheckerRegistry &)> > checkerRegistrationFns)
const LangOptions & getLangOpts() const
void _registerForEvalCall(EvalCallFunc checkfn)
void _registerForEndFunction(CheckEndFunctionFunc checkfn)
void _registerForBlockEntrance(CheckBlockEntranceFunc checkfn)
CheckerFn< ProgramStateRef( ProgramStateRef, const InvalidatedSymbols *symbols, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const StackFrame *SF, const CallEvent *Call)> CheckRegionChangesFunc
void runCheckersForBranchCondition(const Stmt *condition, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers for branch condition.
CheckerNameRef getCurrentCheckerName() const
CheckerFn< void(const ObjCMethodCall &, CheckerContext &)> CheckObjCMessageFunc
CHECKER * getChecker(AT &&...Args)
If the the singleton instance of a checker class is not yet constructed, then construct it (with the ...
void _registerForLocation(CheckLocationFunc checkfn)
ProgramStateRef runCheckersForPointerEscape(ProgramStateRef State, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)
Run checkers when pointers escape.
void _registerForConstPointerEscape(CheckPointerEscapeFunc checkfn)
CheckerFn< void(const BlockEntrance &, CheckerContext &)> CheckBlockEntranceFunc
CheckerFn< void(ProgramStateRef, SymbolReaper &)> CheckLiveSymbolsFunc
void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting function calls (including methods, constructors, destructors etc.
bool(*)(const Stmt *D) HandlesStmtFunc
void _registerForPostCall(CheckCallFunc checkfn)
void runCheckersOnASTBody(const Decl *D, AnalysisManager &mgr, BugReporter &BR)
Run checkers handling Decls containing a Stmt body.
void runCheckersForLifetimeEnd(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const VarDecl *Decl, ExprEngine &Eng)
Run checkers for the end of a variable's lifetime.
void runCheckersForPostCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting function calls (including methods, constructors, destructors etc.
void _registerForLifetimeEnd(CheckLifetimeEndFunc checkfn)
void setCurrentCheckerName(CheckerNameRef name)
ProgramStateRef runCheckersForEvalAssume(ProgramStateRef state, SVal Cond, bool Assumption)
Run checkers for handling assumptions on symbolic values.
const Preprocessor & getPreprocessor() const
This wrapper is used to ensure that only StringRefs originating from the CheckerRegistry are used as ...
Manages a set of available checkers for running a static analysis.
Simple checker classes that implement one frontend (i.e.
Definition Checker.h:565
ExplodedNodeSet is a set of ExplodedNode * elements with the invariant that its elements cannot be nu...
MemRegion - The root abstract class for all memory regions.
Definition MemRegion.h:97
Represents any expression that calls an Objective-C method.
Definition CallEvent.h:1225
Information about invalidation for a particular region/symbol.
Definition MemRegion.h:1664
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition SVals.h:57
A class responsible for cleaning up unused symbols.
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
@ PSK_DirectEscapeOnCall
The pointer has been passed to a function call directly.
@ PSK_EscapeOnBind
A pointer escapes due to binding its value to a location that the analyzer cannot track.
@ PSK_IndirectEscapeOnCall
The pointer has been passed to a function indirectly.
@ PSK_EscapeOther
The reason for pointer escape is unknown.
@ PSK_EscapeOutParameters
Escape for a new symbol that was generated into a region that the analyzer cannot follow during a con...
llvm::DenseSet< SymbolRef > InvalidatedSymbols
Definition Store.h:50
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
Top level wrappers for InstallAPI frontend operations.
int const char * function
Definition c++config.h:31
Hints for figuring out if a call should be inlined during evalCall().
Definition ExprEngine.h:93