clang 22.0.0git
clang::AnalysisDeclContext Class Reference

AnalysisDeclContext contains the context data for the function, method or block under analysis. More...

#include "clang/Analysis/AnalysisDeclContext.h"

Public Types

using referenced_decls_iterator = const VarDecl *const *

Public Member Functions

 AnalysisDeclContext (AnalysisDeclContextManager *Mgr, const Decl *D)
 AnalysisDeclContext (AnalysisDeclContextManager *Mgr, const Decl *D, const CFG::BuildOptions &BuildOptions)
 ~AnalysisDeclContext ()
ASTContextgetASTContext () const
const DeclgetDecl () const
AnalysisDeclContextManagergetManager () const
CFG::BuildOptionsgetCFGBuildOptions ()
const CFG::BuildOptionsgetCFGBuildOptions () const
bool getAddEHEdges () const
bool getUseUnoptimizedCFG () const
bool getAddImplicitDtors () const
bool getAddInitializers () const
void registerForcedBlockExpression (const Stmt *stmt)
const CFGBlockgetBlockForRegisteredExpression (const Stmt *stmt)
StmtgetBody () const
StmtgetBody (bool &IsAutosynthesized) const
bool isBodyAutosynthesized () const
bool isBodyAutosynthesizedFromModelFile () const
CFGgetCFG ()
CFGStmtMapgetCFGStmtMap ()
CFGReverseBlockReachabilityAnalysisgetCFGReachablityAnalysis ()
CFGgetUnoptimizedCFG ()
void dumpCFG (bool ShowColors)
bool isCFGBuilt () const
ParentMapgetParentMap ()
llvm::iterator_range< referenced_decls_iteratorgetReferencedBlockVars (const BlockDecl *BD)
const ImplicitParamDeclgetSelfDecl () const
const StackFrameContextgetStackFrame (LocationContext const *ParentLC, const Stmt *S, const CFGBlock *Blk, unsigned BlockCount, unsigned Index)
 Obtain a context of the call stack using its parent context.
const BlockInvocationContextgetBlockInvocationContext (const LocationContext *ParentLC, const BlockDecl *BD, const void *Data)
 Obtain a context of the block invocation using its parent context.
template<typename T>
TgetAnalysis ()

Static Public Member Functions

static bool isInStdNamespace (const Decl *D)
static std::string getFunctionName (const Decl *D)

Detailed Description

AnalysisDeclContext contains the context data for the function, method or block under analysis.

Definition at line 72 of file AnalysisDeclContext.h.

Member Typedef Documentation

◆ referenced_decls_iterator

Definition at line 171 of file AnalysisDeclContext.h.

Constructor & Destructor Documentation

◆ AnalysisDeclContext() [1/2]

AnalysisDeclContext::AnalysisDeclContext ( AnalysisDeclContextManager * Mgr,
const Decl * D )

Definition at line 60 of file AnalysisDeclContext.cpp.

◆ AnalysisDeclContext() [2/2]

AnalysisDeclContext::AnalysisDeclContext ( AnalysisDeclContextManager * Mgr,
const Decl * D,
const CFG::BuildOptions & BuildOptions )

Definition at line 53 of file AnalysisDeclContext.cpp.

◆ ~AnalysisDeclContext()

AnalysisDeclContext::~AnalysisDeclContext ( )

Definition at line 683 of file AnalysisDeclContext.cpp.

Member Function Documentation

◆ dumpCFG()

void AnalysisDeclContext::dumpCFG ( bool ShowColors)

Definition at line 272 of file AnalysisDeclContext.cpp.

References clang::CFG::dump(), getASTContext(), and getCFG().

◆ getAddEHEdges()

bool clang::AnalysisDeclContext::getAddEHEdges ( ) const
inline
Returns
Whether we are adding exception handling edges from CallExprs. If this is false, then try/catch statements and blocks reachable from them can appear to be dead in the CFG, analysis passes must cope with that.

Definition at line 119 of file AnalysisDeclContext.h.

Referenced by CheckFallThrough().

◆ getAddImplicitDtors()

bool clang::AnalysisDeclContext::getAddImplicitDtors ( ) const
inline

Definition at line 123 of file AnalysisDeclContext.h.

◆ getAddInitializers()

bool clang::AnalysisDeclContext::getAddInitializers ( ) const
inline

Definition at line 124 of file AnalysisDeclContext.h.

◆ getAnalysis()

template<typename T>
T * clang::AnalysisDeclContext::getAnalysis ( )
inline
Returns
The specified analysis object, lazily running the analysis if necessary or nullptr if the analysis could not run.

Definition at line 192 of file AnalysisDeclContext.h.

References clang::T.

Referenced by clang::lifetimes::internal::FactManager::dump(), clang::threadSafety::CFGWalker::init(), and clang::consumed::ConsumedAnalyzer::run().

◆ getASTContext()

◆ getBlockForRegisteredExpression()

const CFGBlock * AnalysisDeclContext::getBlockForRegisteredExpression ( const Stmt * stmt)

◆ getBlockInvocationContext()

const BlockInvocationContext * AnalysisDeclContext::getBlockInvocationContext ( const LocationContext * ParentLC,
const BlockDecl * BD,
const void * Data )

