clang 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
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 62 of file AnalysisDeclContext.cpp.

References clang::CFG::BuildOptions::forcedBlkExprs.

◆ AnalysisDeclContext() [2/2]

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

Definition at line 55 of file AnalysisDeclContext.cpp.

References clang::CFG::BuildOptions::forcedBlkExprs.

◆ ~AnalysisDeclContext()

AnalysisDeclContext::~AnalysisDeclContext ( )

Definition at line 685 of file AnalysisDeclContext.cpp.

Member Function Documentation

◆ dumpCFG()

void AnalysisDeclContext::dumpCFG ( bool  ShowColors)

Definition at line 274 of file AnalysisDeclContext.cpp.

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

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

References clang::CFG::BuildOptions::AddEHEdges.

◆ getAddImplicitDtors()

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

Definition at line 123 of file AnalysisDeclContext.h.

References clang::CFG::BuildOptions::AddImplicitDtors.

◆ getAddInitializers()

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

Definition at line 124 of file AnalysisDeclContext.h.

References clang::CFG::BuildOptions::AddInitializers.

◆ 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::LocationContext::getAnalysis(), and clang::ento::AnalysisManager::getAnalysis().

◆ getASTContext()

ASTContext & clang::AnalysisDeclContext::getASTContext ( ) const
inline

◆ getBlockForRegisteredExpression()

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

Definition at line 190 of file AnalysisDeclContext.cpp.

References clang::ast_matchers::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 318 of file AnalysisDeclContext.cpp.

References clang::Data, and clang::LocationContextManager::getBlockInvocationContext().

◆ getBody() [1/2]

Stmt * AnalysisDeclContext::getBody ( ) const

◆ 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 93 of file AnalysisDeclContext.cpp.

References clang::BodyFarm::getBody(), clang::AnalysisDeclContextManager::getBodyFarm(), and clang::AnalysisDeclContextManager::synthesizeBodies().

◆ getCFG()

CFG * AnalysisDeclContext::getCFG ( )

◆ getCFGBuildOptions() [1/2]

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

Definition at line 110 of file AnalysisDeclContext.h.

Referenced by getCFG(), and getUnoptimizedCFG().

◆ 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 262 of file AnalysisDeclContext.cpp.

References c, and getCFG().

◆ getCFGStmtMap()

CFGStmtMap * AnalysisDeclContext::getCFGStmtMap ( )

◆ getDecl()

const Decl * clang::AnalysisDeclContext::getDecl ( ) const
inline

◆ getFunctionName()

std::string AnalysisDeclContext::getFunctionName ( const Decl D)
static

◆ getManager()

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

◆ getParentMap()

ParentMap & AnalysisDeclContext::getParentMap ( )

◆ getReferencedBlockVars()

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

Definition at line 663 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 311 of file AnalysisDeclContext.cpp.

References clang::LocationContextManager::getStackFrame().

◆ getUnoptimizedCFG()

CFG * AnalysisDeclContext::getUnoptimizedCFG ( )

◆ getUseUnoptimizedCFG()

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

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

◆ isInStdNamespace()

bool AnalysisDeclContext::isInStdNamespace ( const Decl D)
static
Returns
Whether the root namespace of D is the std C++ namespace.

Definition at line 324 of file AnalysisDeclContext.cpp.

References D, clang::Decl::getDeclContext(), clang::DeclContext::getEnclosingNamespaceContext(), and Parent.

Referenced by clang::ento::LikelyFalsePositiveSuppressionBRVisitor::finalizeVisitor().

◆ registerForcedBlockExpression()

void AnalysisDeclContext::registerForcedBlockExpression ( const Stmt stmt)

Definition at line 180 of file AnalysisDeclContext.cpp.

References clang::ast_matchers::stmt.


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