clang  8.0.0svn
Macros | Enumerations | Functions
ExprEngineCallAndReturn.cpp File Reference
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
#include "PrettyStackTraceLocationContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclCXX.h"
#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Analysis/ConstructionContext.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/SaveAndRestore.h"
Include dependency graph for ExprEngineCallAndReturn.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "ExprEngine"
 

Enumerations

enum  DynamicDispatchMode
 

Functions

 STATISTIC (NumOfDynamicDispatchPathSplits, "The # of times we split the path due to imprecise dynamic dispatch info")
 
 STATISTIC (NumInlinedCalls, "The # of times we inlined a call")
 
 STATISTIC (NumReachedInlineCountMax, "The # of times we reached inline count maximum")
 
static std::pair< const Stmt *, const CFGBlock * > getLastStmt (const ExplodedNode *Node)
 
static SVal adjustReturnValue (SVal V, QualType ExpectedTy, QualType ActualTy, StoreManager &StoreMgr)
 Adjusts a return value when the called function's return type does not match the caller's expression type. More...
 
static bool wasDifferentDeclUsedForInlining (CallEventRef<> Call, const StackFrameContext *calleeCtx)
 
 REGISTER_TRAIT_WITH_PROGRAMSTATE (DynamicDispatchBifurcationMap, CLANG_ENTO_PROGRAMSTATE_MAP(const MemRegion *, unsigned)) bool ExprEngine
 
static ProgramStateRef getInlineFailedState (ProgramStateRef State, const Stmt *CallE)
 
static bool hasMember (const ASTContext &Ctx, const CXXRecordDecl *RD, StringRef Name)
 Returns true if the given C++ class contains a member with the given name. More...
 
static bool isContainerClass (const ASTContext &Ctx, const CXXRecordDecl *RD)
 Returns true if the given C++ class is a container or iterator. More...
 
static bool isContainerMethod (const ASTContext &Ctx, const FunctionDecl *FD)
 Returns true if the given function refers to a method of a C++ container or iterator. More...
 
static bool isCXXSharedPtrDtor (const FunctionDecl *FD)
 Returns true if the given function is the destructor of a class named "shared_ptr". More...
 
static bool mayInlineDecl (AnalysisManager &AMgr, AnalysisDeclContext *CalleeADC)
 Returns true if the function in CalleeADC may be inlined in general. More...
 
static bool isTrivialObjectAssignment (const CallEvent &Call)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "ExprEngine"

Definition at line 29 of file ExprEngineCallAndReturn.cpp.

Enumeration Type Documentation

◆ DynamicDispatchMode

Definition at line 403 of file ExprEngineCallAndReturn.cpp.

Function Documentation

◆ adjustReturnValue()

static SVal adjustReturnValue ( SVal  V,
QualType  ExpectedTy,
QualType  ActualTy,
StoreManager StoreMgr 
)
static

Adjusts a return value when the called function's return type does not match the caller's expression type.

This can happen when a dynamic call is devirtualized, and the overriding method has a covariant (more specific) return type than the parent's method. For C++ objects, this means we need to add base casts.

Definition at line 126 of file ExprEngineCallAndReturn.cpp.

References clang::ento::SVal::getAs(), clang::QualType::getCanonicalType(), clang::Type::getPointeeCXXRecordDecl(), and clang::Type::isObjCObjectPointerType().

Referenced by clang::ento::ExprEngine::processCallExit().

◆ getInlineFailedState()

static ProgramStateRef getInlineFailedState ( ProgramStateRef  State,
const Stmt CallE 
)
static

Definition at line 468 of file ExprEngineCallAndReturn.cpp.

◆ getLastStmt()

static std::pair<const Stmt*, const CFGBlock*> getLastStmt ( const ExplodedNode Node)
static

◆ hasMember()

static bool hasMember ( const ASTContext Ctx,
const CXXRecordDecl RD,
StringRef  Name 
)
static

Returns true if the given C++ class contains a member with the given name.

Definition at line 776 of file ExprEngineCallAndReturn.cpp.

Referenced by isContainerClass().

◆ isContainerClass()

static bool isContainerClass ( const ASTContext Ctx,
const CXXRecordDecl RD 
)
static

Returns true if the given C++ class is a container or iterator.

Our heuristic for this is whether it contains a method named 'begin()' or a nested type named 'iterator' or 'iterator_category'.