Obtain a context of the block invocation using its parent context.

Parameters
ADCThe AnalysisDeclContext.
ParentLCThe parent context of this newly created context.
BDThe BlockDecl.
DataThe raw data to store as part of the context.

Definition at line 316 of file AnalysisDeclContext.cpp.

References clang::Data.

◆ getBody() [1/2]

◆ getBody() [2/2]

Stmt * AnalysisDeclContext::getBody ( bool & IsAutosynthesized) const

Returns
The body of the stored Decl D.
Parameters
[out]IsAutosynthesizedSpecifies if the body is auto-generated by the BodyFarm.

Definition at line 91 of file AnalysisDeclContext.cpp.

◆ getCFG()

◆ getCFGBuildOptions() [1/2]

CFG::BuildOptions & clang::AnalysisDeclContext::getCFGBuildOptions ( )
inline

◆ getCFGBuildOptions() [2/2]

const CFG::BuildOptions & clang::AnalysisDeclContext::getCFGBuildOptions ( ) const
inline

Definition at line 112 of file AnalysisDeclContext.h.

◆ getCFGReachablityAnalysis()

CFGReverseBlockReachabilityAnalysis * AnalysisDeclContext::getCFGReachablityAnalysis ( )

Definition at line 260 of file AnalysisDeclContext.cpp.

References c, and getCFG().

Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().

◆ getCFGStmtMap()

◆ getDecl()

◆ getFunctionName()

◆ getManager()

AnalysisDeclContextManager * clang::AnalysisDeclContext::getManager ( ) const
inline

◆ getParentMap()

◆ getReferencedBlockVars()

llvm::iterator_range< AnalysisDeclContext::referenced_decls_iterator > AnalysisDeclContext::getReferencedBlockVars ( const BlockDecl * BD)

Definition at line 661 of file AnalysisDeclContext.cpp.

References LazyInitializeReferencedDecls(), and V.

◆ getSelfDecl()

const ImplicitParamDecl * AnalysisDeclContext::getSelfDecl ( ) const

◆ getStackFrame()

const StackFrameContext * AnalysisDeclContext::getStackFrame ( LocationContext const * ParentLC,
const Stmt * S,
const CFGBlock * Blk,
unsigned BlockCount,
unsigned Index )

Obtain a context of the call stack using its parent context.

Parameters
ADCThe AnalysisDeclContext.
ParentLCThe parent context of this newly created context.
SThe call.
BlockThe basic block.
BlockCountThe current count of entering into Blk.
IndexThe index of Blk.
Returns
The context for D with parent context ParentLC.

Definition at line 309 of file AnalysisDeclContext.cpp.

References clang::LocationContext::getStackFrame().

◆ getUnoptimizedCFG()

CFG * AnalysisDeclContext::getUnoptimizedCFG ( )
Returns
A version of the CFG without any edges pruned.

Definition at line 230 of file AnalysisDeclContext.cpp.

References addParentsForSyntheticStmts(), clang::CFG::buildCFG(), getBody(), getCFGBuildOptions(), and clang::CFG::BuildOptions::Observer.

Referenced by getCFG(), and getParentMap().

◆ getUseUnoptimizedCFG()

bool clang::AnalysisDeclContext::getUseUnoptimizedCFG ( ) const
inline

Definition at line 120 of file AnalysisDeclContext.h.

◆ isBodyAutosynthesized()

bool AnalysisDeclContext::isBodyAutosynthesized ( ) const
Returns
Whether the body of the Decl D is generated by the BodyFarm.
Note
The lookup is not free. We are going to call getBody behind the scenes.
See also
getBody

Definition at line 129 of file AnalysisDeclContext.cpp.

References getBody().

Referenced by clang::ento::PathSensitiveBugReporter::emitReport(), findTopAutosynthesizedParentContext(), clang::ento::ExplodedNode::getStmtForDiagnostics(), clang::ento::retaincountchecker::isSynthesizedAccessor(), and clang::ento::PathDiagnosticCallPiece::setCallee().

◆ isBodyAutosynthesizedFromModelFile()

bool AnalysisDeclContext::isBodyAutosynthesizedFromModelFile ( ) const
Returns
Whether the body of the Decl D is generated by the BodyFarm from a model file.
Note
The lookup is not free. We are going to call getBody behind the scenes.
See also
getBody

Definition at line 135 of file AnalysisDeclContext.cpp.

References clang::Stmt::getBeginLoc(), getBody(), and clang::SourceLocation::isValid().

Referenced by clang::ento::PathSensitiveBugReporter::emitReport().

◆ isCFGBuilt()

bool clang::AnalysisDeclContext::isCFGBuilt ( ) const
inline
Returns
Whether we have built a CFG for this analysis context.
Note
This doesn't correspond to whether or not a valid CFG exists, it corresponds to whether we attempted to build one.

Definition at line 167 of file AnalysisDeclContext.h.

Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().

◆ isInStdNamespace()

bool AnalysisDeclContext::isInStdNamespace ( const Decl * D)
static

◆ registerForcedBlockExpression()

void AnalysisDeclContext::registerForcedBlockExpression ( const Stmt * stmt)

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