35 #include "llvm/ADT/APInt.h" 36 #include "llvm/ADT/FoldingSet.h" 37 #include "llvm/ADT/Optional.h" 38 #include "llvm/ADT/PointerUnion.h" 39 #include "llvm/ADT/SmallString.h" 40 #include "llvm/ADT/StringRef.h" 41 #include "llvm/ADT/Twine.h" 42 #include "llvm/Support/Allocator.h" 43 #include "llvm/Support/Casting.h" 44 #include "llvm/Support/CheckedArithmetic.h" 45 #include "llvm/Support/Compiler.h" 46 #include "llvm/Support/Debug.h" 47 #include "llvm/Support/ErrorHandling.h" 48 #include "llvm/Support/raw_ostream.h" 57 using namespace clang;
60 #define DEBUG_TYPE "MemRegion" 66 template <
typename RegionTy,
typename SuperTy,
typename Arg1Ty>
67 RegionTy* MemRegionManager::getSubRegion(
const Arg1Ty arg1,
68 const SuperTy *superRegion) {
69 llvm::FoldingSetNodeID
ID;
70 RegionTy::ProfileRegion(ID, arg1, superRegion);
72 auto *R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
75 R = A.Allocate<RegionTy>();
76 new (R) RegionTy(arg1, superRegion);
77 Regions.InsertNode(R, InsertPos);
83 template <
typename RegionTy,
typename SuperTy,
typename Arg1Ty,
typename Arg2Ty>
84 RegionTy* MemRegionManager::getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
85 const SuperTy *superRegion) {
86 llvm::FoldingSetNodeID
ID;
87 RegionTy::ProfileRegion(ID, arg1, arg2, superRegion);
89 auto *R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
92 R = A.Allocate<RegionTy>();
93 new (R) RegionTy(arg1, arg2, superRegion);
94 Regions.InsertNode(R, InsertPos);
100 template <
typename RegionTy,
typename SuperTy,
101 typename Arg1Ty,
typename Arg2Ty,
typename Arg3Ty>
102 RegionTy* MemRegionManager::getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
104 const SuperTy *superRegion) {
105 llvm::FoldingSetNodeID
ID;
106 RegionTy::ProfileRegion(ID, arg1, arg2, arg3, superRegion);
108 auto *R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
111 R = A.Allocate<RegionTy>();
112 new (R) RegionTy(arg1, arg2, arg3, superRegion);
113 Regions.InsertNode(R, InsertPos);
138 if (
const auto *sr = dyn_cast<SubRegion>(r))
139 r = sr->getSuperRegion();
142 }
while (r !=
nullptr);
150 if (
const auto *sr = dyn_cast<SubRegion>(superRegion)) {
169 QualType T = getDesugaredValueType(Ctx);
171 if (isa<VariableArrayType>(T))
183 if (getDecl()->isBitField())
193 if (isa<ConstantArrayType>(T))
209 return svalBuilder.
makeIntVal(getStringLiteral()->getByteLength()+1,
214 :
DeclRegion(ivd, sReg, ObjCIvarRegionKind) {}
217 return cast<ObjCIvarDecl>(D);
221 return getDecl()->getType();
225 return QualType(getDecl()->getTypeForDecl(), 0);
233 ID.AddInteger(static_cast<unsigned>(
getKind()));
237 ID.AddInteger(static_cast<unsigned>(
getKind()));
238 ID.AddPointer(getStackFrame());
242 ID.AddInteger(static_cast<unsigned>(
getKind()));
246 void StringRegion::ProfileRegion(llvm::FoldingSetNodeID &
ID,
249 ID.AddInteger(static_cast<unsigned>(StringRegionKind));
251 ID.AddPointer(superRegion);
254 void ObjCStringRegion::ProfileRegion(llvm::FoldingSetNodeID &
ID,
257 ID.AddInteger(static_cast<unsigned>(ObjCStringRegionKind));
259 ID.AddPointer(superRegion);
262 void AllocaRegion::ProfileRegion(llvm::FoldingSetNodeID&
ID,
263 const Expr *Ex,
unsigned cnt,
265 ID.AddInteger(static_cast<unsigned>(AllocaRegionKind));
268 ID.AddPointer(superRegion);
272 ProfileRegion(ID, Ex, Cnt, superRegion);
276 CompoundLiteralRegion::ProfileRegion(ID, CL, superRegion);
279 void CompoundLiteralRegion::ProfileRegion(llvm::FoldingSetNodeID&
ID,
282 ID.AddInteger(static_cast<unsigned>(CompoundLiteralRegionKind));
284 ID.AddPointer(superRegion);
287 void CXXThisRegion::ProfileRegion(llvm::FoldingSetNodeID &
ID,
290 ID.AddInteger(static_cast<unsigned>(CXXThisRegionKind));
292 ID.AddPointer(sRegion);
296 CXXThisRegion::ProfileRegion(ID, ThisPointerTy, superRegion);
299 void ObjCIvarRegion::ProfileRegion(llvm::FoldingSetNodeID&
ID,
307 ID.AddInteger(static_cast<unsigned>(k));
309 ID.AddPointer(superRegion);
317 VarRegion::ProfileRegion(ID, getDecl(), superRegion);
322 ID.AddInteger(static_cast<unsigned>(MemRegion::SymbolicRegionKind));
331 void ElementRegion::ProfileRegion(llvm::FoldingSetNodeID&
ID,
334 ID.AddInteger(MemRegion::ElementRegionKind);
336 ID.AddPointer(superRegion);
341 ElementRegion::ProfileRegion(ID, ElementType, Index, superRegion);
344 void FunctionCodeRegion::ProfileRegion(llvm::FoldingSetNodeID&
ID,
347 ID.AddInteger(MemRegion::FunctionCodeRegionKind);
352 FunctionCodeRegion::ProfileRegion(ID, FD, superRegion);
355 void BlockCodeRegion::ProfileRegion(llvm::FoldingSetNodeID&
ID,
359 ID.AddInteger(MemRegion::BlockCodeRegionKind);
364 BlockCodeRegion::ProfileRegion(ID, BD, locTy, AC, superRegion);
367 void BlockDataRegion::ProfileRegion(llvm::FoldingSetNodeID&
ID,
372 ID.AddInteger(MemRegion::BlockDataRegionKind);
375 ID.AddInteger(BlkCount);
380 BlockDataRegion::ProfileRegion(ID, BC, LC, BlockCount, getSuperRegion());
383 void CXXTempObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &
ID,
391 ProfileRegion(ID, Ex, getSuperRegion());
394 void CXXBaseObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &
ID,
399 ID.AddBoolean(IsVirtual);
404 ProfileRegion(ID, getDecl(), isVirtual(), superRegion);
411 void GlobalsSpaceRegion::anchor() {}
413 void NonStaticGlobalSpaceRegion::anchor() {}
415 void StackSpaceRegion::anchor() {}
417 void TypedRegion::anchor() {}
419 void TypedValueRegion::anchor() {}
421 void CodeTextRegion::anchor() {}
423 void SubRegion::anchor() {}
430 dumpToStream(llvm::errs());
435 llvm::raw_string_ostream os(s);
441 os <<
"<Unknown Region>";
445 os <<
"alloca{" <<
static_cast<const void *
>(Ex) <<
',' << Cnt <<
'}';
449 os <<
"code{" << getDecl()->getDeclName().getAsString() <<
'}';
453 os <<
"block_code{" <<
static_cast<const void *
>(
this) <<
'}';
457 os <<
"block_data{" << BC;
460 I = referenced_vars_begin(),
461 E = referenced_vars_end(); I != E; ++I)
462 os <<
"(" << I.getCapturedRegion() <<
"<-" <<
463 I.getOriginalRegion() <<
") ";
469 os <<
"{ " <<
static_cast<const void *
>(CL) <<
" }";
473 os <<
"temp_object{" << getValueType().getAsString() <<
',' 474 <<
static_cast<const void *
>(Ex) <<
'}';
478 os <<
"base{" << superRegion <<
',' << getDecl()->getName() <<
'}';
486 os <<
"element{" << superRegion <<
',' 487 << Index <<
',' << getElementType().getAsString() <<
'}';
491 os << superRegion <<
"->" << *getDecl();
495 os <<
"ivar{" << superRegion <<
',' << *getDecl() <<
'}';
499 assert(Str !=
nullptr &&
"Expecting non-null StringLiteral");
504 assert(Str !=
nullptr &&
"Expecting non-null ObjCStringLiteral");
509 if (isa<HeapSpaceRegion>(getSuperRegion()))
511 os <<
"SymRegion{" << sym <<
'}';
515 const auto *VD = cast<VarDecl>(D);
519 os <<
"VarRegion{" <<
static_cast<const void *
>(
this) <<
'}';
523 dumpToStream(llvm::errs());
527 os <<
"raw_offset{" << getRegion() <<
',' << getOffset().getQuantity() <<
'}';
531 os <<
"CodeSpaceRegion";
535 os <<
"StaticGlobalsMemSpace{" << CR <<
'}';
539 os <<
"GlobalInternalSpaceRegion";
543 os <<
"GlobalSystemSpaceRegion";
547 os <<
"GlobalImmutableSpaceRegion";
551 os <<
"HeapSpaceRegion";
555 os <<
"UnknownSpaceRegion";
559 os <<
"StackArgumentsSpaceRegion";
563 os <<
"StackLocalsSpaceRegion";
567 return canPrintPrettyAsExpr();
575 assert(canPrintPretty() &&
"This region cannot be printed pretty.");
577 printPrettyAsExpr(os);
582 llvm_unreachable(
"This region cannot be printed pretty.");
590 os << getDecl()->getName();
598 os << getDecl()->getName();
610 assert(canPrintPrettyAsExpr());
612 os <<
"." << getDecl()->getName();
616 if (canPrintPrettyAsExpr()) {
618 printPrettyAsExpr(os);
621 os <<
"field " <<
"\'" << getDecl()->getName() <<
"'";
634 std::string VariableName;
635 std::string ArrayIndices;
638 llvm::raw_svector_ostream os(buf);
646 CI->getValue().toString(Idx);
647 ArrayIndices = (llvm::Twine(
"[") + Idx.str() +
"]" + ArrayIndices).str();
654 ArrayIndices = (llvm::Twine(
"[") + Idx +
"]" + ArrayIndices).str();
664 return (llvm::Twine(
"'") + os.str() + ArrayIndices +
"'").str();
666 return (llvm::Twine(os.str()) + ArrayIndices).str();
673 const auto *
const VR = dyn_cast<
VarRegion>(this->getBaseRegion());
674 const auto *
const FR = dyn_cast<
FieldRegion>(
this);
683 return VR->getDecl()->getSourceRange();
694 template <
typename REG>
695 const REG *MemRegionManager::LazyAllocate(REG*& region) {
697 region = A.Allocate<REG>();
698 new (region) REG(
this);
704 template <
typename REG,
typename ARG>
705 const REG *MemRegionManager::LazyAllocate(REG*& region, ARG a) {
707 region = A.Allocate<REG>();
708 new (region) REG(
this, a);
744 if (K == MemRegion::GlobalSystemSpaceRegionKind)
745 return LazyAllocate(SystemGlobals);
746 if (K == MemRegion::GlobalImmutableSpaceRegionKind)
747 return LazyAllocate(ImmutableGlobals);
748 assert(K == MemRegion::GlobalInternalSpaceRegionKind);
749 return LazyAllocate(InternalGlobals);
752 assert(K == MemRegion::StaticGlobalSpaceRegionKind);
763 return LazyAllocate(heap);
767 return LazyAllocate(unknown);
771 return LazyAllocate(code);
779 return getSubRegion<StringRegion>(
785 return getSubRegion<ObjCStringRegion>(
792 static llvm::PointerUnion<const StackFrameContext *, const VarRegion *>
797 if (
const auto *SFC = dyn_cast<StackFrameContext>(LC)) {
798 if (cast<DeclContext>(SFC->getDecl()) == DC)
801 if (
const auto *BC = dyn_cast<BlockInvocationContext>(LC)) {
806 I = BR->referenced_vars_begin(),
807 E = BR->referenced_vars_end(); I != E; ++I) {
808 const VarRegion *VR = I.getOriginalRegion();
810 return cast<VarRegion>(I.getCapturedRegion());
829 if (D->
getName().find(
"errno") != StringRef::npos)
851 llvm::PointerUnion<const StackFrameContext *, const VarRegion *> V =
865 sReg = isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)
872 if (isa<FunctionDecl>(STCD) || isa<ObjCMethodDecl>(STCD))
875 else if (
const auto *BD = dyn_cast<BlockDecl>(STCD)) {
891 STC->getAnalysisDeclContext());
902 return getSubRegion<VarRegion>(D, sReg);
907 return getSubRegion<VarRegion>(D, superR);
913 unsigned blockCount) {
935 return getSubRegion<BlockDataRegion>(BC, LC, blockCount, sReg);
940 return getSubRegion<CXXTempObjectRegion>(
957 return getSubRegion<CompoundLiteralRegion>(CL, sReg);
966 llvm::FoldingSetNodeID
ID;
967 ElementRegion::ProfileRegion(ID, T, Idx, superRegion);
970 MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
971 auto *R = cast_or_null<ElementRegion>(data);
976 Regions.InsertNode(R, InsertPos);
984 return getSubRegion<FunctionCodeRegion>(FD,
getCodeRegion());
990 return getSubRegion<BlockCodeRegion>(BD, locTy, AC,
getCodeRegion());
1005 return getSubRegion<FieldRegion>(d, superRegion);
1011 return getSubRegion<ObjCIvarRegion>(d, superRegion);
1036 for (
const auto &I : Class->
bases()) {
1037 if (I.getType()->getAsCXXRecordDecl()->getCanonicalDecl() == BaseClass)
1048 if (isa<TypedValueRegion>(Super)) {
1049 assert(
isValidBaseClass(RD, dyn_cast<TypedValueRegion>(Super), IsVirtual));
1055 while (
const auto *
Base = dyn_cast<CXXBaseObjectRegion>(Super))
1056 Super = cast<SubRegion>(
Base->getSuperRegion());
1057 assert(Super && !isa<MemSpaceRegion>(Super));
1061 return getSubRegion<CXXBaseObjectRegion>(RD, IsVirtual, Super);
1076 (!D || D->isStatic() ||
1096 const auto *SR = dyn_cast<
SubRegion>(
this);
1099 R = SR->getSuperRegion();
1107 return isa<StackSpaceRegion>(getMemorySpace());
1111 return isa<StackLocalsSpaceRegion>(getMemorySpace());
1115 return isa<StackArgumentsSpaceRegion>(getMemorySpace());
1120 return isa<StackArgumentsSpaceRegion>(MS) ||
1121 isa<GlobalsSpaceRegion>(MS);
1130 case MemRegion::ElementRegionKind:
1131 case MemRegion::FieldRegionKind:
1132 case MemRegion::ObjCIvarRegionKind:
1133 case MemRegion::CXXBaseObjectRegionKind:
1134 R = cast<SubRegion>(R)->getSuperRegion();
1156 case ElementRegionKind: {
1157 const auto *ER = cast<ElementRegion>(R);
1158 if (!ER->getIndex().isZeroConstant())
1160 R = ER->getSuperRegion();
1163 case CXXBaseObjectRegionKind:
1164 if (!StripBaseCasts)
1166 R = cast<CXXBaseObjectRegion>(R)->getSuperRegion();
1175 const auto *SubR = dyn_cast<
SubRegion>(
this);
1178 if (
const auto *SymR = dyn_cast<SymbolicRegion>(SubR))
1180 SubR = dyn_cast<
SubRegion>(SubR->getSuperRegion());
1200 int64_t i = CI->getValue().getSExtValue();
1212 if (
auto NewOffset = llvm::checkedMulAdd(i, size, offset)) {
1213 offset = *NewOffset;
1215 LLVM_DEBUG(llvm::dbgs() <<
"MemRegion::getAsArrayOffset: " 1216 <<
"offset overflowing, returning unknown\n");
1230 assert(superR &&
"super region cannot be NULL");
1237 assert(Child &&
"Child must not be null");
1241 for (
const auto &I : Child->
bases()) {
1242 if (I.getType()->getAsCXXRecordDecl() == Base)
1250 const MemRegion *SymbolicOffsetBase =
nullptr;
1255 case MemRegion::CodeSpaceRegionKind:
1256 case MemRegion::StackLocalsSpaceRegionKind:
1257 case MemRegion::StackArgumentsSpaceRegionKind:
1258 case MemRegion::HeapSpaceRegionKind:
1259 case MemRegion::UnknownSpaceRegionKind:
1260 case MemRegion::StaticGlobalSpaceRegionKind:
1261 case MemRegion::GlobalInternalSpaceRegionKind:
1262 case MemRegion::GlobalSystemSpaceRegionKind:
1263 case MemRegion::GlobalImmutableSpaceRegionKind:
1265 assert(Offset == 0 && !SymbolicOffsetBase);
1268 case MemRegion::FunctionCodeRegionKind:
1269 case MemRegion::BlockCodeRegionKind:
1270 case MemRegion::BlockDataRegionKind:
1274 SymbolicOffsetBase = R;
1277 case MemRegion::SymbolicRegionKind:
1278 case MemRegion::AllocaRegionKind:
1279 case MemRegion::CompoundLiteralRegionKind:
1280 case MemRegion::CXXThisRegionKind:
1281 case MemRegion::StringRegionKind:
1282 case MemRegion::ObjCStringRegionKind:
1283 case MemRegion::VarRegionKind:
1284 case MemRegion::CXXTempObjectRegionKind:
1288 case MemRegion::ObjCIvarRegionKind:
1296 case MemRegion::CXXBaseObjectRegionKind: {
1297 const auto *BOR = cast<CXXBaseObjectRegion>(R);
1298 R = BOR->getSuperRegion();
1301 bool RootIsSymbolic =
false;
1302 if (
const auto *TVR = dyn_cast<TypedValueRegion>(R)) {
1303 Ty = TVR->getDesugaredValueType(R->getContext());
1304 }
else if (
const auto *SR = dyn_cast<SymbolicRegion>(R)) {
1309 RootIsSymbolic =
true;
1315 SymbolicOffsetBase = R;
1317 if (RootIsSymbolic) {
1321 if (BOR->isVirtual()) {
1323 SymbolicOffsetBase = R;
1326 SymbolicOffsetBase = R;
1333 if (SymbolicOffsetBase)
1337 const ASTRecordLayout &Layout = R->getContext().getASTRecordLayout(Child);
1338 if (BOR->isVirtual())
1344 Offset += BaseOffset.
getQuantity() * R->getContext().getCharWidth();
1347 case MemRegion::ElementRegionKind: {
1348 const auto *ER = cast<ElementRegion>(R);
1349 R = ER->getSuperRegion();
1351 QualType EleTy = ER->getValueType();
1354 SymbolicOffsetBase = R;
1358 SVal Index = ER->getIndex();
1363 if (SymbolicOffsetBase)
1366 int64_t i = CI->getValue().getSExtValue();
1368 Offset += i * R->getContext().getTypeSize(EleTy);
1371 SymbolicOffsetBase = R;
1375 case MemRegion::FieldRegionKind: {
1376 const auto *FR = cast<FieldRegion>(R);
1377 R = FR->getSuperRegion();
1386 SymbolicOffsetBase = R;
1391 if (SymbolicOffsetBase)
1397 FE = RD->
field_end(); FI != FE; ++FI, ++idx) {
1398 if (FR->getDecl() == *FI)
1401 const ASTRecordLayout &Layout = R->getContext().getASTRecordLayout(RD);
1410 if (SymbolicOffsetBase)
1418 return *cachedOffset;
1425 std::pair<const VarRegion *, const VarRegion *>
1426 BlockDataRegion::getCaptureRegions(
const VarDecl *VD) {
1445 return std::make_pair(VR, OriginalVR);
1448 void BlockDataRegion::LazyInitializeReferencedVars() {
1455 std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());
1457 if (NumBlockVars == 0) {
1458 ReferencedVars = (
void*) 0x1;
1468 auto *BV = A.Allocate<VarVec>();
1469 new (BV) VarVec(BC, NumBlockVars);
1470 auto *BVOriginal = A.Allocate<VarVec>();
1471 new (BVOriginal) VarVec(BC, NumBlockVars);
1473 for (
const auto *VD : ReferencedBlockVars) {
1476 std::tie(VR, OriginalVR) = getCaptureRegions(VD);
1479 BV->push_back(VR, BC);
1480 BVOriginal->push_back(OriginalVR, BC);
1483 ReferencedVars = BV;
1484 OriginalVars = BVOriginal;
1493 if (Vec == (
void*) 0x1)
1500 VecOriginal->begin());
1509 if (Vec == (
void*) 0x1)
1516 VecOriginal->end());
1521 E = referenced_vars_end();
1523 if (I.getCapturedRegion() == R)
1524 return I.getOriginalRegion();
1535 SymTraitsMap[Sym] |= IK;
1541 if (
const auto *SR = dyn_cast<SymbolicRegion>(MR))
1542 setTrait(SR->getSymbol(), IK);
1544 MRTraitsMap[MR] |= IK;
1549 const_symbol_iterator I = SymTraitsMap.find(Sym);
1550 if (I != SymTraitsMap.end())
1551 return I->second & IK;
1561 if (
const auto *SR = dyn_cast<SymbolicRegion>(MR))
1562 return hasTrait(SR->getSymbol(), IK);
1564 const_region_iterator I = MRTraitsMap.find(MR);
1565 if (I != MRTraitsMap.end())
1566 return I->second & IK;
Defines the clang::ASTContext interface.
void dumpToStream(raw_ostream &os) const override
TypedValueRegion - An abstract class representing regions having a typed value.
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
CompoundLiteralRegion - A memory region representing a compound literal.
const ObjCIvarDecl * getDecl() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getArrayIndexType() const
SymbolManager & getSymbolManager()
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const
bool hasCaptures() const
True if this block (or its nested blocks) captures anything of local storage from its enclosing scope...
std::string getString() const
Get a string representation of a region for debug use.
bool isArithmeticType() const
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
C Language Family Type Representation.
Defines the SourceManager interface.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression...
virtual void dumpToStream(raw_ostream &os) const
BlockCodeRegion - A region that represents code texts of blocks (closures).
virtual QualType getValueType() const =0
Decl - This represents one declaration (or definition), e.g.
void dumpToStream(raw_ostream &os) const override
const StringRegion * getStringRegion(const StringLiteral *Str)
const GlobalsSpaceRegion * getGlobalsRegion(MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
getGlobalsRegion - Retrieve the memory region associated with global variables.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
MemSpaceRegion - A memory region that represents a "memory space"; for example, the set of global var...
A container of type source information.
Value representing integer constant.
const ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
AllocaRegion - A region that represents an untyped blob of bytes created by a call to 'alloca'...
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
CodeSpaceRegion - The memory space that holds the executable code of functions and blocks...
const StackArgumentsSpaceRegion * getStackArgumentsRegion(const StackFrameContext *STC)
getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the...
ASTContext & getContext()
Represents a variable declaration or definition.
void printPretty(raw_ostream &os) const override
Print the region for use in diagnostics.
CompoundLiteralExpr - [C99 6.5.2.5].
void Profile(llvm::FoldingSetNodeID &ID) const override
const T * getAs() const
Member-template getAs<specific type>'.
void setTrait(SymbolRef Sym, InvalidationKinds IK)
QualType getElementType() const
void Profile(llvm::FoldingSetNodeID &ID) const override
const ObjCStringRegion * getObjCStringRegion(const ObjCStringLiteral *Str)
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...
Describes how types, statements, expressions, and declarations should be printed. ...
CXXThisRegion - Represents the region for the implicit 'this' parameter in a call to a C++ method...
const MemRegion * getSuperRegion() const
Represents a struct/union/class.
const SymbolicRegion * getSymbolicBase() const
If this is a symbolic region, returns the region.
One of these records is kept for each identifier that is lexed.
DefinedOrUnknownSVal getExtent(SValBuilder &svalBuilder) const override
getExtent - Returns the size of the region in bytes.
const HeapSpaceRegion * getHeapRegion()
getHeapRegion - Retrieve the memory region associated with the generic "heap".
The region associated with an ObjCStringLiteral.
void dumpToStream(raw_ostream &os) const
void Profile(llvm::FoldingSetNodeID &ID) const override
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const FieldDecl * getDecl() const
Represents a member of a struct/union/class.
AnalysisDeclContext contains the context data for the function or method under analysis.
const StackLocalsSpaceRegion * getStackLocalsRegion(const StackFrameContext *STC)
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame...
void Profile(llvm::FoldingSetNodeID &ID) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
TypeSourceInfo * getSignatureAsWritten() const
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym)
Retrieve or create a "symbolic" memory region.
void Profile(llvm::FoldingSetNodeID &ID) const override
BlockDataRegion - A region that represents a block instance.
const AllocaRegion * getAllocaRegion(const Expr *Ex, unsigned Cnt, const LocationContext *LC)
getAllocaRegion - Retrieve a region associated with a call to alloca().
const UnknownSpaceRegion * getUnknownRegion()
getUnknownRegion - Retrieve the memory region associated with unknown memory space.
CharUnits - This is an opaque type for sizes expressed in character units.
void dumpToStream(raw_ostream &os) const override
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
QualType getValueType() const override
virtual bool inTopFrame() const
Return true if the current LocationContext has no caller context.
const LocationContext * getParent() const
bool hasStackParametersStorage() const
void Profile(llvm::FoldingSetNodeID &ID) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
ObjCStringLiteral, used for Objective-C string literals i.e.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
void Profile(llvm::FoldingSetNodeID &ID) const override
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
void dumpToStream(raw_ostream &os) const override
void dumpToStream(raw_ostream &os) const override
referenced_vars_iterator referenced_vars_end() const
void dumpToStream(raw_ostream &os) const override
Represent a region's offset within the top level base region.
const MemSpaceRegion * getMemorySpace() const
void Profile(llvm::FoldingSetNodeID &ID) const override
static void ProfileRegion(llvm::FoldingSetNodeID &ID, const Decl *D, const MemRegion *superRegion, Kind k)
bool canPrintPretty() const override
Returns true if this region can be printed in a user-friendly way.
const BlockCodeRegion * getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
void dumpToStream(raw_ostream &os) const override
const CodeSpaceRegion * getCodeRegion()
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
DefinedOrUnknownSVal getExtent(SValBuilder &svalBuilder) const override
getExtent - Returns the size of the region in bytes.
SourceRange sourceRange() const
Retrieve source range from memory region.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
DefinedOrUnknownSVal getExtent(SValBuilder &svalBuilder) const override
getExtent - Returns the size of the region in bytes.
const RegionTy * getAs() const
SymbolicRegion - A special, "non-concrete" region.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression...
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Expr - This represents one expression.
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression...
DefinedOrUnknownSVal getExtent(SValBuilder &svalBuilder) const override
getExtent - Returns the size of the region in bytes.
void dumpToStream(raw_ostream &os) const override
field_iterator field_end() const
static const int64_t Symbolic
DeclContext * getDeclContext()
llvm::BumpPtrAllocator & getAllocator()
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void Profile(llvm::FoldingSetNodeID &ID) const override
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const StackFrameContext * getStackFrame() const
The region of the static variables within the current CodeTextRegion scope.
const VarDecl * getDecl() const
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
bool isConstQualified() const
Determine whether this type is const-qualified.
void dumpToStream(raw_ostream &os) const override
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
const MemRegion * StripCasts(bool StripBaseCasts=true) const
void Profile(llvm::FoldingSetNodeID &ID) const
const BlockDecl * getDecl() const
FunctionCodeRegion - A region that represents code texts of function.
virtual bool canPrintPretty() const
Returns true if this region can be printed in a user-friendly way.
static bool isImmediateBase(const CXXRecordDecl *Child, const CXXRecordDecl *Base)
Returns true if Base is an immediate base class of Child.
void dumpToStream(raw_ostream &os) const override
const CXXTempObjectRegion * getCXXTempObjectRegion(Expr const *Ex, LocationContext const *LC)
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
void dumpToStream(raw_ostream &os) const override
Represents a static or instance method of a struct/union/class.
ASTContext & getContext()
void dumpToStream(raw_ostream &os) const override
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
void dumpToStream(raw_ostream &os) const override
const StackFrameContext * getStackFrame() const
DefinedOrUnknownSVal getExtent(SValBuilder &svalBuilder) const override
getExtent - Returns the size of the region in bytes.
virtual void printPrettyAsExpr(raw_ostream &os) const
Print the region as expression.
const CompoundLiteralRegion * getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC)
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
void Profile(llvm::FoldingSetNodeID &ID) const override
referenced_vars_iterator referenced_vars_begin() const
void dumpToStream(raw_ostream &os) const override
std::string getDescriptiveName(bool UseQuotes=true) const
Get descriptive name for memory region.
const CXXThisRegion * getCXXThisRegion(QualType thisPointerTy, const LocationContext *LC)
getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'...
RegionRawOffset getAsArrayOffset() const
Compute the offset within the array. The array might also be a subobject.
virtual void printPretty(raw_ostream &os) const
Print the region for use in diagnostics.
const CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is virtually derived from the class Base.
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
Dataflow Directional Tag Classes.
QualType getValueType() const override
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isZeroConstant() const
llvm::iterator_range< referenced_decls_iterator > getReferencedBlockVars(const BlockDecl *BD)
const VarRegion * getVarRegion(const VarDecl *D, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
InvalidationKinds
Describes different invalidation traits.
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type...
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
Represents symbolic expression that isn't a location.
const VarRegion * getOriginalRegion(const VarRegion *VR) const
Return the original region for a captured region, if one exists.
void Profile(llvm::FoldingSetNodeID &ID) const override
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...
void dumpToStream(raw_ostream &os) const override
const FunctionCodeRegion * getFunctionCodeRegion(const NamedDecl *FD)
virtual bool canPrintPrettyAsExpr() const
Returns true if this region's textual representation can be used as part of a larger expression...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
const Decl * getDecl() const
const CXXTempObjectRegion * getCXXStaticTempObjectRegion(const Expr *Ex)
Create a CXXTempObjectRegion for temporaries which are lifetime-extended by static references...
void dumpToStream(raw_ostream &os) const override
virtual MemRegionManager * getMemRegionManager() const =0
void dumpToStream(raw_ostream &os) const override
SubRegion - A region that subsets another larger region.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
bool hasStackStorage() const
const StackFrameContext * getStackFrame() const
void Profile(llvm::FoldingSetNodeID &ID) const override
const Type * getTypePtrOrNull() const
SourceManager & getSourceManager()
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
const BlockDataRegion * getBlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount)
getBlockDataRegion - Get the memory region associated with an instance of a block.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
MemRegionManager * getMemRegionManager() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression...
const SymbolExtent * getExtentSymbol(const SubRegion *R)
static void ProfileRegion(llvm::FoldingSetNodeID &ID, SymbolRef sym, const MemRegion *superRegion)
Represents a C++ struct/union/class.
void dumpToStream(raw_ostream &os) const override
static RegionOffset calculateOffset(const MemRegion *R)
virtual bool isSubRegionOf(const MemRegion *R) const
Check if the region is a subregion of the given region.
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
ObjCIvarDecl - Represents an ObjC instance variable.
const MemRegion * getBaseRegion() const
StringLiteral - This represents a string literal expression, e.g.
void dumpToStream(raw_ostream &os) const override
StringRegion - Region associated with a StringLiteral.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
void Profile(llvm::FoldingSetNodeID &ID) const override
ElementRegin is used to represent both array elements and casts.
static Decl::Kind getKind(const Decl *D)
void dumpToStream(raw_ostream &os) const override
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
bool hasStackNonParametersStorage() const
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
bool hasGlobalsOrParametersStorage() const
void dumpToStream(raw_ostream &os) const override
const FieldRegion * getFieldRegion(const FieldDecl *fd, const SubRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl...
void dumpToStream(raw_ostream &os) const override
SourceLocation getLocation() const
void dumpToStream(raw_ostream &os) const override