clang 24.0.0git
clang::ento::CheckerContext Class Reference

#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"

Public Member Functions

 CheckerContext (ExprEngine &Eng, ExplodedNode *Pred, ExplodedNodeSet &Dst, const ProgramPoint &Loc, bool WasInlined=false)
AnalysisManager & getAnalysisManager ()
const AnalysisManager & getAnalysisManager () const
ConstraintManager & getConstraintManager ()
const ConstraintManager & getConstraintManager () const
StoreManager & getStoreManager ()
const StoreManager & getStoreManager () const
ExplodedNode * getPredecessor () const
 Returns the previous node in the exploded graph, which includes the state of the program before the checker ran.
const ProgramPoint getLocation () const
const ProgramStateRef & getState () const
bool isDifferent () const
 Check if the checker changed the state of the execution; ex: added a new transition or a bug report.
unsigned blockCount () const
 Returns the number of times the current block has been visited along the analyzed path.
ASTContext & getASTContext ()
const ASTContext & getASTContext () const
const LangOptions & getLangOpts () const
const StackFrame * getStackFrame () const
llvm::iterator_range< StackFrame::parent_iterator > stackframes () const
 Iterates over the current stack frame and all of its ancestors.
bool inTopFrame () const
 Return true if the current StackFrame has no caller context.
BugReporter & getBugReporter ()
const BugReporter & getBugReporter () const
const SourceManager & getSourceManager ()
const SourceManager & getSourceManager () const
Preprocessor & getPreprocessor ()
const Preprocessor & getPreprocessor () const
SValBuilder & getSValBuilder ()
const SValBuilder & getSValBuilder () const
SymbolManager & getSymbolManager ()
const SymbolManager & getSymbolManager () const
ProgramStateManager & getStateManager ()
const ProgramStateManager & getStateManager () const
AnalysisDeclContext * getCurrentAnalysisDeclContext () const
unsigned getBlockID () const
 Get the blockID.
SVal getSVal (const Expr *E) const
 Get the value of arbitrary expressions at this point in the path.
ConstCFGElementRef getCFGElementRef () const
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.
bool isNegative (const Expr *E)
 Returns true if the value of E is negative.
