;
62#define DEBUG_TYPE "MemRegion" 69 const auto*TyReg = llvm::dyn_cast<TypedValueRegion>(R);
70 returnTyReg && TyReg->getValueType()->isReferenceType();
73template<
typenameRegionTy,
typenameSuperTy,
typenameArg1Ty>
74RegionTy* MemRegionManager::getSubRegion(
constArg1Ty arg1,
75 constSuperTy *superRegion) {
76llvm::FoldingSetNodeID
ID;
77RegionTy::ProfileRegion(ID, arg1, superRegion);
79 auto*R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
82R =
new(A) RegionTy(arg1, superRegion);
83Regions.InsertNode(R, InsertPos);
90template<
typenameRegionTy,
typenameSuperTy,
typenameArg1Ty,
typenameArg2Ty>
91RegionTy* MemRegionManager::getSubRegion(
constArg1Ty arg1,
constArg2Ty arg2,
92 constSuperTy *superRegion) {
93llvm::FoldingSetNodeID
ID;
94RegionTy::ProfileRegion(ID, arg1, arg2, superRegion);
96 auto*R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
99R =
new(A) RegionTy(arg1, arg2, superRegion);
100Regions.InsertNode(R, InsertPos);
107template<
typenameRegionTy,
typenameSuperTy,
108 typenameArg1Ty,
typenameArg2Ty,
typenameArg3Ty>
109RegionTy* MemRegionManager::getSubRegion(
constArg1Ty arg1,
constArg2Ty arg2,
111 constSuperTy *superRegion) {
112llvm::FoldingSetNodeID
ID;
113RegionTy::ProfileRegion(ID, arg1, arg2, arg3, superRegion);
115 auto*R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
118R =
new(A) RegionTy(arg1, arg2, arg3, superRegion);
119Regions.InsertNode(R, InsertPos);
145 if(
const auto*sr = dyn_cast<SubRegion>(r))
146r = sr->getSuperRegion();
149}
while(r !=
nullptr);
157 if(
const auto*sr = dyn_cast<SubRegion>(
superRegion)) {
167 returnSSR ? SSR->getStackFrame() :
nullptr;
173 returnSSR ? SSR->getStackFrame() :
nullptr;
178 "A temporary object can only be allocated on the stack");
179 returncast<StackSpaceRegion>(
getMemorySpace())->getStackFrame();
183:
DeclRegion(sReg, ObjCIvarRegionKind), IVD(ivd) {
203 "`ParamVarRegion` support functions without `Decl` not implemented" 211 if(
const auto*FD = dyn_cast<FunctionDecl>(
D)) {
212assert(Index < FD->param_size());
213 returnFD->parameters()[Index];
214}
else if(
const auto*BD = dyn_cast<BlockDecl>(
D)) {
215assert(Index < BD->param_size());
216 returnBD->parameters()[Index];
217}
else if(
const auto*MD = dyn_cast<ObjCMethodDecl>(
D)) {
218assert(Index < MD->param_size());
219 returnMD->parameters()[Index];
220}
else if(
const auto*CD = dyn_cast<CXXConstructorDecl>(
D)) {
221assert(Index < CD->param_size());
222 returnCD->parameters()[Index];
224llvm_unreachable(
"Unexpected Decl kind!");
233ID.AddInteger(
static_cast<unsigned>(
getKind()));
237ID.AddInteger(
static_cast<unsigned>(
getKind()));
242ID.AddInteger(
static_cast<unsigned>(
getKind()));
246voidStringRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
249ID.AddInteger(
static_cast<unsigned>(StringRegionKind));
254voidObjCStringRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
257ID.AddInteger(
static_cast<unsigned>(ObjCStringRegionKind));
262voidAllocaRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
263 const Expr*Ex,
unsignedcnt,
265ID.AddInteger(
static_cast<unsigned>(AllocaRegionKind));
276CompoundLiteralRegion::ProfileRegion(ID, CL,
superRegion);
279voidCompoundLiteralRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
282ID.AddInteger(
static_cast<unsigned>(CompoundLiteralRegionKind));
287voidCXXThisRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
290ID.AddInteger(
static_cast<unsigned>(CXXThisRegionKind));
292ID.AddPointer(sRegion);
296CXXThisRegion::ProfileRegion(ID, ThisPointerTy,
superRegion);
303voidObjCIvarRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
306ID.AddInteger(
static_cast<unsigned>(ObjCIvarRegionKind));
315voidNonParamVarRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
318ID.AddInteger(
static_cast<unsigned>(NonParamVarRegionKind));
327voidParamVarRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
const Expr*OE,
329ID.AddInteger(
static_cast<unsigned>(ParamVarRegionKind));
341ID.AddInteger(
static_cast<unsigned>(MemRegion::SymbolicRegionKind));
350voidElementRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
353ID.AddInteger(MemRegion::ElementRegionKind);
360ElementRegion::ProfileRegion(ID, ElementType, Index,
superRegion);
363voidFunctionCodeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
366ID.AddInteger(MemRegion::FunctionCodeRegionKind);
371FunctionCodeRegion::ProfileRegion(ID, FD,
superRegion);
374voidBlockCodeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
378ID.AddInteger(MemRegion::BlockCodeRegionKind);
383BlockCodeRegion::ProfileRegion(ID, BD, locTy, AC,
superRegion);
386voidBlockDataRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
391ID.AddInteger(MemRegion::BlockDataRegionKind);
394ID.AddInteger(BlkCount);
399BlockDataRegion::ProfileRegion(ID, BC, LC, BlockCount,
getSuperRegion());
402voidCXXTempObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
413voidCXXLifetimeExtendedObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
423llvm::FoldingSetNodeID &ID)
const{
427voidCXXBaseObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
432ID.AddBoolean(IsVirtual);
440voidCXXDerivedObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
455voidGlobalsSpaceRegion::anchor() {}
457voidNonStaticGlobalSpaceRegion::anchor() {}
459voidStackSpaceRegion::anchor() {}
461voidTypedRegion::anchor() {}
463voidTypedValueRegion::anchor() {}
465voidCodeTextRegion::anchor() {}
467voidSubRegion::anchor() {}
479llvm::raw_string_ostream os(
s);
485os <<
"<Unknown Region>";
497os <<
"block_code{"<<
static_cast<const void*
>(
this) <<
'}';
501os <<
"block_data{"<< BC;
504os <<
"("<< Var.getCapturedRegion() <<
"<-"<< Var.getOriginalRegion()
520os <<
"lifetime_extended_object{"<<
getValueType() <<
", ";
524os <<
"D"<< ExD->
getID();
555assert(Str !=
nullptr&&
"Expecting non-null StringLiteral");
560assert(Str !=
nullptr&&
"Expecting non-null ObjCStringLiteral");
567os <<
"SymRegion{"<< sym <<
'}';
574os <<
"NonParamVarRegion{D"<< VD->
getID() <<
'}';
586os <<
"CodeSpaceRegion";
590os <<
"StaticGlobalsMemSpace{"<< CR <<
'}';
594os <<
"GlobalInternalSpaceRegion";
598os <<
"GlobalSystemSpaceRegion";
602os <<
"GlobalImmutableSpaceRegion";
606os <<
"HeapSpaceRegion";
610os <<
"UnknownSpaceRegion";
614os <<
"StackArgumentsSpaceRegion";
618os <<
"StackLocalsSpaceRegion";
624 "`ParamVarRegion` support functions without `Decl` not implemented" 629os <<
"ParamVarRegion{P"<< PVD->
getID() <<
'}';
643#define REGION(Id, Parent) \ 646#include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def" 649llvm_unreachable(
"Unkown kind!");
653assert(
canPrintPretty() &&
"This region cannot be printed pretty.");
660llvm_unreachable(
"This region cannot be printed pretty.");
673 "`ParamVarRegion` support functions without `Decl` not implemented" 727std::string VariableName;
728std::string ArrayIndices;
731llvm::raw_svector_ostream os(buf);
734 autoQuoteIfNeeded = [UseQuotes](
constTwine &Subject) -> std::string {
736 return(
"'"+ Subject +
"'").str();
737 returnSubject.str();
746CI->getValue()->toString(Idx);
747ArrayIndices = (llvm::Twine(
"[") + Idx.str() +
"]"+ ArrayIndices).str();
755 const MemRegion*OR = SI->getAsSymbol()->getOriginRegion();
763ArrayIndices = (llvm::Twine(
"[") + Idx +
"]"+ ArrayIndices).str();
773 returnQuoteIfNeeded(llvm::Twine(os.str()) + ArrayIndices);
778std::string Super = FR->getSuperRegion()->getDescriptiveName(
false);
781 returnQuoteIfNeeded(Super +
"."+ FR->getDecl()->getName());
790 if(
auto*FR = dyn_cast<FieldRegion>(
this)) {
791 returnFR->getDecl()->getSourceRange();
794 if(
auto*VR = dyn_cast<VarRegion>(this->
getBaseRegion())) {
795 returnVR->getDecl()->getSourceRange();
808 const auto*SR = cast<SubRegion>(MR);
811 switch(SR->getKind()) {
812 caseMemRegion::AllocaRegionKind:
813 caseMemRegion::SymbolicRegionKind:
815 caseMemRegion::StringRegionKind:
817cast<StringRegion>(SR)->getStringLiteral()->getByteLength() + 1,
819 caseMemRegion::CompoundLiteralRegionKind:
820 caseMemRegion::CXXBaseObjectRegionKind:
821 caseMemRegion::CXXDerivedObjectRegionKind:
822 caseMemRegion::CXXTempObjectRegionKind:
823 caseMemRegion::CXXLifetimeExtendedObjectRegionKind:
824 caseMemRegion::CXXThisRegionKind:
825 caseMemRegion::ObjCIvarRegionKind:
826 caseMemRegion::NonParamVarRegionKind:
827 caseMemRegion::ParamVarRegionKind:
828 caseMemRegion::ElementRegionKind:
829 caseMemRegion::ObjCStringRegionKind: {
830 QualTypeTy = cast<TypedValueRegion>(SR)->getDesugaredValueType(Ctx);
831 if(isa<VariableArrayType>(Ty))
839 caseMemRegion::FieldRegionKind: {
841 if(cast<FieldRegion>(SR)->getDecl()->isBitField())
844 QualTypeTy = cast<TypedValueRegion>(SR)->getDesugaredValueType(Ctx);
852 const autoisFlexibleArrayMemberCandidate =
857 autoIsIncompleteArray = [](
const ArrayType*AT) {
858 returnisa<IncompleteArrayType>(AT);
860 autoIsArrayOfZero = [](
const ArrayType*AT) {
861 const auto*CAT = dyn_cast<ConstantArrayType>(AT);
862 returnCAT && CAT->isZeroSize();
864 autoIsArrayOfOne = [](
const ArrayType*AT) {
865 const auto*CAT = dyn_cast<ConstantArrayType>(AT);
866 returnCAT && CAT->getSize() == 1;
870 constFAMKind StrictFlexArraysLevel =
876 if(StrictFlexArraysLevel == FAMKind::Default)
877 returnIsArrayOfOne(AT) || IsArrayOfZero(AT) || IsIncompleteArray(AT);
879 if(StrictFlexArraysLevel == FAMKind::OneZeroOrIncomplete)
880 returnIsArrayOfOne(AT) || IsArrayOfZero(AT) || IsIncompleteArray(AT);
882 if(StrictFlexArraysLevel == FAMKind::ZeroOrIncomplete)
883 returnIsArrayOfZero(AT) || IsIncompleteArray(AT);
885assert(StrictFlexArraysLevel == FAMKind::IncompleteOnly);
886 returnIsIncompleteArray(AT);
897 caseMemRegion::BlockDataRegionKind:
898 caseMemRegion::BlockCodeRegionKind:
899 caseMemRegion::FunctionCodeRegionKind:
902llvm_unreachable(
"Unhandled region");
906template<
typenameREG>
907constREG *MemRegionManager::LazyAllocate(REG*& region) {
909region =
new(A) REG(*
this);
915template<
typenameREG,
typenameARG>
916constREG *MemRegionManager::LazyAllocate(REG*& region, ARG a) {
918region =
new(A) REG(
this, a);
952 if(K == MemRegion::GlobalSystemSpaceRegionKind)
953 returnLazyAllocate(SystemGlobals);
954 if(K == MemRegion::GlobalImmutableSpaceRegionKind)
955 returnLazyAllocate(ImmutableGlobals);
956assert(K == MemRegion::GlobalInternalSpaceRegionKind);
957 returnLazyAllocate(InternalGlobals);
960assert(K == MemRegion::StaticGlobalSpaceRegionKind);
970 returnLazyAllocate(heap);
974 returnLazyAllocate(unknown);
978 returnLazyAllocate(code);
986 returngetSubRegion<StringRegion>(
992 returngetSubRegion<ObjCStringRegion>(
999staticllvm::PointerUnion<const StackFrameContext *, const VarRegion *>
1004 if(
const auto*SFC = dyn_cast<StackFrameContext>(LC)) {
1005 if(cast<DeclContext>(SFC->getDecl()) == DC)
1008 if(
const auto*BC = dyn_cast<BlockInvocationContext>(LC)) {
1009 const auto*BR =
static_cast<const BlockDataRegion*
>(BC->getData());
1011 for(
autoVar : BR->referenced_vars()) {
1013 if(
const auto*VR = dyn_cast<VarRegion>(OrigR)) {
1014 if(VR->getDecl() == VD)
1015 returncast<VarRegion>(Var.getCapturedRegion());
1027 const auto*PVD = dyn_cast<ParmVarDecl>(
D);
1029 unsignedIndex = PVD->getFunctionScopeIndex();
1034 if(
const auto*FD = dyn_cast<FunctionDecl>(
D)) {
1035 if(Index < FD->param_size() && FD->parameters()[Index] == PVD)
1036 returngetSubRegion<ParamVarRegion>(cast<Expr>(CallSite), Index,
1038}
else if(
const auto*BD = dyn_cast<BlockDecl>(
D)) {
1039 if(Index < BD->param_size() && BD->
parameters()[Index] == PVD)
1040 returngetSubRegion<ParamVarRegion>(cast<Expr>(CallSite), Index,
1043 returngetSubRegion<ParamVarRegion>(cast<Expr>(CallSite), Index,
1052 if(
D->hasGlobalStorage() && !
D->isStaticLocal()) {
1068llvm::PointerUnion<const StackFrameContext *, const VarRegion *>
V=
1071 if(
const auto*VR = dyn_cast_if_present<const VarRegion *>(
V))
1074 const auto*STC = cast<const StackFrameContext *>(
V);
1081 if(
D->hasLocalStorage()) {
1083isa<ParmVarDecl, ImplicitParamDecl>(
D)
1088assert(
D->isStaticLocal());
1089 const Decl*STCD = STC->getDecl();
1090 if(isa<FunctionDecl, ObjCMethodDecl>(STCD))
1093 else if(
const auto*BD = dyn_cast<BlockDecl>(STCD)) {
1111STC->getAnalysisDeclContext());
1130 if(
const VarDecl*Def =
D->getDefinition())
1132 returngetSubRegion<NonParamVarRegion>(
D, superR);
1140 returngetSubRegion<ParamVarRegion>(OriginExpr, Index,
1147 unsignedblockCount) {
1155 boolIsArcManagedBlock = Ctx.
getLangOpts().ObjCAutoRefCount;
1160 if(!IsArcManagedBlock && LC) {
1173 returngetSubRegion<BlockDataRegion>(BC, LC, blockCount, sReg);
1189 returngetSubRegion<CompoundLiteralRegion>(CL, sReg);
1198llvm::FoldingSetNodeID ID;
1199ElementRegion::ProfileRegion(ID,
T, Idx, superRegion);
1202 MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
1203 auto*R = cast_or_null<ElementRegion>(data);
1207Regions.InsertNode(R, InsertPos);
1216 returngetSubRegion<FunctionCodeRegion>(FD,
getCodeRegion());
1222 returngetSubRegion<BlockCodeRegion>(BD, locTy, AC,
getCodeRegion());
1228 if(MemSpace ==
nullptr)
1230 returngetSubRegion<SymbolicRegion>(sym, MemSpace);
1240 returngetSubRegion<FieldRegion>(d, superRegion);
1246 returngetSubRegion<ObjCIvarRegion>(d, superRegion);
1262 returngetSubRegion<CXXLifetimeExtendedObjectRegion>(
1269 returngetSubRegion<CXXLifetimeExtendedObjectRegion>(
1286 return Class->isVirtuallyDerivedFrom(BaseClass);
1288 for(
const auto&I :
Class->bases()) {
1289 if(I.getType()->getAsCXXRecordDecl()->getCanonicalDecl() == BaseClass)
1300 if(isa<TypedValueRegion>(Super)) {
1307 while(
const auto*
Base= dyn_cast<CXXBaseObjectRegion>(Super))
1308Super = cast<SubRegion>(
Base->getSuperRegion());
1309assert(Super && !isa<MemSpaceRegion>(Super));
1313 returngetSubRegion<CXXBaseObjectRegion>(RD, IsVirtual, Super);
1319 returngetSubRegion<CXXDerivedObjectRegion>(RD, Super);
1329 const auto*
D= dyn_cast<CXXMethodDecl>(LC->
getDecl());
1333 while(!LC->
inTopFrame() && (!
D||
D->isStatic() ||
1336 D= dyn_cast<CXXMethodDecl>(LC->
getDecl());
1353 const auto*SR = dyn_cast<SubRegion>(
this);
1356R = SR->getSuperRegion();
1357SR = dyn_cast<SubRegion>(R);
1360 returncast<MemSpaceRegion>(R);
1381 caseMemRegion::ElementRegionKind:
1382 caseMemRegion::FieldRegionKind:
1383 caseMemRegion::ObjCIvarRegionKind:
1384 caseMemRegion::CXXBaseObjectRegionKind:
1385 caseMemRegion::CXXDerivedObjectRegionKind:
1386R = cast<SubRegion>(R)->getSuperRegion();
1399 while(
const auto*BR = dyn_cast<CXXBaseObjectRegion>(R))
1400R = BR->getSuperRegion();
1416 caseElementRegionKind: {
1417 const auto*ER = cast<ElementRegion>(R);
1418 if(!ER->getIndex().isZeroConstant())
1420R = ER->getSuperRegion();
1423 caseCXXBaseObjectRegionKind:
1424 caseCXXDerivedObjectRegionKind:
1425 if(!StripBaseAndDerivedCasts)
1427R = cast<TypedValueRegion>(R)->getSuperRegion();
1436 const auto*SubR = dyn_cast<SubRegion>(
this);
1439 if(
const auto*SymR = dyn_cast<SymbolicRegion>(SubR))
1441SubR = dyn_cast<SubRegion>(SubR->getSuperRegion());
1461 if(int64_t i = CI->getValue()->getSExtValue(); i != 0) {
1470int64_t size =
C.getTypeSizeInChars(elemType).getQuantity();
1471 if(
autoNewOffset = llvm::checkedMulAdd(i, size, offset)) {
1472offset = *NewOffset;
1474LLVM_DEBUG(llvm::dbgs() <<
"MemRegion::getAsArrayOffset: " 1475<<
"offset overflowing, returning unknown\n");
1482ER = dyn_cast<ElementRegion>(superR);
1489assert(superR &&
"super region cannot be NULL");
1496assert(Child &&
"Child must not be null");
1500 for(
const auto&I : Child->bases()) {
1501 if(I.getType()->getAsCXXRecordDecl() ==
Base)
1509 const MemRegion*SymbolicOffsetBase =
nullptr;
1514 caseMemRegion::CodeSpaceRegionKind:
1515 caseMemRegion::StackLocalsSpaceRegionKind:
1516 caseMemRegion::StackArgumentsSpaceRegionKind:
1517 caseMemRegion::HeapSpaceRegionKind:
1518 caseMemRegion::UnknownSpaceRegionKind:
1519 caseMemRegion::StaticGlobalSpaceRegionKind:
1520 caseMemRegion::GlobalInternalSpaceRegionKind:
1521 caseMemRegion::GlobalSystemSpaceRegionKind:
1522 caseMemRegion::GlobalImmutableSpaceRegionKind:
1524assert(Offset == 0 && !SymbolicOffsetBase);
1527 caseMemRegion::FunctionCodeRegionKind:
1528 caseMemRegion::BlockCodeRegionKind:
1529 caseMemRegion::BlockDataRegionKind:
1533SymbolicOffsetBase = R;
1536 caseMemRegion::SymbolicRegionKind:
1537 caseMemRegion::AllocaRegionKind:
1538 caseMemRegion::CompoundLiteralRegionKind:
1539 caseMemRegion::CXXThisRegionKind:
1540 caseMemRegion::StringRegionKind:
1541 caseMemRegion::ObjCStringRegionKind:
1542 caseMemRegion::NonParamVarRegionKind:
1543 caseMemRegion::ParamVarRegionKind:
1544 caseMemRegion::CXXTempObjectRegionKind:
1545 caseMemRegion::CXXLifetimeExtendedObjectRegionKind:
1549 caseMemRegion::ObjCIvarRegionKind:
1557 caseMemRegion::CXXBaseObjectRegionKind: {
1558 const auto*BOR = cast<CXXBaseObjectRegion>(R);
1559R = BOR->getSuperRegion();
1562 boolRootIsSymbolic =
false;
1563 if(
const auto*TVR = dyn_cast<TypedValueRegion>(R)) {
1564Ty = TVR->getDesugaredValueType(R->
getContext());
1565}
else if(
const auto*SR = dyn_cast<SymbolicRegion>(R)) {
1569Ty = SR->getPointeeStaticType();
1570RootIsSymbolic =
true;
1576SymbolicOffsetBase = R;
1578 if(RootIsSymbolic) {
1582 if(BOR->isVirtual()) {
1583 if(!Child->isVirtuallyDerivedFrom(BOR->getDecl()))
1584SymbolicOffsetBase = R;
1587SymbolicOffsetBase = R;
1594 if(SymbolicOffsetBase)
1599 if(BOR->isVirtual())
1609 caseMemRegion::CXXDerivedObjectRegionKind: {
1614 caseMemRegion::ElementRegionKind: {
1615 const auto*ER = cast<ElementRegion>(R);
1616R = ER->getSuperRegion();
1618 QualTypeEleTy = ER->getValueType();
1621SymbolicOffsetBase = R;
1625 SValIndex = ER->getIndex();
1626 if(std::optional<nonloc::ConcreteInt> CI =
1630 if(SymbolicOffsetBase)
1633int64_t i = CI->getValue()->getSExtValue();
1638SymbolicOffsetBase = R;
1642 caseMemRegion::FieldRegionKind: {
1643 const auto*FR = cast<FieldRegion>(R);
1644R = FR->getSuperRegion();
1654SymbolicOffsetBase = R;
1659 if(SymbolicOffsetBase)
1665FE = RD->
field_end(); FI != FE; ++FI, ++idx) {
1666 if(FR->getDecl() == *FI)
1678 if(SymbolicOffsetBase)
1686 return*cachedOffset;
1693std::pair<const VarRegion *, const VarRegion *>
1694BlockDataRegion::getCaptureRegions(
const VarDecl*VD) {
1713 returnstd::make_pair(VR, OriginalVR);
1716voidBlockDataRegion::LazyInitializeReferencedVars() {
1721 const auto&ReferencedBlockVars = AC->getReferencedBlockVars(BC->
getDecl());
1723std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());
1725 if(NumBlockVars == 0) {
1726ReferencedVars = (
void*) 0x1;
1736 auto*BV =
new(A) VarVec(BC, NumBlockVars);
1737 auto*BVOriginal =
new(A) VarVec(BC, NumBlockVars);
1739 for(
const auto*VD : ReferencedBlockVars) {
1742std::tie(VR, OriginalVR) = getCaptureRegions(VD);
1745BV->push_back(VR, BC);
1746BVOriginal->push_back(OriginalVR, BC);
1749ReferencedVars = BV;
1750OriginalVars = BVOriginal;
1755 const_cast<BlockDataRegion*
>(
this)->LazyInitializeReferencedVars();
1759 if(Vec == (
void*) 0x1)
1766VecOriginal->begin());
1771 const_cast<BlockDataRegion*
>(
this)->LazyInitializeReferencedVars();
1775 if(Vec == (
void*) 0x1)
1782VecOriginal->end());
1785llvm::iterator_range<BlockDataRegion::referenced_vars_iterator>
1792 if(I.getCapturedRegion() == R)
1793 returnI.getOriginalRegion();
1804SymTraitsMap[Sym] |= IK;
1810 if(
const auto*SR = dyn_cast<SymbolicRegion>(MR))
1813MRTraitsMap[MR] |= IK;
1818const_symbol_iterator I = SymTraitsMap.find(Sym);
1819 if(I != SymTraitsMap.end())
1820 returnI->second & IK;
1830 if(
const auto*SR = dyn_cast<SymbolicRegion>(MR))
1831 return hasTrait(SR->getSymbol(), IK);
1833const_region_iterator I = MRTraitsMap.find(MR);
1834 if(I != MRTraitsMap.end())
1835 returnI->second & IK;
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static bool isAReferenceTypedValueRegion(const MemRegion *R)
static llvm::PointerUnion< const StackFrameContext *, const VarRegion * > getStackOrCaptureRegionForDeclContext(const LocationContext *LC, const DeclContext *DC, const VarDecl *VD)
Look through a chain of LocationContexts to either find the StackFrameContext that matches a DeclCont...
static bool isImmediateBase(const CXXRecordDecl *Child, const CXXRecordDecl *Base)
Returns true if Base is an immediate base class of Child.
static bool isValidBaseClass(const CXXRecordDecl *BaseClass, const TypedValueRegion *Super, bool IsVirtual)
Checks whether BaseClass is a valid virtual or direct non-virtual base class of the type of Super.
static RegionOffset calculateOffset(const MemRegion *R)
Defines the SourceManager interface.
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
const LangOptions & getLangOpts() const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool hasCaptures() const
True if this block (or its nested blocks) captures anything of local storage from its enclosing scope...
ArrayRef< ParmVarDecl * > parameters() const
TypeSourceInfo * getSignatureAsWritten() const
Represents a C++ struct/union/class.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CompoundLiteralExpr - [C99 6.5.2.5].
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
DeclContext * getDeclContext()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
std::string getAsString() const
Retrieve the human-readable string for this name.
This represents one expression.
Represents a member of a struct/union/class.
FunctionType - C99 6.7.5.3 - Function Declarators.
One of these records is kept for each identifier that is lexed.
StrictFlexArraysLevelKind
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const Decl * getDecl() const
const LocationContext * getParent() const
It might return null.
const StackFrameContext * getStackFrame() const
virtual bool inTopFrame() const
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCStringLiteral, used for Objective-C string literals i.e.
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isConstQualified() const
Determine whether this type is const-qualified.
Represents a struct/union/class.
field_iterator field_end() const
field_iterator field_begin() const
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
It represents a stack frame of the call stack (based on CallEvent).
const Stmt * getCallSite() const
Stmt - This represents one statement.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
int64_t getID(const ASTContext &Context) const
StringLiteral - This represents a string literal expression, e.g.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
A container of type source information.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
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.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
AllocaRegion - A region that represents an untyped blob of bytes created by a call to 'alloca'.
void dumpToStream(raw_ostream &os) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
BlockCodeRegion - A region that represents code texts of blocks (closures).
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
void Profile(llvm::FoldingSetNodeID &ID) const override
BlockDataRegion - A region that represents a block instance.
const VarRegion * getOriginalRegion(const VarRegion *VR) const
Return the original region for a captured region, if one exists.
referenced_vars_iterator referenced_vars_begin() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockCodeRegion * getCodeRegion() const
void Profile(llvm::FoldingSetNodeID &ID) const override
referenced_vars_iterator referenced_vars_end() const
void dumpToStream(raw_ostream &os) const override
llvm::iterator_range< referenced_vars_iterator > referenced_vars() const
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
QualType getValueType() const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
void dumpToStream(raw_ostream &os) const override
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
const StackFrameContext * getStackFrame() const
It might return null.
QualType getValueType() const override
QualType getValueType() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrameContext * getStackFrame() const
CXXThisRegion - Represents the region for the implicit 'this' parameter in a call to a C++ method.
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
CodeSpaceRegion - The memory space that holds the executable code of functions and blocks.
void dumpToStream(raw_ostream &os) const override
CompoundLiteralRegion - A memory region representing a compound literal.
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
ElementRegion is used to represent both array elements and casts.
QualType getElementType() const
void Profile(llvm::FoldingSetNodeID &ID) const override
RegionRawOffset getAsArrayOffset() const
Compute the offset within the array. The array might also be a subobject.
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
bool canPrintPretty() const override
Returns true if this region can be printed in a user-friendly way.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void dumpToStream(raw_ostream &os) const override
void printPretty(raw_ostream &os) const override
Print the region for use in diagnostics.
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const FieldDecl * getDecl() const override
FunctionCodeRegion - A region that represents code texts of function.
const NamedDecl * getDecl() const
void dumpToStream(raw_ostream &os) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
void dumpToStream(raw_ostream &os) const override
void dumpToStream(raw_ostream &os) const override
void dumpToStream(raw_ostream &os) const override
const HeapSpaceRegion * getHeapRegion()
getHeapRegion - Retrieve the memory region associated with the generic "heap".
const StackArgumentsSpaceRegion * getStackArgumentsRegion(const StackFrameContext *STC)
getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the...
const CXXThisRegion * getCXXThisRegion(QualType thisPointerTy, const LocationContext *LC)
getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'.
llvm::BumpPtrAllocator & getAllocator()
const BlockCodeRegion * getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
const UnknownSpaceRegion * getUnknownRegion()
getUnknownRegion - Retrieve the memory region associated with unknown memory space.
const CXXDerivedObjectRegion * getCXXDerivedObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super)
Create a CXXDerivedObjectRegion with the given derived class for region Super.
const CompoundLiteralRegion * getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC)
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
const FieldRegion * getFieldRegion(const FieldDecl *fd, const SubRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl.
const AllocaRegion * getAllocaRegion(const Expr *Ex, unsigned Cnt, const LocationContext *LC)
getAllocaRegion - Retrieve a region associated with a call to alloca().
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, const ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type,...
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
const NonParamVarRegion * getNonParamVarRegion(const VarDecl *VD, const MemRegion *superR)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
const StackLocalsSpaceRegion * getStackLocalsRegion(const StackFrameContext *STC)
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame.
const ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
const ObjCStringRegion * getObjCStringRegion(const ObjCStringLiteral *Str)
const StringRegion * getStringRegion(const StringLiteral *Str)
ASTContext & getContext()
DefinedOrUnknownSVal getStaticSize(const MemRegion *MR, SValBuilder &SVB) const
const ParamVarRegion * getParamVarRegion(const Expr *OriginExpr, unsigned Index, const LocationContext *LC)
getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr,...
const CodeSpaceRegion * getCodeRegion()
const CXXLifetimeExtendedObjectRegion * getCXXLifetimeExtendedObjectRegion(Expr const *Ex, ValueDecl const *VD, LocationContext const *LC)
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by local referen...
const CXXTempObjectRegion * getCXXTempObjectRegion(Expr const *Ex, LocationContext const *LC)
const GlobalsSpaceRegion * getGlobalsRegion(MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
getGlobalsRegion - Retrieve the memory region associated with global variables.
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym, const MemSpaceRegion *MemSpace=nullptr)
Retrieve or create a "symbolic" memory region.
const FunctionCodeRegion * getFunctionCodeRegion(const NamedDecl *FD)
const BlockDataRegion * getBlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount)
getBlockDataRegion - Get the memory region associated with an instance of a block.
const CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
const CXXLifetimeExtendedObjectRegion * getCXXStaticLifetimeExtendedObjectRegion(const Expr *Ex, ValueDecl const *VD)
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by static refere...
MemRegion - The root abstract class for all memory regions.
virtual bool canPrintPrettyAsExpr() const
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getMemorySpace() const
bool hasStackParametersStorage() const
StringRef getKindStr() const
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
bool hasStackStorage() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
ASTContext & getContext() const
std::string getDescriptiveName(bool UseQuotes=true) const
Get descriptive name for memory region.
virtual bool isSubRegionOf(const MemRegion *R) const
Check if the region is a subregion of the given region.
virtual void dumpToStream(raw_ostream &os) const
const SymbolicRegion * getSymbolicBase() const
If this is a symbolic region, returns the region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
virtual void printPretty(raw_ostream &os) const
Print the region for use in diagnostics.
virtual void printPrettyAsExpr(raw_ostream &os) const
Print the region as expression.
bool hasStackNonParametersStorage() const
std::string getString() const
Get a string representation of a region for debug use.
const RegionTy * getAs() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getMostDerivedObjectRegion() const
Recursively retrieve the region of the most derived class instance of regions of C++ base class insta...
virtual MemRegionManager & getMemRegionManager() const =0
virtual bool canPrintPretty() const
Returns true if this region can be printed in a user-friendly way.
SourceRange sourceRange() const
Retrieve source range from memory region.
MemSpaceRegion - A memory region that represents a "memory space"; for example, the set of global var...
void Profile(llvm::FoldingSetNodeID &ID) const override
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarDecl * getDecl() const override
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const ObjCIvarDecl * getDecl() const override
void dumpToStream(raw_ostream &os) const override
The region associated with an ObjCStringLiteral.
void dumpToStream(raw_ostream &os) const override
ParamVarRegion - Represents a region for paremters.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getOriginExpr() const
const ParmVarDecl * getDecl() const override
TODO: What does this return?
unsigned getIndex() const
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
InvalidationKinds
Describes different invalidation traits.
bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const
void setTrait(SymbolRef Sym, InvalidationKinds IK)
Represent a region's offset within the top level base region.
static const int64_t Symbolic
CharUnits getOffset() const
void dumpToStream(raw_ostream &os) const
const MemRegion * getRegion() const
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
QualType getArrayIndexType() const
SymbolManager & getSymbolManager()
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
void Profile(llvm::FoldingSetNodeID &ID) const
std::optional< T > getAs() const
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type.
void dumpToStream(raw_ostream &os) const override
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrameContext * getStackFrame() const
void Profile(llvm::FoldingSetNodeID &ID) const override
The region of the static variables within the current CodeTextRegion scope.
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const CodeTextRegion * getCodeRegion() const
StringRegion - Region associated with a StringLiteral.
void dumpToStream(raw_ostream &os) const override
SubRegion - A region that subsets another larger region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getSuperRegion() const
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
const MemRegion * superRegion
MemRegionManager & getMemRegionManager() const override
SymbolExtent - Represents the extent (size in bytes) of a bounded region.
const SymExprT * acquire(Args &&...args)
Create or retrieve a SymExpr of type SymExprT for the given arguments.
SymbolicRegion - A special, "non-concrete" region.
void dumpToStream(raw_ostream &os) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
static void ProfileRegion(llvm::FoldingSetNodeID &ID, SymbolRef sym, const MemRegion *superRegion)
TypedValueRegion - An abstract class representing regions having a typed value.
virtual QualType getValueType() const =0
void dumpToStream(raw_ostream &os) const override
const StackFrameContext * getStackFrame() const
It might return null.
Value representing integer constant.
Represents symbolic expression that isn't a location.
DefinedOrUnknownSVal getElementExtent(QualType Ty, SValBuilder &SVB)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Extra information about a function prototype.
Describes how types, statements, expressions, and declarations should be printed.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4