25#include "llvm/ADT/STLExtras.h"
26#include "llvm/ADT/Sequence.h"
27#include "llvm/Support/Casting.h"
40 state = createTemporaryRegionIfNeeded(state, SF, tempExpr, ME);
41 Dst.
insert(Engine.makePostStmtNode(ME, state, Pred));
47 bool AlwaysReturnsLValue;
50 assert(Ctor->getDecl()->isTrivial());
51 assert(Ctor->getDecl()->isCopyOrMoveConstructor());
52 ThisVal = Ctor->getCXXThisVal();
54 AlwaysReturnsLValue =
false;
61 AlwaysReturnsLValue =
true;
73 const Expr *VExpr =
Call.getArgExpr(0);
77 if (std::optional<Loc> L =
V.getAs<
Loc>())
80 assert(
V.isUnknownOrUndef());
86 evalBind(DstEval,
CallExpr, N, ThisVal,
V, !AlwaysReturnsLValue);
95 for (ExplodedNode *N : DstEval) {
97 if (AlwaysReturnsLValue)
98 State = State->BindExpr(CallExpr, SF, ThisVal);
101 Dst.
insert(Engine.makePostStmtNode(CallExpr, State, N));
106 QualType &Ty,
bool &IsArray,
unsigned Idx) {
107 SValBuilder &SVB = State->getStateManager().getSValBuilder();
112 Ty = AT->getElementType();
113 AT = dyn_cast<ArrayType>(AT->getElementType());
140 const auto *DS = DSCC->getDeclStmt();
143 return makeElementRegion(State, State->getLValue(Var, SF), Ty,
149 const auto *
Init = ICC->getCXXCtorInitializer();
152 SVal ThisVal = State->getSVal(ThisPtr);
153 if (
Init->isBaseInitializer()) {
156 Init->getBaseClass()->getAsCXXRecordDecl();
157 const auto *BaseReg =
158 MRMgr.getCXXBaseObjectRegion(BaseClass, ThisReg,
159 Init->isBaseVirtual());
162 if (
Init->isDelegatingInitializer())
167 if (
Init->isIndirectMemberInitializer()) {
168 Field =
Init->getIndirectMember();
169 FieldVal = State->getLValue(
Init->getIndirectMember(), ThisVal);
171 Field =
Init->getMember();
172 FieldVal = State->getLValue(
Init->getMember(), ThisVal);
180 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
182 const auto *NE = NECC->getCXXNewExpr();
185 dyn_cast_or_null<SubRegion>(
V.getAsRegion())) {
189 auto Ty = NE->getType()->getPointeeType();
190 while (
const auto *AT =
getContext().getAsArrayType(Ty))
191 Ty = AT->getElementType();
193 auto R = MRMgr.getElementRegion(Ty, svalBuilder.makeArrayIndex(Idx),
223 RTC->getConstructionContext(), CallOpts);
237 static const int TopLevelSymRegionTag = 0;
238 const Expr *RetE = RCC->getReturnStmt()->getRetValue();
239 assert(RetE &&
"Void returns should not have a construction context");
245 llvm_unreachable(
"Unhandled return value construction context!");
248 assert(AMgr.getAnalyzerOptions().ShouldElideConstructors);
262 TCC->getConstructorAfterElision(), State, NumVisitedCaller, SF,
263 TCC->getConstructionContextAfterElision(), CallOpts);
273 CallOpts = PreElideCallOpts;
286 if (!VD->getType()->isReferenceType()) {
297 MRMgr.getCXXStaticLifetimeExtendedObjectRegion(E, VD));
300 MRMgr.getCXXLifetimeExtendedObjectRegion(E, VD, SF));
313 MRMgr.getCXXTempObjectRegion(LCC->getInitializer(), SF));
315 const auto *CE = dyn_cast_or_null<CXXConstructExpr>(E);
318 Base = State->getLValue(E->
getType(), svalBuilder.makeArrayIndex(Idx),
329 const Expr *E = ACC->getCallLikeExpr();
330 unsigned Idx = ACC->getIndex();
333 auto getArgLoc = [&](
CallEventRef<> Caller) -> std::optional<SVal> {
335 Caller->getCalleeStackFrame(NumVisitedCaller);
354 *Caller->getAdjustedParameterIndex(Idx), NumVisitedCaller);
361 if (
const auto *CE = dyn_cast<CallExpr>(E)) {
364 if (std::optional<SVal>
V = getArgLoc(Caller))
368 }
else if (
const auto *CCE = dyn_cast<CXXConstructExpr>(E)) {
373 if (std::optional<SVal>
V = getArgLoc(Caller))
377 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(E)) {
380 if (std::optional<SVal>
V = getArgLoc(Caller))
406 assert(CC &&
"Computed target region without construction context?");
411 return addObjectUnderConstruction(State, DSCC->getDeclStmt(), SF,
V);
416 const auto *
Init = ICC->getCXXCtorInitializer();
418 assert(
Init->isAnyMemberInitializer() &&
419 "Base and delegating initializers should have been handled by"
420 "computeObjectUnderConstruction()");
421 return addObjectUnderConstruction(State,
Init, SF,
V);
436 assert(RTC &&
"Could not have had a target region without it");
439 V, SF->
getCallSite(), State, CallerSF, RTC->getConstructionContext(),
443 assert(AMgr.getAnalyzerOptions().ShouldElideConstructors);
447 V, TCC->getConstructorAfterElision(), State, SF,
448 TCC->getConstructionContextAfterElision(), CallOpts);
451 State = addObjectUnderConstruction(
452 State, TCC->getConstructorAfterElision(), SF,
V);
455 if (
const auto *BTE = TCC->getCXXBindTemporaryExpr())
456 State = elideDestructor(State, BTE, SF);
460 if (
const auto *MTE = TCC->getMaterializedTemporaryExpr())
461 State = addObjectUnderConstruction(State, MTE, SF,
V);
471 if (
const auto *BTE = TCC->getCXXBindTemporaryExpr())
472 State = addObjectUnderConstruction(State, BTE, SF,
V);
474 if (
const auto *MTE = TCC->getMaterializedTemporaryExpr())
475 State = addObjectUnderConstruction(State, MTE, SF,
V);
484 if (
const auto *EL = dyn_cast_or_null<ElementRegion>(
V.getAsRegion()))
487 return addObjectUnderConstruction(
488 State, {LCC->getLambdaExpr(), LCC->getIndex()}, SF,
V);
492 if (
const auto *BTE = ACC->getCXXBindTemporaryExpr())
493 State = addObjectUnderConstruction(State, BTE, SF,
V);
495 return addObjectUnderConstruction(
496 State, {ACC->getCallLikeExpr(), ACC->getIndex()}, SF,
V);
499 llvm_unreachable(
"Unhandled construction context!");
517 const auto *SourceArrayRegion =
525void ExprEngine::handleConstructor(
const Expr *E,
ExplodedNode *Pred,
527 const auto *CE = dyn_cast<CXXConstructExpr>(E);
528 const auto *CIE = dyn_cast<CXXInheritedCtorInitExpr>(E);
534 SVal
Target = UnknownVal();
537 if (std::optional<SVal> ElidedTarget =
543 State = finishObjectConstruction(State, CE, SF);
544 if (
auto L =
Target.getAs<Loc>())
545 State = State->BindExpr(CE, SF, State->getSVal(*L, CE->getType()));
546 Dst.
insert(Engine.makePostStmtNode(CE, State, Pred));
551 EvalCallOptions CallOpts;
554 const ConstructionContext *CC =
C ?
C->getConstructionContext() :
nullptr;
557 CE ? CE->getConstructionKind() : CIE->getConstructionKind();
561 assert(CE && !CIE &&
"A complete constructor is inherited?!");
568 if (CE->getType()->isArrayType() || AILE) {
570 auto isZeroSizeArray = [&] {
573 if (
const auto *CAT = dyn_cast<ConstantArrayType>(CE->getType()))
582 if (isZeroSizeArray()) {
583 static SimpleProgramPointTag
T{
"ExprEngine",
584 "Skipping 0 size array construction"};
586 Dst.
insert(Engine.makeNode(Loc, State, Pred));
591 State = setIndexOfElementToConstruct(State, CE, SF, Idx + 1);
597 State = setPendingInitLoop(
598 State, CE, SF,
getContext().getArrayInitLoopExprElementCount(AILE));
601 State, AILE, SF, svalBuilder.makeArrayIndex(Idx));
606 SF, CC, CallOpts, Idx);
612 const auto *OuterCtor =
613 dyn_cast_or_null<CXXConstructExpr>(SF->
getCallSite());
618 (
"This virtual base should have already been initialized by "
619 "the most derived class!"));
635 if (isa_and_nonnull<InitListExpr, CXXParenListInitExpr>(
638 Target = loc::MemRegionVal(MRMgr.getCXXTempObjectRegion(E, SF));
646 SVal ThisVal = State->getSVal(ThisPtr);
662 static SimpleProgramPointTag
T(
"ExprEngine",
663 "Prepare for object construction");
664 Pred = Engine.makeNode(PreStmt(E, SF, &
T), State, Pred);
669 const MemRegion *TargetRegion =
Target.getAsRegion();
671 CallEventRef<>
Call =
677 ExplodedNodeSet DstPreVisit;
680 ExplodedNodeSet PreInitialized;
683 for (ExplodedNode *N : DstPreVisit) {
685 if (CE->requiresZeroInitialization()) {
698 const CXXRecordDecl *TargetHeldRecord =
699 dyn_cast_or_null<CXXRecordDecl>(CE->getType()->getAsRecordDecl());
701 if (!TargetHeldRecord || !TargetHeldRecord->
isEmpty())
702 State = State->bindDefaultZero(
Target, SF);
705 PreStmt P(CE, N->getStackFrame(),
nullptr);
706 PreInitialized.
insert(Engine.makeNode(P, State, N));
709 PreInitialized = DstPreVisit;
712 ExplodedNodeSet DstPreCall;
716 ExplodedNodeSet DstEvaluated;
718 if (CE && CE->getConstructor()->isTrivial() &&
719 CE->getConstructor()->isCopyOrMoveConstructor() &&
722 for (ExplodedNode *N : DstPreCall)
723 performTrivialCopy(DstEvaluated, N, *
Call);
726 for (ExplodedNode *N : DstPreCall)
738 ExplodedNodeSet DstEvaluatedPostProcessed;
741 if (llvm::isa_and_nonnull<CXXTempObjectRegion,
742 CXXLifetimeExtendedObjectRegion>(TargetRegion) &&
745 ->isAnyDestructorNoReturn()) {
754 assert(!DstEvaluated.
empty() &&
755 "We should not have inlined this constructor!");
757 for (ExplodedNode *N : DstEvaluated) {
758 Engine.makePostStmtNode(E, N->getState(), N,
true);
768 DstEvaluatedPostProcessed.
insert(DstEvaluated);
769 ExplodedNodeSet DstPostArgumentCleanup;
770 for (ExplodedNode *I : DstEvaluatedPostProcessed)
771 finishArgumentConstruction(DstPostArgumentCleanup, I, *
Call);
775 ExplodedNodeSet DstPostCall;
777 DstPostArgumentCleanup,
785 handleConstructor(CE, Pred, Dst);
791 handleConstructor(CE, Pred, Dst);
801 assert(S &&
"A destructor without a trigger!");
806 assert(
RecordDecl &&
"Only CXXRecordDecls should have destructors");
828 if (
const Expr *E = dyn_cast_or_null<Expr>(S)) {
829 Dest = MRMgr.getCXXTempObjectRegion(E, Pred->
getStackFrame());
843 Call->getSourceRange().getBegin(),
844 "Error evaluating destructor");
865 "Error evaluating New Allocator Call");
902 SVal RetVal = State->getSVal(CNE, SF);
907 State = State->bindDefaultInitial(RetVal,
UndefinedVal{}, SF);
919 if (!ProtoType->isNothrow())
923 DstPostValue.
insert(Engine.makePostStmtNode(
924 CNE, addObjectUnderConstruction(State, CNE, SF, RetVal), I));
929 DstPostValue, *
Call, *
this);
947 bool IsStandardGlobalOpNewFunction =
953 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
955 State = finishObjectConstruction(State, CNE, SF);
962 if (IsStandardGlobalOpNewFunction)
966 symVal = svalBuilder.conjureSymbolVal(
974 if (!AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
979 State =
Call->invalidateRegions(blockCount, State);
991 if (!ProtoType->isNothrow())
993 State = State->assume(*dSymVal,
true);
1000 if (
const auto *NewReg = cast_or_null<SubRegion>(symVal.
getAsRegion())) {
1006 isa_and_nonnull<InitListExpr, CXXParenListInitExpr>(
Init);
1011 MRMgr.getElementRegion(ObjTy, svalBuilder.makeArrayIndex(0), NewReg,
1012 svalBuilder.getContext());
1018 Pred = Engine.makePostStmtNode(CNE, State, Pred);
1025 Dst.
insert(Engine.makeNodeWithBinding(N, CNE,
Result));
1030 Dst.
insert(Engine.makeNodeWithBinding(Pred, CNE,
Result, State));
1055 assert(Dst.
size() == 1);
1057 evalBind(Dst, CNE, NewN,
Result, State->getSVal(
Init, SF),
1058 IsStandardGlobalOpNewFunction);
1074 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
1083 DstPostCall = std::move(DstPreCall);
1100 state = state->bindLoc(state->getLValue(VD, SF),
V, SF);
1102 Dst.
insert(Engine.makePostStmtNode(CS, state, Pred));
1109 const MemRegion *R = svalBuilder.getRegionManager().getCXXThisRegion(
1114 Dst.
insert(Engine.makeNodeWithBinding(Pred, TE,
V));
1123 svalBuilder.getRegionManager().getCXXTempObjectRegion(LE, SF);
1130 for (
auto const [Idx, FieldForCapture, InitExpr] :
1131 llvm::zip(llvm::seq<unsigned>(0, -1), LE->getLambdaClass()->fields(),
1132 LE->capture_inits())) {
1133 SVal FieldLoc = State->getLValue(FieldForCapture,
V);
1136 if (!FieldForCapture->hasCapturedVLAType()) {
1137 assert(InitExpr &&
"Capture missing initialization expression");
1143 const auto FTy = FieldForCapture->getType();
1144 if (FTy->isConstantArrayType() &&
1146 getContext().getAsConstantArrayType(FTy)) == 0)
1153 InitVal = State->getSVal(OUC->getAsRegion());
1155 State = finishObjectConstruction(State, {LE, Idx}, SF);
1157 InitVal = State->getSVal(InitExpr, SF);
1162 "VLA capture by value is a compile time error!");
1167 Expr *SizeExpr = FieldForCapture->getCapturedVLAType()->getSizeExpr();
1168 InitVal = State->getSVal(SizeExpr, SF);
1171 State = State->bindLoc(FieldLoc, InitVal, SF);
1177 SVal LambdaRVal = State->getSVal(R);
1180 ExplodedNode *N = Engine.makeNodeWithBinding(Pred, LE, LambdaRVal, State,
1198 SVal AssumedVal = State->getSVal(
Attr->getAssumption(), SF);
1202 State = State->assume(*ValidAssumedVal,
true);
1210 EvalSet.
insert(Engine.makePostStmtNode(A, State, N));
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static ProgramStateRef bindRequiredArrayElementToEnvironment(ProgramStateRef State, const ArrayInitLoopExpr *AILE, const StackFrame *SF, NonLoc Idx)
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE) const
Return number of elements initialized in an ArrayInitLoopExpr.
CFG::BuildOptions & getCFGBuildOptions()
Represents a loop initializing the elements of an array.
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Attr - This represents one attribute.
Represents an attribute applied to a statement.
ArrayRef< const Attr * > getAttrs() const
Represents a function call that returns a C++ object by value.
std::optional< T > getAs() const
Convert to the specified CFGElement type, returning std::nullopt if this CFGElement is not of the des...
CXXCatchStmt - This represents a C++ catch block.
VarDecl * getExceptionDecl() const
Represents a call to a C++ constructor.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents a C++ destructor within a class.
Represents a call to an inherited base class constructor from an inheriting constructor.
Represents a static or instance method of a struct/union/class.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Expr * getPlacementArg(unsigned I)
SourceLocation getBeginLoc() const
FunctionDecl * getOperatorNew() const
Expr * getInitializer()
The initializer of this new-expression.
Represents a C++ struct/union/class.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
ConstructionContext's subclasses describe different ways of constructing an object in C++.
virtual const ArrayInitLoopExpr * getArrayInitLoop() const
@ CXX17ElidedCopyVariableKind
@ ElidedTemporaryObjectKind
@ SimpleTemporaryObjectKind
@ CXX17ElidedCopyConstructorInitializerKind
@ SimpleConstructorInitializerKind
@ SimpleReturnedValueKind
@ CXX17ElidedCopyReturnedValueKind
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Represents a function declaration or definition.
bool isReplaceableGlobalAllocationFunction(UnsignedOrNone *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions:
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
Represents a prototype with parameter type info, e.g.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Stmt * getParent(Stmt *) const
Represents a program point just after an implicit call event.
If a crash happens while one of these objects are live, the message is printed out along with the spe...
ProgramPoint withTag(const ProgramPointTag *tag) const
Create a new ProgramPoint object that is the same as the original except for using the specified tag ...
A (possibly-)qualified type.
Represents a struct/union/class.
It represents a stack frame of the call stack.
const ParentMap & getParentMap() const
unsigned getIndex() const
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
const Expr * getCallSite() const
const Decl * getDecl() const
const StackFrame * getParent() const
It might return null.
const CFGBlock * getCallSiteBlock() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
const T * getAs() const
Member-template getAs<specific type>'.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Represents a call to a C++ constructor.
Manages the lifetime of CallEvent objects.
CallEventRef< CXXConstructorCall > getCXXConstructorCall(const CXXConstructExpr *E, const MemRegion *Target, ProgramStateRef State, const StackFrame *SF, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXAllocatorCall > getCXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef State, const StackFrame *SF, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXInheritedConstructorCall > getCXXInheritedConstructorCall(const CXXInheritedCtorInitExpr *E, const MemRegion *Target, ProgramStateRef State, const StackFrame *SF, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXDeallocatorCall > getCXXDeallocatorCall(const CXXDeleteExpr *E, ProgramStateRef State, const StackFrame *SF, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXDestructorCall > getCXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBase, ProgramStateRef State, const StackFrame *SF, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< ObjCMethodCall > getObjCMethodCall(const ObjCMessageExpr *E, ProgramStateRef State, const StackFrame *SF, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef getSimpleCall(const CallExpr *E, ProgramStateRef State, const StackFrame *SF, CFGBlock::ConstCFGElementRef ElemRef)
Represents an abstract call to a function or method along a particular path.
static bool isVariadic(const Decl *D)
Returns true if the given decl is known to be variadic.
void runCheckersForPreCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng)
Run checkers for pre-visiting function calls (including methods, constructors, destructors etc.
void runCheckersForEvalCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &CE, ExprEngine &Eng, const EvalCallOptions &CallOpts)
Run checkers for evaluating a call.
void runCheckersForPostStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting Stmts.
void runCheckersForNewAllocator(const CXXAllocatorCall &Call, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, bool wasInlined=false)
Run checkers between C++ operator new and constructor calls.
void runCheckersForPreStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng)
Run checkers for pre-visiting Stmts.
void runCheckersForPostCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting function calls (including methods, constructors, destructors etc.
ElementRegion is used to represent both array elements and casts.
ExplodedNodeSet is a set of ExplodedNode * elements with the invariant that its elements cannot be nu...
void insert(ExplodedNode *N)
bool erase(ExplodedNode *N)
const ProgramStateRef & getState() const
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
const StackFrame * getStackFrame() const
ProgramStateManager & getStateManager()
void VisitCXXDestructor(QualType ObjectType, const MemRegion *Dest, const Stmt *S, bool IsBaseDtor, ExplodedNode *Pred, ExplodedNodeSet &Dst, EvalCallOptions &Options)
void VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitLambdaExpr - Transfer function logic for LambdaExprs.
CFGElement getCurrentCFGElement()
Return the CFG element corresponding to the worklist element that is currently being processed by Exp...
static std::optional< unsigned > getIndexOfElementToConstruct(ProgramStateRef State, const CXXConstructExpr *E, const StackFrame *SF)
Retrieves which element is being constructed in a non-POD type array.
ProgramStateRef bindReturnValue(const CallEvent &Call, const StackFrame *SF, ProgramStateRef State)
Create a new state in which the call return value is binded to the call origin expression.
static std::optional< unsigned > getPendingInitLoop(ProgramStateRef State, const CXXConstructExpr *E, const StackFrame *SF)
Retrieves the size of the array in the pending ArrayInitLoopExpr.
ASTContext & getContext() const
getContext - Return the ASTContext associated with this analysis.
StoreManager & getStoreManager()
void VisitCXXNewAllocatorCall(const CXXNewExpr *CNE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Create a C++ temporary object for an rvalue.
ProgramStateRef updateObjectsUnderConstruction(SVal V, const Expr *E, ProgramStateRef State, const StackFrame *SF, const ConstructionContext *CC, const EvalCallOptions &CallOpts)
Update the program state with all the path-sensitive information that's necessary to perform construc...
void defaultEvalCall(ExplodedNodeSet &Dst, ExplodedNode *Pred, const CallEvent &Call, const EvalCallOptions &CallOpts={})
Default implementation of call evaluation.
ConstCFGElementRef getCFGElementRef() const
CheckerManager & getCheckerManager() const
static std::optional< SVal > getObjectUnderConstruction(ProgramStateRef State, const ConstructionContextItem &Item, const StackFrame *SF)
By looking at a certain item that may be potentially part of an object's ConstructionContext,...
SVal computeObjectUnderConstruction(const Expr *E, ProgramStateRef State, unsigned NumVisitedCaller, const StackFrame *SF, const ConstructionContext *CC, EvalCallOptions &CallOpts, unsigned Idx=0)
Find location of the object that is being constructed by a given constructor.
void VisitCXXThisExpr(const CXXThisExpr *TE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXConstructExpr(const CXXConstructExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst)
unsigned getNumVisitedCurrent() const
void VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred, ExplodedNodeSet &Dst)
std::pair< ProgramStateRef, SVal > handleConstructionContext(const Expr *E, ProgramStateRef State, const NodeBuilderContext *BldrCtx, const StackFrame *SF, const ConstructionContext *CC, EvalCallOptions &CallOpts, unsigned Idx=0)
A convenient wrapper around computeObjectUnderConstruction and updateObjectsUnderConstruction.
SValBuilder & getSValBuilder()
void VisitAttributedStmt(const AttributedStmt *A, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitAttributedStmt - Transfer function logic for AttributedStmt.
unsigned getNumVisited(const StackFrame *SF, const CFGBlock *Block) const
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, const ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type,...
MemRegion - The root abstract class for all memory regions.
SValBuilder & getSValBuilder()
CallEventManager & getCallEventManager()
MemRegionManager & getRegionManager()
ProgramStateManager & getStateManager()
NonLoc makeArrayIndex(uint64_t idx)
ASTContext & getContext()
loc::MemRegionVal makeLoc(SymbolRef sym)
loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrame *SF)
Return a memory region for the 'this' object reference.
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, ConstCFGElementRef elem, const StackFrame *SF, unsigned count)
Create a new symbol with a unique 'name'.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
std::optional< T > getAs() const
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type.
const MemRegion * getAsRegion() const
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
SVal evalDerivedToBase(SVal Derived, const CastExpr *Cast)
Evaluates a chain of derived-to-base casts through the path specified in Cast.
SubRegion - A region that subsets another larger region.
TypedValueRegion - An abstract class representing regions having a typed value.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
@ SD_Thread
Thread storage duration.
@ SD_Static
Static storage duration.
@ SD_FullExpression
Full-expression storage duration (for temporaries).
@ Result
The result type of a method or function.
const FunctionProtoType * T
auto getSpecificAttrs(const Container &container)
U cast(CodeGen::Address addr)
Expr * extractElementInitializerFromNestedAILE(const ArrayInitLoopExpr *AILE)
Hints for figuring out if a call should be inlined during evalCall().
bool IsTemporaryLifetimeExtendedViaAggregate
This call is a constructor for a temporary that is lifetime-extended by binding it to a reference-typ...
bool IsTemporaryCtorOrDtor
This call is a constructor or a destructor of a temporary value.
bool IsArrayCtorOrDtor
This call is a constructor or a destructor for a single element within an array, a part of array cons...
bool IsElidableCtorThatHasNotBeenElided
This call is a pre-C++17 elidable constructor that we failed to elide because we failed to compute th...
bool IsCtorOrDtorWithImproperlyModeledTargetRegion
This call is a constructor or a destructor for which we do not currently compute the this-region corr...