64#include "llvm/ADT/APSInt.h"
65#include "llvm/ADT/DenseMap.h"
66#include "llvm/ADT/ImmutableMap.h"
67#include "llvm/ADT/ImmutableSet.h"
68#include "llvm/ADT/STLExtras.h"
69#include "llvm/ADT/SmallVector.h"
70#include "llvm/Support/Casting.h"
71#include "llvm/Support/Compiler.h"
72#include "llvm/Support/DOTGraphTraits.h"
73#include "llvm/Support/ErrorHandling.h"
74#include "llvm/Support/GraphWriter.h"
75#include "llvm/Support/IOSandbox.h"
76#include "llvm/Support/TimeProfiler.h"
77#include "llvm/Support/raw_ostream.h"
90#define DEBUG_TYPE "ExprEngine"
93 "The # of times RemoveDeadBindings is called");
95 NumMaxBlockCountReached,
96 "The # of aborted paths due to reaching the maximum block count in "
97 "a top level function");
99 NumMaxBlockCountReachedInInlined,
100 "The # of aborted paths due to reaching the maximum block count in "
101 "an inlined function");
103 "The # of times we re-evaluated a call without inlining");
124class ConstructedObjectKey {
125 using ConstructedObjectKeyImpl =
126 std::pair<ConstructionContextItem, const LocationContext *>;
127 const ConstructedObjectKeyImpl Impl;
134 const ConstructionContextItem &getItem()
const {
return Impl.first; }
135 const LocationContext *getLocationContext()
const {
return Impl.second; }
137 ASTContext &getASTContext()
const {
138 return getLocationContext()->getDecl()->getASTContext();
141 void printJson(llvm::raw_ostream &Out, PrinterHelper *Helper,
142 PrintingPolicy &PP)
const {
143 const Stmt *S = getItem().getStmtOrNull();
144 const CXXCtorInitializer *I =
nullptr;
146 I = getItem().getCXXCtorInitializer();
149 Out <<
"\"stmt_id\": " << S->
getID(getASTContext());
151 Out <<
"\"init_id\": " << I->
getID(getASTContext());
154 Out <<
", \"kind\": \"" << getItem().getKindAsString()
155 <<
"\", \"argument_index\": ";
158 Out << getItem().getIndex();
163 Out <<
", \"pretty\": ";
172 void Profile(llvm::FoldingSetNodeID &ID)
const {
174 ID.AddPointer(Impl.second);
177 bool operator==(
const ConstructedObjectKey &RHS)
const {
178 return Impl == RHS.Impl;
181 bool operator<(
const ConstructedObjectKey &RHS)
const {
182 return Impl < RHS.Impl;
187typedef llvm::ImmutableMap<ConstructedObjectKey, SVal>
198typedef llvm::ImmutableMap<
199 std::pair<const CXXConstructExpr *, const LocationContext *>,
unsigned>
200 IndexOfElementToConstructMap;
202 IndexOfElementToConstructMap)
207typedef llvm::ImmutableMap<
208 std::pair<const CXXConstructExpr *, const LocationContext *>,
unsigned>
212typedef llvm::ImmutableMap<const LocationContext *, unsigned>
221static const char* TagProviderName =
"ExprEngine";
226 : CTU(CTU), IsCTUEnabled(mgr.getAnalyzerOptions().IsNaiveCTUEnabled),
228 Engine(*this, FS, mgr.getAnalyzerOptions()), G(Engine.
getGraph()),
229 StateMgr(
getContext(), mgr.getStoreManagerCreator(),
230 mgr.getConstraintManagerCreator(), G.getAllocator(), this),
232 svalBuilder(StateMgr.
getSValBuilder()), ObjCNoRet(mgr.getASTContext()),
233 BR(mgr, *this), VisitedCallees(VisitedCalleesIn),
234 HowToInline(HowToInlineIn) {
235 unsigned TrimInterval = mgr.
options.GraphTrimInterval;
236 if (TrimInterval != 0) {
238 G.enableNodeReclamation(TrimInterval);
254 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
258 if (!II || !(II->
getName() ==
"main" && FD->getNumParams() > 0))
263 const auto *BT = dyn_cast<BuiltinType>(
T);
264 if (!BT || !BT->isInteger())
267 const MemRegion *R = state->getRegion(PD, InitLoc);
273 svalBuilder.makeZeroVal(
T),
274 svalBuilder.getConditionType());
276 std::optional<DefinedOrUnknownSVal> Constraint =
289 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
293 const MemRegion *R = state->getRegion(SelfD, InitLoc);
296 if (std::optional<Loc> LV =
V.getAs<
Loc>()) {
298 state = state->assume(*LV,
true);
299 assert(state &&
"'self' cannot be null");
303 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
304 if (MD->isImplicitObjectMemberFunction()) {
311 SVal V = state->getSVal(L);
312 if (std::optional<Loc> LV =
V.getAs<
Loc>()) {
313 state = state->assume(*LV,
true);
314 assert(state &&
"'this' cannot be null");
326 const SubRegion **OutRegionWithAdjustments) {
332 SVal InitValWithAdjustments = State->getSVal(InitWithAdjustments, LC);
337 if (OutRegionWithAdjustments)
338 *OutRegionWithAdjustments =
nullptr;
341 Result = InitWithAdjustments;
345 assert(!
isa<Loc>(InitValWithAdjustments) ||
347 Result->getType()->isMemberPointerType());
350 ProgramStateManager &StateMgr = State->getStateManager();
351 MemRegionManager &MRMgr = StateMgr.getRegionManager();
352 StoreManager &StoreMgr = StateMgr.getStoreManager();
375 SmallVector<const Expr *, 2> CommaLHSs;
376 SmallVector<SubobjectAdjustment, 2> Adjustments;
379 CommaLHSs, Adjustments);
386 const TypedValueRegion *TR =
nullptr;
387 if (
const auto *MT = dyn_cast<MaterializeTemporaryExpr>(
Result)) {
389 State = finishObjectConstruction(State, MT, LC);
390 State = State->BindExpr(
Result, LC, *
V);
392 }
else if (
const ValueDecl *VD = MT->getExtendingDecl()) {
398 TR = MRMgr.getCXXStaticLifetimeExtendedObjectRegion(
Init, VD);
400 TR = MRMgr.getCXXLifetimeExtendedObjectRegion(
Init, VD, LC);
404 TR = MRMgr.getCXXTempObjectRegion(
Init, LC);
407 TR = MRMgr.getCXXTempObjectRegion(
Init, LC);
410 SVal Reg = loc::MemRegionVal(TR);
414 for (
const SubobjectAdjustment &Adj : llvm::reverse(Adjustments)) {
425 currBldrCtx->blockCount(), LC,
true,
426 nullptr,
nullptr,
nullptr);
439 SVal InitVal = State->getSVal(
Init, LC);
443 State = State->bindLoc(BaseReg.
castAs<Loc>(), InitVal, LC,
false);
447 if (InitValWithAdjustments.
isUnknown()) {
452 currBldrCtx->blockCount());
455 State->bindLoc(Reg.
castAs<Loc>(), InitValWithAdjustments, LC,
false);
457 State = State->bindLoc(BaseReg.
castAs<Loc>(), InitVal, LC,
false);
463 if (
Result->isGLValue()) {
464 State = State->BindExpr(
Result, LC, Reg);
466 State = State->BindExpr(
Result, LC, InitValWithAdjustments);
472 if (OutRegionWithAdjustments)
479 const LocationContext *LCtx,
unsigned Idx) {
482 assert(!State->contains<IndexOfElementToConstruct>(Key) || Idx > 0);
484 return State->set<IndexOfElementToConstruct>(Key, Idx);
487std::optional<unsigned>
490 const unsigned *
V = State->get<PendingInitLoop>({E, LCtx->
getStackFrame()});
491 return V ? std::make_optional(*
V) : std::nullopt;
499 assert(E && State->contains<PendingInitLoop>(Key));
500 return State->remove<PendingInitLoop>(Key);
509 assert(!State->contains<PendingInitLoop>(Key) && Size > 0);
511 return State->set<PendingInitLoop>(Key, Size);
514std::optional<unsigned>
519 State->get<IndexOfElementToConstruct>({E, LCtx->
getStackFrame()});
520 return V ? std::make_optional(*
V) : std::nullopt;
529 assert(E && State->contains<IndexOfElementToConstruct>(Key));
530 return State->remove<IndexOfElementToConstruct>(Key);
533std::optional<unsigned>
536 assert(LCtx &&
"LocationContext shouldn't be null!");
540 return V ? std::make_optional(*
V) : std::nullopt;
545 assert(LCtx &&
"LocationContext shouldn't be null!");
549 return State->set<PendingArrayDestruction>(Key, Idx);
555 assert(LCtx &&
"LocationContext shouldn't be null!");
559 assert(LCtx && State->contains<PendingArrayDestruction>(Key));
560 return State->remove<PendingArrayDestruction>(Key);
571 if (
auto DS = dyn_cast_or_null<DeclStmt>(Item.
getStmtOrNull())) {
572 if (
auto VD = dyn_cast_or_null<VarDecl>(DS->getSingleDecl()))
573 Init = VD->getInit();
576 if (
auto LE = dyn_cast_or_null<LambdaExpr>(Item.
getStmtOrNull()))
585 if (
const auto *AILE = dyn_cast_or_null<ArrayInitLoopExpr>(
Init))
594 assert((!State->get<ObjectsUnderConstruction>(Key) ||
595 Key.getItem().getKind() ==
597 State->contains<IndexOfElementToConstruct>(
598 {dyn_cast_or_null<CXXConstructExpr>(Init), LC})) &&
599 "The object is already marked as `UnderConstruction`, when it's not "
601 return State->set<ObjectsUnderConstruction>(Key,
V);
609 const SVal *
V = State->get<ObjectsUnderConstruction>(Key);
610 return V ? std::make_optional(*
V) : std::nullopt;
618 assert(State->contains<ObjectsUnderConstruction>(Key));
619 return State->remove<ObjectsUnderConstruction>(Key);
625 ConstructedObjectKey Key({BTE,
true}, LC);
628 return State->set<ObjectsUnderConstruction>(Key,
UnknownVal());
633 const CXXBindTemporaryExpr *BTE,
634 const LocationContext *LC) {
635 ConstructedObjectKey Key({BTE,
true}, LC);
636 assert(State->contains<ObjectsUnderConstruction>(Key));
637 return State->remove<ObjectsUnderConstruction>(Key);
641 const CXXBindTemporaryExpr *BTE,
642 const LocationContext *LC) {
643 ConstructedObjectKey Key({BTE,
true}, LC);
644 return State->contains<ObjectsUnderConstruction>(Key);
648 const LocationContext *FromLC,
649 const LocationContext *ToLC) {
650 const LocationContext *LC = FromLC;
652 assert(LC &&
"ToLC must be a parent of FromLC!");
653 for (
auto I : State->get<ObjectsUnderConstruction>())
654 if (I.first.getLocationContext() == LC)
670 SVal cond,
bool assumption) {
689 unsigned int Space = 0,
bool IsDot =
false) {
694 bool HasItem =
false;
697 const ConstructedObjectKey *LastKey =
nullptr;
698 for (
const auto &I : State->get<ObjectsUnderConstruction>()) {
699 const ConstructedObjectKey &Key = I.first;
700 if (Key.getLocationContext() != LCtx)
711 for (
const auto &I : State->get<ObjectsUnderConstruction>()) {
712 const ConstructedObjectKey &Key = I.first;
714 if (Key.getLocationContext() != LCtx)
717 Indent(Out, Space, IsDot) <<
"{ ";
718 Key.printJson(Out,
nullptr, PP);
719 Out <<
", \"value\": \"" <<
Value <<
"\" }";
727 Indent(Out, --Space, IsDot) <<
']';
735 const LocationContext *LCtx,
unsigned int Space = 0,
bool IsDot =
false) {
736 using KeyT = std::pair<const Expr *, const LocationContext *>;
742 bool HasItem =
false;
746 for (
const auto &I : State->get<IndexOfElementToConstruct>()) {
747 const KeyT &Key = I.first;
748 if (Key.second != LCtx)
759 for (
const auto &I : State->get<IndexOfElementToConstruct>()) {
760 const KeyT &Key = I.first;
761 unsigned Value = I.second;
762 if (Key.second != LCtx)
765 Indent(Out, Space, IsDot) <<
"{ ";
768 const Expr *E = Key.first;
769 Out <<
"\"stmt_id\": " << E->
getID(Context);
772 Out <<
", \"kind\": null";
775 Out <<
", \"pretty\": ";
781 Out <<
", \"value\": \"Current index: " <<
Value - 1 <<
"\" }";
789 Indent(Out, --Space, IsDot) <<
']';
798 unsigned int Space = 0,
799 bool IsDot =
false) {
800 using KeyT = std::pair<const CXXConstructExpr *, const LocationContext *>;
806 bool HasItem =
false;
810 for (
const auto &I : State->get<PendingInitLoop>()) {
811 const KeyT &Key = I.first;
812 if (Key.second != LCtx)
823 for (
const auto &I : State->get<PendingInitLoop>()) {
824 const KeyT &Key = I.first;
825 unsigned Value = I.second;
826 if (Key.second != LCtx)
829 Indent(Out, Space, IsDot) <<
"{ ";
832 Out <<
"\"stmt_id\": " << E->
getID(Context);
834 Out <<
", \"kind\": null";
835 Out <<
", \"pretty\": ";
841 Out <<
", \"value\": \"Flattened size: " <<
Value <<
"\"}";
849 Indent(Out, --Space, IsDot) <<
']';
858 unsigned int Space = 0,
bool IsDot =
false) {
862 bool HasItem =
false;
865 KeyT LastKey =
nullptr;
866 for (
const auto &I : State->get<PendingArrayDestruction>()) {
867 const KeyT &Key = I.first;
879 for (
const auto &I : State->get<PendingArrayDestruction>()) {
880 const KeyT &Key = I.first;
884 Indent(Out, Space, IsDot) <<
"{ ";
886 Out <<
"\"stmt_id\": null";
887 Out <<
", \"kind\": null";
888 Out <<
", \"pretty\": \"Current index: \"";
889 Out <<
", \"value\": \"" << I.second <<
"\" }";
897 Indent(Out, --Space, IsDot) <<
']';
911template <
typename Trait,
typename Printer,
typename... Args>
914 const char *NL,
unsigned int Space,
bool IsDot,
915 const char *jsonPropertyName, Printer printer, Args &&...args) {
923 static_assert(std::is_function_v<std::remove_pointer_t<Printer>>,
924 "Printer is not a function!");
925 static_assert(std::is_convertible_v<Printer, RequiredType>,
926 "Printer doesn't have the required type!");
928 if (LCtx && !State->get<Trait>().isEmpty()) {
929 Indent(Out, Space, IsDot) <<
'\"' << jsonPropertyName <<
"\": ";
933 printer(Out, State, NL, LC, Space, IsDot, std::forward<Args>(args)...);
937 Indent(Out, Space, IsDot) <<
"]," << NL;
943 unsigned int Space,
bool IsDot)
const {
946 Out, State, LCtx, NL, Space, IsDot,
"constructing_objects",
949 Out, State, LCtx, NL, Space, IsDot,
"index_of_element",
952 Out, State, LCtx, NL, Space, IsDot,
"pending_init_loops",
955 Out, State, LCtx, NL, Space, IsDot,
"pending_destructors",
970 currStmtIdx = StmtIdx;
1031 const Stmt *ReferenceStmt,
1033 const Stmt *DiagnosticStmt,
1035 llvm::TimeTraceScope TimeScope(
"ExprEngine::removeDead");
1038 &&
"PostStmt is not generally supported by the SymbolReaper yet");
1039 assert(LC &&
"Must pass the current (or expiring) LocationContext");
1041 if (!DiagnosticStmt) {
1042 DiagnosticStmt = ReferenceStmt;
1043 assert(DiagnosticStmt &&
"Required for clearing a LocationContext");
1046 NumRemoveDeadBindings++;
1052 if (!ReferenceStmt) {
1054 "Use PostStmtPurgeDeadSymbolsKind for clearing a LocationContext");
1061 for (
auto I : CleanedState->get<ObjectsUnderConstruction>()) {
1062 if (
SymbolRef Sym = I.second.getAsSymbol())
1064 if (
const MemRegion *MR = I.second.getAsRegion())
1073 CleanedState = StateMgr.removeDeadBindingsFromEnvironmentAndStore(
1074 CleanedState, SFC, SymReaper);
1081 DiagnosticStmt, *
this, K);
1092 for (
const auto I : CheckedSet) {
1099 assert(StateMgr.haveEqualEnvironments(CheckerState, Pred->
getState()) &&
1100 "Checkers are not allowed to modify the Environment as a part of "
1101 "checkDeadSymbols processing.");
1102 assert(StateMgr.haveEqualStores(CheckerState, Pred->
getState()) &&
1103 "Checkers are not allowed to modify the Store as a part of "
1104 "checkDeadSymbols processing.");
1109 StateMgr.getPersistentStateWithGDM(CleanedState, CheckerState);
1121 G.reclaimRecentlyAllocatedNodes();
1125 "Error evaluating statement");
1134 CleanedStates.
Add(Pred);
1138 for (
const auto I : CleanedStates) {
1141 Visit(currStmt, I, DstI);
1146 Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx);
1152 "Error evaluating end of the loop");
1158 if(AMgr.options.ShouldUnrollLoops)
1164 Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx);
1175 "Error evaluating initializer");
1182 SVal thisVal = State->getSVal(svalBuilder.getCXXThis(
decl, stackFrame));
1194 State = finishObjectConstruction(State, BMI, LC);
1205 FieldLoc = State->getLValue(BMI->
getMember(), thisVal);
1209 if (
Init->getType()->isArrayType()) {
1213 while ((ASE = dyn_cast<ArraySubscriptExpr>(
Init)))
1216 InitVal = State->getSVal(
Init, stackFrame);
1223 Field->getType(), currBldrCtx->blockCount());
1226 InitVal = State->getSVal(BMI->
getInit(), stackFrame);
1230 evalBind(Tmp,
Init, Pred, FieldLoc, InitVal,
true, &PP);
1238 SVal InitVal = State->getSVal(
Init, stackFrame);
1239 evalBind(Tmp,
Init, Pred, BaseLoc, InitVal,
true);
1251 for (
const auto I : Tmp) {
1257 Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx);
1260std::pair<ProgramStateRef, uint64_t>
1261ExprEngine::prepareStateForArrayDestruction(
const ProgramStateRef State,
1265 SVal *ElementCountVal) {
1266 assert(Region !=
nullptr &&
"Not-null region expected");
1269 while (
const auto *NTy = dyn_cast<ArrayType>(Ty))
1270 Ty = NTy->getElementType().getDesugaredType(
getContext());
1274 if (ElementCountVal)
1275 *ElementCountVal = ElementCount;
1283 if (!ElementCount.isConstant())
1286 Idx = ElementCount.getAsInteger()->getLimitedValue();
1294 return {setPendingArrayDestruction(State, LCtx, Idx), Idx};
1317 llvm_unreachable(
"Unexpected dtor kind.");
1321 Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx);
1332 if (Opts.MayInlineCXXAllocator)
1341 Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx);
1358 const MemRegion *ValueRegion = state->getSVal(Region).getAsRegion();
1373 std::tie(state, Idx) = prepareStateForArrayDestruction(
1374 state, Region, varType, LCtx, &ElementCount);
1376 if (ElementCount.isConstant()) {
1377 uint64_t ArrayLength = ElementCount.getAsInteger()->getLimitedValue();
1378 assert(ArrayLength &&
1379 "An automatic dtor for a 0 length array shouldn't be triggered!");
1384 "ExprEngine",
"Skipping automatic 0 length array destruction, "
1385 "which shouldn't be in the CFG.");
1403 "Prepare for object destruction");
1413 false, Pred, Dst, CallOpts);
1424 SVal ArgVal = State->getSVal(Arg, LCtx);
1428 if (State->isNull(ArgVal).isConstrainedTrue()) {
1439 auto getDtorDecl = [](
const QualType &DTy) {
1451 while (
const auto *AT =
getContext().getAsArrayType(DTy))
1452 DTy = AT->getElementType();
1456 std::tie(State, Idx) = prepareStateForArrayDestruction(
1457 State, ArgR, DTy, LCtx, &ElementCount);
1461 if (ElementCount.isConstant() &&
1462 ElementCount.getAsInteger()->getLimitedValue() == 0) {
1465 "ExprEngine",
"Skipping 0 length array delete destruction");
1473 ArgR = State->getLValue(DTy, svalBuilder.makeArrayIndex(Idx), ArgVal)
1480 "Prepare for object destruction");
1509 true, Pred, Dst, CallOpts);
1521 Loc ThisStorageLoc =
1523 Loc ThisLoc = State->getSVal(ThisStorageLoc).
castAs<
Loc>();
1524 SVal FieldVal = State->getLValue(
Member, ThisLoc);
1529 std::tie(State, Idx) = prepareStateForArrayDestruction(
1530 State, FieldVal.getAsRegion(),
T, LCtx, &ElementCount);
1532 if (ElementCount.isConstant()) {
1533 uint64_t ArrayLength = ElementCount.getAsInteger()->getLimitedValue();
1534 assert(ArrayLength &&
1535 "A member dtor for a 0 length array shouldn't be triggered!");
1540 "ExprEngine",
"Skipping member 0 length array destruction, which "
1541 "shouldn't be in the CFG.");
1558 "Prepare for object destruction");
1568 false, Pred, Dst, CallOpts);
1586 MR =
V->getAsRegion();
1591 if (isDestructorElided(State, BTE, LC)) {
1592 State = cleanupElidedDestructor(State, BTE, LC);
1608 assert(CleanDtorState.
size() <= 1);
1610 CleanDtorState.
empty() ? Pred : *CleanDtorState.
begin();
1633 T = AT->getElementType();
1644 false, CleanPred, Dst, CallOpts);
1684 State = addObjectUnderConstruction(State, BTE, LC,
UnknownVal());
1694 class CollectReachableSymbolsCallback final :
public SymbolVisitor {
1699 : Symbols(Symbols) {}
1703 bool VisitSymbol(
SymbolRef Sym)
override {
1704 Symbols.insert(Sym);
1709 CollectReachableSymbolsCallback CallBack(Symbols);
1711 State->scanReachableSymbols(
V, CallBack);
1714 State, CallBack.getSymbols(),
Call, K,
nullptr);
1728 case Stmt::CXXDependentScopeMemberExprClass:
1729 case Stmt::CXXTryStmtClass:
1730 case Stmt::CXXTypeidExprClass:
1731 case Stmt::CXXUuidofExprClass:
1732 case Stmt::CXXFoldExprClass:
1733 case Stmt::MSPropertyRefExprClass:
1734 case Stmt::MSPropertySubscriptExprClass:
1735 case Stmt::CXXUnresolvedConstructExprClass:
1736 case Stmt::DependentScopeDeclRefExprClass:
1737 case Stmt::ArrayTypeTraitExprClass:
1738 case Stmt::ExpressionTraitExprClass:
1739 case Stmt::UnresolvedLookupExprClass:
1740 case Stmt::UnresolvedMemberExprClass:
1741 case Stmt::RecoveryExprClass:
1742 case Stmt::CXXNoexceptExprClass:
1743 case Stmt::PackExpansionExprClass:
1744 case Stmt::PackIndexingExprClass:
1745 case Stmt::SubstNonTypeTemplateParmPackExprClass:
1746 case Stmt::FunctionParmPackExprClass:
1747 case Stmt::CoroutineBodyStmtClass:
1748 case Stmt::CoawaitExprClass:
1749 case Stmt::DependentCoawaitExprClass:
1750 case Stmt::CoreturnStmtClass:
1751 case Stmt::CoyieldExprClass:
1752 case Stmt::SEHTryStmtClass:
1753 case Stmt::SEHExceptStmtClass:
1754 case Stmt::SEHLeaveStmtClass:
1755 case Stmt::SEHFinallyStmtClass:
1756 case Stmt::OMPCanonicalLoopClass:
1757 case Stmt::OMPParallelDirectiveClass:
1758 case Stmt::OMPSimdDirectiveClass:
1759 case Stmt::OMPForDirectiveClass:
1760 case Stmt::OMPForSimdDirectiveClass:
1761 case Stmt::OMPSectionsDirectiveClass:
1762 case Stmt::OMPSectionDirectiveClass:
1763 case Stmt::OMPScopeDirectiveClass:
1764 case Stmt::OMPSingleDirectiveClass:
1765 case Stmt::OMPMasterDirectiveClass:
1766 case Stmt::OMPCriticalDirectiveClass:
1767 case Stmt::OMPParallelForDirectiveClass:
1768 case Stmt::OMPParallelForSimdDirectiveClass:
1769 case Stmt::OMPParallelSectionsDirectiveClass:
1770 case Stmt::OMPParallelMasterDirectiveClass:
1771 case Stmt::OMPParallelMaskedDirectiveClass:
1772 case Stmt::OMPTaskDirectiveClass:
1773 case Stmt::OMPTaskyieldDirectiveClass:
1774 case Stmt::OMPBarrierDirectiveClass:
1775 case Stmt::OMPTaskwaitDirectiveClass:
1776 case Stmt::OMPErrorDirectiveClass:
1777 case Stmt::OMPTaskgroupDirectiveClass:
1778 case Stmt::OMPFlushDirectiveClass:
1779 case Stmt::OMPDepobjDirectiveClass:
1780 case Stmt::OMPScanDirectiveClass:
1781 case Stmt::OMPOrderedDirectiveClass:
1782 case Stmt::OMPAtomicDirectiveClass:
1783 case Stmt::OMPAssumeDirectiveClass:
1784 case Stmt::OMPTargetDirectiveClass:
1785 case Stmt::OMPTargetDataDirectiveClass:
1786 case Stmt::OMPTargetEnterDataDirectiveClass:
1787 case Stmt::OMPTargetExitDataDirectiveClass:
1788 case Stmt::OMPTargetParallelDirectiveClass:
1789 case Stmt::OMPTargetParallelForDirectiveClass:
1790 case Stmt::OMPTargetUpdateDirectiveClass:
1791 case Stmt::OMPTeamsDirectiveClass:
1792 case Stmt::OMPCancellationPointDirectiveClass:
1793 case Stmt::OMPCancelDirectiveClass:
1794 case Stmt::OMPTaskLoopDirectiveClass:
1795 case Stmt::OMPTaskLoopSimdDirectiveClass:
1796 case Stmt::OMPMasterTaskLoopDirectiveClass:
1797 case Stmt::OMPMaskedTaskLoopDirectiveClass:
1798 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
1799 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
1800 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
1801 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
1802 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
1803 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
1804 case Stmt::OMPDistributeDirectiveClass:
1805 case Stmt::OMPDistributeParallelForDirectiveClass:
1806 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
1807 case Stmt::OMPDistributeSimdDirectiveClass:
1808 case Stmt::OMPTargetParallelForSimdDirectiveClass:
1809 case Stmt::OMPTargetSimdDirectiveClass:
1810 case Stmt::OMPTeamsDistributeDirectiveClass:
1811 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
1812 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
1813 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
1814 case Stmt::OMPTargetTeamsDirectiveClass:
1815 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
1816 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
1817 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
1818 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
1819 case Stmt::OMPReverseDirectiveClass:
1820 case Stmt::OMPStripeDirectiveClass:
1821 case Stmt::OMPTileDirectiveClass:
1822 case Stmt::OMPInterchangeDirectiveClass:
1823 case Stmt::OMPFuseDirectiveClass:
1824 case Stmt::OMPInteropDirectiveClass:
1825 case Stmt::OMPDispatchDirectiveClass:
1826 case Stmt::OMPMaskedDirectiveClass:
1827 case Stmt::OMPGenericLoopDirectiveClass:
1828 case Stmt::OMPTeamsGenericLoopDirectiveClass:
1829 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
1830 case Stmt::OMPParallelGenericLoopDirectiveClass:
1831 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
1832 case Stmt::CapturedStmtClass:
1833 case Stmt::SYCLKernelCallStmtClass:
1834 case Stmt::OpenACCComputeConstructClass:
1835 case Stmt::OpenACCLoopConstructClass:
1836 case Stmt::OpenACCCombinedConstructClass:
1837 case Stmt::OpenACCDataConstructClass:
1838 case Stmt::OpenACCEnterDataConstructClass:
1839 case Stmt::OpenACCExitDataConstructClass:
1840 case Stmt::OpenACCHostDataConstructClass:
1841 case Stmt::OpenACCWaitConstructClass:
1842 case Stmt::OpenACCCacheConstructClass:
1843 case Stmt::OpenACCInitConstructClass:
1844 case Stmt::OpenACCShutdownConstructClass:
1845 case Stmt::OpenACCSetConstructClass:
1846 case Stmt::OpenACCUpdateConstructClass:
1847 case Stmt::OpenACCAtomicConstructClass:
1848 case Stmt::OMPUnrollDirectiveClass:
1849 case Stmt::OMPMetaDirectiveClass:
1850 case Stmt::HLSLOutArgExprClass: {
1852 Engine.addAbortedBlock(node, currBldrCtx->getBlock());
1856 case Stmt::ParenExprClass:
1857 llvm_unreachable(
"ParenExprs already handled.");
1858 case Stmt::GenericSelectionExprClass:
1859 llvm_unreachable(
"GenericSelectionExprs already handled.");
1862 case Stmt::BreakStmtClass:
1863 case Stmt::CaseStmtClass:
1864 case Stmt::CompoundStmtClass:
1865 case Stmt::ContinueStmtClass:
1866 case Stmt::CXXForRangeStmtClass:
1867 case Stmt::DefaultStmtClass:
1868 case Stmt::DoStmtClass:
1869 case Stmt::ForStmtClass:
1870 case Stmt::GotoStmtClass:
1871 case Stmt::IfStmtClass:
1872 case Stmt::IndirectGotoStmtClass:
1873 case Stmt::LabelStmtClass:
1875 case Stmt::NullStmtClass:
1876 case Stmt::SwitchStmtClass:
1877 case Stmt::WhileStmtClass:
1878 case Stmt::DeferStmtClass:
1879 case Expr::MSDependentExistsStmtClass:
1880 llvm_unreachable(
"Stmt should not be in analyzer evaluation loop");
1881 case Stmt::ImplicitValueInitExprClass:
1885 llvm_unreachable(
"Should be pruned from CFG");
1887 case Stmt::ObjCSubscriptRefExprClass:
1888 case Stmt::ObjCPropertyRefExprClass:
1889 llvm_unreachable(
"These are handled by PseudoObjectExpr");
1891 case Stmt::GNUNullExprClass: {
1894 state = state->BindExpr(
1896 svalBuilder.makeIntValWithWidth(
getContext().VoidPtrTy, 0));
1901 case Stmt::ObjCAtSynchronizedStmtClass:
1907 case Expr::ConstantExprClass:
1908 case Stmt::ExprWithCleanupsClass:
1912 case Stmt::CXXBindTemporaryExprClass: {
1923 case Stmt::ArrayInitLoopExprClass:
1929 case Stmt::DesignatedInitExprClass:
1930 case Stmt::DesignatedInitUpdateExprClass:
1931 case Stmt::ArrayInitIndexExprClass:
1932 case Stmt::ExtVectorElementExprClass:
1933 case Stmt::ImaginaryLiteralClass:
1934 case Stmt::ObjCAtCatchStmtClass:
1935 case Stmt::ObjCAtFinallyStmtClass:
1936 case Stmt::ObjCAtTryStmtClass:
1937 case Stmt::ObjCAutoreleasePoolStmtClass:
1938 case Stmt::ObjCEncodeExprClass:
1939 case Stmt::ObjCIsaExprClass:
1940 case Stmt::ObjCProtocolExprClass:
1941 case Stmt::ObjCSelectorExprClass:
1942 case Stmt::ParenListExprClass:
1943 case Stmt::ShuffleVectorExprClass:
1944 case Stmt::ConvertVectorExprClass:
1945 case Stmt::VAArgExprClass:
1946 case Stmt::CUDAKernelCallExprClass:
1947 case Stmt::OpaqueValueExprClass:
1948 case Stmt::AsTypeExprClass:
1949 case Stmt::ConceptSpecializationExprClass:
1950 case Stmt::CXXRewrittenBinaryOperatorClass:
1951 case Stmt::RequiresExprClass:
1952 case Stmt::EmbedExprClass:
1957 case Stmt::PredefinedExprClass:
1958 case Stmt::AddrLabelExprClass:
1959 case Stmt::IntegerLiteralClass:
1960 case Stmt::FixedPointLiteralClass:
1961 case Stmt::CharacterLiteralClass:
1962 case Stmt::CXXScalarValueInitExprClass:
1963 case Stmt::CXXBoolLiteralExprClass:
1964 case Stmt::ObjCBoolLiteralExprClass:
1965 case Stmt::ObjCAvailabilityCheckExprClass:
1966 case Stmt::FloatingLiteralClass:
1967 case Stmt::NoInitExprClass:
1968 case Stmt::SizeOfPackExprClass:
1969 case Stmt::StringLiteralClass:
1970 case Stmt::SourceLocExprClass:
1971 case Stmt::ObjCStringLiteralClass:
1972 case Stmt::CXXPseudoDestructorExprClass:
1973 case Stmt::SubstNonTypeTemplateParmExprClass:
1974 case Stmt::CXXNullPtrLiteralExprClass:
1975 case Stmt::ArraySectionExprClass:
1976 case Stmt::OMPArrayShapingExprClass:
1977 case Stmt::OMPIteratorExprClass:
1978 case Stmt::SYCLUniqueStableNameExprClass:
1979 case Stmt::OpenACCAsteriskSizeExprClass:
1980 case Stmt::TypeTraitExprClass: {
1989 case Stmt::AttributedStmtClass: {
1996 case Stmt::CXXDefaultArgExprClass:
1997 case Stmt::CXXDefaultInitExprClass: {
2006 if (
const auto *DefE = dyn_cast<CXXDefaultArgExpr>(S))
2007 ArgE = DefE->getExpr();
2008 else if (
const auto *DefE = dyn_cast<CXXDefaultInitExpr>(S))
2009 ArgE = DefE->getExpr();
2011 llvm_unreachable(
"unknown constant wrapper kind");
2013 bool IsTemporary =
false;
2014 if (
const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(ArgE)) {
2015 ArgE = MTE->getSubExpr();
2019 std::optional<SVal> ConstantVal = svalBuilder.getConstantVal(ArgE);
2024 for (
const auto I : PreVisit) {
2026 State = State->BindExpr(S, LCtx, *ConstantVal);
2028 State = createTemporaryRegionIfNeeded(State, LCtx,
2040 case Stmt::CXXStdInitializerListExprClass:
2041 case Expr::ObjCArrayLiteralClass:
2042 case Expr::ObjCDictionaryLiteralClass:
2043 case Expr::ObjCBoxedExprClass: {
2053 QualType resultType = Ex->getType();
2055 for (
const auto N : preVisit) {
2057 SVal result = svalBuilder.conjureSymbolVal(
2059 currBldrCtx->blockCount());
2067 for (
auto Child : Ex->children()) {
2069 SVal Val = State->getSVal(Child, LCtx);
2081 case Stmt::ArraySubscriptExprClass:
2087 case Stmt::MatrixSingleSubscriptExprClass:
2089 "Support for MatrixSingleSubscriptExprClass is not implemented.");
2092 case Stmt::MatrixSubscriptExprClass:
2093 llvm_unreachable(
"Support for MatrixSubscriptExpr is not implemented.");
2096 case Stmt::GCCAsmStmtClass: {
2108 case Stmt::MSAsmStmtClass:
2114 case Stmt::BlockExprClass:
2120 case Stmt::LambdaExprClass:
2121 if (AMgr.options.ShouldInlineLambdas) {
2127 Engine.addAbortedBlock(node, currBldrCtx->getBlock());
2131 case Stmt::BinaryOperatorClass: {
2133 if (B->isLogicalOp()) {
2139 else if (B->getOpcode() == BO_Comma) {
2143 state->getSVal(B->getRHS(),
2150 if (AMgr.options.ShouldEagerlyAssume &&
2151 (B->isRelationalOp() || B->isEqualityOp())) {
2163 case Stmt::CXXOperatorCallExprClass: {
2168 const Decl *Callee = OCE->getCalleeDecl();
2169 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(Callee)) {
2170 if (MD->isImplicitObjectMemberFunction()) {
2174 createTemporaryRegionIfNeeded(State, LCtx, OCE->getArg(0));
2175 if (NewState != State) {
2187 case Stmt::CallExprClass:
2188 case Stmt::CXXMemberCallExprClass:
2189 case Stmt::UserDefinedLiteralClass:
2195 case Stmt::CXXCatchStmtClass:
2201 case Stmt::CXXTemporaryObjectExprClass:
2202 case Stmt::CXXConstructExprClass:
2208 case Stmt::CXXInheritedCtorInitExprClass:
2215 case Stmt::CXXNewExprClass: {
2222 for (
const auto i : PreVisit)
2230 case Stmt::CXXDeleteExprClass: {
2238 for (
const auto i : PostVisit)
2247 case Stmt::ChooseExprClass: {
2255 case Stmt::CompoundAssignOperatorClass:
2261 case Stmt::CompoundLiteralExprClass:
2267 case Stmt::BinaryConditionalOperatorClass:
2268 case Stmt::ConditionalOperatorClass: {
2276 case Stmt::CXXThisExprClass:
2282 case Stmt::DeclRefExprClass: {
2290 case Stmt::DeclStmtClass:
2296 case Stmt::ImplicitCastExprClass:
2297 case Stmt::CStyleCastExprClass:
2298 case Stmt::CXXStaticCastExprClass:
2299 case Stmt::CXXDynamicCastExprClass:
2300 case Stmt::CXXReinterpretCastExprClass:
2301 case Stmt::CXXConstCastExprClass:
2302 case Stmt::CXXFunctionalCastExprClass:
2303 case Stmt::BuiltinBitCastExprClass:
2304 case Stmt::ObjCBridgedCastExprClass:
2305 case Stmt::CXXAddrspaceCastExprClass: {
2317 case Expr::MaterializeTemporaryExprClass: {
2323 for (
const auto i : dstPrevisit)
2330 case Stmt::InitListExprClass: {
2338 case Expr::CXXParenListInitExprClass: {
2347 case Stmt::MemberExprClass:
2353 case Stmt::AtomicExprClass:
2359 case Stmt::ObjCIvarRefExprClass:
2365 case Stmt::ObjCForCollectionStmtClass:
2371 case Stmt::ObjCMessageExprClass:
2377 case Stmt::ObjCAtThrowStmtClass:
2378 case Stmt::CXXThrowExprClass:
2384 case Stmt::ReturnStmtClass:
2390 case Stmt::OffsetOfExprClass: {
2396 for (
const auto Node : PreVisit)
2404 case Stmt::UnaryExprOrTypeTraitExprClass:
2411 case Stmt::StmtExprClass: {
2414 if (SE->getSubStmt()->body_empty()) {
2417 &&
"Empty statement expression must have void type.");
2421 if (
const auto *LastExpr =
2422 dyn_cast<Expr>(*SE->getSubStmt()->body_rbegin())) {
2426 state->getSVal(LastExpr,
2432 case Stmt::UnaryOperatorClass: {
2435 if (AMgr.options.ShouldEagerlyAssume && (
U->getOpcode() == UO_LNot)) {
2446 case Stmt::PseudoObjectExprClass: {
2450 if (
const Expr *
Result = PE->getResultExpr()) {
2464 case Expr::ObjCIndirectCopyRestoreExprClass: {
2471 const Expr *E = OIE->getSubExpr();
2485 assert(CalleeSF && CallerSF);
2492 BeforeProcessingCall = N;
2507 if (SP->getStmt() == CE)
2512 if (!BeforeProcessingCall)
2541 NumTimesRetriedWithoutInlining++;
2565 if(AMgr.options.ShouldUnrollLoops) {
2566 unsigned maxBlockVisitOnPath = AMgr.options.maxBlockVisitOnPath;
2570 Pred, maxBlockVisitOnPath);
2571 if (NewState != Pred->
getState()) {
2586 if (BlockCount == AMgr.options.maxBlockVisitOnPath - 1 &&
2587 AMgr.options.ShouldWidenLoops) {
2589 if (!isa_and_nonnull<ForStmt, WhileStmt, DoStmt, CXXForRangeStmt>(Term))
2609 if (BlockCount >= AMgr.options.maxBlockVisitOnPath) {
2624 Engine.FunctionSummaries->markShouldNotInline(
2631 if ((!AMgr.options.NoRetryExhausted && replayWithoutInlining(Pred, LC)))
2633 NumMaxBlockCountReachedInInlined++;
2635 NumMaxBlockCountReached++;
2638 Engine.blocksExhausted.push_back(std::make_pair(L, Sink));
2646 llvm::PrettyStackTraceFormat CrashInfo(
2647 "Processing block entrance B%d -> B%d",
2650 currBldrCtx = &BldCtx;
2652 currBldrCtx =
nullptr;
2669 const auto *Ex = dyn_cast<Expr>(
Condition);
2674 bool bitsInit =
false;
2676 while (
const auto *CE = dyn_cast<CastExpr>(Ex)) {
2679 if (!
T->isIntegralOrEnumerationType())
2683 if (!bitsInit || newBits < bits) {
2688 Ex = CE->getSubExpr();
2694 if (!bitsInit || !
T->isIntegralOrEnumerationType() ||
2698 return state->getSVal(Ex, LCtx);
2704 const auto *BO = dyn_cast<BinaryOperator>(
Condition);
2705 if (!BO || !BO->isLogicalOp()) {
2708 Condition = BO->getRHS()->IgnoreParens();
2730 if (
const auto *Ex = dyn_cast<Expr>(
Condition))
2733 const auto *BO = dyn_cast<BinaryOperator>(
Condition);
2734 if (!BO || !BO->isLogicalOp())
2738 "Other kinds of branches are handled separately!");
2749 std::optional<CFGStmt> CS = Elem.getAs<
CFGStmt>();
2752 const Stmt *LastStmt = CS->getStmt();
2756 llvm_unreachable(
"could not resolve condition");
2760 std::pair<const ObjCForCollectionStmt *, const LocationContext *>;
2767 assert(!State->contains<ObjCForHasMoreIterations>({O, LC}));
2768 return State->set<ObjCForHasMoreIterations>({O, LC}, HasMoreIteraton);
2775 assert(State->contains<ObjCForHasMoreIterations>({O, LC}));
2776 return State->remove<ObjCForHasMoreIterations>({O, LC});
2782 assert(State->contains<ObjCForHasMoreIterations>({O, LC}));
2783 return *State->get<ObjCForHasMoreIterations>({O, LC});
2789static std::optional<std::pair<ProgramStateRef, ProgramStateRef>>
2792 if (
const auto *ObjCFor = dyn_cast<ObjCForCollectionStmt>(
Condition)) {
2793 bool HasMoreIteraton =
2800 if (HasMoreIteraton)
2801 return std::pair<ProgramStateRef, ProgramStateRef>{State,
nullptr};
2803 return std::pair<ProgramStateRef, ProgramStateRef>{
nullptr, State};
2807 if (
X.isUnknownOrUndef()) {
2809 if (
const auto *Ex = dyn_cast<Expr>(
Condition)) {
2810 if (Ex->getType()->isIntegralOrEnumerationType()) {
2817 N->
getState()->getStateManager().getContext());
2827 if (
X.isUnknownOrUndef())
2828 return std::nullopt;
2833 return State->assume(
V);
2839 std::optional<unsigned> IterationsCompletedInLoop) {
2841 "CXXBindTemporaryExprs are handled by processBindTemporary.");
2842 currBldrCtx = &BldCtx;
2851 if (
const auto *Ex = dyn_cast<Expr>(
Condition))
2857 "Error evaluating branch");
2863 if (CheckersOutSet.
empty())
2868 if (PredN->isSink())
2875 std::tie(StTrue, StFalse) = *KnownCondValueAssumption;
2877 if (StTrue && StFalse)
2888 (StTrue && StFalse) ||
2907 bool CompletedTwoIterations = IterationsCompletedInLoop.value_or(0) >= 2;
2908 bool SkipTrueBranch = BothFeasible && CompletedTwoIterations;
2914 if (!SkipTrueBranch || AMgr.options.ShouldWidenLoops) {
2915 Builder.generateNode(StTrue,
true, PredN);
2916 }
else if (!AMgr.options.InlineFunctionsWithAmbiguousLoops) {
2933 Engine.FunctionSummaries->markShouldNotInline(
2952 bool BeforeFirstIteration = IterationsCompletedInLoop == std::optional{0};
2953 bool SkipFalseBranch = BothFeasible && BeforeFirstIteration &&
2954 AMgr.options.ShouldAssumeAtLeastOneIteration;
2955 if (!SkipFalseBranch)
2956 Builder.generateNode(StFalse,
false, PredN);
2959 currBldrCtx =
nullptr;
2965 llvm::ImmutableSet<const VarDecl *>)
2970 currBldrCtx = &BuilderCtx;
2974 bool initHasRun = state->contains<InitializedGlobalsSet>(VD);
2978 state = state->add<InitializedGlobalsSet>(VD);
2981 Builder.generateNode(state, initHasRun, Pred);
2983 currBldrCtx =
nullptr;
3005 if (Succ.getLabel() == L) {
3006 builder.generateNode(Succ, state);
3011 llvm_unreachable(
"No block with label.");
3045 State = finishArgumentConstruction(
3060 while (LC != ToLC) {
3061 assert(LC &&
"ToLC must be a parent of FromLC!");
3062 for (
auto I : State->get<ObjectsUnderConstruction>())
3063 if (I.first.getLocationContext() == LC) {
3067 assert(I.first.getItem().getKind() ==
3069 I.first.getItem().getKind() ==
3071 State = State->remove<ObjectsUnderConstruction>(I.first);
3089 assert(areAllObjectsFullyConstructed(Pred->
getState(),
3099 for (
const auto I : AfterRemovedDead)
3105 Engine.enqueueEndOfFunction(Dst, RS);
3117 if (CondV_untested.
isUndef()) {
3129 bool defaultIsFeasible = I == EI;
3131 for ( ; I != EI; ++I) {
3136 const CaseStmt *Case = I.getCase();
3150 if (std::optional<NonLoc> NL = CondV.
getAs<
NonLoc>())
3151 std::tie(StateCase, DefaultSt) =
3152 DefaultSt->assumeInclusiveRange(*NL, V1, V2);
3154 StateCase = DefaultSt;
3162 defaultIsFeasible =
true;
3164 defaultIsFeasible =
false;
3169 if (!defaultIsFeasible)
3201 auto resolveAsLambdaCapturedVar =
3202 [&](
const ValueDecl *VD) -> std::optional<std::pair<SVal, QualType>> {
3203 const auto *MD = dyn_cast<CXXMethodDecl>(LCtx->
getDecl());
3204 const auto *DeclRefEx = dyn_cast<DeclRefExpr>(Ex);
3205 if (AMgr.options.ShouldInlineLambdas && DeclRefEx &&
3206 DeclRefEx->refersToEnclosingVariableOrCapture() && MD &&
3207 MD->getParent()->isLambda()) {
3210 llvm::DenseMap<const ValueDecl *, FieldDecl *> LambdaCaptureFields;
3216 if (
const FieldDecl *FD = LambdaCaptureFields[VD]) {
3219 return std::make_pair(state->getLValue(FD, CXXThisVal), FD->getType());
3223 return std::nullopt;
3226 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
3229 assert(Ex->
isGLValue() || VD->getType()->isVoidType());
3231 std::optional<std::pair<SVal, QualType>> VInfo =
3232 resolveAsLambdaCapturedVar(VD);
3235 VInfo = std::make_pair(state->getLValue(VD, LocCtxt), VD->getType());
3237 SVal V = VInfo->first;
3238 bool IsReference = VInfo->second->isReferenceType();
3244 V = state->getSVal(R);
3249 Bldr.
generateNode(Ex, Pred, state->BindExpr(Ex, LCtx,
V),
nullptr,
3253 if (
const auto *ED = dyn_cast<EnumConstantDecl>(D)) {
3255 SVal V = svalBuilder.makeIntVal(ED->getInitVal());
3259 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3260 SVal V = svalBuilder.getFunctionPointer(FD);
3261 Bldr.
generateNode(Ex, Pred, state->BindExpr(Ex, LCtx,
V),
nullptr,
3270 if (
const auto *BD = dyn_cast<BindingDecl>(D)) {
3272 if (std::optional<std::pair<SVal, QualType>> VInfo =
3273 resolveAsLambdaCapturedVar(BD)) {
3274 auto [
V,
T] = VInfo.value();
3276 if (
T->isReferenceType()) {
3278 V = state->getSVal(R);
3283 Bldr.
generateNode(Ex, Pred, state->BindExpr(Ex, LCtx,
V),
nullptr,
3290 SVal Base = state->getLValue(DD, LCtx);
3291 if (DD->getType()->isReferenceType()) {
3293 Base = state->getSVal(R);
3301 if (
const auto *ME = dyn_cast<MemberExpr>(BD->getBinding())) {
3303 V = state->getLValue(Field,
Base);
3306 else if (
const auto *ASE = dyn_cast<ArraySubscriptExpr>(BD->getBinding())) {
3307 SVal Idx = state->getSVal(ASE->getIdx(), LCtx);
3312 assert(Idx.
isConstant() &&
"BindingDecl array index is not a constant!");
3314 V = state->getLValue(BD->getType(), Idx,
Base);
3317 else if (
const auto *HV = BD->getHoldingVar()) {
3318 V = state->getLValue(HV, LCtx);
3320 if (HV->getType()->isReferenceType()) {
3322 V = state->getSVal(R);
3327 llvm_unreachable(
"An unknown case of structured binding encountered!");
3331 if (BD->getType()->isReferenceType() && !BD->getHoldingVar()) {
3333 V = state->getSVal(R);
3338 Bldr.
generateNode(Ex, Pred, state->BindExpr(Ex, LCtx,
V),
nullptr,
3344 if (
const auto *TPO = dyn_cast<TemplateParamObjectDecl>(D)) {
3350 llvm_unreachable(
"Support for this Decl not implemented.");
3365 for (
auto *Node : CheckerPreStmt) {
3410 if (
const auto *ME = dyn_cast<MemberExpr>(Arr)) {
3411 Expr *MEBase = ME->getBase();
3414 if (
auto CXXSCE = dyn_cast<CXXStaticCastExpr>(MEBase)) {
3415 MEBase = CXXSCE->getSubExpr();
3436 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arr))
3441 Base = state->getSVal(R);
3470 (A->
getType().isCForbiddenLValueType() && !AMgr.getLangOpts().CPlusPlus);
3472 for (
auto *Node : CheckerPreStmt) {
3476 if (IsGLValueLike) {
3482 if (
T->isVoidType())
3485 SVal V = state->getLValue(
T,
3486 state->getSVal(Idx, LCtx),
3487 state->getSVal(
Base, LCtx));
3488 Bldr.
generateNode(A, Node, state->BindExpr(A, LCtx,
V),
nullptr,
3490 }
else if (IsVectorType) {
3494 llvm_unreachable(
"Array subscript should be an lValue when not \
3495a vector and not a forbidden lvalue type");
3515 for (
const auto I : CheckedSet)
3521 for (
const auto I : CheckedSet) {
3527 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
Member)) {
3528 if (MD->isImplicitObjectMemberFunction())
3529 state = createTemporaryRegionIfNeeded(state, LCtx, BaseExpr);
3531 SVal MDVal = svalBuilder.getFunctionPointer(MD);
3532 state = state->BindExpr(M, LCtx, MDVal);
3540 state = createTemporaryRegionIfNeeded(state, LCtx, BaseExpr,
3547 if (
const auto *SR =
3548 dyn_cast_or_null<SymbolicRegion>(baseExprVal.
getAsRegion())) {
3549 QualType T = SR->getPointeeStaticType();
3555 SVal L = state->getLValue(field, baseExprVal);
3565 dyn_cast<ImplicitCastExpr>(I->getParentMap().getParentIgnoreParens(M));
3566 if (!PE || PE->getCastKind() != CK_ArrayToPointerDecay) {
3567 llvm_unreachable(
"should always be wrapped in ArrayToPointerDecay");
3571 if (field->getType()->isReferenceType()) {
3573 L = state->getSVal(R);
3578 Bldr.
generateNode(M, I, state->BindExpr(M, LCtx, L),
nullptr,
3602 for (
const auto I : AfterPreSet) {
3607 for (
unsigned SI = 0, Count = AE->
getNumSubExprs(); SI != Count; SI++) {
3609 SVal SubExprVal = State->getSVal(SubExpr, LCtx);
3610 ValuesToInvalidate.push_back(SubExprVal);
3614 currBldrCtx->blockCount(), LCtx,
3619 State = State->BindExpr(AE, LCtx, ResultVal);
3639 for (
const std::pair<SVal, SVal> &LocAndVal : LocAndVals) {
3641 const MemRegion *MR = LocAndVal.first.getAsRegion();
3644 Escaped.push_back(LocAndVal.second);
3649 if (
const auto *VR = dyn_cast<VarRegion>(MR->
getBaseRegion()))
3651 VR->getStackFrame()->inTopFrame())
3652 if (
const auto *RD = VR->getValueType()->getAsCXXRecordDecl())
3653 if (!RD->hasTrivialDestructor()) {
3654 Escaped.push_back(LocAndVal.second);
3663 SVal StoredVal = State->getSVal(MR);
3664 if (StoredVal != LocAndVal.second)
3667 Escaped.push_back(LocAndVal.second);
3670 if (Escaped.empty())
3679 std::pair<SVal, SVal> LocAndVal(
Loc, Val);
3690 if (!Invalidated || Invalidated->empty())
3703 for (
const auto I : ExplicitRegions) {
3705 SymbolsDirectlyInvalidated.insert(R->getSymbol());
3709 for (
const auto &sym : *Invalidated) {
3710 if (SymbolsDirectlyInvalidated.count(sym))
3712 SymbolsIndirectlyInvalidated.insert(sym);
3715 if (!SymbolsDirectlyInvalidated.empty())
3720 if (!SymbolsIndirectlyInvalidated.empty())
3740 StoreE, AtDeclInit, *
this, *PP);
3751 Bldr.generateNode(L, state, Pred);
3755 for (
const auto PredI : CheckedSet) {
3763 state = state->bindLoc(location.
castAs<
Loc>(), Val, LC,
3767 if (std::optional<loc::MemRegionVal> LocRegVal =
3769 LocReg = LocRegVal->getRegion();
3773 Bldr.generateNode(L, state, PredI);
3786 const Expr *LocationE,
3792 const Expr *StoreE = AssignE ? AssignE : LocationE;
3796 evalLocation(Tmp, AssignE, LocationE, Pred, state, location,
false);
3804 for (
const auto I : Tmp)
3805 evalBind(Dst, StoreE, I, location, Val,
false);
3810 const Expr *BoundEx,
3816 assert(!
isa<NonLoc>(location) &&
"location cannot be a NonLoc.");
3821 evalLocation(Tmp, NodeEx, BoundEx, Pred, state, location,
true);
3830 for (
const auto I : Tmp) {
3831 state = I->getState();
3838 V = state->getSVal(location.
castAs<
Loc>(), LoadTy);
3841 Bldr.
generateNode(NodeEx, I, state->BindExpr(BoundEx, LCtx,
V), tag,
3848 const Stmt *BoundEx,
3860 BldrTop.takeNodes(Pred);
3873 Bldr.generateNode(NodeEx, Pred, state, &tag);
3877 NodeEx, BoundEx, *
this);
3878 BldrTop.addNodes(Tmp);
3881std::pair<const ProgramPointTag *, const ProgramPointTag *>
3884 FalseTag(TagProviderName,
"Eagerly Assume False");
3886 return std::make_pair(&TrueTag, &FalseTag);
3910 State = State->set<LastEagerlyAssumeExprIfSuccessful>(
nullptr);
3913 if (SEV && SEV->isExpression()) {
3916 auto [StateTrue, StateFalse] = State->assume(*SEV);
3918 if (StateTrue && StateFalse) {
3919 StateTrue = StateTrue->set<LastEagerlyAssumeExprIfSuccessful>(Ex);
3920 StateFalse = StateFalse->set<LastEagerlyAssumeExprIfSuccessful>(Ex);
3941 const Expr *Ex)
const {
3942 return Ex && State->get<LastEagerlyAssumeExprIfSuccessful>() == Ex;
3961 if (std::optional<Loc> LV =
X.getAs<
Loc>())
3963 currBldrCtx->blockCount(),
3972 if (std::optional<Loc> LV =
X.getAs<
Loc>())
3974 currBldrCtx->blockCount(),
4003 for (
const auto &
Report : Class.getReports()) {
4004 const auto *PR = dyn_cast<PathSensitiveBugReport>(
Report.get());
4022 llvm::function_ref<
void(
const ExplodedNode *)> PreCallback,
4023 llvm::function_ref<
void(
const ExplodedNode *)> PostCallback,
4045 llvm::raw_string_ostream Out(Buf);
4047 const bool IsDot =
true;
4048 const unsigned int Space = 1;
4051 Out <<
"{ \"state_id\": " << State->getID()
4054 Indent(Out, Space, IsDot) <<
"\"program_points\": [\\l";
4060 Indent(Out, Space + 1, IsDot) <<
"{ ";
4062 Out <<
", \"tag\": ";
4064 Out <<
'\"' << Tag->getDebugTag() <<
'\"';
4067 Out <<
", \"node_id\": " << OtherNode->
getID() <<
4068 ", \"is_sink\": " << OtherNode->
isSink() <<
4076 Indent(Out, Space, IsDot) <<
"],\\l";
4089 llvm::DisplayGraph(Filename,
false, llvm::GraphProgram::DOT);
4093 std::string Filename =
DumpGraph(Nodes);
4094 llvm::DisplayGraph(Filename,
false, llvm::GraphProgram::DOT);
4099 std::vector<const ExplodedNode *> Src;
4102 for (
const auto &
Class : BR.equivalenceClasses()) {
4104 dyn_cast<PathSensitiveBugReport>(
Class.getReports()[0].get());
4107 const auto *N =
const_cast<ExplodedNode *
>(R->getErrorNode());
4114 auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
4115 return llvm::WriteGraph(&G,
"ExprEngine",
false,
4117 std::string(Filename));
4121 StringRef Filename) {
4122 std::unique_ptr<ExplodedGraph> TrimmedG(G.trim(Nodes));
4125 llvm::errs() <<
"warning: Trimmed ExplodedGraph is empty.\n";
4130 auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
4131 return llvm::WriteGraph(TrimmedG.get(),
"TrimmedExprEngine",
4133 "Trimmed Exploded Graph",
4134 std::string(Filename));
4138 static int index = 0;
4142void ExprEngine::anchor() { }
4155 bool IsCompound =
T->isArrayType() ||
T->isRecordType() ||
4156 T->isAnyComplexType() ||
T->isVectorType();
4158 if (Args.size() > 1 || (E->
isPRValue() && IsCompound && !IsTransparent)) {
4160 for (
Expr *E : llvm::reverse(Args))
4164 S->BindExpr(E, LC, svalBuilder.makeCompoundVal(
T, ArgList)));
4170 : S->getSVal(Args.front(), LC)));
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
static const MemRegion * getRegion(const CallEvent &Call, const MutexDescriptor &Descriptor, bool IsLock)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
#define STAT_COUNTER(VARNAME, DESC)
Defines the clang::Expr interface and subclasses for C++ expressions.
static const Stmt * getRightmostLeaf(const Stmt *Condition)
static SVal RecoverCastedSymbol(ProgramStateRef state, const Stmt *Condition, const LocationContext *LCtx, ASTContext &Ctx)
RecoverCastedSymbol - A helper function for ProcessBranch that is used to try to recover some path-se...
static void printObjectsUnderConstructionJson(raw_ostream &Out, ProgramStateRef State, const char *NL, const LocationContext *LCtx, unsigned int Space=0, bool IsDot=false)
static void printIndicesOfElementsToConstructJson(raw_ostream &Out, ProgramStateRef State, const char *NL, const LocationContext *LCtx, unsigned int Space=0, bool IsDot=false)
static void printStateTraitWithLocationContextJson(raw_ostream &Out, ProgramStateRef State, const LocationContext *LCtx, const char *NL, unsigned int Space, bool IsDot, const char *jsonPropertyName, Printer printer, Args &&...args)
A helper function to generalize program state trait printing.
static void printPendingArrayDestructionsJson(raw_ostream &Out, ProgramStateRef State, const char *NL, const LocationContext *LCtx, unsigned int Space=0, bool IsDot=false)
static bool shouldRemoveDeadBindings(AnalysisManager &AMgr, const Stmt *S, const ExplodedNode *Pred, const LocationContext *LC)
static const Stmt * ResolveCondition(const Stmt *Condition, const CFGBlock *B)
REGISTER_TRAIT_WITH_PROGRAMSTATE(ObjectsUnderConstruction, ObjectsUnderConstructionMap) typedef llvm REGISTER_TRAIT_WITH_PROGRAMSTATE(IndexOfElementToConstruct, IndexOfElementToConstructMap) typedef llvm typedef llvm::ImmutableMap< const LocationContext *, unsigned > PendingArrayDestructionMap
static void printPendingInitLoopJson(raw_ostream &Out, ProgramStateRef State, const char *NL, const LocationContext *LCtx, unsigned int Space=0, bool IsDot=false)
llvm::ImmutableMap< ConstructedObjectKey, SVal > ObjectsUnderConstructionMap
static const LocationContext * getInlinedLocationContext(ExplodedNode *Node, ExplodedGraph &G)
Return the innermost location context which is inlined at Node, unless it's the top-level (entry poin...
static std::optional< std::pair< ProgramStateRef, ProgramStateRef > > assumeCondition(const Stmt *Condition, ExplodedNode *N)
Split the state on whether there are any more iterations left for this loop.
std::pair< const ObjCForCollectionStmt *, const LocationContext * > ObjCForLctxPair
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
This header contains the declarations of functions which are used to decide which loops should be com...
This header contains the declarations of functions which are used to widen loops which do not otherwi...
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
#define REGISTER_MAP_WITH_PROGRAMSTATE(Name, Key, Value)
Declares an immutable map of type NameTy, suitable for placement into the ProgramState.
#define REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, Type)
Declares a program state trait for type Type called Name, and introduce a type named NameTy.
static bool isRecordType(QualType T)
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Defines the Objective-C statement AST node classes.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
const clang::PrintingPolicy & getPrintingPolicy() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ParentMap & getParentMap()
ASTContext & getASTContext() const
Stores options for the analyzer from the command line.
AnalysisPurgeMode AnalysisPurgeOpt
Represents a loop initializing the elements of an array.
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Expr * getSubExpr() const
Get the initializer to use for each array element.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
const CFGBlock * getPreviousBlock() const
const CFGBlock * getBlock() const
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
const VarDecl * getVarDecl() const
const Stmt * getTriggerStmt() const
Represents C++ object destructor implicitly generated for base object in destructor.
const CXXBaseSpecifier * getBaseSpecifier() const
Represents a single basic block in a source-level CFG.
CFGTerminator getTerminator() const
Stmt * getTerminatorStmt()
unsigned getBlockID() const
Represents C++ object destructor generated from a call to delete.
const CXXDeleteExpr * getDeleteExpr() const
Represents a top-level expression in a basic block.
T castAs() const
Convert to the specified CFGElement type, asserting that this CFGElement is of the desired type.
Represents C++ object destructor implicitly generated by compiler on various occasions.
const CXXDestructorDecl * getDestructorDecl(ASTContext &astContext) const
Represents C++ base or member initializer from constructor's initialization list.
const CXXCtorInitializer * getInitializer() const
Represents the point where a loop ends.
const Stmt * getLoopStmt() const
Represents C++ object destructor implicitly generated for member object in destructor.
const FieldDecl * getFieldDecl() const
Represents C++ allocator call.
const CXXNewExpr * getAllocatorExpr() const
const Stmt * getStmt() const
Represents C++ object destructor implicitly generated at the end of full expression for temporary obj...
const CXXBindTemporaryExpr * getBindTemporaryExpr() const
bool isStmtBranch() const
Represents a base class of a C++ class.
Represents binding an expression to a temporary.
const Expr * getSubExpr() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a call to a C++ constructor.
Represents a C++ base or member initializer.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Expr * getInit() const
Get the initializer.
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
bool isAnyMemberInitializer() const
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
bool isIndirectMemberInitializer() const
int64_t getID(const ASTContext &Context) const
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
FieldDecl * getAnyMember() const
IndirectFieldDecl * getIndirectMember() const
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Represents a delete expression for memory deallocation and destructor calls, e.g.
SourceLocation getBeginLoc() const
QualType getDestroyedType() const
Retrieve the type being destroyed.
Represents a C++ destructor within a class.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Represents a list-initialization with parenthesis.
MutableArrayRef< Expr * > getInitExprs()
Represents a C++ struct/union/class.
void getCaptureFields(llvm::DenseMap< const ValueDecl *, FieldDecl * > &Captures, FieldDecl *&ThisCapture) const
For a closure type, retrieve the mapping from captured variables and this to the non-static data memb...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Represents a point when we begin processing an inlined call.
CaseStmt - Represent a case statement.
Represents a single point (AST node) in the program that requires attention during construction of an...
unsigned getIndex() const
If a single trigger statement triggers multiple constructors, they are usually being enumerated.
const CXXCtorInitializer * getCXXCtorInitializer() const
The construction site is not necessarily a statement.
@ TemporaryDestructorKind
const Stmt * getStmtOrNull() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
A reference to a declared variable, function, enum, etc.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
const Decl * getSingleDecl() const
Decl - This represents one declaration (or definition), e.g.
This is a meta program point, which should be skipped by all the diagnostic reasoning etc.
This represents one expression.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Represents a member of a struct/union/class.
This represents a GCC inline-assembly statement extension.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Describes an C or C++ initializer list.
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
ArrayRef< Expr * > inits()
Represents the declaration of a label.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const Decl * getDecl() const
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
const LocationContext * getParent() const
It might return null.
const StackFrameContext * getStackFrame() const
virtual bool inTopFrame() const
void printJson(raw_ostream &Out, const char *NL="\n", unsigned int Space=0, bool IsDot=false, std::function< void(const LocationContext *)> printMoreInfoPerContext=[](const LocationContext *) {}) const
Prints out the call stack in json format.
Represents a point when we exit a loop.
This represents a Microsoft inline-assembly statement extension.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
This represents a decl that may have a name.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents Objective-C's collection statement.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
bool isConsumedExpr(Expr *E) const
Represents a parameter to a function.
Represents a program point just after an implicit call event.
Represents a program point after a store evaluation.
Represents a program point just before an implicit call event.
If a crash happens while one of these objects are live, the message is printed out along with the spe...
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
const ProgramPointTag * getTag() const
bool isPurgeKind()
Is this a program point corresponding to purge/removal of dead symbols and bindings.
T castAs() const
Convert to the specified ProgramPoint type, asserting that this ProgramPoint is of the desired type.
void printJson(llvm::raw_ostream &Out, const char *NL="\n") const
@ PreStmtPurgeDeadSymbolsKind
@ PostStmtPurgeDeadSymbolsKind
const StackFrameContext * getStackFrame() const
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
const LocationContext * getLocationContext() const
A (possibly-)qualified type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
std::string getAsString() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
std::string printToString(const SourceManager &SM) const
It represents a stack frame of the call stack (based on CallEvent).
unsigned getIndex() const
const Stmt * getCallSite() const
const CFGBlock * getCallSiteBlock() const
bool inTopFrame() const override
const Stmt * getStmt() const
Stmt - This represents one statement.
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const char * getStmtClassName() const
int64_t getID(const ASTContext &Context) const
SourceLocation getBeginLoc() const LLVM_READONLY
SwitchStmt - This represents a 'switch' stmt.
bool isAllEnumCasesCovered() const
Returns true if the SwitchStmt is a switch of an enum value and all cases have been explicitly covere...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isReferenceType() const
bool isEnumeralType() const
bool isVectorType() const
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.
This class is used for tools that requires cross translation unit capability.
AnalyzerOptions & options
llvm::ImmutableList< SVal > getEmptySValList()
llvm::ImmutableList< SVal > prependSVal(SVal X, llvm::ImmutableList< SVal > L)
BranchNodeBuilder is responsible for constructing the nodes corresponding to the two branches of the ...
ExplodedNode * generateNode(ProgramStateRef State, bool branch, ExplodedNode *Pred)
BugReporter is a utility class for generating PathDiagnostics for analysis.
llvm::iterator_range< EQClasses_iterator > equivalenceClasses()
Represents an abstract call to a function or method along a particular path.
static bool isCallStmt(const Stmt *S)
Returns true if this is a statement is a function or method call of some kind.
void runCheckersForEndFunction(NodeBuilderContext &BC, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, const ReturnStmt *RS)
Run checkers on end of function.
void runCheckersForLocation(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, bool isLoad, const Stmt *NodeEx, const Stmt *BoundEx, ExprEngine &Eng)
Run checkers for load/store of a location.
void runCheckersForBind(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, SVal val, const Stmt *S, bool AtDeclInit, ExprEngine &Eng, const ProgramPoint &PP)
Run checkers for binding of a value to a location.
void runCheckersForEndAnalysis(ExplodedGraph &G, BugReporter &BR, ExprEngine &Eng)
Run checkers for end of analysis.
void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\n", unsigned int Space=0, bool IsDot=false) const
Run checkers for debug-printing a ProgramState.
void runCheckersForDeadSymbols(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SymbolReaper &SymReaper, const Stmt *S, ExprEngine &Eng, ProgramPoint::Kind K)
Run checkers for dead symbols.
ProgramStateRef runCheckersForRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const LocationContext *LCtx, const CallEvent *Call)
Run checkers for region changes.
void runCheckersForLiveSymbols(ProgramStateRef state, SymbolReaper &SymReaper)
Run checkers for live symbols.
void runCheckersForBeginFunction(ExplodedNodeSet &Dst, const BlockEdge &L, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers on beginning of function.
void runCheckersForPostStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting Stmts.
void runCheckersForPreStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng)
Run checkers for pre-visiting Stmts.
void runCheckersForBlockEntrance(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const BlockEntrance &Entrance, ExprEngine &Eng) const
Run checkers after taking a control flow edge.
void runCheckersForBranchCondition(const Stmt *condition, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers for branch condition.
ProgramStateRef runCheckersForPointerEscape(ProgramStateRef State, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)
Run checkers when pointers escape.
ProgramStateRef runCheckersForEvalAssume(ProgramStateRef state, SVal Cond, bool Assumption)
Run checkers for handling assumptions on symbolic values.
virtual ProgramStateRef removeDeadBindings(ProgramStateRef state, SymbolReaper &SymReaper)=0
Scan all symbols referenced by the constraints.
void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx)
Enqueue a single node created as a result of statement processing.
ExplodedNode * getNode(const ProgramPoint &L, ProgramStateRef State, bool IsSink=false, bool *IsNew=nullptr)
Retrieve the node associated with a (Location, State) pair, where the 'Location' is a ProgramPoint in...
ExplodedNode * getRoot() const
Get the root node of the graph.
void insert(const ExplodedNodeSet &S)
void Add(ExplodedNode *N)
const ProgramStateRef & getState() const
pred_iterator pred_begin()
bool isTrivial() const
The node is trivial if it has only one successor, only one predecessor, it's predecessor has only one...
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
void addPredecessor(ExplodedNode *V, ExplodedGraph &G)
addPredeccessor - Adds a predecessor to the current node, and in tandem add this node as a successor ...
ExplodedNode * getFirstSucc()
const StackFrameContext * getStackFrame() const
const LocationContext * getLocationContext() const
unsigned succ_size() const
void processEndOfFunction(NodeBuilderContext &BC, ExplodedNode *Pred, const ReturnStmt *RS=nullptr)
Called by CoreEngine.
void VisitBinaryOperator(const BinaryOperator *B, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitBinaryOperator - Transfer function logic for binary operators.
ProgramStateManager & getStateManager()
void VisitArraySubscriptExpr(const ArraySubscriptExpr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitArraySubscriptExpr - Transfer function for array accesses.
void VisitCommonDeclRefExpr(const Expr *DR, const NamedDecl *D, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Transfer function logic for DeclRefExprs and BlockDeclRefExprs.
void ProcessInitializer(const CFGInitializer I, ExplodedNode *Pred)
void VisitObjCMessage(const ObjCMessageExpr *ME, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void ProcessTemporaryDtor(const CFGTemporaryDtor D, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitGuardedExpr(const Expr *Ex, const Expr *L, const Expr *R, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitGuardedExpr - Transfer function logic for ?, __builtin_choose.
void processBeginOfFunction(NodeBuilderContext &BC, ExplodedNode *Pred, ExplodedNodeSet &Dst, const BlockEdge &L)
Called by CoreEngine.
void VisitCast(const CastExpr *CastE, const Expr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitCast - Transfer function logic for all casts (implicit and explicit).
void removeDead(ExplodedNode *Node, ExplodedNodeSet &Out, const Stmt *ReferenceStmt, const LocationContext *LC, const Stmt *DiagnosticStmt=nullptr, ProgramPoint::Kind K=ProgramPoint::PreStmtPurgeDeadSymbolsKind)
Run the analyzer's garbage collection - remove dead symbols and bindings from the state.
BasicValueFactory & getBasicVals()
void VisitLogicalExpr(const BinaryOperator *B, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitLogicalExpr - Transfer function logic for '&&', '||'.
void VisitCXXDestructor(QualType ObjectType, const MemRegion *Dest, const Stmt *S, bool IsBaseDtor, ExplodedNode *Pred, ExplodedNodeSet &Dst, EvalCallOptions &Options)
void evalEagerlyAssumeBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, const Expr *Ex)
evalEagerlyAssumeBifurcation - Given the nodes in 'Src', eagerly assume concrete boolean values for '...
void VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Transfer function logic for ObjCAtSynchronizedStmts.
void VisitReturnStmt(const ReturnStmt *R, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitReturnStmt - Transfer function logic for return statements.
SVal evalBinOp(ProgramStateRef ST, BinaryOperator::Opcode Op, SVal LHS, SVal RHS, QualType T)
void VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
ProgramStateRef processRegionChange(ProgramStateRef state, const MemRegion *MR, const LocationContext *LCtx)
void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitLambdaExpr - Transfer function logic for LambdaExprs.
void ProcessImplicitDtor(const CFGImplicitDtor D, ExplodedNode *Pred)
void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitObjCForCollectionStmt - Transfer function logic for ObjCForCollectionStmt.
void VisitUnaryOperator(const UnaryOperator *B, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitUnaryOperator - Transfer function logic for unary operators.
ProgramStateRef getInitialState(const LocationContext *InitLoc)
getInitialState - Return the initial state used for the root vertex in the ExplodedGraph.
void VisitLvalObjCIvarRefExpr(const ObjCIvarRefExpr *DR, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Transfer function logic for computing the lvalue of an Objective-C ivar.
static bool hasMoreIteration(ProgramStateRef State, const ObjCForCollectionStmt *O, const LocationContext *LC)
void VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitDeclStmt - Transfer function logic for DeclStmts.
void VisitMSAsmStmt(const MSAsmStmt *A, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitMSAsmStmt - Transfer function logic for MS inline asm.
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,...
std::string DumpGraph(bool trim=false, StringRef Filename="")
Dump graph to the specified filename.
void printJson(raw_ostream &Out, ProgramStateRef State, const LocationContext *LCtx, const char *NL, unsigned int Space, bool IsDot) const
printJson - Called by ProgramStateManager to print checker-specific data.
InliningModes
The modes of inlining, which override the default analysis-wide settings.
ProgramStateRef processPointerEscapedOnBind(ProgramStateRef State, ArrayRef< std::pair< SVal, SVal > > LocAndVals, const LocationContext *LCtx, PointerEscapeKind Kind, const CallEvent *Call)
Call PointerEscape callback when a value escapes as a result of bind.
const LocationContext * getRootLocationContext() const
static ProgramStateRef removeIterationState(ProgramStateRef State, const ObjCForCollectionStmt *O, const LocationContext *LC)
ProgramStateRef processAssume(ProgramStateRef state, SVal cond, bool assumption)
evalAssume - Callback function invoked by the ConstraintManager when making assumptions about state v...
AnalysisDeclContextManager & getAnalysisDeclContextManager()
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.
void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitBlockExpr - Transfer function logic for BlockExprs.
void ProcessBaseDtor(const CFGBaseDtor D, ExplodedNode *Pred, ExplodedNodeSet &Dst)
static std::pair< const ProgramPointTag *, const ProgramPointTag * > getEagerlyAssumeBifurcationTags()
void VisitCallExpr(const CallExpr *CE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitCall - Transfer function for function calls.
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.
void VisitGCCAsmStmt(const GCCAsmStmt *A, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitGCCAsmStmt - Transfer function logic for inline asm.
BugReporter & getBugReporter()
void processCFGBlockEntrance(const BlockEdge &L, NodeBuilderWithSinks &nodeBuilder, ExplodedNode *Pred)
Called by CoreEngine when processing the entrance of a CFGBlock.
ProgramStateRef processRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const LocationContext *LCtx, const CallEvent *Call)
processRegionChanges - Called by ProgramStateManager whenever a change is made to the store.
void ProcessStmt(const Stmt *S, ExplodedNode *Pred)
ConstCFGElementRef getCFGElementRef() const
ExprEngine(cross_tu::CrossTranslationUnitContext &CTU, AnalysisManager &mgr, SetOfConstDecls *VisitedCalleesIn, FunctionSummariesTy *FS, InliningModes HowToInlineIn)
void ViewGraph(bool trim=false)
Visualize the ExplodedGraph created by executing the simulation.
static std::optional< unsigned > getPendingArrayDestruction(ProgramStateRef State, const LocationContext *LCtx)
Retreives which element is being destructed in a non-POD type array.
ProgramStateRef notifyCheckersOfPointerEscape(ProgramStateRef State, const InvalidatedSymbols *Invalidated, ArrayRef< const MemRegion * > ExplicitRegions, const CallEvent *Call, RegionAndSymbolInvalidationTraits &ITraits)
Call PointerEscape callback when a value escapes as a result of region invalidation.
static const ProgramPointTag * cleanupNodeTag()
A tag to track convenience transitions, which can be removed at cleanup.
void processCFGElement(const CFGElement E, ExplodedNode *Pred, unsigned StmtIdx, NodeBuilderContext *Ctx)
processCFGElement - Called by CoreEngine.
void processStaticInitializer(const DeclStmt *DS, NodeBuilderContext &BuilderCtx, ExplodedNode *Pred, ExplodedNodeSet &Dst, const CFGBlock *DstT, const CFGBlock *DstF)
Called by CoreEngine.
void ConstructInitList(const Expr *Source, ArrayRef< Expr * > Args, bool IsTransparent, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitUnaryExprOrTypeTraitExpr - Transfer function for sizeof.
ProgramStateRef escapeValues(ProgramStateRef State, ArrayRef< SVal > Vs, PointerEscapeKind K, const CallEvent *Call=nullptr) const
A simple wrapper when you only need to notify checkers of pointer-escape of some values.
void processBranch(const Stmt *Condition, NodeBuilderContext &BuilderCtx, ExplodedNode *Pred, ExplodedNodeSet &Dst, const CFGBlock *DstT, const CFGBlock *DstF, std::optional< unsigned > IterationsCompletedInLoop)
ProcessBranch - Called by CoreEngine.
void ProcessLoopExit(const Stmt *S, ExplodedNode *Pred)
void processSwitch(SwitchNodeBuilder &builder)
ProcessSwitch - Called by CoreEngine.
void processEndWorklist()
Called by CoreEngine when the analysis worklist has terminated.
CheckerManager & getCheckerManager() const
SymbolManager & getSymbolManager()
void VisitAtomicExpr(const AtomicExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitAtomicExpr - Transfer function for builtin atomic expressions.
MemRegionManager & getRegionManager()
void ProcessMemberDtor(const CFGMemberDtor D, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXThisExpr(const CXXThisExpr *TE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitMemberExpr - Transfer function for member expressions.
void VisitCXXConstructExpr(const CXXConstructExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst)
bool didEagerlyAssumeBifurcateAt(ProgramStateRef State, const Expr *Ex) const
ConstraintManager & getConstraintManager()
void processCleanupTemporaryBranch(const CXXBindTemporaryExpr *BTE, NodeBuilderContext &BldCtx, ExplodedNode *Pred, ExplodedNodeSet &Dst, const CFGBlock *DstT, const CFGBlock *DstF)
Called by CoreEngine.
void ProcessAutomaticObjDtor(const CFGAutomaticObjDtor D, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitOffsetOfExpr(const OffsetOfExpr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitOffsetOfExpr - Transfer function for offsetof.
void evalLoad(ExplodedNodeSet &Dst, const Expr *NodeEx, const Expr *BoundExpr, ExplodedNode *Pred, ProgramStateRef St, SVal location, const ProgramPointTag *tag=nullptr, QualType LoadTy=QualType())
Simulate a read of the result of Ex.
void removeDeadOnEndOfFunction(NodeBuilderContext &BC, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Remove dead bindings/symbols before exiting a function.
void Visit(const Stmt *S, ExplodedNode *Pred, ExplodedNodeSet &Dst)
Visit - Transfer function logic for all statements.
AnalysisManager & getAnalysisManager()
ExplodedGraph & getGraph()
void runCheckersForBlockEntrance(const NodeBuilderContext &BldCtx, const BlockEntrance &Entrance, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void ProcessDeleteDtor(const CFGDeleteDtor D, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred, ExplodedNodeSet &Dst)
void VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitCompoundLiteralExpr - Transfer function logic for compound literals.
SValBuilder & getSValBuilder()
void VisitArrayInitLoopExpr(const ArrayInitLoopExpr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitArrayInitLoopExpr - Transfer function for array init loop.
void evalStore(ExplodedNodeSet &Dst, const Expr *AssignE, const Expr *StoreE, ExplodedNode *Pred, ProgramStateRef St, SVal TargetLV, SVal Val, const ProgramPointTag *tag=nullptr)
evalStore - Handle the semantics of a store via an assignment.
void VisitAttributedStmt(const AttributedStmt *A, ExplodedNode *Pred, ExplodedNodeSet &Dst)
VisitAttributedStmt - Transfer function logic for AttributedStmt.
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE, ExplodedNodeSet &PreVisit, ExplodedNodeSet &Dst)
void processIndirectGoto(IndirectGotoNodeBuilder &builder)
processIndirectGoto - Called by CoreEngine.
const NodeBuilderContext & getBuilderContext()
static ProgramStateRef setWhetherHasMoreIteration(ProgramStateRef State, const ObjCForCollectionStmt *O, const LocationContext *LC, bool HasMoreIteraton)
Note whether this loop has any more iterations to model. These methods.
static std::optional< unsigned > getPendingInitLoop(ProgramStateRef State, const CXXConstructExpr *E, const LocationContext *LCtx)
Retreives the size of the array in the pending ArrayInitLoopExpr.
void ProcessNewAllocator(const CXXNewExpr *NE, ExplodedNode *Pred)
const Expr * getTarget() const
const LocationContext * getLocationContext() const
ProgramStateRef getState() const
ExplodedNode * generateNode(const iterator &I, ProgramStateRef State, bool isSink=false)
static bool isLocType(QualType T)
MemRegion - The root abstract class for all memory regions.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getMemorySpace(ProgramStateRef State) const
Returns the most specific memory space for this memory region in the given ProgramStateRef.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
MemSpaceRegion - A memory region that represents a "memory space"; for example, the set of global var...
const CFGBlock * getBlock() const
Return the CFGBlock associated with this builder.
unsigned blockCount() const
Returns the number of times the current basic block has been visited on the exploded graph path.
This node builder keeps track of the generated sink nodes.
ExplodedNode * generateNode(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
ExplodedNode * generateSink(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
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 NodeBuilderContext & getContext()
While alive, includes the current analysis stack in a crash trace.
Information about invalidation for a particular region/symbol.
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
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.
bool isUnknownOrUndef() const
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)
ExplodedNode * generateSink(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.
virtual SVal getLValueField(const FieldDecl *D, SVal Base)
SubRegion - A region that subsets another larger region.
ProgramStateRef getState() const
const Expr * getCondition() const
ExplodedNode * generateDefaultCaseNode(ProgramStateRef State, bool isSink=false)
ExplodedNode * generateCaseStmtNode(const iterator &I, ProgramStateRef State)
const LocationContext * getLocationContext() const
const SwitchStmt * getSwitch() const
A class responsible for cleaning up unused symbols.
void markLive(SymbolRef sym)
Unconditionally marks a symbol as live.
SymbolicRegion - A special, "non-concrete" region.
Represents symbolic expression that isn't a location.
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
@ PSK_DirectEscapeOnCall
The pointer has been passed to a function call directly.
@ PSK_EscapeOnBind
A pointer escapes due to binding its value to a location that the analyzer cannot track.
@ PSK_IndirectEscapeOnCall
The pointer has been passed to a function indirectly.
@ PSK_EscapeOther
The reason for pointer escape is unknown.
DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State, const MemRegion *MR, SValBuilder &SVB, QualType Ty)
llvm::DenseSet< const Decl * > SetOfConstDecls
llvm::DenseSet< SymbolRef > InvalidatedSymbols
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const SymExpr * SymbolRef
ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State)
Updates the given ProgramState.
bool isUnrolledState(ProgramStateRef State)
Returns if the given State indicates that is inside a completely unrolled loop.
void markAllDynamicExtentLive(ProgramStateRef State, SymbolReaper &SymReaper)
ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState, const LocationContext *LCtx, unsigned BlockCount, ConstCFGElementRef Elem)
Get the states that result from widening the loop.
ProgramStateRef updateLoopStack(const Stmt *LoopStmt, ASTContext &ASTCtx, ExplodedNode *Pred, unsigned maxVisitOnPath)
Updates the stack of loops contained by the ProgramState.
bool LE(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
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
U cast(CodeGen::Address addr)
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Expr * extractElementInitializerFromNestedAILE(const ArrayInitLoopExpr *AILE)
@ CXXThis
Parameter for C++ 'this' argument.
Diagnostic wrappers for TextAPI types for error reporting.
Describes how types, statements, expressions, and declarations should be printed.
@ DerivedToBaseAdjustment
@ MemberPointerAdjustment
Hints for figuring out of a call should be inlined during evalCall().
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...
Traits for storing the call processing policy inside GDM.
DOTGraphTraits(bool isSimple=false)
static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G)
static bool nodeHasBugReport(const ExplodedNode *N)
static bool traverseHiddenNodes(const ExplodedNode *N, llvm::function_ref< void(const ExplodedNode *)> PreCallback, llvm::function_ref< void(const ExplodedNode *)> PostCallback, llvm::function_ref< bool(const ExplodedNode *)> Stop)
PreCallback: callback before break.
static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G)