1//==- MemRegion.h - Abstract memory regions for static analysis -*- C++ -*--==//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//===----------------------------------------------------------------------===//
9// This file defines MemRegion and its subclasses. MemRegion defines a
10// partially-typed abstraction of memory useful for path-sensitive dataflow
13//===----------------------------------------------------------------------===//
15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
32#include "llvm/ADT/DenseMap.h"
33#include "llvm/ADT/FoldingSet.h"
34#include "llvm/ADT/PointerIntPair.h"
35#include "llvm/ADT/iterator_range.h"
36#include "llvm/Support/Allocator.h"
37#include "llvm/Support/Casting.h"
38#include "llvm/Support/ErrorHandling.h"
64/// Represent a region's offset within the top level base region.
69 /// The bit offset within the base region. Can be negative.
73 // We're using a const instead of an enumeration due to the size required;
74 // Visual Studio will only create enumerations of size int, not long long.
75 static const int64_t
Symbolic = std::numeric_limits<int64_t>::max();
80 /// It might return null.
93//===----------------------------------------------------------------------===//
94// Base region classes.
95//===----------------------------------------------------------------------===//
97/// MemRegion - The root abstract class for all memory regions.
101 #define REGION(Id, Parent) Id ## Kind,
102 #define REGION_RANGE(Id, First, Last) BEGIN_##Id = First, END_##Id = Last,
103#include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
110 mutable std::optional<RegionOffset> cachedOffset;
119 virtual void Profile(llvm::FoldingSetNodeID& ID)
const = 0;
123 /// Deprecated. Gets the 'raw' memory space of a memory region's base region.
124 /// If the MemRegion is originally associated with Unknown memspace, then the
125 /// State may have a more accurate memspace for this region.
126 /// Use getMemorySpace(ProgramStateRef) instead.
127 [[nodiscard]] LLVM_ATTRIBUTE_RETURNS_NONNULL
const MemSpaceRegion *
130 /// Deprecated. Use getMemorySpace(ProgramStateRef) instead.
131 template <
class MemSpace>
136 /// Returns the most specific memory space for this memory region in the given
137 /// ProgramStateRef. We may infer a more accurate memory space for unknown
138 /// space regions and associate this in the State.
139 [[nodiscard]] LLVM_ATTRIBUTE_RETURNS_NONNULL
const MemSpaceRegion *
142 template <
class MemSpace>
147 template <
typename... MemorySpaces>
149 static_assert(
sizeof...(MemorySpaces));
153 /// Set the dynamically deduced memory space of a MemRegion that currently has
154 /// UnknownSpaceRegion. \p Space shouldn't be UnknownSpaceRegion.
160 /// Recursively retrieve the region of the most derived class instance of
161 /// regions of C++ base class instances.
162 LLVM_ATTRIBUTE_RETURNS_NONNULL
165 /// Check if the region is a subregion of the given region.
166 /// Each region is a subregion of itself.
169 LLVM_ATTRIBUTE_RETURNS_NONNULL
172 /// If this is a symbolic region, returns the region. Otherwise,
173 /// goes up the base chain looking for the first symbolic base region.
174 /// It might return null.
177 /// Compute the offset within the top level memory object.
180 /// Get a string representation of a region for debug use.
187 /// Returns true if this region can be printed in a user-friendly way.
190 /// Print the region for use in diagnostics.
193 /// Returns true if this region's textual representation can be used
194 /// as part of a larger expression.
197 /// Print the region as expression.
199 /// When this region represents a subexpression, the method is for printing
200 /// an expression containing it.
207 template<
typename RegionTy>
const RegionTy*
getAs()
const;
208 template <
typename RegionTy>
209 LLVM_ATTRIBUTE_RETURNS_NONNULL
const RegionTy *
castAs()
const;
213 /// Get descriptive name for memory region. The name is obtained from
214 /// the variable/field declaration retrieved from the memory region.
215 /// Regions that point to an element of an array are returned as: "arr[0]".
216 /// Regions that point to a struct are returned as: "st.var".
218 /// \param UseQuotes Set if the name should be quoted.
220 /// \returns variable name for memory region
223 /// Retrieve source range from memory region. The range retrieval
224 /// is based on the decl obtained from the memory region.
225 /// For a VarRegion the range of the base region is returned.
226 /// For a FieldRegion the range of the field is returned.
227 /// If no declaration is found, an empty source range is returned.
228 /// The client is responsible for checking if the returned range is valid.
230 /// \returns source range for declaration retrieved from memory region
234/// MemSpaceRegion - A memory region that represents a "memory space";
235/// for example, the set of global variables, the stack frame, etc.
249 void Profile(llvm::FoldingSetNodeID &ID)
const override;
253 return k >= BEGIN_MEMSPACES && k <= END_MEMSPACES;
257/// CodeSpaceRegion - The memory space that holds the executable code of
258/// functions and blocks.
269 return R->
getKind() == CodeSpaceRegionKind;
274 virtual void anchor();
284 return k >= BEGIN_GLOBAL_MEMSPACES && k <= END_GLOBAL_MEMSPACES;
288/// The region of the static variables within the current CodeTextRegion
291/// Currently, only the static locals are placed there, so we know that these
292/// variables do not get invalidated by calls to other functions.
304 void Profile(llvm::FoldingSetNodeID &ID)
const override;
308 LLVM_ATTRIBUTE_RETURNS_NONNULL
312 return R->
getKind() == StaticGlobalSpaceRegionKind;
316/// The region for all the non-static global variables.
318/// This class is further split into subclasses for efficient implementation of
319/// invalidating a set of related global values as is done in
320/// RegionStoreManager::invalidateRegions (instead of finding all the dependent
321/// globals, we invalidate the whole parent region).
323 void anchor()
override;
334 return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
335 k <= END_NON_STATIC_GLOBAL_MEMSPACES;
339/// The region containing globals which are defined in system/external
340/// headers and are considered modifiable by system calls (ex: errno).
351 return R->
getKind() == GlobalSystemSpaceRegionKind;
355/// The region containing globals which are considered not to be modified
356/// or point to data which could be modified as a result of a function call
357/// (system or internal). Ex: Const global scalars would be modeled as part of
358/// this region. This region also includes most system globals since they have
359/// low chance of being modified.
370 return R->
getKind() == GlobalImmutableSpaceRegionKind;
374/// The region containing globals which can be modified by calls to
375/// "internally" defined functions - (for now just) functions other than system
387 return R->
getKind() == GlobalInternalSpaceRegionKind;
401 return R->
getKind() == HeapSpaceRegionKind;
415 return R->
getKind() == UnknownSpaceRegionKind;
420 virtual void anchor();
432 LLVM_ATTRIBUTE_RETURNS_NONNULL
435 void Profile(llvm::FoldingSetNodeID &ID)
const override;
439 return k >= BEGIN_STACK_MEMSPACES && k <= END_STACK_MEMSPACES;
453 return R->
getKind() == StackLocalsSpaceRegionKind;
468 return R->
getKind() == StackArgumentsSpaceRegionKind;
472/// SubRegion - A region that subsets another larger region. Most regions
473/// are subclasses of SubRegion.
475 virtual void anchor();
486 LLVM_ATTRIBUTE_RETURNS_NONNULL
496 return R->
getKind() > END_MEMSPACES;
500//===----------------------------------------------------------------------===//
501// MemRegion subclasses.
502//===----------------------------------------------------------------------===//
504/// AllocaRegion - A region that represents an untyped blob of bytes created
505/// by a call to 'alloca'.
509 // Block counter. Used to distinguish different pieces of memory allocated by
510 // alloca at the same call site.
520 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const Expr *Ex,
524 LLVM_ATTRIBUTE_RETURNS_NONNULL
529 void Profile(llvm::FoldingSetNodeID& ID)
const override;
534 return R->
getKind() == AllocaRegionKind;
538/// TypedRegion - An abstract class representing regions that are typed.
540 void anchor()
override;
558 return k >= BEGIN_TYPED_REGIONS && k <= END_TYPED_REGIONS;
562/// TypedValueRegion - An abstract class representing regions having a typed value.
564 void anchor()
override;
575 // FIXME: We can possibly optimize this later to cache this value.
585 return T.getTypePtrOrNull() ?
T.getDesugaredType(Context) :
T;
590 return k >= BEGIN_TYPED_VALUE_REGIONS && k <= END_TYPED_VALUE_REGIONS;
595 void anchor()
override;
607 return k >= BEGIN_CODE_TEXT_REGIONS && k <= END_CODE_TEXT_REGIONS;
611/// FunctionCodeRegion - A region that represents code texts of function.
622 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const NamedDecl *FD,
628 if (
const auto *D = dyn_cast<FunctionDecl>(FD)) {
633 assert(
false &&
"Getting the type of ObjCMethod is not supported yet");
635 // TODO: We might want to return a different type here (ex: id (*ty)(...))
636 // depending on how it is used.
646 void Profile(llvm::FoldingSetNodeID& ID)
const override;
649 return R->
getKind() == FunctionCodeRegionKind;
653/// BlockCodeRegion - A region that represents code texts of blocks (closures).
654/// Blocks are represented with two kinds of regions. BlockCodeRegions
655/// represent the "code", while BlockDataRegions represent instances of blocks,
656/// which correspond to "code+data". The distinction is important, because
657/// like a closure a block captures the values of externally referenced
668 :
CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {
674 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const BlockDecl *BD,
683 LLVM_ATTRIBUTE_RETURNS_NONNULL
688 LLVM_ATTRIBUTE_RETURNS_NONNULL
693 void Profile(llvm::FoldingSetNodeID& ID)
const override;
696 return R->
getKind() == BlockCodeRegionKind;
700/// BlockDataRegion - A region that represents a block instance.
701/// Blocks are represented with two kinds of regions. BlockCodeRegions
702/// represent the "code", while BlockDataRegions represent instances of blocks,
703/// which correspond to "code+data". The distinction is important, because
704/// like a closure a block captures the values of externally referenced
712 void *ReferencedVars =
nullptr;
713 void *OriginalVars =
nullptr;
717 :
TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
727 static void ProfileRegion(llvm::FoldingSetNodeID&,
const BlockCodeRegion *,
732 LLVM_ATTRIBUTE_RETURNS_NONNULL
735 LLVM_ATTRIBUTE_RETURNS_NONNULL
747 : R(r), OriginalR(originalR) {}
749 LLVM_ATTRIBUTE_RETURNS_NONNULL
754 LLVM_ATTRIBUTE_RETURNS_NONNULL
760 assert((R ==
nullptr) == (I.R ==
nullptr));
765 assert((R ==
nullptr) == (I.R ==
nullptr));
775 // This isn't really a conventional iterator.
776 // We just implement the deref as a no-op for now to make range-based for
781 /// Return the original region for a captured region, if
782 /// one exists. It might return null.
787 llvm::iterator_range<referenced_vars_iterator>
referenced_vars()
const;
791 void Profile(llvm::FoldingSetNodeID& ID)
const override;
794 return R->
getKind() == BlockDataRegionKind;
798 void LazyInitializeReferencedVars();
799 std::pair<const VarRegion *, const VarRegion *>
800 getCaptureRegions(
const VarDecl *VD);
803/// SymbolicRegion - A special, "non-concrete" region. Unlike other region
804/// classes, SymbolicRegion represents a region that serves as an alias for
805/// either a real region, a NULL pointer, etc. It essentially is used to
806/// map the concept of symbolic values into the domain of regions. Symbolic
807/// regions do not need to be typed.
814 :
SubRegion(sreg, SymbolicRegionKind), sym(
s) {
815 // Because pointer arithmetic is represented by ElementRegion layers,
816 // the base symbol here should not contain any arithmetic.
817 assert(isa_and_nonnull<SymbolData>(
s));
818 assert(
s->getType()->isAnyPointerType() ||
819 s->getType()->isReferenceType() ||
820 s->getType()->isBlockPointerType());
826 /// It might return null.
829 /// Gets the type of the wrapped symbol.
830 /// This type might not be accurate at all times - it's just our best guess.
831 /// Consider these cases:
832 /// void foo(void *data, char *str, base *obj) {...}
833 /// The type of the pointee of `data` is of course not `void`, yet that's our
834 /// best guess. `str` might point to any object and `obj` might point to some
835 /// derived instance. `TypedRegions` other hand are representing the cases
836 /// when we actually know their types.
843 void Profile(llvm::FoldingSetNodeID& ID)
const override;
852 return R->
getKind() == SymbolicRegionKind;
856/// StringRegion - Region associated with a StringLiteral.
867 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
872 LLVM_ATTRIBUTE_RETURNS_NONNULL
879 void Profile(llvm::FoldingSetNodeID& ID)
const override {
886 return R->
getKind() == StringRegionKind;
890/// The region associated with an ObjCStringLiteral.
902 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
907 LLVM_ATTRIBUTE_RETURNS_NONNULL
914 void Profile(llvm::FoldingSetNodeID& ID)
const override {
921 return R->
getKind() == ObjCStringRegionKind;
925/// CompoundLiteralRegion - A memory region representing a compound literal.
926/// Compound literals are essentially temporaries that are stack allocated
927/// or in the global constant pool.
941 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
950 void Profile(llvm::FoldingSetNodeID& ID)
const override;
954 LLVM_ATTRIBUTE_RETURNS_NONNULL
958 return R->
getKind() == CompoundLiteralRegionKind;
969 // TODO what does this return?
974 return k >= BEGIN_DECL_REGIONS && k <= END_DECL_REGIONS;
982 // Constructors and protected methods.
984 // VarRegion appears in unknown space when it's a block variable as seen
985 // from a block using it, when this block is analyzed at top-level.
986 // Other block variables appear within block data regions,
987 // which, unlike everything else on this list, are not memory spaces.
993 // TODO what does this return?
996 /// It might return null.
1000 // FIXME: We can cache this if needed.
1006 return k >= BEGIN_VAR_REGIONS && k <= END_VAR_REGIONS;
1015 // Constructors and private methods.
1017 :
VarRegion(sReg, NonParamVarRegionKind), VD(vd) {
1018 // VarRegion appears in unknown space when it's a block variable as seen
1019 // from a block using it, when this block is analyzed at top-level.
1020 // Other block variables appear within block data regions,
1021 // which, unlike everything else on this list, are not memory spaces.
1027 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const VarDecl *VD,
1031 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1033 LLVM_ATTRIBUTE_RETURNS_NONNULL
1037 // FIXME: We can cache this if needed.
1048 return R->
getKind() == NonParamVarRegionKind;
1052/// ParamVarRegion - Represents a region for parameters. Only parameters of the
1053/// function in the current stack frame are represented as `ParamVarRegion`s.
1054/// Parameters of top-level analyzed functions as well as captured paremeters
1055/// by lambdas and blocks are repesented as `VarRegion`s.
1057// FIXME: `ParamVarRegion` only supports parameters of functions, C++
1058// constructors, blocks and Objective-C methods with existing `Decl`. Upon
1059// implementing stack frame creations for functions without decl (functions
1060// passed by unknown function pointer) methods of `ParamVarRegion` must be
1065 const Expr *OriginExpr;
1068 ParamVarRegion(
const Expr *OE,
unsigned Idx,
const MemRegion *SReg)
1069 :
VarRegion(SReg, ParamVarRegionKind), OriginExpr(OE), Index(Idx) {
1074 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const Expr *OE,
1078 LLVM_ATTRIBUTE_RETURNS_NONNULL
1082 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1088 /// TODO: What does this return?
1095 return R->
getKind() == ParamVarRegionKind;
1099/// CXXThisRegion - Represents the region for the implicit 'this' parameter
1100/// in a call to a C++ method. This region doesn't represent the object
1101/// referred to by 'this', but rather 'this' itself.
1108 ThisPointerTy(thisPointerTy) {
1109 assert(ThisPointerTy->getPointeeType()->getAsCXXRecordDecl() &&
1110 "Invalid region type!");
1113 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1118 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1127 return R->
getKind() == CXXThisRegionKind;
1140 :
DeclRegion(sReg, FieldRegionKind), FD(fd) {
1144 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const FieldDecl *FD,
1146 ID.AddInteger(
static_cast<unsigned>(FieldRegionKind));
1152 LLVM_ATTRIBUTE_RETURNS_NONNULL
1155 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1158 // FIXME: We can cache this if needed.
1170 return R->
getKind() == FieldRegionKind;
1181 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const ObjCIvarDecl *ivd,
1185 LLVM_ATTRIBUTE_RETURNS_NONNULL
1188 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1198 return R->
getKind() == ObjCIvarRegionKind;
1202//===----------------------------------------------------------------------===//
1203// Auxiliary data classes for use with MemRegions.
1204//===----------------------------------------------------------------------===//
1206 class RegionRawOffset {
1213 : Region(reg), Offset(offset) {}
1216 // FIXME: Eventually support symbolic offsets.
1219 // It might return null.
1226/// ElementRegion is used to represent both array elements and casts.
1238 "The index must be signed");
1240 "Invalid region type!");
1243 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
QualType elementType,
1253 /// Compute the offset within the array. The array might also be a subobject.
1258 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1261 return R->
getKind() == ElementRegionKind;
1265// C++ temporary object associated with an expression.
1277 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1281 LLVM_ATTRIBUTE_RETURNS_NONNULL
1284 LLVM_ATTRIBUTE_RETURNS_NONNULL
1291 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1294 return R->
getKind() == CXXTempObjectRegionKind;
1298// C++ temporary object that have lifetime extended to lifetime of the
1299// variable. Usually they represent temporary bounds to reference variables.
1306 CXXLifetimeExtendedObjectRegion(
Expr const *E,
ValueDecl const *D,
1315 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
Expr const *E,
1319 LLVM_ATTRIBUTE_RETURNS_NONNULL
1321 LLVM_ATTRIBUTE_RETURNS_NONNULL
1323 /// It might return null.
1330 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1333 return R->
getKind() == CXXLifetimeExtendedObjectRegionKind;
1337// CXXBaseObjectRegion represents a base object within a C++ object. It is
1338// identified by the base class declaration and the region of its parent object.
1342 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> Data;
1344 CXXBaseObjectRegion(
const CXXRecordDecl *RD,
bool IsVirtual,
1350 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const CXXRecordDecl *RD,
1354 LLVM_ATTRIBUTE_RETURNS_NONNULL
1362 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1369 return region->
getKind() == CXXBaseObjectRegionKind;
1373// CXXDerivedObjectRegion represents a derived-class object that surrounds
1374// a C++ object. It is identified by the derived class declaration and the
1375// region of its parent object. It is a bit counter-intuitive (but not otherwise
1376// unseen) that this region represents a larger segment of memory that its
1386 // In case of a concrete region, it should always be possible to model
1387 // the base-to-derived cast by undoing a previous derived-to-base cast,
1388 // otherwise the cast is most likely ill-formed.
1390 "Should have unwrapped a base region instead!");
1393 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const CXXRecordDecl *RD,
1397 LLVM_ATTRIBUTE_RETURNS_NONNULL
1404 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1411 return region->
getKind() == CXXDerivedObjectRegionKind;
1415template<
typename RegionTy>
1417 if (
const auto *RT = dyn_cast<RegionTy>(
this))
1423template <
typename RegionTy>
1428//===----------------------------------------------------------------------===//
1429// MemRegionManager - Factory object for creating regions.
1430//===----------------------------------------------------------------------===//
1434 llvm::BumpPtrAllocator& A;
1436 llvm::FoldingSet<MemRegion> Regions;
1442 llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *>
1443 StackLocalsSpaceRegions;
1444 llvm::DenseMap<const StackFrameContext *, StackArgumentsSpaceRegion *>
1445 StackArgumentsSpaceRegions;
1446 llvm::DenseMap<const CodeTextRegion *, StaticGlobalSpaceRegion *>
1447 StaticsGlobalSpaceRegions;
1462 /// \returns The static size in bytes of the region \p MR.
1463 /// \note The region \p MR must be a 'SubRegion'.
1467 /// getStackLocalsRegion - Retrieve the memory region associated with the
1468 /// specified stack frame.
1472 /// getStackArgumentsRegion - Retrieve the memory region associated with
1473 /// function/method arguments of the specified stack frame.
1477 /// getGlobalsRegion - Retrieve the memory region associated with
1478 /// global variables.
1483 /// getHeapRegion - Retrieve the memory region associated with the
1487 /// getUnknownRegion - Retrieve the memory region associated with unknown
1493 /// getAllocaRegion - Retrieve a region associated with a call to alloca().
1497 /// getCompoundLiteralRegion - Retrieve the region associated with a
1498 /// given CompoundLiteral.
1503 /// getCXXThisRegion - Retrieve the [artificial] region associated with the
1504 /// parameter 'this'.
1508 /// Retrieve or create a "symbolic" memory region.
1509 /// If no memory space is specified, `UnknownSpaceRegion` will be used.
1513 /// Return a unique symbolic region belonging to heap memory space.
1520 /// getVarRegion - Retrieve or create the memory region associated with
1521 /// a specified VarDecl and LocationContext.
1524 /// getVarRegion - Retrieve or create the memory region associated with
1525 /// a specified VarDecl and LocationContext.
1529 /// getParamVarRegion - Retrieve or create the memory region
1530 /// associated with a specified CallExpr, Index and LocationContext.
1535 /// getElementRegion - Retrieve the memory region associated with the
1536 /// associated element type, index, and super region.
1547 /// getFieldRegion - Retrieve or create the memory region associated with
1548 /// a specified FieldDecl. 'superRegion' corresponds to the containing
1549 /// memory region (which typically represents the memory representing
1550 /// a structure or class).
1559 /// getObjCIvarRegion - Retrieve or create the memory region associated with
1560 /// a specified Objective-c instance variable. 'superRegion' corresponds
1561 /// to the containing region (which typically represents the Objective-C
1569 /// Create a CXXLifetimeExtendedObjectRegion for temporaries which are
1570 /// lifetime-extended by local references.
1575 /// Create a CXXLifetimeExtendedObjectRegion for temporaries which are
1576 /// lifetime-extended by *static* references.
1577 /// This differs from \ref getCXXLifetimeExtendedObjectRegion(Expr const *,
1578 /// ValueDecl const *, LocationContext const *) in the super-region used.
1582 /// Create a CXXBaseObjectRegion with the given base class for region
1585 /// The type of \p Super is assumed be a class deriving from \p BaseClass.
1590 /// Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different
1599 /// Create a CXXDerivedObjectRegion with the given derived class for region
1600 /// \p Super. This should not be used for casting an existing
1601 /// CXXBaseObjectRegion back to the derived type; instead, CXXBaseObjectRegion
1602 /// should be removed.
1612 /// getBlockDataRegion - Get the memory region associated with an instance
1613 /// of a block. Unlike many other MemRegions, the LocationContext*
1614 /// argument is allowed to be NULL for cases where we have no known
1618 unsigned blockCount);
1621 template <
typename RegionTy,
typename SuperTy,
1623 RegionTy* getSubRegion(
const Arg1Ty arg1,
1624 const SuperTy* superRegion);
1626 template <
typename RegionTy,
typename SuperTy,
1627 typename Arg1Ty,
typename Arg2Ty>
1628 RegionTy* getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
1629 const SuperTy* superRegion);
1631 template <
typename RegionTy,
typename SuperTy,
1632 typename Arg1Ty,
typename Arg2Ty,
typename Arg3Ty>
1633 RegionTy* getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
1635 const SuperTy* superRegion);
1637 template <
typename REG>
1638 const REG* LazyAllocate(REG*& region);
1640 template <
typename REG,
typename ARG>
1641 const REG* LazyAllocate(REG*& region, ARG a);
1644//===----------------------------------------------------------------------===//
1645// Out-of-line member definitions.
1646//===----------------------------------------------------------------------===//
1652//===----------------------------------------------------------------------===//
1653// Means for storing region/symbol handling traits.
1654//===----------------------------------------------------------------------===//
1656/// Information about invalidation for a particular region/symbol.
1658 using StorageTypeForKinds =
unsigned char;
1660 llvm::DenseMap<const MemRegion *, StorageTypeForKinds> MRTraitsMap;
1661 llvm::DenseMap<SymbolRef, StorageTypeForKinds> SymTraitsMap;
1663 using const_region_iterator =
1664 llvm::DenseMap<const MemRegion *, StorageTypeForKinds>::const_iterator;
1665 using const_symbol_iterator =
1666 llvm::DenseMap<SymbolRef, StorageTypeForKinds>::const_iterator;
1669 /// Describes different invalidation traits.
1671 /// Tells that a region's contents is not changed.
1674 /// Suppress pointer-escaping of a region.
1677 // Do not invalidate super region.
1680 /// When applied to a MemSpaceRegion, indicates the entire memory space
1681 /// should be invalidated.
1684 // Do not forget to extend StorageTypeForKinds if number of traits exceed
1685 // the number of bits StorageTypeForKinds can store.
1694//===----------------------------------------------------------------------===//
1695// Pretty-printing regions.
1696//===----------------------------------------------------------------------===//
1706#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents a C++ struct/union/class.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CharUnits - This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
CompoundLiteralExpr - [C99 6.5.2.5].
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a member of a struct/union/class.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
This represents a decl that may have a 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.
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.
A trivial tuple used to represent a source range.
It represents a stack frame of the call stack (based on CallEvent).
StringLiteral - This represents a string literal expression, e.g.
bool isBlockPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
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.
AllocaRegion - A region that represents an untyped blob of bytes created by a call to 'alloca'.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
bool isBoundable() const override
friend class MemRegionManager
BlockCodeRegion - A region that represents code texts of blocks (closures).
QualType getLocationType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
friend class MemRegionManager
bool operator==(const referenced_vars_iterator &I) const
const referenced_vars_iterator & operator*() const
bool operator!=(const referenced_vars_iterator &I) const
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarRegion * getCapturedRegion() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarRegion * getOriginalRegion() const
referenced_vars_iterator & operator++()
referenced_vars_iterator(const MemRegion *const *r, const MemRegion *const *originalR)
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.
QualType getLocationType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
static bool classof(const MemRegion *R)
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
friend class MemRegionManager
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
static bool classof(const MemRegion *region)
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
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
static bool classof(const MemRegion *region)
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
friend class MemRegionManager
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const ValueDecl * getExtendingDecl() const
void dumpToStream(raw_ostream &os) const override
const StackFrameContext * getStackFrame() const
It might return null.
friend class MemRegionManager
QualType getValueType() const override
QualType getValueType() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrameContext * getStackFrame() const
friend class MemRegionManager
CXXThisRegion - Represents the region for the implicit 'this' parameter in a call to a C++ method.
QualType getValueType() const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
CodeSpaceRegion - The memory space that holds the executable code of functions and blocks.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
friend class MemRegionManager
CodeTextRegion(const MemSpaceRegion *sreg, Kind k)
static bool classof(const MemRegion *R)
bool isBoundable() const override
CompoundLiteralRegion - A memory region representing a compound literal.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CompoundLiteralExpr * getLiteralExpr() const
QualType getValueType() const override
bool isBoundable() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
static bool classof(const MemRegion *R)
DeclRegion(const MemRegion *sReg, Kind k)
virtual const ValueDecl * getDecl() const =0
static bool classof(const MemRegion *R)
ElementRegion is used to represent both array elements and casts.
static bool classof(const MemRegion *R)
QualType getValueType() const override
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
friend class MemRegionManager
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
static bool classof(const MemRegion *R)
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
QualType getValueType() 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
friend class MemRegionManager
FunctionCodeRegion - A region that represents code texts of function.
static bool classof(const MemRegion *R)
QualType getLocationType() const override
const NamedDecl * getDecl() const
void dumpToStream(raw_ostream &os) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
friend class MemRegionManager
The region containing globals which are considered not to be modified or point to data which could be...
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
friend class MemRegionManager
The region containing globals which can be modified by calls to "internally" defined functions - (for...
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
friend class MemRegionManager
The region containing globals which are defined in system/external headers and are considered modifia...
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
GlobalsSpaceRegion(MemRegionManager &mgr, Kind k)
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
friend class MemRegionManager
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 FieldRegion * getFieldRegion(const FieldDecl *FD, const SubRegion *SuperRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl.
const BlockCodeRegion * getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
const ASTContext & getContext() const
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 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 FieldRegion * getFieldRegionWithSuper(const FieldRegion *FR, const SubRegion *superRegion)
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)
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a)
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 ElementRegion * getElementRegionWithSuper(const ElementRegion *ER, const SubRegion *superRegion)
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...
const CXXBaseObjectRegion * getCXXBaseObjectRegionWithSuper(const CXXBaseObjectRegion *baseReg, const SubRegion *superRegion)
Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different super region.
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.
virtual void Profile(llvm::FoldingSetNodeID &ID) const =0
LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy * castAs() const
const MemSpace * getMemorySpaceAs(ProgramStateRef State) const
virtual bool isBoundable() const
StringRef getKindStr() const
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
bool hasMemorySpace(ProgramStateRef State) const
const MemSpace * getRawMemorySpaceAs() const
Deprecated. Use getMemorySpace(ProgramStateRef) instead.
ProgramStateRef setMemorySpace(ProgramStateRef State, const MemSpaceRegion *Space) const
Set the dynamically deduced memory space of a MemRegion that currently has UnknownSpaceRegion.
ASTContext & getContext() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getMemorySpace(ProgramStateRef State) const
Returns the most specific memory space for this memory region in the given ProgramStateRef.
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.
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...
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getRawMemorySpace() const
Deprecated.
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...
MemRegionManager & getMemRegionManager() const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
bool isBoundable() const override
MemSpaceRegion(MemRegionManager &mgr, Kind k)
QualType getValueType() 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
friend class MemRegionManager
static bool classof(const MemRegion *R)
NonStaticGlobalSpaceRegion(MemRegionManager &mgr, Kind k)
static bool classof(const MemRegion *R)
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
static bool classof(const MemRegion *R)
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const ObjCIvarDecl * getDecl() const override
friend class MemRegionManager
void dumpToStream(raw_ostream &os) const override
The region associated with an ObjCStringLiteral.
QualType getValueType() const override
bool isBoundable() const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const ObjCStringLiteral * getObjCStringLiteral() const
void Profile(llvm::FoldingSetNodeID &ID) const override
friend class MemRegionManager
ParamVarRegion - Represents a region for parameters.
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
static bool classof(const MemRegion *R)
const ParmVarDecl * getDecl() const override
TODO: What does this return?
unsigned getIndex() const
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
friend class MemRegionManager
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Information about invalidation for a particular region/symbol.
InvalidationKinds
Describes different invalidation traits.
@ TK_PreserveContents
Tells that a region's contents is not changed.
@ TK_DoNotInvalidateSuperRegion
@ TK_EntireMemSpace
When applied to a MemSpaceRegion, indicates the entire memory space should be invalidated.
@ TK_SuppressEscape
Suppress pointer-escaping of a region.
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
bool hasSymbolicOffset() const
const MemRegion * getRegion() const
It might return null.
RegionOffset(const MemRegion *r, int64_t off)
int64_t getOffset() const
CharUnits getOffset() const
void dumpToStream(raw_ostream &os) const
friend class ElementRegion
const MemRegion * getRegion() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
StackSpaceRegion(MemRegionManager &mgr, Kind k, const StackFrameContext *sfc)
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrameContext * getStackFrame() const
void Profile(llvm::FoldingSetNodeID &ID) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const CodeTextRegion * getCodeRegion() const
friend class MemRegionManager
StringRegion - Region associated with a StringLiteral.
static bool classof(const MemRegion *R)
QualType getValueType() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
bool isBoundable() const override
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const StringLiteral * getStringLiteral() const
friend class MemRegionManager
SubRegion - A region that subsets another larger region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getSuperRegion() const
static bool classof(const MemRegion *R)
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
SubRegion(const MemRegion *sReg, Kind k)
const MemRegion * superRegion
MemRegionManager & getMemRegionManager() const override
SymbolicRegion - A special, "non-concrete" region.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
bool isBoundable() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
SymbolRef getSymbol() const
It might return null.
static void ProfileRegion(llvm::FoldingSetNodeID &ID, SymbolRef sym, const MemRegion *superRegion)
friend class MemRegionManager
QualType getPointeeStaticType() const
Gets the type of the wrapped symbol.
QualType getDesugaredLocationType(ASTContext &Context) const
bool isBoundable() const override
virtual QualType getLocationType() const =0
TypedRegion(const MemRegion *sReg, Kind k)
static bool classof(const MemRegion *R)
virtual QualType getValueType() const =0
QualType getLocationType() const override
static bool classof(const MemRegion *R)
QualType getDesugaredValueType(ASTContext &Context) const
TypedValueRegion(const MemRegion *sReg, Kind k)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
friend class MemRegionManager
QualType getValueType() const override
const VarDecl * getDecl() const override=0
const StackFrameContext * getStackFrame() const
It might return null.
VarRegion(const MemRegion *sReg, Kind k)
static bool classof(const MemRegion *R)
friend class MemRegionManager
Value representing integer constant.
APSIntPtr getValue() const
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const SymExpr * SymbolRef
raw_ostream & operator<<(raw_ostream &os, const MemRegion *R)
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
const FunctionProtoType * T
U cast(CodeGen::Address addr)