25#include "llvm/ADT/STLExtras.h"
26#include "llvm/ADT/Sequence.h"
27#include "llvm/Support/Casting.h"
41 state = createTemporaryRegionIfNeeded(state, LCtx, tempExpr, ME);
50 bool AlwaysReturnsLValue;
53 assert(Ctor->getDecl()->isTrivial());
54 assert(Ctor->getDecl()->isCopyOrMoveConstructor());
55 ThisVal = Ctor->getCXXThisVal();
57 AlwaysReturnsLValue =
false;
64 AlwaysReturnsLValue =
true;
77 const Expr *VExpr =
Call.getArgExpr(0);
81 if (std::optional<Loc> L =
V.getAs<
Loc>())
84 assert(
V.isUnknownOrUndef());
90 evalBind(Dst,
CallExpr, N, ThisVal,
V, !AlwaysReturnsLValue);
99 PostStmt PS(CallExpr, LCtx);
100 for (ExplodedNode *N : Dst) {
102 if (AlwaysReturnsLValue)
103 State = State->BindExpr(CallExpr, LCtx, ThisVal);
111 QualType &Ty,
bool &IsArray,
unsigned Idx) {
112 SValBuilder &SVB = State->getStateManager().getSValBuilder();
117 Ty = AT->getElementType();
118 AT = dyn_cast<ArrayType>(AT->getElementType());
146 const auto *DS = DSCC->getDeclStmt();
149 return makeElementRegion(State, State->getLValue(Var, LCtx), Ty,
155 const auto *
Init = ICC->getCXXCtorInitializer();
158 SVal ThisVal = State->getSVal(ThisPtr);
159 if (
Init->isBaseInitializer()) {
162 Init->getBaseClass()->getAsCXXRecordDecl();
163 const auto *BaseReg =
164 MRMgr.getCXXBaseObjectRegion(BaseClass, ThisReg,
165 Init->isBaseVirtual());
168 if (
Init->isDelegatingInitializer())
173 if (
Init->isIndirectMemberInitializer()) {
174 Field =
Init->getIndirectMember();
175 FieldVal = State->getLValue(
Init->getIndirectMember(), ThisVal);
177 Field =
Init->getMember();
178 FieldVal = State->getLValue(
Init->getMember(), ThisVal);
186 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
188 const auto *NE = NECC->getCXXNewExpr();
191 dyn_cast_or_null<SubRegion>(
V.getAsRegion())) {
195 auto Ty = NE->getType()->getPointeeType();
196 while (
const auto *AT =
getContext().getAsArrayType(Ty))
197 Ty = AT->getElementType();
199 auto R = MRMgr.getElementRegion(Ty, svalBuilder.makeArrayIndex(Idx),
229 CallerLCtx = CallerLCtx->getParent();
237 RTC->getConstructionContext(), CallOpts);
251 static const int TopLevelSymRegionTag = 0;
252 const Expr *RetE = RCC->getReturnStmt()->getRetValue();
253 assert(RetE &&
"Void returns should not have a construction context");
257 SFC, RegionTy, currBldrCtx->blockCount());
259 llvm_unreachable(
"Unhandled return value construction context!");
262 assert(AMgr.getAnalyzerOptions().ShouldElideConstructors);
276 TCC->getConstructorAfterElision(), State, BldrCtx, LCtx,
277 TCC->getConstructionContextAfterElision(), CallOpts);
287 CallOpts = PreElideCallOpts;
300 if (!VD->getType()->isReferenceType()) {
311 MRMgr.getCXXStaticLifetimeExtendedObjectRegion(E, VD));
314 MRMgr.getCXXLifetimeExtendedObjectRegion(E, VD, LCtx));
327 MRMgr.getCXXTempObjectRegion(LCC->getInitializer(), LCtx));
329 const auto *CE = dyn_cast_or_null<CXXConstructExpr>(E);
332 Base = State->getLValue(E->
getType(), svalBuilder.makeArrayIndex(Idx),
343 const Expr *E = ACC->getCallLikeExpr();
344 unsigned Idx = ACC->getIndex();
347 auto getArgLoc = [&](
CallEventRef<> Caller) -> std::optional<SVal> {
349 Caller->getCalleeStackFrame(BldrCtx->
blockCount());
368 *Caller->getAdjustedParameterIndex(Idx), BldrCtx->
blockCount());
375 if (
const auto *CE = dyn_cast<CallExpr>(E)) {
378 if (std::optional<SVal>
V = getArgLoc(Caller))
382 }
else if (
const auto *CCE = dyn_cast<CXXConstructExpr>(E)) {
387 if (std::optional<SVal>
V = getArgLoc(Caller))
391 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(E)) {
394 if (std::optional<SVal>
V = getArgLoc(Caller))
420 assert(CC &&
"Computed target region without construction context?");
425 return addObjectUnderConstruction(State, DSCC->getDeclStmt(), LCtx,
V);
430 const auto *
Init = ICC->getCXXCtorInitializer();
432 assert(
Init->isAnyMemberInitializer() &&
433 "Base and delegating initializers should have been handled by"
434 "computeObjectUnderConstruction()");
435 return addObjectUnderConstruction(State,
Init, LCtx,
V);
451 assert(RTC &&
"Could not have had a target region without it");
461 RTC->getConstructionContext(), CallOpts);
464 assert(AMgr.getAnalyzerOptions().ShouldElideConstructors);
468 V, TCC->getConstructorAfterElision(), State, LCtx,
469 TCC->getConstructionContextAfterElision(), CallOpts);
472 State = addObjectUnderConstruction(
473 State, TCC->getConstructorAfterElision(), LCtx,
V);
476 if (
const auto *BTE = TCC->getCXXBindTemporaryExpr())
477 State = elideDestructor(State, BTE, LCtx);
481 if (
const auto *MTE = TCC->getMaterializedTemporaryExpr())
482 State = addObjectUnderConstruction(State, MTE, LCtx,
V);
492 if (
const auto *BTE = TCC->getCXXBindTemporaryExpr())
493 State = addObjectUnderConstruction(State, BTE, LCtx,
V);
495 if (
const auto *MTE = TCC->getMaterializedTemporaryExpr())
496 State = addObjectUnderConstruction(State, MTE, LCtx,
V);
505 if (
const auto *EL = dyn_cast_or_null<ElementRegion>(
V.getAsRegion()))
508 return addObjectUnderConstruction(
509 State, {LCC->getLambdaExpr(), LCC->getIndex()}, LCtx,
V);
513 if (
const auto *BTE = ACC->getCXXBindTemporaryExpr())
514 State = addObjectUnderConstruction(State, BTE, LCtx,
V);
516 return addObjectUnderConstruction(
517 State, {ACC->getCallLikeExpr(), ACC->getIndex()}, LCtx,
V);
520 llvm_unreachable(
"Unhandled construction context!");
538 const auto *SourceArrayRegion =
543 return State->BindExpr(Ctor->getArg(0), LCtx,
547void ExprEngine::handleConstructor(
const Expr *E,
550 const auto *CE = dyn_cast<CXXConstructExpr>(E);
551 const auto *CIE = dyn_cast<CXXInheritedCtorInitExpr>(E);
557 SVal
Target = UnknownVal();
560 if (std::optional<SVal> ElidedTarget =
566 StmtNodeBuilder Bldr(Pred, destNodes, *currBldrCtx);
567 State = finishObjectConstruction(State, CE, LCtx);
568 if (
auto L =
Target.getAs<Loc>())
569 State = State->BindExpr(CE, LCtx, State->getSVal(*L, CE->getType()));
575 EvalCallOptions CallOpts;
578 const ConstructionContext *CC =
C ?
C->getConstructionContext() :
nullptr;
581 CE ? CE->getConstructionKind() : CIE->getConstructionKind();
585 assert(CE && !CIE &&
"A complete constructor is inherited?!");
592 if (CE->getType()->isArrayType() || AILE) {
594 auto isZeroSizeArray = [&] {
597 if (
const auto *CAT = dyn_cast<ConstantArrayType>(CE->getType()))
606 if (isZeroSizeArray()) {
607 StmtNodeBuilder Bldr(Pred, destNodes, *currBldrCtx);
608 static SimpleProgramPointTag
T{
"ExprEngine",
609 "Skipping 0 size array construction"};
615 State = setIndexOfElementToConstruct(State, CE, LCtx, Idx + 1);
621 State = setPendingInitLoop(
623 getContext().getArrayInitLoopExprElementCount(AILE));
626 State, AILE, LCtx, svalBuilder.makeArrayIndex(Idx));
631 CE, State, currBldrCtx, LCtx, CC, CallOpts, Idx);
637 const auto *OuterCtor = dyn_cast_or_null<CXXConstructExpr>(
643 (
"This virtual base should have already been initialized by "
644 "the most derived class!"));
660 if (isa_and_nonnull<InitListExpr, CXXParenListInitExpr>(
663 Target = loc::MemRegionVal(MRMgr.getCXXTempObjectRegion(E, LCtx));
672 SVal ThisVal = State->getSVal(ThisPtr);
688 static SimpleProgramPointTag
T(
"ExprEngine",
689 "Prepare for object construction");
690 ExplodedNodeSet DstPrepare;
691 StmtNodeBuilder BldrPrepare(Pred, DstPrepare, *currBldrCtx);
693 assert(DstPrepare.
size() <= 1);
694 if (DstPrepare.
size() == 0)
696 Pred = *BldrPrepare.begin();
699 const MemRegion *TargetRegion =
Target.getAsRegion();
701 CallEventRef<>
Call =
707 ExplodedNodeSet DstPreVisit;
710 ExplodedNodeSet PreInitialized;
713 StmtNodeBuilder Bldr(DstPreVisit, PreInitialized, *currBldrCtx);
714 for (ExplodedNode *N : DstPreVisit) {
716 if (CE->requiresZeroInitialization()) {
729 const CXXRecordDecl *TargetHeldRecord =
730 dyn_cast_or_null<CXXRecordDecl>(CE->getType()->getAsRecordDecl());
732 if (!TargetHeldRecord || !TargetHeldRecord->
isEmpty())
733 State = State->bindDefaultZero(
Target, LCtx);
740 PreInitialized = DstPreVisit;
743 ExplodedNodeSet DstPreCall;
747 ExplodedNodeSet DstEvaluated;
749 if (CE && CE->getConstructor()->isTrivial() &&
750 CE->getConstructor()->isCopyOrMoveConstructor() &&
752 StmtNodeBuilder Bldr(DstPreCall, DstEvaluated, *currBldrCtx);
754 for (ExplodedNode *N : DstPreCall)
755 performTrivialCopy(Bldr, N, *
Call);
758 for (ExplodedNode *N : DstPreCall)
770 ExplodedNodeSet DstEvaluatedPostProcessed;
771 StmtNodeBuilder Bldr(DstEvaluated, DstEvaluatedPostProcessed, *currBldrCtx);
774 if (llvm::isa_and_nonnull<CXXTempObjectRegion,
775 CXXLifetimeExtendedObjectRegion>(TargetRegion) &&
778 ->isAnyDestructorNoReturn()) {
787 assert(!DstEvaluated.
empty() &&
788 "We should not have inlined this constructor!");
790 for (ExplodedNode *N : DstEvaluated) {
801 ExplodedNodeSet DstPostArgumentCleanup;
802 for (ExplodedNode *I : DstEvaluatedPostProcessed)
803 finishArgumentConstruction(DstPostArgumentCleanup, I, *
Call);
807 ExplodedNodeSet DstPostCall;
809 DstPostArgumentCleanup,
817 handleConstructor(CE, Pred, Dst);
823 handleConstructor(CE, Pred, Dst);
833 assert(S &&
"A destructor without a trigger!");
838 assert(
RecordDecl &&
"Only CXXRecordDecls should have destructors");
861 if (
const Expr *E = dyn_cast_or_null<Expr>(S)) {
877 Call->getSourceRange().getBegin(),
878 "Error evaluating destructor");
900 "Error evaluating New Allocator Call");
932 SVal RetVal = State->getSVal(CNE, LCtx);
937 State = State->bindDefaultInitial(RetVal,
UndefinedVal{}, LCtx);
949 if (!ProtoType->isNothrow())
954 CNE, I, addObjectUnderConstruction(State, CNE, LCtx, RetVal));
959 DstPostValue, *
Call, *
this);
972 unsigned blockCount = currBldrCtx->blockCount();
977 bool IsStandardGlobalOpNewFunction =
983 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
985 State = finishObjectConstruction(State, CNE, LCtx);
992 if (IsStandardGlobalOpNewFunction)
996 symVal = svalBuilder.conjureSymbolVal(
1004 if (!AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
1009 State =
Call->invalidateRegions(blockCount);
1021 if (!ProtoType->isNothrow())
1023 State = State->assume(*dSymVal,
true);
1032 if (
const auto *NewReg = cast_or_null<SubRegion>(symVal.
getAsRegion())) {
1038 isa_and_nonnull<InitListExpr, CXXParenListInitExpr>(
Init);
1043 MRMgr.getElementRegion(ObjTy, svalBuilder.makeArrayIndex(0), NewReg,
1044 svalBuilder.getContext());
1055 evalBind(evaluated, CNE, Pred,
Result,
V,
true);
1060 Pred = *evaluated.
begin();
1082 State = State->BindExpr(CNE, LCtx,
Result);
1093 evalBind(Dst, CNE, NewN,
Result, State->getSVal(
Init, LCtx),
1094 IsStandardGlobalOpNewFunction);
1110 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
1116 DstPostCall = DstPreCall;
1131 currBldrCtx->blockCount());
1133 state = state->bindLoc(state->getLValue(VD, LCtx),
V, LCtx);
1146 svalBuilder.getRegionManager().getCXXThisRegion(
1160 const MemRegion *R = svalBuilder.getRegionManager().getCXXTempObjectRegion(
1168 for (
auto const [Idx, FieldForCapture, InitExpr] :
1169 llvm::zip(llvm::seq<unsigned>(0, -1), LE->getLambdaClass()->fields(),
1170 LE->capture_inits())) {
1171 SVal FieldLoc = State->getLValue(FieldForCapture,
V);
1174 if (!FieldForCapture->hasCapturedVLAType()) {
1175 assert(InitExpr &&
"Capture missing initialization expression");
1181 const auto FTy = FieldForCapture->getType();
1182 if (FTy->isConstantArrayType() &&
1184 getContext().getAsConstantArrayType(FTy)) == 0)
1190 if (
const auto OUC =
1192 InitVal = State->getSVal(OUC->getAsRegion());
1194 State = finishObjectConstruction(State, {LE, Idx}, LocCtxt);
1196 InitVal = State->getSVal(InitExpr, LocCtxt);
1201 "VLA capture by value is a compile time error!");
1206 Expr *SizeExpr = FieldForCapture->getCapturedVLAType()->getSizeExpr();
1207 InitVal = State->getSVal(SizeExpr, LocCtxt);
1210 State = State->bindLoc(FieldLoc, InitVal, LocCtxt);
1216 SVal LambdaRVal = State->getSVal(R);
1222 State->BindExpr(LE, LocCtxt, LambdaRVal),
1239 Visit(
Attr->getAssumption()->IgnoreParens(), N, EvalSet);
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 LocationContext *LCtx, 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: void *operato...
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...
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const Decl * getDecl() const
const ParentMap & getParentMap() const
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
const LocationContext * getParent() const
It might return null.
const StackFrameContext * getStackFrame() const
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 (based on CallEvent).
unsigned getIndex() const
const Stmt * getCallSite() const
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< CXXDestructorCall > getCXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBase, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXDeallocatorCall > getCXXDeallocatorCall(const CXXDeleteExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef getSimpleCall(const CallExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< ObjCMethodCall > getObjCMethodCall(const ObjCMessageExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXAllocatorCall > getCXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXConstructorCall > getCXXConstructorCall(const CXXConstructExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXInheritedConstructorCall > getCXXInheritedConstructorCall(const CXXInheritedCtorInitExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx, 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 obj-c messages.
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 obj-c messages.
ElementRegion is used to represent both array elements and casts.
void Add(ExplodedNode *N)
const ProgramStateRef & getState() const
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
const LocationContext * getLocationContext() const
ProgramStateManager & getStateManager()
std::pair< ProgramStateRef, SVal > handleConstructionContext(const Expr *E, ProgramStateRef State, const NodeBuilderContext *BldrCtx, const LocationContext *LCtx, const ConstructionContext *CC, EvalCallOptions &CallOpts, unsigned Idx=0)
A convenient wrapper around computeObjectUnderConstruction and updateObjectsUnderConstruction.
void VisitCXXDestructor(QualType ObjectType, const MemRegion *Dest, const Stmt *S, bool IsBaseDtor, ExplodedNode *Pred, ExplodedNodeSet &Dst, EvalCallOptions &Options)
const CoreEngine & getCoreEngine() const
void VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitLambdaExpr - Transfer function logic for LambdaExprs.
static std::optional< SVal > getObjectUnderConstruction(ProgramStateRef State, const ConstructionContextItem &Item, const LocationContext *LC)
By looking at a certain item that may be potentially part of an object's ConstructionContext,...
CFGElement getCurrentCFGElement()
Return the CFG element corresponding to the worklist element that is currently being processed by Exp...
SVal computeObjectUnderConstruction(const Expr *E, ProgramStateRef State, const NodeBuilderContext *BldrCtx, const LocationContext *LCtx, const ConstructionContext *CC, EvalCallOptions &CallOpts, unsigned Idx=0)
Find location of the object that is being constructed by a given constructor.
static std::optional< unsigned > getIndexOfElementToConstruct(ProgramStateRef State, const CXXConstructExpr *E, const LocationContext *LCtx)
Retreives which element is being constructed in a non-POD type array.
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.
ConstCFGElementRef getCFGElementRef() const
CheckerManager & getCheckerManager() 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 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)
void Visit(const Stmt *S, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Visit - Transfer function logic for all statements.
void defaultEvalCall(NodeBuilder &B, ExplodedNode *Pred, const CallEvent &Call, const EvalCallOptions &CallOpts={})
Default implementation of call evaluation.
void VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred, ExplodedNodeSet &Dst)
SValBuilder & getSValBuilder()
ProgramStateRef updateObjectsUnderConstruction(SVal V, const Expr *E, ProgramStateRef State, const LocationContext *LCtx, const ConstructionContext *CC, const EvalCallOptions &CallOpts)
Update the program state with all the path-sensitive information that's necessary to perform construc...
void VisitAttributedStmt(const AttributedStmt *A, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitAttributedStmt - Transfer function logic for AttributedStmt.
static std::optional< unsigned > getPendingInitLoop(ProgramStateRef State, const CXXConstructExpr *E, const LocationContext *LCtx)
Retreives the size of the array in the pending ArrayInitLoopExpr.
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.
unsigned blockCount() const
Returns the number of times the current basic block has been visited on the exploded graph path.
This is the simplest builder which generates nodes in the ExplodedGraph.
ExplodedNode * generateNode(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a node in the ExplodedGraph.
void takeNodes(const ExplodedNodeSet &S)
ExplodedNode * generateSink(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a sink in the ExplodedGraph.
void addNodes(const ExplodedNodeSet &S)
const ExplodedNodeSet & getResults()
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 StackFrameContext *SFC)
Return a memory region for the 'this' object reference.
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, ConstCFGElementRef elem, const LocationContext *LCtx, 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.
This builder class is useful for generating nodes that resulted from visiting a statement.
ExplodedNode * generateNode(const Stmt *S, ExplodedNode *Pred, ProgramStateRef St, const ProgramPointTag *tag=nullptr, ProgramPoint::Kind K=ProgramPoint::PostStmtKind)
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
The JSON file list parser is used to communicate input to InstallAPI.
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 of 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...