22 using namespace clang;
33 state = createTemporaryRegionIfNeeded(state, LCtx, tempExpr, ME);
42 bool AlwaysReturnsLValue;
44 assert(Ctor->getDecl()->isTrivial());
45 assert(Ctor->getDecl()->isCopyOrMoveConstructor());
46 ThisVal = Ctor->getCXXThisVal();
47 AlwaysReturnsLValue =
false;
50 assert(cast<CXXMethodDecl>(Call.
getDecl())->getOverloadedOperator() ==
52 ThisVal = cast<CXXInstanceCall>(Call).getCXXThisVal();
53 AlwaysReturnsLValue =
true;
71 evalBind(Dst, CallExpr, Pred, ThisVal, V,
true);
77 if (AlwaysReturnsLValue)
78 State = State->BindExpr(CallExpr, LCtx, ThisVal);
94 SValBuilder &SVB = State->getStateManager().getSValBuilder();
98 Ty = AT->getElementType();
108 unsigned int CurrStmtIdx) {
116 unsigned int NextStmtIdx = CurrStmtIdx + 1;
117 if (NextStmtIdx < B->size()) {
124 Next = (*B)[NextStmtIdx];
129 if (
const DeclStmt *DS = dyn_cast<DeclStmt>(StmtElem->getStmt())) {
130 if (
const VarDecl *Var = dyn_cast<VarDecl>(DS->getSingleDecl())) {
131 if (Var->getInit() && Var->getInit()->IgnoreImplicit() == CE) {
132 SVal LValue = State->getLValue(Var, LCtx);
149 SVal ThisVal = State->getSVal(ThisPtr);
158 FieldVal = State->getLValue(Init->
getMember(), ThisVal);
218 SVal ThisVal = State->getSVal(ThisPtr);
249 E = DstPreVisit.
end();
278 bool IsArray = isa<ElementRegion>(Target);
285 performTrivialCopy(Bldr, *I, *Call);
318 assert(RecordDecl &&
"Only CXXRecordDecls should have destructors");
326 Call->getSourceRange().getBegin(),
327 "Error evaluating destructor");
351 "Error evaluating New Allocator Call");
354 CEMgr.getCXXAllocatorCall(CNE, State, LCtx);
377 unsigned blockCount = currBldrCtx->
blockCount();
382 bool IsStandardGlobalOpNewFunction =
false;
383 if (FD && !isa<CXXMethodDecl>(FD) && !FD->
isVariadic()) {
388 IsStandardGlobalOpNewFunction = II->getName().equals(
"nothrow_t");
392 IsStandardGlobalOpNewFunction = (FD->
getNumParams() == 1);
398 if (IsStandardGlobalOpNewFunction)
412 State = Call->invalidateRegions(blockCount);
427 State = State->assume(symVal,
true);
458 State = State->BindExpr(CNE, LCtx, Result);
466 if (!isa<CXXConstructExpr>(Init)) {
469 evalBind(Dst, CNE, NewN, Result, State->getSVal(Init, LCtx),
470 IsStandardGlobalOpNewFunction);
495 state = state->bindLoc(state->getLValue(VD, LCtx), V);
514 Bldr.
generateNode(TE, Pred, state->BindExpr(TE, LCtx, V));
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
SVal evalDerivedToBase(SVal Derived, const CastExpr *Cast)
MemRegion - The root abstract class for all memory regions.
This builder class is useful for generating nodes that resulted from visiting a statement. The main difference from its parent NodeBuilder is that it creates a statement specific ProgramPoint.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
Manages the lifetime of CallEvent objects.
CallEventRef< CXXDestructorCall > getCXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBase, ProgramStateRef State, const LocationContext *LCtx)
Represents a call to a C++ constructor.
SVal evalCast(SVal val, QualType castTy, QualType originalType)
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
void takeNodes(const ExplodedNodeSet &S)
loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrameContext *SFC)
Return a memory region for the 'this' object reference.
const NodeBuilderContext & getBuilderContext()
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
void VisitCXXThisExpr(const CXXThisExpr *TE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
MemRegionManager & getRegionManager()
ImplTy::iterator iterator
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceLocation getStartLoc() const
void VisitCXXDestructor(QualType ObjectType, const MemRegion *Dest, const Stmt *S, bool IsBaseDtor, ExplodedNode *Pred, ExplodedNodeSet &Dst)
const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call. May be null.
Expr * getPlacementArg(unsigned i)
ASTContext & getContext() const
getContext - Return the ASTContext associated with this analysis.
IndirectFieldDecl * getIndirectMember() const
void runCheckersForPreCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng)
Run checkers for pre-visiting obj-c messages.
Expr * getInitializer()
The initializer of this new-expression.
const ArrayType * getAsArrayType(QualType T) const
const Stmt * getCallSite() const
bool isVariadic() const
Whether this function is variadic.
void runCheckersForPostCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting obj-c messages.
Represents the this expression in C++.
void evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE, ExplodedNode *Pred, SVal location, SVal Val, bool atDeclInit=false, const ProgramPoint *PP=nullptr)
const LocationContext * getLocationContext() const
ProgramStateRef bindReturnValue(const CallEvent &Call, const LocationContext *LCtx, ProgramStateRef State)
Create a new state in which the call return value is binded to the call origin expression.
void VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred, ExplodedNodeSet &Dst)
unsigned blockCount() const
Returns the number of times the current basic block has been visited on the exploded graph path...
CheckerManager & getCheckerManager() const
void runCheckersForPostStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting Stmts.
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
DefinedOrUnknownSVal makeZeroVal(QualType type)
Construct an SVal representing '0' for the specified type.
const ProgramStateRef & getState() const
void VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXNewAllocatorCall(const CXXNewExpr *CNE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Represents a C++ destructor within a class.
static const MemRegion * getRegionForConstructedObject(const CXXConstructExpr *CE, ExplodedNode *Pred, ExprEngine &Eng, unsigned int CurrStmtIdx)
const ElementRegion * GetElementZeroRegion(const MemRegion *R, QualType T)
This is the simplest builder which generates nodes in the ExplodedGraph.
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
void Add(ExplodedNode *N)
const ParmVarDecl * getParamDecl(unsigned i) const
const ExplodedNodeSet & getResults()
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
bool isIndirectMemberInitializer() const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
The result type of a method or function.
NonLoc makeZeroArrayIndex()
CallEventRef< CXXAllocatorCall > getCXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef State, const LocationContext *LCtx)
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, const Expr *expr, const LocationContext *LCtx, unsigned count)
Create a new symbol with a unique 'name'.
unsigned getNumParams() const
const StackFrameContext * getCurrentStackFrame() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
CallEventManager & getCallEventManager()
static SVal makeZeroElementRegion(ProgramStateRef State, SVal LValue, QualType &Ty)
const CXXTempObjectRegion * getCXXTempObjectRegion(Expr const *Ex, LocationContext const *LC)
Represents a static or instance method of a struct/union/class.
ASTContext & getContext()
void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
const Decl * getDecl() const
void runCheckersForPreStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng)
Run checkers for pre-visiting Stmts.
DefinedOrUnknownSVal getConjuredHeapSymbolVal(const Expr *E, const LocationContext *LCtx, unsigned Count)
Conjure a symbol representing heap allocated memory region.
const CXXThisRegion * getCXXThisRegion(QualType thisPointerTy, const LocationContext *LC)
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called. May be null.
SValBuilder & getSValBuilder()
Represents a delete expression for memory deallocation and destructor calls, e.g. "delete[] pArray"...
StoreManager & getStoreManager()
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
const MemRegion * getAsRegion() const
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Represents an abstract call to a function or method along a particular path.
ProgramStateManager & getStateManager() override
const CFGBlock * getBlock() const
Return the CFGBlock associated with this builder.
FunctionDecl * getOperatorNew() const
Represents a C++ base or member initializer.
void VisitCXXConstructExpr(const CXXConstructExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst)
CXXConstructorDecl * getConstructor() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isAnyMemberInitializer() const
CallEventRef< CXXConstructorCall > getCXXConstructorCall(const CXXConstructExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx)
void defaultEvalCall(NodeBuilder &B, ExplodedNode *Pred, const CallEvent &Call)
Default implementation of call evaluation.
ExplodedNode * generateNode(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a node in the ExplodedGraph.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
bool isTrivial(const SExpr *E)
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
CFGElement - Represents a top-level expression in a basic block.
ExplodedNode * generateNode(const Stmt *S, ExplodedNode *Pred, ProgramStateRef St, const ProgramPointTag *tag=nullptr, ProgramPoint::Kind K=ProgramPoint::PostStmtKind)
ElementRegin is used to represent both array elements and casts.
VarDecl * getExceptionDecl() const
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
void CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Create a C++ temporary object for an rvalue.
Represents a call to a C++ constructor.
Optional< T > getAs() const
Convert to the specified CFGElement type, returning None if this CFGElement is not of the desired typ...
Expr * IgnoreParens() LLVM_READONLY