Go to the documentation of this file.
14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERCONTEXT_H
15 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERCONTEXT_H
53 "We should not call the checkers on an empty state.");
144 return reinterpret_cast<const MemRegion*
>(PSL->getLocationValue());
183 return addTransitionImpl(
State,
false, Pred, Tag);
212 (Tag ? Tag : Location.
getTag()));
228 (Tag ? Tag : Location.
getTag()));
276 LLVM_ATTRIBUTE_RETURNS_NONNULL
290 bool IsPrunable =
false) {
305 bool IsPrunable =
false) {
333 bool IsPrunable =
false) {
337 llvm::raw_svector_ostream
OS(Str);
380 StringRef Name = StringRef());
StringRef getCalleeName(const CallExpr *CE) const
Get the name of the called function (path-sensitive).
ProgramStateManager & getStateManager()
ProgramPoint withTag(const ProgramPointTag *tag) const
Create a new ProgramPoint object that is the same as the original except for using the specified tag ...
const LocationContext * getLocationContext() const
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const ASTContext & getASTContext() const
ExplodedNode * generateErrorNode(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
StringRef getDeclDescription(const Decl *D)
Returns the word that should be used to refer to the declaration in the report.
const NoteTag * getNoteTag(StringRef Note, bool IsPrunable=false)
A shorthand version of getNoteTag that accepts a plain note.
DataTag::Factory & getDataTags()
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
Encodes a location in the source.
ASTContext & getContext() const
getContext - Return the ASTContext associated with this analysis.
const LocationContext * getLocationContext() const
unsigned getBlockID() const
const FunctionDecl * getCalleeDecl(const CallExpr *CE) const
Get the declaration of the called function (path-sensitive).
AnalysisDeclContext contains the context data for the function, method or block under analysis.
const StackFrameContext * getStackFrame() const
ExplodedNode * generateNonFatalErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
StoreManager & getStoreManager()
const NoteTag * getNoteTag(std::function< std::string()> &&Cb, bool IsPrunable=false)
A shorthand version of getNoteTag that doesn't require you to accept the arguments when you don't nee...
void addSink(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Add a sink node to the current path of execution, halting analysis.
static const MemRegion * getLocationRegionIfPostStore(const ExplodedNode *N)
If the given node corresponds to a PostStore program point, retrieve the location region as it was ut...
bool isGreaterOrEqual(const Expr *E, unsigned long long Val)
Returns true if the value of E is greater than or equal to Val under unsigned comparison.
It represents a stack frame of the call stack (based on CallEvent).
AnalysisDeclContext * getCurrentAnalysisDeclContext() const
ExplodedNode * generateErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
const ProgramStateRef & getState() const
Preprocessor & getPreprocessor()
This class handles loading and caching of source files into memory.
MemRegion - The root abstract class for all memory regions.
const IdentifierInfo * getCalleeIdentifier(const CallExpr *CE) const
Get the identifier of the called function (path-sensitive).
const ProgramStateRef & getState() const
ExplodedNode * generateSink(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a sink in the ExplodedGraph.
virtual void emitReport(std::unique_ptr< BugReport > R)
Add the given report to the set of reports tracked by BugReporter.
Preprocessor & getPreprocessor()
const DataTagType * make(Args &&... ConstructorArgs)
virtual bool inTopFrame() const
AnalysisManager & getAnalysisManager()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
StringRef getCalleeName(const FunctionDecl *FunDecl) const
Get the name of the called function (path-sensitive).
const ProgramPointTag * getTag() const
Represents a program point after a store evaluation.
SymbolManager & getSymbolManager()
const NoteTag * getNoteTag(std::function< void(PathSensitiveBugReport &BR, llvm::raw_ostream &OS)> &&Cb, bool IsPrunable=false)
A shorthand version of getNoteTag that accepts a lambda with stream for note.
ExplodedNode * addTransition(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generates a new transition in the program state graph (ExplodedGraph).
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
bool inTopFrame() const
Return true if the current LocationContext has no caller context.
BugReporter is a utility class for generating PathDiagnostics for analysis.
unsigned blockCount() const
Returns the number of times the current basic block has been visited on the exploded graph path.
StringRef getMacroNameOrSpelling(SourceLocation &Loc)
Depending on wither the location corresponds to a macro, return either the macro name or the token sp...
ProgramStateManager & getStateManager()
const SourceManager & getSourceManager()
const LangOptions & getLangOpts() const
SValBuilder & getSValBuilder()
ExplodedNode * getPredecessor()
Returns the previous node in the exploded graph, which includes the state of the program before the c...
ConstraintManager & getConstraintManager()
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
const NodeBuilderContext & getContext()
const NoteTag * getNoteTag(std::function< std::string(PathSensitiveBugReport &)> &&Cb, bool IsPrunable=false)
A shorthand version of getNoteTag that doesn't require you to accept the 'BugReporterContext' argumen...
const SourceManager & getSourceManager()
ASTContext & getASTContext()
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
Decl - This represents one declaration (or definition), e.g.
SValBuilder & getSValBuilder()
BugReporter & getBugReporter()
One of these records is kept for each identifier that is lexed.
AnalysisManager & getAnalysisManager()
static bool isCLibraryFunction(const FunctionDecl *FD, StringRef Name=StringRef())
Returns true if the callee is an externally-visible function in the top-level namespace,...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
ExplodedNode * addTransition(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
Generates a new transition with the given predecessor.
BugReporter & getBugReporter()
StoreManager & getStoreManager()
bool isNegative(const Expr *E)
Returns true if the value of E is negative.
ExplodedNode * generateNonFatalErrorNode(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
const StackFrameContext * getStackFrame() const
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
Stmt - This represents one statement.
ExplodedNode * generateNode(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a node in the ExplodedGraph.
ExplodedNode * generateSink(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
Generate a sink node.
const CFGBlock * getBlock() const
Return the CFGBlock associated with this builder.
unsigned getBlockID() const
Get the blockID.
SVal getSVal(const Stmt *S) const
Get the value of an arbitrary expression at this node.
SymbolManager & getSymbolManager()
CheckerContext(NodeBuilder &builder, ExprEngine &eng, ExplodedNode *pred, const ProgramPoint &loc, bool wasInlined=false)
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
This represents one expression.
ConstraintManager & getConstraintManager()
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const LLVM_ATTRIBUTE_RETURNS_NONNULL NoteTag * getNoteTag(NoteTag::Callback &&Cb, bool IsPrunable=false)
Produce a program point tag that displays an additional path note to the user.
const bool wasInlined
If we are post visiting a call, this flag will be set if the call was inlined.
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
The tag upon which the TagVisitor reacts.
std::function< std::string(BugReporterContext &, PathSensitiveBugReport &)> Callback
Represents a function declaration or definition.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
unsigned blockCount() const
Returns the number of times the current block has been visited along the analyzed path.
const LangOptions & getLangOpts() const
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
bool isDifferent()
Check if the checker changed the state of the execution; ex: added a new transition or a bug report.