clang 22.0.0git
clang::LocationContext Class Referenceabstract

It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext and inside the function calls the BlockInvocationContext. More...

#include "clang/Analysis/AnalysisDeclContext.h"

Inheritance diagram for clang::LocationContext:
[legend]

Public Types

enum  ContextKind { StackFrame , Block }

Public Member Functions

virtual ~LocationContext ()
ContextKind getKind () const
int64_t getID () const
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContextgetAnalysisDeclContext () const
const LocationContextgetParent () const
 It might return null.
bool isParentOf (const LocationContext *LC) const
const DeclgetDecl () const
CFGgetCFG () const
template<typename T>
TgetAnalysis () const
const ParentMapgetParentMap () const
const ImplicitParamDeclgetSelfDecl () const
const StackFrameContextgetStackFrame () const
virtual bool inTopFrame () const
virtual void Profile (llvm::FoldingSetNodeID &ID)=0
LLVM_DUMP_METHOD void dumpStack (raw_ostream &Out) const
 Prints out the call stack.
void printJson (raw_ostream &Out, const char *NL="\n", unsigned int Space=0, bool IsDot=false, std::function< void(const LocationContext *)> printMoreInfoPerContext=[](const LocationContext *) {}) const
 Prints out the call stack in json format.
LLVM_DUMP_METHOD void dump () const

Static Public Member Functions

static void ProfileCommon (llvm::FoldingSetNodeID &ID, ContextKind ck, AnalysisDeclContext *ctx, const LocationContext *parent, const void *data)

Protected Member Functions

 LocationContext (ContextKind k, AnalysisDeclContext *ctx, const LocationContext *parent, int64_t ID)

Detailed Description

It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext and inside the function calls the BlockInvocationContext.

It is needed for context sensitive analysis to model entering, leaving or inlining function calls.

Definition at line 215 of file AnalysisDeclContext.h.

Member Enumeration Documentation

◆ ContextKind

Enumerator
StackFrame 
Block 

Definition at line 217 of file AnalysisDeclContext.h.

Constructor & Destructor Documentation

◆ LocationContext()

◆ ~LocationContext()

LocationContext::~LocationContext ( )
virtualdefault

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void LocationContext::dump ( ) const

Definition at line 581 of file AnalysisDeclContext.cpp.

References printJson().

◆ dumpStack()

◆ getAnalysis()

template<typename T>
T * clang::LocationContext::getAnalysis ( ) const
inline

Definition at line 255 of file AnalysisDeclContext.h.

References clang::T.

Referenced by clang::ento::ExplodedNode::getAnalysis().

◆ getAnalysisDeclContext()

◆ getCFG()

◆ getDecl()

const Decl * clang::LocationContext::getDecl ( ) const
inline
Examples
/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/StaticAnalyzer/Core/RegionStore.cpp.