ExplodedNode * addTransition (ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
 Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of 'getPredecessor()', the node that was passed to the constructor of CheckerContext.
ExplodedNode * addTransition (ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
 Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of the parameter Pred.
ExplodedNode * addSink (ProgramStateRef State=nullptr, ExplodedNode *Pred=nullptr, const ProgramPointTag *Tag=nullptr)
 Creates a new ExplodedNode which is marked as a sink and adds it to the ExplodedGraph.
ExplodedNode * generateNonFatalErrorNode (ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
 Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of 'getPredecessor()', the node that was passed to the constructor of CheckerContext.
ExplodedNode * generateNonFatalErrorNode (ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
 Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of the parameter Pred.
void emitReport (std::unique_ptr< BugReport > R)
 Emit the diagnostics report.
LLVM_ATTRIBUTE_RETURNS_NONNULL const NoteTag * getNoteTag (NoteTag::Callback &&Cb, bool IsPrunable=false)
 Produce a program point tag that displays an additional path note to the user.
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' argument when you don't need it.
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 need it.
const NoteTag * getNoteTag (StringRef Note, bool IsPrunable=false)
 A shorthand version of getNoteTag that accepts a plain note.
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.
StringRef getDeclDescription (const Decl *D)
 Returns the word that should be used to refer to the declaration in the report.
const FunctionDecl * getCalleeDecl (const CallExpr *CE) const
 Get the declaration of the called function (path-sensitive).
StringRef getCalleeName (const FunctionDecl *FunDecl) const
 Get the name of the called function (path-sensitive).
const IdentifierInfo * getCalleeIdentifier (const CallExpr *CE) const
 Get the identifier of the called function (path-sensitive).
StringRef getCalleeName (const CallExpr *CE) const
 Get the name of the called function (path-sensitive).
std::string getMacroNameOrSpelling (SourceLocation &Loc)
 Depending on whether the location corresponds to a macro, return either the macro name or the token spelling.

Static Public Member Functions

static const MemRegion * getLocationRegionIfPostStore (const ExplodedNode *N)
 If the given node corresponds to a PostStore program point, retrieve the location region as it was uttered in the code.
static bool isCLibraryFunction (const FunctionDecl *FD, StringRef Name=StringRef())
 Returns true if the given function is an externally-visible function in the top-level namespace, such as malloc.
static bool isHardenedVariantOf (const FunctionDecl *FD, StringRef Name)
 In builds that use source hardening (-D_FORTIFY_SOURCE), many standard functions are implemented as macros that expand to calls of hardened functions that take additional arguments compared to the "usual" variant and perform additional input validation.

Public Attributes

const bool wasInlined
 If we are post visiting a call, this flag will be set if the call was inlined.

Detailed Description

Definition at line 24 of file CheckerContext.h.

Constructor & Destructor Documentation

◆ CheckerContext()

clang::ento::CheckerContext::CheckerContext ( ExprEngine & Eng,
ExplodedNode * Pred,
ExplodedNodeSet & Dst,
const ProgramPoint & Loc,
bool WasInlined = false )
inline

Definition at line 47 of file CheckerContext.h.

References false, and wasInlined.

Member Function Documentation

◆ addSink()

ExplodedNode * clang::ento::CheckerContext::addSink ( ProgramStateRef State = nullptr,
ExplodedNode * Pred = nullptr,
const ProgramPointTag * Tag = nullptr )
inline

Creates a new ExplodedNode which is marked as a sink and adds it to the ExplodedGraph.

A sink node terminates the execution path: it cannot have children and prevents the default behavior that the path "passes through" the checker callback without changes if the checker doesn't create any node. Can return nullptr if the node creation fails (when it would recreate an existing node or when the state is posteriorly overconstrained).

Parameters
StateThe state of the generated sink node; nullptr (the default) means keeping the state of the parent node.
PredThe node that will become the predecessor of the new node; nullptr (the default) means the node that was passed to the constructor of CheckerContext.
TagA ProgramPointTag that will be attached to the node; nullptr (the default) means using the active checker as the tag. Using another tag has no compelling use case (apart from debugging).

Definition at line 247 of file CheckerContext.h.

Referenced by clang::ento::retaincountchecker::RetainCountChecker::handleAutoreleaseCounts().

◆ addTransition() [1/2]

ExplodedNode * clang::ento::CheckerContext::addTransition ( ProgramStateRef State,
ExplodedNode * Pred,
const ProgramPointTag * Tag = nullptr )
inline

Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of the parameter Pred.

Allows checkers to make a chain of nodes. Can return nullptr if the node creation fails (when it would recreate an existing node or when the state is posteriorly overconstrained).

Can return getPredecessor(), the node that was passed to the constructor of CheckerContext (often the ancestor of Pred) in some corner cases. FIXME: This is bad logic and should be fixed in the next non-NFC change.

Parameters
StateThe state of the generated node.
PredThe node that will become the predecessor of the new node.
TagA ProgramPointTag that will be attached to the node. This is primarily useful for attaching a NoteTag; but another tag could be used as a workaround when the node wouldn't be unique otherwise. When Tag is nullptr, node creation will default to using the active checker as the tag.

Definition at line 217 of file CheckerContext.h.

References getPredecessor(), and getState().

◆ addTransition() [2/2]

ExplodedNode * clang::ento::CheckerContext::addTransition ( ProgramStateRef State = nullptr,
const ProgramPointTag * Tag = nullptr )
inline

Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of 'getPredecessor()', the node that was passed to the constructor of CheckerContext.

Can return nullptr if the node creation fails (when it would recreate an existing node or when the state is posteriorly overconstrained). Can return 'getPredecessor()' instead of creating a node when the state would remain unchanged and there is no explicitly specified tag.

Parameters
StateThe state of the generated node. Passing nullptr is handled as passing 'getState()' (the state of 'getPredecessor()').
TagA ProgramPointTag that will be attached to the node. This is primarily useful for attaching a NoteTag; but another tag could be used as a workaround when the node wouldn't be unique otherwise. When Tag is nullptr, node creation will default to using the active checker as the tag – but if there is no state change, the predecessor node may be returned even if it isn't tagged so.

Definition at line 194 of file CheckerContext.h.

References getPredecessor(), and getState().

Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkBeginFunction(), clang::ento::mpi::MPIChecker::checkDoubleNonblocking(), clang::ento::mpi::MPIChecker::checkMissingWaits(), clang::ento::mpi::MPIChecker::checkUnmatchedWaits(), and clang::ento::retaincountchecker::RetainCountChecker::processLeaks().

◆ blockCount()

unsigned clang::ento::CheckerContext::blockCount ( ) const
inline

Returns the number of times the current block has been visited along the analyzed path.

Definition at line 89 of file CheckerContext.h.

◆ emitReport()

void clang::ento::CheckerContext::emitReport ( std::unique_ptr< BugReport > R)
inline

◆ generateNonFatalErrorNode() [1/2]

ExplodedNode * clang::ento::CheckerContext::generateNonFatalErrorNode ( ProgramStateRef State,
ExplodedNode * Pred,
const ProgramPointTag * Tag = nullptr )
inline

Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of the parameter Pred.

Allows checkers to make a chain of nodes. The difference between this and 'addTransition()' should be that this always attempts to create a new node (even if there is no state change and no explicitly specified tag). Currently this logic is incorrect in addTransition and the difference is that this function lacks one of the two problematic early return statements. Can return nullptr if the node creation fails (when it would recreate an existing node or when the state is posteriorly overconstrained).

Parameters
StateThe state of the generated node.
PredThe node that will become the predecessor of the new node.
TagA ProgramPointTag that will be attached to the node. This is primarily useful for attaching a NoteTag; but another tag could be used as a workaround when the node wouldn't be unique otherwise. When Tag is nullptr, node creation will default to using the active checker as the tag.

Definition at line 292 of file CheckerContext.h.

References getPredecessor().

◆ generateNonFatalErrorNode() [2/2]

ExplodedNode * clang::ento::CheckerContext::generateNonFatalErrorNode ( ProgramStateRef State = nullptr,
const ProgramPointTag * Tag = nullptr )
inline

Creates a new ExplodedNode and adds it to the ExplodedGraph as a child of 'getPredecessor()', the node that was passed to the constructor of CheckerContext.

The difference between this and 'addTransition' is that this always attempts to create a new node, even if there is no state change and no explicitly speficified tag. Can return nullptr if the node creation fails (when it would recreate an existing node or when the state is posteriorly overconstrained).

Parameters
StateThe state of the generated node. Passing nullptr is handled as passing 'getState()' (the state of 'getPredecessor()').
TagA ProgramPointTag that will be attached to the node. This is primarily useful for attaching a NoteTag; but another tag could be used as a workaround when the node wouldn't be unique otherwise. When Tag is nullptr, node creation will default to using the active checker as the tag.

Definition at line 269 of file CheckerContext.h.

Referenced by clang::ento::mpi::MPIChecker::checkDoubleNonblocking(), clang::ento::mpi::MPIChecker::checkMissingWaits(), and clang::ento::mpi::MPIChecker::checkUnmatchedWaits().

◆ getAnalysisManager() [1/2]

AnalysisManager & clang::ento::CheckerContext::getAnalysisManager ( )
inline

Definition at line 57 of file CheckerContext.h.

◆ getAnalysisManager() [2/2]

const AnalysisManager & clang::ento::CheckerContext::getAnalysisManager ( ) const
inline

Definition at line 60 of file CheckerContext.h.

◆ getASTContext() [1/2]

◆ getASTContext() [2/2]

const ASTContext & clang::ento::CheckerContext::getASTContext ( ) const
inline

Definition at line 95 of file CheckerContext.h.

◆ getBlockID()

unsigned clang::ento::CheckerContext::getBlockID ( ) const
inline

Get the blockID.

Definition at line 152 of file CheckerContext.h.

◆ getBugReporter() [1/2]

◆ getBugReporter() [2/2]

const BugReporter & clang::ento::CheckerContext::getBugReporter ( ) const
inline

Definition at line 114 of file CheckerContext.h.

◆ getCalleeDecl()

const FunctionDecl * CheckerContext::getCalleeDecl ( const CallExpr * CE) const

Get the declaration of the called function (path-sensitive).

Definition at line 22 of file CheckerContext.cpp.

References clang::ento::SVal::getAsFunctionDecl(), clang::CallExpr::getCallee(), and clang::CallExpr::getDirectCallee().

Referenced by getCalleeIdentifier(), and getCalleeName().

◆ getCalleeIdentifier()

const IdentifierInfo * clang::ento::CheckerContext::getCalleeIdentifier ( const CallExpr * CE) const
inline

Get the identifier of the called function (path-sensitive).

Definition at line 397 of file CheckerContext.h.

References getCalleeDecl(), and clang::NamedDecl::getIdentifier().

◆ getCalleeName() [1/2]

StringRef clang::ento::CheckerContext::getCalleeName ( const CallExpr * CE) const
inline

Get the name of the called function (path-sensitive).

Definition at line 406 of file CheckerContext.h.

References getCalleeDecl(), and getCalleeName().

◆ getCalleeName() [2/2]

StringRef CheckerContext::getCalleeName ( const FunctionDecl * FunDecl) const

Get the name of the called function (path-sensitive).

Definition at line 32 of file CheckerContext.cpp.

References clang::NamedDecl::getIdentifier(), and clang::IdentifierInfo::getName().

Referenced by getCalleeName().

◆ getCFGElementRef()

ConstCFGElementRef clang::ento::CheckerContext::getCFGElementRef ( ) const
inline

Definition at line 169 of file CheckerContext.h.

◆ getConstraintManager() [1/2]

ConstraintManager & clang::ento::CheckerContext::getConstraintManager ( )
inline

Definition at line 64 of file CheckerContext.h.

◆ getConstraintManager() [2/2]

const ConstraintManager & clang::ento::CheckerContext::getConstraintManager ( ) const
inline

Definition at line 67 of file CheckerContext.h.

◆ getCurrentAnalysisDeclContext()

AnalysisDeclContext * clang::ento::CheckerContext::getCurrentAnalysisDeclContext ( ) const
inline

◆ getDeclDescription()

StringRef CheckerContext::getDeclDescription ( const Decl * D)

Returns the word that should be used to refer to the declaration in the report.

Definition at line 41 of file CheckerContext.cpp.

References clang::isa().

◆ getLangOpts()

const LangOptions & clang::ento::CheckerContext::getLangOpts ( ) const
inline

Definition at line 97 of file CheckerContext.h.

Referenced by getMacroNameOrSpelling().

◆ getLocation()

const ProgramPoint clang::ento::CheckerContext::getLocation ( ) const
inline

Definition at line 80 of file CheckerContext.h.

◆ getLocationRegionIfPostStore()

const MemRegion * clang::ento::CheckerContext::getLocationRegionIfPostStore ( const ExplodedNode * N)
inlinestatic

If the given node corresponds to a PostStore program point, retrieve the location region as it was uttered in the code.

This utility can be useful for generating extensive diagnostics, for example, for finding variables that the given symbol was assigned to.

Definition at line 159 of file CheckerContext.h.

References clang::ProgramPoint::getAs(), and clang::ento::ExplodedNode::getLocation().

◆ getMacroNameOrSpelling()

std::string CheckerContext::getMacroNameOrSpelling ( SourceLocation & Loc)

Depending on whether the location corresponds to a macro, return either the macro name or the token spelling.

This could be useful when checkers' logic depends on whether a function is called with a given macro argument. For example: s = socket(AF_INET,..) If AF_INET is a macro, the result should be treated as a source of taint.

See also
clang::Lexer::getSpelling(), clang::Lexer::getImmediateMacroName().

Definition at line 131 of file CheckerContext.cpp.

References clang::Lexer::getImmediateMacroName(), getLangOpts(), getSourceManager(), and clang::Lexer::getSpelling().

◆ getNoteTag() [1/5]

LLVM_ATTRIBUTE_RETURNS_NONNULL const NoteTag * clang::ento::CheckerContext::getNoteTag ( NoteTag::Callback && Cb,
bool IsPrunable = false )
inline

Produce a program point tag that displays an additional path note to the user.

This is a lightweight alternative to the BugReporterVisitor mechanism: instead of visiting the bug report node-by-node to restore the sequence of events that led to discovering a bug, you can add notes as you add your transitions.

Parameters
CbCallback with 'BugReporterContext &, BugReport &' parameters.
IsPrunableWhether the note is prunable. It allows BugReporter to omit the note from the report if it would make the displayed bug path significantly shorter.

Definition at line 319 of file CheckerContext.h.

Referenced by getNoteTag(), getNoteTag(), getNoteTag(), and getNoteTag().

◆ getNoteTag() [2/5]

const NoteTag * clang::ento::CheckerContext::getNoteTag ( std::function< std::string()> && Cb,
bool IsPrunable = false )
inline

A shorthand version of getNoteTag that doesn't require you to accept the arguments when you don't need it.

Parameters
CbCallback without parameters.
IsPrunableWhether the note is prunable. It allows BugReporter to omit the note from the report if it would make the displayed bug path significantly shorter.

Definition at line 346 of file CheckerContext.h.

References std::function, and getNoteTag().

◆ getNoteTag() [3/5]

const NoteTag * clang::ento::CheckerContext::getNoteTag ( std::function< std::string(PathSensitiveBugReport &)> && Cb,
bool IsPrunable = false )
inline

A shorthand version of getNoteTag that doesn't require you to accept the 'BugReporterContext' argument when you don't need it.

Parameters
CbCallback only with 'BugReport &' parameter.
IsPrunableWhether the note is prunable. It allows BugReporter to omit the note from the report if it would make the displayed bug path significantly shorter.

Definition at line 331 of file CheckerContext.h.

References std::function, and getNoteTag().

◆ getNoteTag() [4/5]

const NoteTag * clang::ento::CheckerContext::getNoteTag ( std::function< void(PathSensitiveBugReport &BR, llvm::raw_ostream &OS)> && Cb,
bool IsPrunable = false )
inline

A shorthand version of getNoteTag that accepts a lambda with stream for note.

Parameters
CbCallback with 'BugReport &' and 'llvm::raw_ostream &'.
IsPrunableWhether the note is prunable. It allows BugReporter to omit the note from the report if it would make the displayed bug path significantly shorter.

Definition at line 373 of file CheckerContext.h.

References std::function, getNoteTag(), and clang::ento::OS.

◆ getNoteTag() [5/5]

const NoteTag * clang::ento::CheckerContext::getNoteTag ( StringRef Note,
bool IsPrunable = false )
inline

A shorthand version of getNoteTag that accepts a plain note.

Parameters
NoteThe note.
IsPrunableWhether the note is prunable. It allows BugReporter to omit the note from the report if it would make the displayed bug path significantly shorter.

Definition at line 359 of file CheckerContext.h.

References getNoteTag(), and clang::Note.

◆ getPredecessor()

ExplodedNode * clang::ento::CheckerContext::getPredecessor ( ) const
inline

Returns the previous node in the exploded graph, which includes the state of the program before the checker ran.

Note, checkers should not retain the node in their state since the nodes might get invalidated.

Definition at line 79 of file CheckerContext.h.

Referenced by addTransition(), addTransition(), and generateNonFatalErrorNode().

◆ getPreprocessor() [1/2]

Preprocessor & clang::ento::CheckerContext::getPreprocessor ( )
inline

◆ getPreprocessor() [2/2]

const Preprocessor & clang::ento::CheckerContext::getPreprocessor ( ) const
inline

◆ getSourceManager() [1/2]

const SourceManager & clang::ento::CheckerContext::getSourceManager ( )
inline

◆ getSourceManager() [2/2]

const SourceManager & clang::ento::CheckerContext::getSourceManager ( ) const
inline

◆ getStackFrame()

const StackFrame * clang::ento::CheckerContext::getStackFrame ( ) const
inline

◆ getState()

◆ getStateManager() [1/2]

ProgramStateManager & clang::ento::CheckerContext::getStateManager ( )
inline

Definition at line 140 of file CheckerContext.h.

◆ getStateManager() [2/2]

const ProgramStateManager & clang::ento::CheckerContext::getStateManager ( ) const
inline

Definition at line 143 of file CheckerContext.h.

◆ getStoreManager() [1/2]

StoreManager & clang::ento::CheckerContext::getStoreManager ( )
inline

Definition at line 71 of file CheckerContext.h.

◆ getStoreManager() [2/2]

const StoreManager & clang::ento::CheckerContext::getStoreManager ( ) const
inline

Definition at line 74 of file CheckerContext.h.

◆ getSVal()

SVal clang::ento::CheckerContext::getSVal ( const Expr * E) const
inline

Get the value of arbitrary expressions at this point in the path.

Definition at line 167 of file CheckerContext.h.

Referenced by isGreaterOrEqual(), and isNegative().

◆ getSValBuilder() [1/2]

SValBuilder & clang::ento::CheckerContext::getSValBuilder ( )
inline

Definition at line 128 of file CheckerContext.h.

Referenced by getSymbolManager(), getSymbolManager(), isGreaterOrEqual(), and isNegative().

◆ getSValBuilder() [2/2]

const SValBuilder & clang::ento::CheckerContext::getSValBuilder ( ) const
inline

Definition at line 131 of file CheckerContext.h.

◆ getSymbolManager() [1/2]

SymbolManager & clang::ento::CheckerContext::getSymbolManager ( )
inline

◆ getSymbolManager() [2/2]

const SymbolManager & clang::ento::CheckerContext::getSymbolManager ( ) const
inline

◆ inTopFrame()

bool clang::ento::CheckerContext::inTopFrame ( ) const
inline

Return true if the current StackFrame has no caller context.

Definition at line 109 of file CheckerContext.h.

References getStackFrame(), and clang::StackFrame::inTopFrame().

Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkBeginFunction().

◆ isCLibraryFunction()

bool CheckerContext::isCLibraryFunction ( const FunctionDecl * FD,
StringRef Name = StringRef() )
static

Returns true if the given function is an externally-visible function in the top-level namespace, such as malloc.

If a name is provided, the function must additionally match the given name.

Note that this also accepts functions from the std namespace (because headers like <cstdlib> declare them there) and does not check if the function is declared as 'extern "C"' or if it uses C++ name mangling.

Definition at line 49 of file CheckerContext.cpp.

References clang::ASTContext::BuiltinInfo, clang::Decl::getASTContext(), clang::FunctionDecl::getBuiltinID(), clang::Decl::getDeclContext(), clang::NamedDecl::getIdentifier(), clang::Builtin::Context::getName(), clang::IdentifierInfo::getName(), clang::DeclContext::getRedeclContext(), clang::NamedDecl::isExternallyVisible(), clang::FunctionDecl::isInlined(), clang::DeclContext::isStdNamespace(), and clang::DeclContext::isTranslationUnit().

Referenced by clang::ento::CallEvent::isGlobalCFunction().

◆ isDifferent()

bool clang::ento::CheckerContext::isDifferent ( ) const
inline

Check if the checker changed the state of the execution; ex: added a new transition or a bug report.

Definition at line 85 of file CheckerContext.h.

◆ isGreaterOrEqual()

bool CheckerContext::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.

Definition at line 163 of file CheckerContext.cpp.

References evalComparison(), getASTContext(), getState(), getSVal(), getSValBuilder(), clang::ento::SValBuilder::makeIntVal(), and V.

◆ isHardenedVariantOf()

bool CheckerContext::isHardenedVariantOf ( const FunctionDecl * FD,
StringRef Name )
static

In builds that use source hardening (-D_FORTIFY_SOURCE), many standard functions are implemented as macros that expand to calls of hardened functions that take additional arguments compared to the "usual" variant and perform additional input validation.

For example, a memcpy call may expand to __memcpy_chk() or __builtin___memcpy_chk().

This method returns true if FD declares a fortified variant of the standard library function Name.

NOTE: This method relies on heuristics; extend it if you need to handle a hardened variant that's not yet covered by it.

Definition at line 116 of file CheckerContext.cpp.

References clang::NamedDecl::getIdentifier(), and clang::IdentifierInfo::getName().

◆ isNegative()

bool CheckerContext::isNegative ( const Expr * E)

Returns true if the value of E is negative.

Definition at line 168 of file CheckerContext.cpp.

References evalComparison(), getState(), getSVal(), getSValBuilder(), clang::ento::SValBuilder::makeIntVal(), and V.

◆ stackframes()

llvm::iterator_range< StackFrame::parent_iterator > clang::ento::CheckerContext::stackframes ( ) const
inline

Iterates over the current stack frame and all of its ancestors.

Definition at line 104 of file CheckerContext.h.

References getStackFrame(), and clang::StackFrame::parentsIncludingSelf().

Member Data Documentation

◆ wasInlined

const bool clang::ento::CheckerContext::wasInlined

If we are post visiting a call, this flag will be set if the call was inlined.

In all other cases it will be false.

Definition at line 45 of file CheckerContext.h.

Referenced by CheckerContext().


The documentation for this class was generated from the following files: