clang
9.0.0
|
AnalysisDeclContext contains the context data for the function or method 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 () | |
ASTContext & | getASTContext () const |
const Decl * | getDecl () const |
AnalysisDeclContextManager * | getManager () const |
Return the AnalysisDeclContextManager (if any) that created this AnalysisDeclContext. More... | |
CFG::BuildOptions & | getCFGBuildOptions () |
Return the build options used to construct the CFG. More... | |
const CFG::BuildOptions & | getCFGBuildOptions () const |
bool | getAddEHEdges () const |
getAddEHEdges - Return true iff we are adding exceptional edges from callExprs. More... | |
bool | getUseUnoptimizedCFG () const |
bool | getAddImplicitDtors () const |
bool | getAddInitializers () const |
void | registerForcedBlockExpression (const Stmt *stmt) |
const CFGBlock * | getBlockForRegisteredExpression (const Stmt *stmt) |
Stmt * | getBody () const |
Get the body of the Declaration. More... | |
Stmt * | getBody (bool &IsAutosynthesized) const |
Get the body of the Declaration. More... | |
bool | isBodyAutosynthesized () const |
Checks if the body of the Decl is generated by the BodyFarm. More... | |
bool | isBodyAutosynthesizedFromModelFile () const |
Checks if the body of the Decl is generated by the BodyFarm from a model file. More... | |
CFG * | getCFG () |
CFGStmtMap * | getCFGStmtMap () |
CFGReverseBlockReachabilityAnalysis * | getCFGReachablityAnalysis () |
CFG * | getUnoptimizedCFG () |
Return a version of the CFG without any edges pruned. More... | |
void | dumpCFG (bool ShowColors) |
bool | isCFGBuilt () const |
Returns true if we have built a CFG for this analysis context. More... | |
ParentMap & | getParentMap () |
llvm::iterator_range< referenced_decls_iterator > | getReferencedBlockVars (const BlockDecl *BD) |
const ImplicitParamDecl * | getSelfDecl () const |
Return the ImplicitParamDecl* associated with 'self' if this AnalysisDeclContext wraps an ObjCMethodDecl. More... | |
const StackFrameContext * | getStackFrame (LocationContext const *Parent, const Stmt *S, const CFGBlock *Blk, unsigned Idx) |
const BlockInvocationContext * | getBlockInvocationContext (const LocationContext *parent, const BlockDecl *BD, const void *ContextData) |
template<typename T > | |
T * | getAnalysis () |
Return the specified analysis object, lazily running the analysis if necessary. More... | |
Static Public Member Functions | |
static bool | isInStdNamespace (const Decl *D) |
Returns true if the root namespace of the given declaration is the 'std' C++ namespace. More... | |
AnalysisDeclContext contains the context data for the function or method under analysis.
Definition at line 69 of file AnalysisDeclContext.h.
using clang::AnalysisDeclContext::referenced_decls_iterator = const VarDecl * const * |
Definition at line 176 of file AnalysisDeclContext.h.
AnalysisDeclContext::AnalysisDeclContext | ( | AnalysisDeclContextManager * | Mgr, |
const Decl * | D | ||
) |
Definition at line 62 of file AnalysisDeclContext.cpp.
References clang::CFG::BuildOptions::forcedBlkExprs.
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 | ( | ) |
Definition at line 674 of file AnalysisDeclContext.cpp.
References clang::LocationContext::~LocationContext().
void AnalysisDeclContext::dumpCFG | ( | bool | ShowColors | ) |
Definition at line 275 of file AnalysisDeclContext.cpp.
|
inline |
getAddEHEdges - Return true iff we are adding exceptional 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 125 of file AnalysisDeclContext.h.
References clang::CFG::BuildOptions::AddEHEdges.
Referenced by CheckFallThrough().
|
inline |
Definition at line 129 of file AnalysisDeclContext.h.
References clang::CFG::BuildOptions::AddImplicitDtors.
|
inline |
Definition at line 130 of file AnalysisDeclContext.h.
References clang::CFG::BuildOptions::AddInitializers, and clang::ast_matchers::stmt.
|
inline |
Return the specified analysis object, lazily running the analysis if necessary.
Return NULL if the analysis could not run.
Definition at line 198 of file AnalysisDeclContext.h.
References clang::serialized_diags::create().
Referenced by clang::ento::AnalysisManager::getAnalysis(), clang::threadSafety::CFGWalker::init(), isCXXSharedPtrDtor(), clang::consumed::ConsumedAnalyzer::run(), and clang::runUninitializedVariablesAnalysis().
|
inline |
Definition at line 103 of file AnalysisDeclContext.h.
References clang::Decl::getASTContext().
Referenced by DiagnoseSwitchLabelsFallthrough(), clang::reachable_code::FindUnreachableCode(), clang::ento::SValBuilder::getRegionValueSymbolVal(), clang::ento::getWidenedLoopState(), isCXXSharedPtrDtor(), isPointerToConst(), printObjectsUnderConstructionJson(), and clang::consumed::ConsumedAnalyzer::run().
Definition at line 190 of file AnalysisDeclContext.cpp.
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().
const BlockInvocationContext * AnalysisDeclContext::getBlockInvocationContext | ( | const LocationContext * | parent, |
const BlockDecl * | BD, | ||
const void * | ContextData | ||
) |
Definition at line 318 of file AnalysisDeclContext.cpp.
References clang::LocationContextManager::getBlockInvocationContext().
Referenced by REGISTER_MAP_WITH_PROGRAMSTATE().
Stmt * AnalysisDeclContext::getBody | ( | ) | const |
Get the body of the Declaration.
Definition at line 126 of file AnalysisDeclContext.cpp.
Referenced by DiagnoseSwitchLabelsFallthrough(), getLocationForCaller(), clang::ento::AnyFunctionCall::getRuntimeDefinition(), LookThroughTransitiveAssignmentsAndCommaOperators(), and clang::ento::ExprEngine::removeDeadOnEndOfFunction().
Get the body of the Declaration.
[out] | IsAutosynthesized | Specifies if the body is auto-generated by the BodyFarm. |
Definition at line 93 of file AnalysisDeclContext.cpp.
CFG * AnalysisDeclContext::getCFG | ( | ) |
Definition at line 213 of file AnalysisDeclContext.cpp.
References addParentsForSyntheticStmts(), clang::CFG::buildCFG(), clang::AnalysisDeclContextManager::getCFGBuildOptions(), clang::CFG::BuildOptions::Observer, and clang::CFG::BuildOptions::PruneTriviallyFalseEdges.
Referenced by CheckFallThrough(), checkRecursiveFunction(), checkThrowInNonThrowingFunc(), clang::LiveVariables::computeLiveness(), clang::PostOrderCFGView::create(), DiagnoseSwitchLabelsFallthrough(), clang::reachable_code::FindUnreachableCode(), clang::ento::AnalysisManager::getCFG(), clang::threadSafety::CFGWalker::init(), isCXXSharedPtrDtor(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), clang::ento::ExprEngine::processCallExit(), and clang::consumed::ConsumedAnalyzer::run().
|
inline |
Return the build options used to construct the CFG.
Definition at line 113 of file AnalysisDeclContext.h.
Referenced by clang::ento::ExprEngine::bindReturnValue(), clang::reachable_code::FindUnreachableCode(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), and clang::ento::ExprEngine::VisitCXXConstructExpr().
|
inline |
Definition at line 117 of file AnalysisDeclContext.h.
CFGReverseBlockReachabilityAnalysis * AnalysisDeclContext::getCFGReachablityAnalysis | ( | ) |
Definition at line 263 of file AnalysisDeclContext.cpp.
References c.
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().
CFGStmtMap * AnalysisDeclContext::getCFGStmtMap | ( | ) |
Definition at line 251 of file AnalysisDeclContext.cpp.
References clang::CFGStmtMap::Build(), and c.
Referenced by clang::ento::CallEvent::getCalleeStackFrame().
|
inline |
Definition at line 104 of file AnalysisDeclContext.h.
Referenced by CheckUnreachable(), DiagnoseSwitchLabelsFallthrough(), findVar(), clang::ento::CallEvent::getCalleeAnalysisDeclContext(), getLocationForCaller(), clang::ento::AnyFunctionCall::getRuntimeDefinition(), clang::threadSafety::CFGWalker::init(), isCXXSharedPtrDtor(), isPointerToConst(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), LookThroughTransitiveAssignmentsAndCommaOperators(), and clang::consumed::ConsumedAnalyzer::run().
|
inline |
Return the AnalysisDeclContextManager (if any) that created this AnalysisDeclContext.
Definition at line 108 of file AnalysisDeclContext.h.
Referenced by clang::ento::CallEvent::getCalleeAnalysisDeclContext(), and clang::ento::CallEvent::getCalleeStackFrame().
ParentMap & AnalysisDeclContext::getParentMap | ( | ) |
Definition at line 279 of file AnalysisDeclContext.cpp.
References addParentsForSyntheticStmts(), clang::ParentMap::addStmt(), and clang::C.
Referenced by clang::ento::AnalysisManager::getParentMap(), isReceiverUnconsumedSelf(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), and shouldRemoveDeadBindings().
llvm::iterator_range< AnalysisDeclContext::referenced_decls_iterator > AnalysisDeclContext::getReferencedBlockVars | ( | const BlockDecl * | BD | ) |
Definition at line 652 of file AnalysisDeclContext.cpp.
References LazyInitializeReferencedDecls(), V, and clang::ManagedAnalysis::~ManagedAnalysis().
Referenced by clang::ento::MemRegion::getAsOffset().
const ImplicitParamDecl * AnalysisDeclContext::getSelfDecl | ( | ) | const |
Return the ImplicitParamDecl* associated with 'self' if this AnalysisDeclContext wraps an ObjCMethodDecl.
Returns NULL otherwise.
Definition at line 148 of file AnalysisDeclContext.cpp.
References clang::CXXRecordDecl::captures(), clang::DeclContext::getParent(), clang::CXXRecordDecl::isLambda(), and isSelfDecl().
Referenced by clang::ObjCMethodCall::getInitialStackFrameContents(), clang::LocationContext::getSelfDecl(), and isSelfVar().
const StackFrameContext * AnalysisDeclContext::getStackFrame | ( | LocationContext const * | Parent, |
const Stmt * | S, | ||
const CFGBlock * | Blk, | ||
unsigned | Idx | ||
) |
Definition at line 312 of file AnalysisDeclContext.cpp.
Referenced by REGISTER_MAP_WITH_PROGRAMSTATE().
CFG * AnalysisDeclContext::getUnoptimizedCFG | ( | ) |
Return a version of the CFG without any edges pruned.
Definition at line 232 of file AnalysisDeclContext.cpp.
References addParentsForSyntheticStmts(), clang::CFG::buildCFG(), clang::AnalysisDeclContextManager::getCFGBuildOptions(), clang::CFG::BuildOptions::Observer, and clang::CFG::BuildOptions::PruneTriviallyFalseEdges.
|
inline |
Definition at line 126 of file AnalysisDeclContext.h.
References clang::CFG::BuildOptions::PruneTriviallyFalseEdges.
bool AnalysisDeclContext::isBodyAutosynthesized | ( | ) | const |
Checks if the body of the Decl is generated by the BodyFarm.
Note, the lookup is not free. We are going to call getBody behind the scenes.
Definition at line 131 of file AnalysisDeclContext.cpp.
Referenced by CompactMacroExpandedPieces(), findTopAutosynthesizedParentContext(), clang::ento::PathDiagnosticLocation::getStmt(), isCXXSharedPtrDtor(), clang::ento::retaincountchecker::isSynthesizedAccessor(), and clang::ento::PathDiagnosticCallPiece::setCallee().
bool AnalysisDeclContext::isBodyAutosynthesizedFromModelFile | ( | ) | const |
Checks if the body of the Decl is generated by the BodyFarm from a model file.
Note, the lookup is not free. We are going to call getBody behind the scenes.
Definition at line 137 of file AnalysisDeclContext.cpp.
References clang::Stmt::getBeginLoc(), and clang::SourceLocation::isValid().
Referenced by CompactMacroExpandedPieces().
|
inline |
Returns true if we have built a CFG for this analysis context.
Note that this doesn't correspond to whether or not a valid CFG exists, it corresponds to whether we attempted to build one.
Definition at line 172 of file AnalysisDeclContext.h.
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().
Returns true if the root namespace of the given declaration 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().
void AnalysisDeclContext::registerForcedBlockExpression | ( | const Stmt * | stmt | ) |
Definition at line 180 of file AnalysisDeclContext.cpp.
References clang::ast_matchers::stmt.
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().