Definition at line 251 of file AnalysisDeclContext.h.

Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkBeginFunction(), checkInvariantViolation(), checkSelfIvarsForInvariantViolation(), clang::ento::ExprEngine::computeObjectUnderConstruction(), clang::ento::PathDiagnosticCallPiece::construct(), clang::ento::PathDiagnosticLocation::create(), clang::ento::PathDiagnosticLocation::createDeclBegin(), clang::ento::PathDiagnosticLocation::createDeclEnd(), dumpStack(), clang::ento::CoreEngine::ExecuteWorkList(), clang::ento::ExprEngine::ExecuteWorkList(), exitingDestructor(), clang::ento::LikelyFalsePositiveSuppressionBRVisitor::finalizeVisitor(), findExecutedLines(), clang::ento::CallEventManager::getCaller(), clang::ento::ExplodedNode::getCodeDecl(), clang::ento::MemRegionManager::getCXXThisRegion(), clang::ento::ParamVarRegion::getDecl(), clang::ento::PathSensitiveBugReport::getDeclWithIssue(), getEnclosingStmtLocation(), clang::ento::AnyCXXConstructorCall::getInitialStackFrameContents(), clang::ento::AnyFunctionCall::getInitialStackFrameContents(), clang::ento::BlockCall::getInitialStackFrameContents(), clang::ento::CXXInstanceCall::getInitialStackFrameContents(), clang::ento::ObjCMethodCall::getInitialStackFrameContents(), clang::ento::ExprEngine::getInitialState(), clang::ento::MemRegionManager::getVarRegion(), clang::ento::getWidenedLoopState(), clang::ento::isCapturedByReference(), isInMIGCall(), clang::ento::retaincountchecker::isSynthesizedAccessor(), printJson(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::processBranch(), clang::ento::ExprEngine::processCallExit(), clang::ento::ExprEngine::processCFGBlockEntrance(), clang::ento::ExprEngine::ProcessMemberDtor(), clang::ento::PathDiagnosticCallPiece::setCallee(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), clang::ento::SValExplainer::VisitParamVarRegion(), wasDifferentDeclUsedForInlining(), clang::ento::NoOwnershipChangeVisitor::wasModifiedInFunction(), and willObjectBeAnalyzedLater().

◆ getID()

int64_t clang::LocationContext::getID ( ) const
inline

Definition at line 241 of file AnalysisDeclContext.h.

◆ getKind()

ContextKind clang::LocationContext::getKind ( ) const
inline

◆ getParent()

◆ getParentMap()

const ParentMap & clang::LocationContext::getParentMap ( ) const
inline

◆ getSelfDecl()

const ImplicitParamDecl * clang::LocationContext::getSelfDecl ( ) const
inline

Returns
The ImplicitParamDecl associated with self if this AnalysisDeclContext wraps an ObjCMethodDecl or nullptr otherwise.

Definition at line 260 of file AnalysisDeclContext.h.

Referenced by checkSelfIvarsForInvariantViolation(), and clang::ento::ProgramState::getSelfSVal().

◆ getStackFrame()

const StackFrameContext * LocationContext::getStackFrame ( ) const

Definition at line 460 of file AnalysisDeclContext.cpp.

References getParent(), and LocationContext().

Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction(), clang::ento::MemRegionManager::getAllocaRegion(), GetAllocationSite(), clang::ento::MemRegionManager::getBlockDataRegion(), getCalleeNode(), clang::ento::CallEventManager::getCaller(), clang::ento::MemRegionManager::getCompoundLiteralRegion(), clang::ento::MemRegionManager::getCXXLifetimeExtendedObjectRegion(), clang::ento::MemRegionManager::getCXXTempObjectRegion(), clang::ento::MemRegionManager::getCXXThisRegion(), clang::ento::PathSensitiveBugReport::getDeclWithIssue(), clang::ento::ExprEngine::getIndexOfElementToConstruct(), clang::ento::CXXInheritedConstructorCall::getInheritingStackFrame(), clang::ento::ExprEngine::getInitialState(), getInlinedLocationContext(), clang::ento::ExprEngine::getObjectUnderConstruction(), clang::ento::MemRegionManager::getParamVarRegion(), clang::ento::ExprEngine::getPendingArrayDestruction(), clang::ento::ExprEngine::getPendingInitLoop(), clang::AnalysisDeclContext::getStackFrame(), clang::AnalysisDeclContextManager::getStackFrame(), clang::AnalysisDeclContextManager::getStackFrame(), clang::ento::CheckerContext::getStackFrame(), clang::ProgramPoint::getStackFrame(), clang::ento::MemRegionManager::getVarRegion(), clang::ento::getWidenedLoopState(), inTopFrame(), isInitializationOfVar(), isInMIGCall(), clang::ento::SymbolReaper::isLive(), clang::ento::Environment::printJson(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::processBranch(), clang::ento::ExprEngine::processCallExit(), clang::ento::ExprEngine::processCFGBlockEntrance(), clang::ento::ExprEngine::processEndOfFunction(), clang::ento::ExprEngine::ProcessMemberDtor(), clang::ento::ExprEngine::removeDead(), clang::ento::ExprEngine::updateObjectsUnderConstruction(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), clang::ento::NoStateChangeFuncVisitor::VisitNode(), and clang::ento::retaincountchecker::RefCountReportVisitor::VisitNode().

◆ inTopFrame()

◆ isParentOf()

◆ printJson()

void LocationContext::printJson ( raw_ostream & Out,
const char * NL = "\n",
unsigned int Space = 0,
bool IsDot = false,
std::function< void(const LocationContext *)> printMoreInfoPerContext = [](const LocationContext *) {} ) const

Prints out the call stack in json format.

Parameters
OutThe out stream.
NLThe newline.
SpaceThe space count for indentation.
IsDotWhether the output format is dot.
printMoreInfoPerContextA callback to print more information for each context, for example:
[&](const LocationContext *LC) { LC->dump(); }
LocationContext(ContextKind k, AnalysisDeclContext *ctx, const LocationContext *parent, int64_t ID)

Definition at line 529 of file AnalysisDeclContext.cpp.

References Block, clang::cast(), std::function, getAnalysisDeclContext(), clang::AnalysisDeclContext::getASTContext(), getDecl(), clang::ASTContext::getSourceManager(), clang::Indent(), LocationContext(), clang::printSourceLocationAsJson(), SM, StackFrame, and clang::PrintingPolicy::TerseOutput.

Referenced by dump(), clang::ento::Environment::printJson(), and printStateTraitWithLocationContextJson().

◆ Profile()

virtual void clang::LocationContext::Profile ( llvm::FoldingSetNodeID & ID)
pure virtual

◆ ProfileCommon()

void LocationContext::ProfileCommon ( llvm::FoldingSetNodeID & ID,
ContextKind ck,
AnalysisDeclContext * ctx,
const LocationContext * parent,
const void * data )
static

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