clang  12.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. More...
 
const BlockInvocationContextgetBlockInvocationContext (const LocationContext *ParentLC, const BlockDecl *BD, const void *Data)
 Obtain a context of the block invocation using its parent context. More...
 
template<typename T >
T * getAnalysis ()
 

Static Public Member Functions

static bool isInStdNamespace (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.

◆ ~AnalysisDeclContext()

AnalysisDeclContext::~AnalysisDeclContext ( )

Member Function Documentation

◆ dumpCFG()

void AnalysisDeclContext::dumpCFG ( bool  ShowColors)

Definition at line 275 of file AnalysisDeclContext.cpp.

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

Referenced by CheckFallThrough().

◆ 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

◆ 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::serialized_diags::create().

Referenced by clang::ForwardDataflowWorklist::ForwardDataflowWorklist(), clang::ento::AnalysisManager::getAnalysis(), clang::LocationContext::getAnalysis(), clang::threadSafety::CFGWalker::init(), isCXXSharedPtrDtor(), and clang::consumed::ConsumedAnalyzer::run().

◆ getASTContext()

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

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

References clang::LocationContextManager::getBlockInvocationContext().

Referenced by REGISTER_MAP_WITH_PROGRAMSTATE().

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

◆ getCFG()

CFG * AnalysisDeclContext::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 263 of file AnalysisDeclContext.cpp.

References c.

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

◆ getCFGStmtMap()

CFGStmtMap * AnalysisDeclContext::getCFGStmtMap ( )

Definition at line 251 of file AnalysisDeclContext.cpp.

References clang::CFGStmtMap::Build(), and c.

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

◆ getDecl()

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

◆ getManager()

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

◆ getParentMap()

ParentMap & AnalysisDeclContext::getParentMap ( )

◆ getReferencedBlockVars()

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

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

Referenced by REGISTER_MAP_WITH_PROGRAMSTATE().

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

Referenced by CompactMacroExpandedPieces(), findTopAutosynthesizedParentContext(), clang::ento::ExplodedNode::getStmtForDiagnostics(), isCXXSharedPtrDtor(), 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(), and clang::SourceLocation::isValid().

Referenced by CompactMacroExpandedPieces().

◆ 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
Returns
Whether the root namespace of D is the std C++ namespace.

Definition at line 325 of file AnalysisDeclContext.cpp.

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

Referenced by isCXXSharedPtrDtor().

◆ registerForcedBlockExpression()

void AnalysisDeclContext::registerForcedBlockExpression ( const Stmt stmt)

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