Definition at line 798 of file ExprEngineCallAndReturn.cpp.

References hasMember().

Referenced by isContainerMethod().

◆ isContainerMethod()

static bool isContainerMethod ( const ASTContext Ctx,
const FunctionDecl FD 
)
static

Returns true if the given function refers to a method of a C++ container or iterator.

We generally do a poor job modeling most containers right now, and might prefer not to inline their methods.

Definition at line 809 of file ExprEngineCallAndReturn.cpp.

References isContainerClass().

Referenced by mayInlineDecl().

◆ isCXXSharedPtrDtor()

static bool isCXXSharedPtrDtor ( const FunctionDecl FD)
static

Returns true if the given function is the destructor of a class named "shared_ptr".

Definition at line 818 of file ExprEngineCallAndReturn.cpp.

References clang::DeclarationName::getAsIdentifierInfo(), clang::NamedDecl::getDeclName(), and clang::CXXMethodDecl::getParent().

Referenced by mayInlineDecl().

◆ isTrivialObjectAssignment()

static bool isTrivialObjectAssignment ( const CallEvent Call)
static

◆ mayInlineDecl()

static bool mayInlineDecl ( AnalysisManager AMgr,
AnalysisDeclContext CalleeADC 
)
static

Returns true if the function in CalleeADC may be inlined in general.

This checks static properties of the function, such as its signature and CFG, to determine whether the analyzer should ever consider inlining it, in any context.

Definition at line 836 of file ExprEngineCallAndReturn.cpp.

References clang::AnalyzerOptions::getAlwaysInlineSize(), clang::AnalysisDeclContext::getAnalysis(), clang::ento::AnalysisManager::getAnalysisDeclContextManager(), clang::ento::ExprEngine::getAnalysisManager(), clang::ento::AnalysisManager::getAnalyzerOptions(), clang::AnalysisDeclContext::getASTContext(), clang::AnalysisDeclContext::getCFG(), clang::AnalysisDeclContextManager::getContext(), clang::AnalysisDeclContext::getDecl(), clang::ASTContext::getLangOpts(), clang::ento::ExplodedNode::getLocationContext(), clang::AnalyzerOptions::getMaxInlinableSize(), clang::AnalyzerOptions::getMaxTimesInlineLarge(), clang::AnalyzerOptions::getMinCFGSizeTreatFunctionsAsLarge(), clang::CFG::getNumBlockIDs(), clang::ASTContext::getSourceManager(), clang::ento::ExprEngine::Inline_Minimal, clang::AnalyzerOptions::InlineMaxStackDepth, clang::AnalysisDeclContext::isBodyAutosynthesized(), isContainerMethod(), isCXXSharedPtrDtor(), clang::ento::AnalysisManager::isInCodeFile(), clang::AnalysisDeclContext::isInStdNamespace(), clang::SourceManager::isInSystemHeader(), clang::ento::CallEvent::isVariadic(), clang::AnalyzerOptions::mayInlineCXXContainerMethods(), clang::AnalyzerOptions::mayInlineCXXSharedPtrDtor(), clang::AnalyzerOptions::mayInlineCXXStandardLibrary(), clang::AnalyzerOptions::mayInlineTemplateFunctions(), clang::ento::AnalysisManager::options, clang::ento::AnalysisManager::shouldInlineCall(), and clang::FunctionDecl::TK_NonTemplate.

◆ REGISTER_TRAIT_WITH_PROGRAMSTATE()

REGISTER_TRAIT_WITH_PROGRAMSTATE ( DynamicDispatchBifurcationMap  ,
CLANG_ENTO_PROGRAMSTATE_MAP(const MemRegion *, unsigned)   
)

◆ STATISTIC() [1/3]

STATISTIC ( NumOfDynamicDispatchPathSplits  ,
"The # of times we split the path due to imprecise dynamic dispatch info"   
)

◆ STATISTIC() [2/3]

STATISTIC ( NumInlinedCalls  ,
"The # of times we inlined a call"   
)

◆ STATISTIC() [3/3]

STATISTIC ( NumReachedInlineCountMax  ,
"The # of times we reached inline count maximum"   
)

◆ wasDifferentDeclUsedForInlining()

static bool wasDifferentDeclUsedForInlining ( CallEventRef<>  Call,
const StackFrameContext calleeCtx 
)
static