clang  15.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
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:
Inheritance graph
Collaboration diagram for clang::LocationContext:
Collaboration graph

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. More...
bool isParentOf (const LocationContext *LC) const
const DeclgetDecl () const
CFGgetCFG () const
template<typename T >
T * getAnalysis () 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. More...
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. More...
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


Definition at line 217 of file AnalysisDeclContext.h.

Constructor & Destructor Documentation

◆ LocationContext()

clang::LocationContext::LocationContext ( ContextKind  k,
AnalysisDeclContext ctx,
const LocationContext parent,
int64_t  ID 

Definition at line 230 of file AnalysisDeclContext.h.

References Parent.

◆ ~LocationContext()

LocationContext::~LocationContext ( )

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void LocationContext::dump ( ) const

Definition at line 584 of file AnalysisDeclContext.cpp.

References printJson().

◆ dumpStack()

void LocationContext::dumpStack ( raw_ostream &  Out) const

Prints out the call stack.

OutThe out stream.

Definition at line 497 of file AnalysisDeclContext.cpp.

◆ getAnalysis()

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

◆ getAnalysisDeclContext()

LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext* clang::LocationContext::getAnalysisDeclContext ( ) const

◆ getCFG()

CFG* clang::LocationContext::getCFG ( ) const

◆ getDecl()

const Decl* clang::LocationContext::getDecl ( ) const

Definition at line 251 of file AnalysisDeclContext.h.

References clang::AnalysisDeclContext::getDecl().

Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkBeginFunction(), checkInvariantViolation(), checkSelfIvarsForInvariantViolation(), clang::ento::ExprEngine::computeObjectUnderConstruction(), clang::ento::PathDiagnosticCallPiece::construct(), clang::ento::PathDiagnosticLocation::createDeclBegin(), clang::ento::PathDiagnosticLocation::createDeclEnd(), clang::ento::SymbolConjured::dumpToStream(), clang::ento::CoreEngine::ExecuteWorkList(), clang::ento::ExplodedNode::getCodeDecl(), clang::ento::MemRegionManager::getCXXThisRegion(), clang::ento::ParamVarRegion::getDecl(), clang::ento::PathSensitiveBugReport::getDeclWithIssue(), clang::ento::AnyFunctionCall::getInitialStackFrameContents(), clang::ento::BlockCall::getInitialStackFrameContents(), clang::ento::CXXInstanceCall::getInitialStackFrameContents(), clang::ento::AnyCXXConstructorCall::getInitialStackFrameContents(), clang::ento::ObjCMethodCall::getInitialStackFrameContents(), clang::ento::ExprEngine::getInitialState(), clang::ento::isCapturedByReference(), isInMIGCall(), clang::ento::retaincountchecker::isSynthesizedAccessor(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::processCallExit(), clang::ento::ExprEngine::processCFGBlockEntrance(), clang::ento::ExprEngine::ProcessMemberDtor(), clang::ento::PathDiagnosticCallPiece::setCallee(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), wasDifferentDeclUsedForInlining(), and willObjectBeAnalyzedLater().

◆ getID()

int64_t clang::LocationContext::getID ( ) const

Definition at line 241 of file AnalysisDeclContext.h.

Referenced by clang::ento::SymbolConjured::dumpToStream().

◆ getKind()

ContextKind clang::LocationContext::getKind ( ) const

◆ getParent()

const LocationContext* clang::LocationContext::getParent ( ) const

◆ getParentMap()

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

◆ getSelfDecl()

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

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

Definition at line 260 of file AnalysisDeclContext.h.

References clang::AnalysisDeclContext::getSelfDecl().

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

◆ getStackFrame()

const StackFrameContext * LocationContext::getStackFrame ( ) const

◆ inTopFrame()

bool LocationContext::inTopFrame ( ) const

◆ isParentOf()

bool LocationContext::isParentOf ( const LocationContext LC) const

◆ 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.

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(); }

Definition at line 532 of file AnalysisDeclContext.cpp.

Referenced by dump().

◆ 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 

Definition at line 404 of file AnalysisDeclContext.cpp.

Referenced by clang::BlockInvocationContext::Profile().

The documentation for this class was generated from the following files:
LocationContext(ContextKind k, AnalysisDeclContext *ctx, const LocationContext *parent, int64_t ID)
Definition: AnalysisDeclContext.h:230