25#include "llvm/ADT/STLExtras.h"
26#include "llvm/ADT/Sequence.h"
27#include "llvm/Support/Casting.h"
40 State = createTemporaryRegionIfNeeded(State, SF, TempExpr, MTE);
41 Dst.
insert(Engine.makePostStmtNode(MTE, 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();
136 const auto *DS = DSCC->getDeclStmt();
139 return makeElementRegion(State, State->getLValue(Var, SF), Ty,
145 const auto *
Init = ICC->getCXXCtorInitializer();
148 SVal ThisVal = State->getSVal(ThisPtr);
149 if (
Init->isBaseInitializer()) {
152 Init->getBaseClass()->getAsCXXRecordDecl();
153 const auto *BaseReg =
154 MRMgr.getCXXBaseObjectRegion(BaseClass, ThisReg,
155 Init->isBaseVirtual());
158 if (
Init->isDelegatingInitializer())
163 if (
Init->isIndirectMemberInitializer()) {
164 Field =
Init->getIndirectMember();
165 FieldVal = State->getLValue(
Init->getIndirectMember(), ThisVal);
167 Field =
Init->getMember();
168 FieldVal = State->getLValue(
Init->getMember(), ThisVal);
176 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
178 const auto *NE = NECC->getCXXNewExpr();
181 dyn_cast_or_null<SubRegion>(
V.getAsRegion())) {
185 auto Ty = NE->getType()->getPointeeType();
186 while (
const auto *AT =
getContext().getAsArrayType(Ty))
187 Ty = AT->getElementType();
189 auto R = MRMgr.getElementRegion(Ty, svalBuilder.makeArrayIndex(Idx),
219 RTC->getConstructionContext(), CallOpts);
233 static const int TopLevelSymRegionTag = 0;
234 const Expr *RetE = RCC->getReturnStmt()->getRetValue();
235 assert(RetE &&
"Void returns should not have a construction context");
241 llvm_unreachable(
"Unhandled return value construction context!");
244 assert(AMgr.getAnalyzerOptions().ShouldElideConstructors);
258 TCC->getConstructorAfterElision(), State, NumVisitedCaller, SF,
259 TCC->getConstructionContextAfterElision(), CallOpts);
269 CallOpts = PreElideCallOpts;
282 if (!VD->getType()->isReferenceType()) {
293 MRMgr.getCXXStaticLifetimeExtendedObjectRegion(E, VD));
296 MRMgr.getCXXLifetimeExtendedObjectRegion(E, VD, SF));
309 MRMgr.getCXXTempObjectRegion(LCC->getInitializer(), SF));
311 const auto *CE = dyn_cast_or_null<CXXConstructExpr>(E);
314 Base = State->getLValue(E->
getType(), svalBuilder.makeArrayIndex(Idx),
325 const Expr *E = ACC->getCallLikeExpr();
326 unsigned Idx = ACC->getIndex();
329 auto getArgLoc = [&](
CallEventRef<> Caller) -> std::optional<SVal> {
331 Caller->getCalleeStackFrame(NumVisitedCaller);
350 *Caller->getAdjustedParameterIndex(Idx), NumVisitedCaller);
357 if (
const auto *CE = dyn_cast<CallExpr>(E)) {
360 if (std::optional<SVal>
V = getArgLoc(Caller))
364 }
else if (
const auto *CCE = dyn_cast<CXXConstructExpr>(E)) {
369 if (std::optional<SVal>
V = getArgLoc(Caller))
373 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(E)) {
376 if (std::optional<SVal>
V = getArgLoc(Caller))
402 assert(CC &&
"Computed target region without construction context?");
407 return addObjectUnderConstruction(State, DSCC->getDeclStmt(), SF,
V);
412 const auto *
Init = ICC->getCXXCtorInitializer();
414 assert(
Init->isAnyMemberInitializer() &&
415 "Base and delegating initializers should have been handled by"
416 "computeObjectUnderConstruction()");
417 return addObjectUnderConstruction(State,
Init, SF,
V);
432 assert(RTC &&
"Could not have had a target region without it");
435 V, SF->
getCallSite(), State, CallerSF, RTC->getConstructionContext(),
439 assert(AMgr.getAnalyzerOptions().ShouldElideConstructors);
443 V, TCC->getConstructorAfterElision(), State, SF,
444 TCC->getConstructionContextAfterElision(), CallOpts);
447 State = addObjectUnderConstruction(
448 State, TCC->getConstructorAfterElision(), SF,
V);
451 if (
const auto *BTE = TCC->getCXXBindTemporaryExpr())
452 State = elideDestructor(State, BTE, SF);
456 if (
const auto *MTE = TCC->getMaterializedTemporaryExpr())
457 State = addObjectUnderConstruction(State, MTE, SF,
V);
467 if (
const auto *BTE = TCC->getCXXBindTemporaryExpr())
468 State = addObjectUnderConstruction(State, BTE, SF,
V);
470 if (
const auto *MTE = TCC->getMaterializedTemporaryExpr())
471 State = addObjectUnderConstruction(State, MTE, SF,
V);
480 if (
const auto *EL = dyn_cast_or_null<ElementRegion>(
V.getAsRegion()))
483 return addObjectUnderConstruction(
484 State, {LCC->getLambdaExpr(), LCC->getIndex()}, SF,
V);
488 if (
const auto *BTE = ACC->getCXXBindTemporaryExpr())
489 State = addObjectUnderConstruction(State, BTE, SF,
V);
491 return addObjectUnderConstruction(
492 State, {ACC->getCallLikeExpr(), ACC->getIndex()}, SF,
V);
495 llvm_unreachable(
"Unhandled construction context!");
513 const auto *SourceArrayRegion =
521void ExprEngine::handleConstructor(
const Expr *E,
ExplodedNode *Pred,
523 const auto *CE = dyn_cast<CXXConstructExpr>(E);
524 const auto *CIE = dyn_cast<CXXInheritedCtorInitExpr>(E);
530 SVal
Target = UnknownVal();
533 if (std::optional<SVal> ElidedTarget =
539 State = finishObjectConstruction(State, CE, SF);
540 if (
auto L =
Target.getAs<Loc>())
541 State = State->BindExpr(CE, SF, State->getSVal(*L, CE->getType()));
542 Dst.
insert(Engine.makePostStmtNode(CE, State, Pred));
547 EvalCallOptions CallOpts;
550 const ConstructionContext *CC =
C ?
C->getConstructionContext() :
nullptr;
553 CE ? CE->getConstructionKind() : CIE->getConstructionKind();
557 assert(CE && !CIE &&
"A complete constructor is inherited?!");
564 if (CE->getType()->isArrayType() || AILE) {
566 auto isZeroSizeArray = [&] {
569 if (
const auto *CAT = dyn_cast<ConstantArrayType>(CE->getType()))
578 if (isZeroSizeArray()) {
579 static SimpleProgramPointTag
T{
"ExprEngine",
580 "Skipping 0 size array construction"};
582 Dst.
insert(Engine.makeNode(Loc, State, Pred));
587 State = setIndexOfElementToConstruct(State, CE, SF, Idx + 1);
593 State = setPendingInitLoop(
594 State, CE, SF,
getContext().getArrayInitLoopExprElementCount(AILE));
597 State, AILE, SF, svalBuilder.makeArrayIndex(Idx));
608 const auto *OuterCtor =
609 dyn_cast_or_null<CXXConstructExpr>(SF->
getCallSite());
614 (
"This virtual base should have already been initialized by "
615 "the most derived class!"));
631 if (isa_and_nonnull<InitListExpr, CXXParenListInitExpr>(
634 Target = loc::MemRegionVal(MRMgr.getCXXTempObjectRegion(E, SF));
642 SVal ThisVal = State->getSVal(ThisPtr);
658 static SimpleProgramPointTag
T(
"ExprEngine",
659 "Prepare for object construction");
660 Pred = Engine.makeNode(PreStmt(E, SF, &
T), State, Pred);
665 const MemRegion *TargetRegion =
Target.getAsRegion();
667 CallEventRef<>
Call =
673 ExplodedNodeSet DstPreVisit;
676 ExplodedNodeSet PreInitialized;
679 for (ExplodedNode *N : DstPreVisit) {
681 if (CE->requiresZeroInitialization()) {
694 const CXXRecordDecl *TargetHeldRecord =
695 dyn_cast_or_null<CXXRecordDecl>(CE->getType()->getAsRecordDecl());
697 if (!TargetHeldRecord || !TargetHeldRecord->
isEmpty())
698 State = State->bindDefaultZero(
Target, SF);
701 PreStmt P(CE, N->getStackFrame(),
nullptr);
702 PreInitialized.
insert(Engine.makeNode(P, State, N));
705 PreInitialized = DstPreVisit;
708 ExplodedNodeSet DstPreCall;
712 ExplodedNodeSet DstEvaluated;
714 if (CE && CE->getConstructor()->isTrivial() &&
715 CE->getConstructor()->isCopyOrMoveConstructor() &&
718 for (ExplodedNode *N : DstPreCall)
719 performTrivialCopy(DstEvaluated, N, *
Call);
722 for (ExplodedNode *N : DstPreCall)
734 ExplodedNodeSet DstEvaluatedPostProcessed;
737 if (llvm::isa_and_nonnull<CXXTempObjectRegion,
738 CXXLifetimeExtendedObjectRegion>(TargetRegion) &&
741 ->isAnyDestructorNoReturn()) {
750 assert(!DstEvaluated.
empty() &&
751 "We should not have inlined this constructor!");
753 for (ExplodedNode *N : DstEvaluated) {
754 Engine.makePostStmtNode(E, N->getState(), N,
true);
764 DstEvaluatedPostProcessed.
insert(DstEvaluated);
765 ExplodedNodeSet DstPostArgumentCleanup;
766 for (ExplodedNode *I : DstEvaluatedPostProcessed)
767 finishArgumentConstruction(DstPostArgumentCleanup, I, *
Call);
771 ExplodedNodeSet DstPostCall;
773 DstPostArgumentCleanup,
781 handleConstructor(CE, Pred, Dst);
787 handleConstructor(CE, Pred, Dst);
797 assert(S &&
"A destructor without a trigger!");
802 assert(
RecordDecl &&
"Only CXXRecordDecls should have destructors");
824 if (
const Expr *E = dyn_cast_or_null<Expr>(S)) {
825 Dest = MRMgr.getCXXTempObjectRegion(E, Pred->
getStackFrame());
839 Call->getSourceRange().getBegin(),
840 "Error evaluating destructor");
861 "Error evaluating New Allocator Call");
898 SVal RetVal = State->getSVal(CNE, SF);
903 State = State->bindDefaultInitial(RetVal,
UndefinedVal{}, SF);
915 if (!ProtoType->isNothrow())
919 DstPostValue.
insert(Engine.makePostStmtNode(
920 CNE, addObjectUnderConstruction(State, CNE, SF, RetVal), I));
925 DstPostValue, *
Call, *
this);
943 bool IsStandardGlobalOpNewFunction =
949 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
951 State = finishObjectConstruction(State, CNE, SF);
958 if (IsStandardGlobalOpNewFunction)
962 symVal = svalBuilder.conjureSymbolVal(
970 if (!AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
975 State =
Call->invalidateRegions(blockCount, State);
987 if (!ProtoType->isNothrow())
989 State = State->assume(*dSymVal,
true);
996 if (
const auto *NewReg = cast_or_null<SubRegion>(symVal.
getAsRegion())) {
1002 isa_and_nonnull<InitListExpr, CXXParenListInitExpr>(
Init);
1007 MRMgr.getElementRegion(ObjTy, svalBuilder.makeArrayIndex(0), NewReg,
1008 svalBuilder.getContext());
1014 Pred = Engine.makePostStmtNode(CNE, State, Pred);
1021 Dst.
insert(Engine.makeNodeWithBinding(N, CNE,
Result));
1026 Dst.
insert(Engine.makeNodeWithBinding(Pred, CNE,
Result, State));
1051 assert(Dst.
size() == 1);
1053 evalBind(Dst, CNE, NewN,
Result, State->getSVal(
Init, SF),
1054 IsStandardGlobalOpNewFunction);
1070 if (AMgr.getAnalyzerOptions().MayInlineCXXAllocator) {
1079 DstPostCall = std::move(DstPreCall);
1096 state = state->bindLoc(state->getLValue(VD, SF),
V, SF);
1098 Dst.
insert(Engine.makePostStmtNode(CS, state, Pred));
1111 const MemRegion *R = svalBuilder.getRegionManager().getCXXThisRegion(
1116 Dst.
insert(Engine.makeNodeWithBinding(Pred, TE,
V));
1122 if (!AMgr.options.ShouldInlineLambdas) {
1133 svalBuilder.getRegionManager().getCXXTempObjectRegion(LE, SF);
1140 for (
auto const [Idx, FieldForCapture, InitExpr] :
1141 llvm::zip(llvm::seq<unsigned>(0, -1), LE->getLambdaClass()->fields(),
1142 LE->capture_inits())) {
1143 SVal FieldLoc = State->getLValue(FieldForCapture,
V);
1146 if (!FieldForCapture->hasCapturedVLAType()) {
1147 assert(InitExpr &&
"Capture missing initialization expression");
1153 const auto FTy = FieldForCapture->getType();
1154 if (FTy->isConstantArrayType() &&
1156 getContext().getAsConstantArrayType(FTy)) == 0)
1163 InitVal = State->getSVal(OUC->getAsRegion());
1165 State = finishObjectConstruction(State, {LE, Idx}, SF);
1167 InitVal = State->getSVal(InitExpr, SF);
1172 "VLA capture by value is a compile time error!");
1177 Expr *SizeExpr = FieldForCapture->getCapturedVLAType()->getSizeExpr();
1178 InitVal = State->getSVal(SizeExpr, SF);
1181 State = State->bindLoc(FieldLoc, InitVal, SF);
1187 SVal LambdaRVal = State->getSVal(R);
1190 ExplodedNode *N = Engine.makeNodeWithBinding(Pred, LE, LambdaRVal, State,
1203 SVal AssumedVal = State->getSVal(
Attr->getAssumption(), SF);
1207 State = State->assume(*ValidAssumedVal,
true);
1215 Dst.
insert(Engine.makePostStmtNode(A, State, Pred));
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.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static uint64_t getConstantArrayElementCount(const ConstantArrayType *CA)
Return number of (potentially nested) constant array elements.
static uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE)
Return number of elements initialized in a (potentially nested) 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 list-initialization with parenthesis.
MutableArrayRef< Expr * > getInitExprs()
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)
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
void VisitCXXParenListInitExpr(const CXXParenListInitExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void ConstructInitList(const Expr *Source, ArrayRef< Expr * > Args, bool IsTransparent, ExplodedNode *Pred, ExplodedNodeSet &Dst)
std::pair< ProgramStateRef, SVal > handleConstructionContext(const Expr *E, ProgramStateRef State, const StackFrame *SF, const ConstructionContext *CC, EvalCallOptions &CallOpts, unsigned Idx=0)
A convenient wrapper around computeObjectUnderConstruction and updateObjectsUnderConstruction.
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)
void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Create a C++ temporary object for an rvalue.
unsigned getNumVisitedCurrent() const
void VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred, ExplodedNodeSet &Dst)
SValBuilder & getSValBuilder()
void VisitAttributedStmt(const AttributedStmt *A, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitAttributedStmt - Transfer function logic for AttributedStmt.
const CFGBlock * getCurrBlock() const
Get the 'current' CFGBlock corresponding to the current work item (elementary analysis step handled b...
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...