clang  15.0.0git
MemRegion.h
Go to the documentation of this file.
1 //==- MemRegion.h - Abstract memory regions for static analysis -*- C++ -*--==//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines MemRegion and its subclasses. MemRegion defines a
10 // partially-typed abstraction of memory useful for path-sensitive dataflow
11 // analyses.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
17 
18 #include "clang/AST/ASTContext.h"
19 #include "clang/AST/CharUnits.h"
20 #include "clang/AST/Decl.h"
21 #include "clang/AST/DeclObjC.h"
23 #include "clang/AST/Expr.h"
24 #include "clang/AST/ExprObjC.h"
25 #include "clang/AST/Type.h"
27 #include "clang/Basic/LLVM.h"
31 #include "llvm/ADT/DenseMap.h"
32 #include "llvm/ADT/FoldingSet.h"
33 #include "llvm/ADT/Optional.h"
34 #include "llvm/ADT/PointerIntPair.h"
35 #include "llvm/Support/Allocator.h"
36 #include "llvm/Support/Casting.h"
37 #include <cassert>
38 #include <cstdint>
39 #include <limits>
40 #include <string>
41 #include <utility>
42 
43 namespace clang {
44 
45 class AnalysisDeclContext;
46 class CXXRecordDecl;
47 class Decl;
48 class LocationContext;
49 class StackFrameContext;
50 
51 namespace ento {
52 
53 class CodeTextRegion;
54 class MemRegion;
55 class MemRegionManager;
56 class MemSpaceRegion;
57 class SValBuilder;
58 class SymbolicRegion;
59 class VarRegion;
60 
61 /// Represent a region's offset within the top level base region.
62 class RegionOffset {
63  /// The base region.
64  const MemRegion *R = nullptr;
65 
66  /// The bit offset within the base region. Can be negative.
67  int64_t Offset;
68 
69 public:
70  // We're using a const instead of an enumeration due to the size required;
71  // Visual Studio will only create enumerations of size int, not long long.
73 
74  RegionOffset() = default;
75  RegionOffset(const MemRegion *r, int64_t off) : R(r), Offset(off) {}
76 
77  /// It might return null.
78  const MemRegion *getRegion() const { return R; }
79 
80  bool hasSymbolicOffset() const { return Offset == Symbolic; }
81 
82  int64_t getOffset() const {
83  assert(!hasSymbolicOffset());
84  return Offset;
85  }
86 
87  bool isValid() const { return R; }
88 };
89 
90 //===----------------------------------------------------------------------===//
91 // Base region classes.
92 //===----------------------------------------------------------------------===//
93 
94 /// MemRegion - The root abstract class for all memory regions.
95 class MemRegion : public llvm::FoldingSetNode {
96 public:
97  enum Kind {
98 #define REGION(Id, Parent) Id ## Kind,
99 #define REGION_RANGE(Id, First, Last) BEGIN_##Id = First, END_##Id = Last,
100 #include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
101  };
102 
103 private:
104  const Kind kind;
105  mutable Optional<RegionOffset> cachedOffset;
106 
107 protected:
108  MemRegion(Kind k) : kind(k) {}
109  virtual ~MemRegion();
110 
111 public:
112  ASTContext &getContext() const;
113 
114  virtual void Profile(llvm::FoldingSetNodeID& ID) const = 0;
115 
116  virtual MemRegionManager &getMemRegionManager() const = 0;
117 
118  LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion *getMemorySpace() const;
119 
120  LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion *getBaseRegion() const;
121 
122  /// Recursively retrieve the region of the most derived class instance of
123  /// regions of C++ base class instances.
124  LLVM_ATTRIBUTE_RETURNS_NONNULL
125  const MemRegion *getMostDerivedObjectRegion() const;
126 
127  /// Check if the region is a subregion of the given region.
128  /// Each region is a subregion of itself.
129  virtual bool isSubRegionOf(const MemRegion *R) const;
130 
131  LLVM_ATTRIBUTE_RETURNS_NONNULL
132  const MemRegion *StripCasts(bool StripBaseAndDerivedCasts = true) const;
133 
134  /// If this is a symbolic region, returns the region. Otherwise,
135  /// goes up the base chain looking for the first symbolic base region.
136  /// It might return null.
137  const SymbolicRegion *getSymbolicBase() const;
138 
139  bool hasGlobalsOrParametersStorage() const;
140 
141  bool hasStackStorage() const;
142 
143  bool hasStackNonParametersStorage() const;
144 
145  bool hasStackParametersStorage() const;
146 
147  /// Compute the offset within the top level memory object.
148  RegionOffset getAsOffset() const;
149 
150  /// Get a string representation of a region for debug use.
151  std::string getString() const;
152 
153  virtual void dumpToStream(raw_ostream &os) const;
154 
155  void dump() const;
156 
157  /// Returns true if this region can be printed in a user-friendly way.
158  virtual bool canPrintPretty() const;
159 
160  /// Print the region for use in diagnostics.
161  virtual void printPretty(raw_ostream &os) const;
162 
163  /// Returns true if this region's textual representation can be used
164  /// as part of a larger expression.
165  virtual bool canPrintPrettyAsExpr() const;
166 
167  /// Print the region as expression.
168  ///
169  /// When this region represents a subexpression, the method is for printing
170  /// an expression containing it.
171  virtual void printPrettyAsExpr(raw_ostream &os) const;
172 
173  Kind getKind() const { return kind; }
174 
175  template<typename RegionTy> const RegionTy* getAs() const;
176  template <typename RegionTy>
177  LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy *castAs() const;
178 
179  virtual bool isBoundable() const { return false; }
180 
181  /// Get descriptive name for memory region. The name is obtained from
182  /// the variable/field declaration retrieved from the memory region.
183  /// Regions that point to an element of an array are returned as: "arr[0]".
184  /// Regions that point to a struct are returned as: "st.var".
185  //
186  /// \param UseQuotes Set if the name should be quoted.
187  ///
188  /// \returns variable name for memory region
189  std::string getDescriptiveName(bool UseQuotes = true) const;
190 
191  /// Retrieve source range from memory region. The range retrieval
192  /// is based on the decl obtained from the memory region.
193  /// For a VarRegion the range of the base region is returned.
194  /// For a FieldRegion the range of the field is returned.
195  /// If no declaration is found, an empty source range is returned.
196  /// The client is responsible for checking if the returned range is valid.
197  ///
198  /// \returns source range for declaration retrieved from memory region
199  SourceRange sourceRange() const;
200 };
201 
202 /// MemSpaceRegion - A memory region that represents a "memory space";
203 /// for example, the set of global variables, the stack frame, etc.
204 class MemSpaceRegion : public MemRegion {
205 protected:
207 
209  assert(classof(this));
210  }
211 
212  MemRegionManager &getMemRegionManager() const override { return Mgr; }
213 
214 public:
215  bool isBoundable() const override { return false; }
216 
217  void Profile(llvm::FoldingSetNodeID &ID) const override;
218 
219  static bool classof(const MemRegion *R) {
220  Kind k = R->getKind();
221  return k >= BEGIN_MEMSPACES && k <= END_MEMSPACES;
222  }
223 };
224 
225 /// CodeSpaceRegion - The memory space that holds the executable code of
226 /// functions and blocks.
228  friend class MemRegionManager;
229 
231  : MemSpaceRegion(mgr, CodeSpaceRegionKind) {}
232 
233 public:
234  void dumpToStream(raw_ostream &os) const override;
235 
236  static bool classof(const MemRegion *R) {
237  return R->getKind() == CodeSpaceRegionKind;
238  }
239 };
240 
242  virtual void anchor();
243 
244 protected:
246  assert(classof(this));
247  }
248 
249 public:
250  static bool classof(const MemRegion *R) {
251  Kind k = R->getKind();
252  return k >= BEGIN_GLOBAL_MEMSPACES && k <= END_GLOBAL_MEMSPACES;
253  }
254 };
255 
256 /// The region of the static variables within the current CodeTextRegion
257 /// scope.
258 ///
259 /// Currently, only the static locals are placed there, so we know that these
260 /// variables do not get invalidated by calls to other functions.
262  friend class MemRegionManager;
263 
264  const CodeTextRegion *CR;
265 
267  : GlobalsSpaceRegion(mgr, StaticGlobalSpaceRegionKind), CR(cr) {
268  assert(cr);
269  }
270 
271 public:
272  void Profile(llvm::FoldingSetNodeID &ID) const override;
273 
274  void dumpToStream(raw_ostream &os) const override;
275 
276  LLVM_ATTRIBUTE_RETURNS_NONNULL
277  const CodeTextRegion *getCodeRegion() const { return CR; }
278 
279  static bool classof(const MemRegion *R) {
280  return R->getKind() == StaticGlobalSpaceRegionKind;
281  }
282 };
283 
284 /// The region for all the non-static global variables.
285 ///
286 /// This class is further split into subclasses for efficient implementation of
287 /// invalidating a set of related global values as is done in
288 /// RegionStoreManager::invalidateRegions (instead of finding all the dependent
289 /// globals, we invalidate the whole parent region).
291  void anchor() override;
292 
293 protected:
295  : GlobalsSpaceRegion(mgr, k) {
296  assert(classof(this));
297  }
298 
299 public:
300  static bool classof(const MemRegion *R) {
301  Kind k = R->getKind();
302  return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
303  k <= END_NON_STATIC_GLOBAL_MEMSPACES;
304  }
305 };
306 
307 /// The region containing globals which are defined in system/external
308 /// headers and are considered modifiable by system calls (ex: errno).
310  friend class MemRegionManager;
311 
313  : NonStaticGlobalSpaceRegion(mgr, GlobalSystemSpaceRegionKind) {}
314 
315 public:
316  void dumpToStream(raw_ostream &os) const override;
317 
318  static bool classof(const MemRegion *R) {
319  return R->getKind() == GlobalSystemSpaceRegionKind;
320  }
321 };
322 
323 /// The region containing globals which are considered not to be modified
324 /// or point to data which could be modified as a result of a function call
325 /// (system or internal). Ex: Const global scalars would be modeled as part of
326 /// this region. This region also includes most system globals since they have
327 /// low chance of being modified.
329  friend class MemRegionManager;
330 
332  : NonStaticGlobalSpaceRegion(mgr, GlobalImmutableSpaceRegionKind) {}
333 
334 public:
335  void dumpToStream(raw_ostream &os) const override;
336 
337  static bool classof(const MemRegion *R) {
338  return R->getKind() == GlobalImmutableSpaceRegionKind;
339  }
340 };
341 
342 /// The region containing globals which can be modified by calls to
343 /// "internally" defined functions - (for now just) functions other then system
344 /// calls.
346  friend class MemRegionManager;
347 
349  : NonStaticGlobalSpaceRegion(mgr, GlobalInternalSpaceRegionKind) {}
350 
351 public:
352  void dumpToStream(raw_ostream &os) const override;
353 
354  static bool classof(const MemRegion *R) {
355  return R->getKind() == GlobalInternalSpaceRegionKind;
356  }
357 };
358 
360  friend class MemRegionManager;
361 
363  : MemSpaceRegion(mgr, HeapSpaceRegionKind) {}
364 
365 public:
366  void dumpToStream(raw_ostream &os) const override;
367 
368  static bool classof(const MemRegion *R) {
369  return R->getKind() == HeapSpaceRegionKind;
370  }
371 };
372 
374  friend class MemRegionManager;
375 
377  : MemSpaceRegion(mgr, UnknownSpaceRegionKind) {}
378 
379 public:
380  void dumpToStream(raw_ostream &os) const override;
381 
382  static bool classof(const MemRegion *R) {
383  return R->getKind() == UnknownSpaceRegionKind;
384  }
385 };
386 
388  virtual void anchor();
389 
390  const StackFrameContext *SFC;
391 
392 protected:
394  : MemSpaceRegion(mgr, k), SFC(sfc) {
395  assert(classof(this));
396  assert(sfc);
397  }
398 
399 public:
400  LLVM_ATTRIBUTE_RETURNS_NONNULL
401  const StackFrameContext *getStackFrame() const { return SFC; }
402 
403  void Profile(llvm::FoldingSetNodeID &ID) const override;
404 
405  static bool classof(const MemRegion *R) {
406  Kind k = R->getKind();
407  return k >= BEGIN_STACK_MEMSPACES && k <= END_STACK_MEMSPACES;
408  }
409 };
410 
412  friend class MemRegionManager;
413 
415  : StackSpaceRegion(mgr, StackLocalsSpaceRegionKind, sfc) {}
416 
417 public:
418  void dumpToStream(raw_ostream &os) const override;
419 
420  static bool classof(const MemRegion *R) {
421  return R->getKind() == StackLocalsSpaceRegionKind;
422  }
423 };
424 
426 private:
427  friend class MemRegionManager;
428 
430  : StackSpaceRegion(mgr, StackArgumentsSpaceRegionKind, sfc) {}
431 
432 public:
433  void dumpToStream(raw_ostream &os) const override;
434 
435  static bool classof(const MemRegion *R) {
436  return R->getKind() == StackArgumentsSpaceRegionKind;
437  }
438 };
439 
440 /// SubRegion - A region that subsets another larger region. Most regions
441 /// are subclasses of SubRegion.
442 class SubRegion : public MemRegion {
443  virtual void anchor();
444 
445 protected:
447 
448  SubRegion(const MemRegion *sReg, Kind k) : MemRegion(k), superRegion(sReg) {
449  assert(classof(this));
450  assert(sReg);
451  }
452 
453 public:
454  LLVM_ATTRIBUTE_RETURNS_NONNULL
455  const MemRegion* getSuperRegion() const {
456  return superRegion;
457  }
458 
459  MemRegionManager &getMemRegionManager() const override;
460 
461  bool isSubRegionOf(const MemRegion* R) const override;
462 
463  static bool classof(const MemRegion* R) {
464  return R->getKind() > END_MEMSPACES;
465  }
466 };
467 
468 //===----------------------------------------------------------------------===//
469 // MemRegion subclasses.
470 //===----------------------------------------------------------------------===//
471 
472 /// AllocaRegion - A region that represents an untyped blob of bytes created
473 /// by a call to 'alloca'.
474 class AllocaRegion : public SubRegion {
475  friend class MemRegionManager;
476 
477  // Block counter. Used to distinguish different pieces of memory allocated by
478  // alloca at the same call site.
479  unsigned Cnt;
480 
481  const Expr *Ex;
482 
483  AllocaRegion(const Expr *ex, unsigned cnt, const MemSpaceRegion *superRegion)
484  : SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {
485  assert(Ex);
486  }
487 
488  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr *Ex,
489  unsigned Cnt, const MemRegion *superRegion);
490 
491 public:
492  LLVM_ATTRIBUTE_RETURNS_NONNULL
493  const Expr *getExpr() const { return Ex; }
494 
495  bool isBoundable() const override { return true; }
496 
497  void Profile(llvm::FoldingSetNodeID& ID) const override;
498 
499  void dumpToStream(raw_ostream &os) const override;
500 
501  static bool classof(const MemRegion* R) {
502  return R->getKind() == AllocaRegionKind;
503  }
504 };
505 
506 /// TypedRegion - An abstract class representing regions that are typed.
507 class TypedRegion : public SubRegion {
508  void anchor() override;
509 
510 protected:
511  TypedRegion(const MemRegion *sReg, Kind k) : SubRegion(sReg, k) {
512  assert(classof(this));
513  }
514 
515 public:
516  virtual QualType getLocationType() const = 0;
517 
519  return getLocationType().getDesugaredType(Context);
520  }
521 
522  bool isBoundable() const override { return true; }
523 
524  static bool classof(const MemRegion* R) {
525  unsigned k = R->getKind();
526  return k >= BEGIN_TYPED_REGIONS && k <= END_TYPED_REGIONS;
527  }
528 };
529 
530 /// TypedValueRegion - An abstract class representing regions having a typed value.
532  void anchor() override;
533 
534 protected:
535  TypedValueRegion(const MemRegion* sReg, Kind k) : TypedRegion(sReg, k) {
536  assert(classof(this));
537  }
538 
539 public:
540  virtual QualType getValueType() const = 0;
541 
542  QualType getLocationType() const override {
543  // FIXME: We can possibly optimize this later to cache this value.
544  QualType T = getValueType();
545  ASTContext &ctx = getContext();
546  if (T->getAs<ObjCObjectType>())
547  return ctx.getObjCObjectPointerType(T);
548  return ctx.getPointerType(getValueType());
549  }
550 
552  QualType T = getValueType();
553  return T.getTypePtrOrNull() ? T.getDesugaredType(Context) : T;
554  }
555 
556  static bool classof(const MemRegion* R) {
557  unsigned k = R->getKind();
558  return k >= BEGIN_TYPED_VALUE_REGIONS && k <= END_TYPED_VALUE_REGIONS;
559  }
560 };
561 
562 class CodeTextRegion : public TypedRegion {
563  void anchor() override;
564 
565 protected:
566  CodeTextRegion(const MemSpaceRegion *sreg, Kind k) : TypedRegion(sreg, k) {
567  assert(classof(this));
568  }
569 
570 public:
571  bool isBoundable() const override { return false; }
572 
573  static bool classof(const MemRegion* R) {
574  Kind k = R->getKind();
575  return k >= BEGIN_CODE_TEXT_REGIONS && k <= END_CODE_TEXT_REGIONS;
576  }
577 };
578 
579 /// FunctionCodeRegion - A region that represents code texts of function.
581  friend class MemRegionManager;
582 
583  const NamedDecl *FD;
584 
585  FunctionCodeRegion(const NamedDecl *fd, const CodeSpaceRegion* sreg)
586  : CodeTextRegion(sreg, FunctionCodeRegionKind), FD(fd) {
587  assert(isa<ObjCMethodDecl>(fd) || isa<FunctionDecl>(fd));
588  }
589 
590  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const NamedDecl *FD,
591  const MemRegion*);
592 
593 public:
594  QualType getLocationType() const override {
595  const ASTContext &Ctx = getContext();
596  if (const auto *D = dyn_cast<FunctionDecl>(FD)) {
597  return Ctx.getPointerType(D->getType());
598  }
599 
600  assert(isa<ObjCMethodDecl>(FD));
601  assert(false && "Getting the type of ObjCMethod is not supported yet");
602 
603  // TODO: We might want to return a different type here (ex: id (*ty)(...))
604  // depending on how it is used.
605  return {};
606  }
607 
608  const NamedDecl *getDecl() const {
609  return FD;
610  }
611 
612  void dumpToStream(raw_ostream &os) const override;
613 
614  void Profile(llvm::FoldingSetNodeID& ID) const override;
615 
616  static bool classof(const MemRegion* R) {
617  return R->getKind() == FunctionCodeRegionKind;
618  }
619 };
620 
621 /// BlockCodeRegion - A region that represents code texts of blocks (closures).
622 /// Blocks are represented with two kinds of regions. BlockCodeRegions
623 /// represent the "code", while BlockDataRegions represent instances of blocks,
624 /// which correspond to "code+data". The distinction is important, because
625 /// like a closure a block captures the values of externally referenced
626 /// variables.
628  friend class MemRegionManager;
629 
630  const BlockDecl *BD;
632  CanQualType locTy;
633 
634  BlockCodeRegion(const BlockDecl *bd, CanQualType lTy,
635  AnalysisDeclContext *ac, const CodeSpaceRegion* sreg)
636  : CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {
637  assert(bd);
638  assert(ac);
639  assert(lTy->getTypePtr()->isBlockPointerType());
640  }
641 
642  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const BlockDecl *BD,
644  const MemRegion*);
645 
646 public:
647  QualType getLocationType() const override {
648  return locTy;
649  }
650 
651  LLVM_ATTRIBUTE_RETURNS_NONNULL
652  const BlockDecl *getDecl() const {
653  return BD;
654  }
655 
656  LLVM_ATTRIBUTE_RETURNS_NONNULL
658 
659  void dumpToStream(raw_ostream &os) const override;
660 
661  void Profile(llvm::FoldingSetNodeID& ID) const override;
662 
663  static bool classof(const MemRegion* R) {
664  return R->getKind() == BlockCodeRegionKind;
665  }
666 };
667 
668 /// BlockDataRegion - A region that represents a block instance.
669 /// Blocks are represented with two kinds of regions. BlockCodeRegions
670 /// represent the "code", while BlockDataRegions represent instances of blocks,
671 /// which correspond to "code+data". The distinction is important, because
672 /// like a closure a block captures the values of externally referenced
673 /// variables.
674 class BlockDataRegion : public TypedRegion {
675  friend class MemRegionManager;
676 
677  const BlockCodeRegion *BC;
678  const LocationContext *LC; // Can be null
679  unsigned BlockCount;
680  void *ReferencedVars = nullptr;
681  void *OriginalVars = nullptr;
682 
683  BlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc,
684  unsigned count, const MemSpaceRegion *sreg)
685  : TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
686  BlockCount(count) {
687  assert(bc);
688  assert(bc->getDecl());
689  assert(lc);
690  assert(isa<GlobalImmutableSpaceRegion>(sreg) ||
691  isa<StackLocalsSpaceRegion>(sreg) ||
692  isa<UnknownSpaceRegion>(sreg));
693  }
694 
695  static void ProfileRegion(llvm::FoldingSetNodeID&, const BlockCodeRegion *,
696  const LocationContext *, unsigned,
697  const MemRegion *);
698 
699 public:
700  LLVM_ATTRIBUTE_RETURNS_NONNULL
701  const BlockCodeRegion *getCodeRegion() const { return BC; }
702 
703  LLVM_ATTRIBUTE_RETURNS_NONNULL
704  const BlockDecl *getDecl() const { return BC->getDecl(); }
705 
706  QualType getLocationType() const override { return BC->getLocationType(); }
707 
709  const MemRegion * const *R;
710  const MemRegion * const *OriginalR;
711 
712  public:
713  explicit referenced_vars_iterator(const MemRegion * const *r,
714  const MemRegion * const *originalR)
715  : R(r), OriginalR(originalR) {}
716 
717  LLVM_ATTRIBUTE_RETURNS_NONNULL
718  const VarRegion *getCapturedRegion() const {
719  return cast<VarRegion>(*R);
720  }
721 
722  LLVM_ATTRIBUTE_RETURNS_NONNULL
723  const VarRegion *getOriginalRegion() const {
724  return cast<VarRegion>(*OriginalR);
725  }
726 
727  bool operator==(const referenced_vars_iterator &I) const {
728  assert((R == nullptr) == (I.R == nullptr));
729  return I.R == R;
730  }
731 
732  bool operator!=(const referenced_vars_iterator &I) const {
733  assert((R == nullptr) == (I.R == nullptr));
734  return I.R != R;
735  }
736 
738  ++R;
739  ++OriginalR;
740  return *this;
741  }
742  };
743 
744  /// Return the original region for a captured region, if
745  /// one exists. It might return null.
746  const VarRegion *getOriginalRegion(const VarRegion *VR) const;
747 
748  referenced_vars_iterator referenced_vars_begin() const;
749  referenced_vars_iterator referenced_vars_end() const;
750 
751  void dumpToStream(raw_ostream &os) const override;
752 
753  void Profile(llvm::FoldingSetNodeID& ID) const override;
754 
755  static bool classof(const MemRegion* R) {
756  return R->getKind() == BlockDataRegionKind;
757  }
758 
759 private:
760  void LazyInitializeReferencedVars();
761  std::pair<const VarRegion *, const VarRegion *>
762  getCaptureRegions(const VarDecl *VD);
763 };
764 
765 /// SymbolicRegion - A special, "non-concrete" region. Unlike other region
766 /// classes, SymbolicRegion represents a region that serves as an alias for
767 /// either a real region, a NULL pointer, etc. It essentially is used to
768 /// map the concept of symbolic values into the domain of regions. Symbolic
769 /// regions do not need to be typed.
770 class SymbolicRegion : public SubRegion {
771  friend class MemRegionManager;
772 
773  const SymbolRef sym;
774 
775  SymbolicRegion(const SymbolRef s, const MemSpaceRegion *sreg)
776  : SubRegion(sreg, SymbolicRegionKind), sym(s) {
777  // Because pointer arithmetic is represented by ElementRegion layers,
778  // the base symbol here should not contain any arithmetic.
779  assert(s && isa<SymbolData>(s));
780  assert(s->getType()->isAnyPointerType() ||
781  s->getType()->isReferenceType() ||
782  s->getType()->isBlockPointerType());
783  assert(isa<UnknownSpaceRegion>(sreg) || isa<HeapSpaceRegion>(sreg) ||
784  isa<GlobalSystemSpaceRegion>(sreg));
785  }
786 
787 public:
788  /// It might return null.
789  SymbolRef getSymbol() const { return sym; }
790 
791  bool isBoundable() const override { return true; }
792 
793  void Profile(llvm::FoldingSetNodeID& ID) const override;
794 
795  static void ProfileRegion(llvm::FoldingSetNodeID& ID,
796  SymbolRef sym,
797  const MemRegion* superRegion);
798 
799  void dumpToStream(raw_ostream &os) const override;
800 
801  static bool classof(const MemRegion* R) {
802  return R->getKind() == SymbolicRegionKind;
803  }
804 };
805 
806 /// StringRegion - Region associated with a StringLiteral.
808  friend class MemRegionManager;
809 
810  const StringLiteral *Str;
811 
812  StringRegion(const StringLiteral *str, const GlobalInternalSpaceRegion *sreg)
813  : TypedValueRegion(sreg, StringRegionKind), Str(str) {
814  assert(str);
815  }
816 
817  static void ProfileRegion(llvm::FoldingSetNodeID &ID,
818  const StringLiteral *Str,
819  const MemRegion *superRegion);
820 
821 public:
822  LLVM_ATTRIBUTE_RETURNS_NONNULL
823  const StringLiteral *getStringLiteral() const { return Str; }
824 
825  QualType getValueType() const override { return Str->getType(); }
826 
827  bool isBoundable() const override { return false; }
828 
829  void Profile(llvm::FoldingSetNodeID& ID) const override {
830  ProfileRegion(ID, Str, superRegion);
831  }
832 
833  void dumpToStream(raw_ostream &os) const override;
834 
835  static bool classof(const MemRegion* R) {
836  return R->getKind() == StringRegionKind;
837  }
838 };
839 
840 /// The region associated with an ObjCStringLiteral.
842  friend class MemRegionManager;
843 
844  const ObjCStringLiteral *Str;
845 
847  const GlobalInternalSpaceRegion *sreg)
848  : TypedValueRegion(sreg, ObjCStringRegionKind), Str(str) {
849  assert(str);
850  }
851 
852  static void ProfileRegion(llvm::FoldingSetNodeID &ID,
853  const ObjCStringLiteral *Str,
854  const MemRegion *superRegion);
855 
856 public:
857  LLVM_ATTRIBUTE_RETURNS_NONNULL
858  const ObjCStringLiteral *getObjCStringLiteral() const { return Str; }
859 
860  QualType getValueType() const override { return Str->getType(); }
861 
862  bool isBoundable() const override { return false; }
863 
864  void Profile(llvm::FoldingSetNodeID& ID) const override {
865  ProfileRegion(ID, Str, superRegion);
866  }
867 
868  void dumpToStream(raw_ostream &os) const override;
869 
870  static bool classof(const MemRegion* R) {
871  return R->getKind() == ObjCStringRegionKind;
872  }
873 };
874 
875 /// CompoundLiteralRegion - A memory region representing a compound literal.
876 /// Compound literals are essentially temporaries that are stack allocated
877 /// or in the global constant pool.
879  friend class MemRegionManager;
880 
881  const CompoundLiteralExpr *CL;
882 
884  const MemSpaceRegion *sReg)
885  : TypedValueRegion(sReg, CompoundLiteralRegionKind), CL(cl) {
886  assert(cl);
887  assert(isa<GlobalInternalSpaceRegion>(sReg) ||
888  isa<StackLocalsSpaceRegion>(sReg));
889  }
890 
891  static void ProfileRegion(llvm::FoldingSetNodeID& ID,
892  const CompoundLiteralExpr *CL,
893  const MemRegion* superRegion);
894 
895 public:
896  QualType getValueType() const override { return CL->getType(); }
897 
898  bool isBoundable() const override { return !CL->isFileScope(); }
899 
900  void Profile(llvm::FoldingSetNodeID& ID) const override;
901 
902  void dumpToStream(raw_ostream &os) const override;
903 
904  LLVM_ATTRIBUTE_RETURNS_NONNULL
905  const CompoundLiteralExpr *getLiteralExpr() const { return CL; }
906 
907  static bool classof(const MemRegion* R) {
908  return R->getKind() == CompoundLiteralRegionKind;
909  }
910 };
911 
912 class DeclRegion : public TypedValueRegion {
913 protected:
914  DeclRegion(const MemRegion *sReg, Kind k) : TypedValueRegion(sReg, k) {
915  assert(classof(this));
916  }
917 
918 public:
919  // TODO what does this return?
920  virtual const ValueDecl *getDecl() const = 0;
921 
922  static bool classof(const MemRegion* R) {
923  unsigned k = R->getKind();
924  return k >= BEGIN_DECL_REGIONS && k <= END_DECL_REGIONS;
925  }
926 };
927 
928 class VarRegion : public DeclRegion {
929  friend class MemRegionManager;
930 
931 protected:
932  // Constructors and protected methods.
933  VarRegion(const MemRegion *sReg, Kind k) : DeclRegion(sReg, k) {
934  // VarRegion appears in unknown space when it's a block variable as seen
935  // from a block using it, when this block is analyzed at top-level.
936  // Other block variables appear within block data regions,
937  // which, unlike everything else on this list, are not memory spaces.
938  assert(isa<GlobalsSpaceRegion>(sReg) || isa<StackSpaceRegion>(sReg) ||
939  isa<BlockDataRegion>(sReg) || isa<UnknownSpaceRegion>(sReg));
940  }
941 
942 public:
943  // TODO what does this return?
944  const VarDecl *getDecl() const override = 0;
945 
946  /// It might return null.
947  const StackFrameContext *getStackFrame() const;
948 
949  QualType getValueType() const override {
950  // FIXME: We can cache this if needed.
951  return getDecl()->getType();
952  }
953 
954  static bool classof(const MemRegion *R) {
955  unsigned k = R->getKind();
956  return k >= BEGIN_VAR_REGIONS && k <= END_VAR_REGIONS;
957  }
958 };
959 
960 class NonParamVarRegion : public VarRegion {
961  friend class MemRegionManager;
962 
963  const VarDecl *VD;
964 
965  // Constructors and private methods.
966  NonParamVarRegion(const VarDecl *vd, const MemRegion *sReg)
967  : VarRegion(sReg, NonParamVarRegionKind), VD(vd) {
968  // VarRegion appears in unknown space when it's a block variable as seen
969  // from a block using it, when this block is analyzed at top-level.
970  // Other block variables appear within block data regions,
971  // which, unlike everything else on this list, are not memory spaces.
972  assert(isa<GlobalsSpaceRegion>(sReg) || isa<StackSpaceRegion>(sReg) ||
973  isa<BlockDataRegion>(sReg) || isa<UnknownSpaceRegion>(sReg));
974  assert(vd);
975  }
976 
977  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const VarDecl *VD,
978  const MemRegion *superRegion);
979 
980 public:
981  void Profile(llvm::FoldingSetNodeID &ID) const override;
982 
983  LLVM_ATTRIBUTE_RETURNS_NONNULL
984  const VarDecl *getDecl() const override { return VD; }
985 
986  QualType getValueType() const override {
987  // FIXME: We can cache this if needed.
988  return getDecl()->getType();
989  }
990 
991  void dumpToStream(raw_ostream &os) const override;
992 
993  bool canPrintPrettyAsExpr() const override;
994 
995  void printPrettyAsExpr(raw_ostream &os) const override;
996 
997  static bool classof(const MemRegion* R) {
998  return R->getKind() == NonParamVarRegionKind;
999  }
1000 };
1001 
1002 /// ParamVarRegion - Represents a region for paremters. Only parameters of the
1003 /// function in the current stack frame are represented as `ParamVarRegion`s.
1004 /// Parameters of top-level analyzed functions as well as captured paremeters
1005 /// by lambdas and blocks are repesented as `VarRegion`s.
1006 
1007 // FIXME: `ParamVarRegion` only supports parameters of functions, C++
1008 // constructors, blocks and Objective-C methods with existing `Decl`. Upon
1009 // implementing stack frame creations for functions without decl (functions
1010 // passed by unknown function pointer) methods of `ParamVarRegion` must be
1011 // updated.
1012 class ParamVarRegion : public VarRegion {
1013  friend class MemRegionManager;
1014 
1015  const Expr *OriginExpr;
1016  unsigned Index;
1017 
1018  ParamVarRegion(const Expr *OE, unsigned Idx, const MemRegion *SReg)
1019  : VarRegion(SReg, ParamVarRegionKind), OriginExpr(OE), Index(Idx) {
1020  assert(!cast<StackSpaceRegion>(SReg)->getStackFrame()->inTopFrame());
1021  assert(OriginExpr);
1022  }
1023 
1024  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const Expr *OE,
1025  unsigned Idx, const MemRegion *SReg);
1026 
1027 public:
1028  LLVM_ATTRIBUTE_RETURNS_NONNULL
1029  const Expr *getOriginExpr() const { return OriginExpr; }
1030  unsigned getIndex() const { return Index; }
1031 
1032  void Profile(llvm::FoldingSetNodeID& ID) const override;
1033 
1034  void dumpToStream(raw_ostream &os) const override;
1035 
1036  QualType getValueType() const override;
1037 
1038  /// TODO: What does this return?
1039  const ParmVarDecl *getDecl() const override;
1040 
1041  bool canPrintPrettyAsExpr() const override;
1042  void printPrettyAsExpr(raw_ostream &os) const override;
1043 
1044  static bool classof(const MemRegion *R) {
1045  return R->getKind() == ParamVarRegionKind;
1046  }
1047 };
1048 
1049 /// CXXThisRegion - Represents the region for the implicit 'this' parameter
1050 /// in a call to a C++ method. This region doesn't represent the object
1051 /// referred to by 'this', but rather 'this' itself.
1053  friend class MemRegionManager;
1054 
1055  CXXThisRegion(const PointerType *thisPointerTy,
1056  const StackArgumentsSpaceRegion *sReg)
1057  : TypedValueRegion(sReg, CXXThisRegionKind),
1058  ThisPointerTy(thisPointerTy) {
1059  assert(ThisPointerTy->getPointeeType()->getAsCXXRecordDecl() &&
1060  "Invalid region type!");
1061  }
1062 
1063  static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1064  const PointerType *PT,
1065  const MemRegion *sReg);
1066 
1067 public:
1068  void Profile(llvm::FoldingSetNodeID &ID) const override;
1069 
1070  QualType getValueType() const override {
1071  return QualType(ThisPointerTy, 0);
1072  }
1073 
1074  void dumpToStream(raw_ostream &os) const override;
1075 
1076  static bool classof(const MemRegion* R) {
1077  return R->getKind() == CXXThisRegionKind;
1078  }
1079 
1080 private:
1081  const PointerType *ThisPointerTy;
1082 };
1083 
1084 class FieldRegion : public DeclRegion {
1085  friend class MemRegionManager;
1086 
1087  const FieldDecl *FD;
1088 
1089  FieldRegion(const FieldDecl *fd, const SubRegion *sReg)
1090  : DeclRegion(sReg, FieldRegionKind), FD(fd) {
1091  assert(FD);
1092  }
1093 
1094  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const FieldDecl *FD,
1095  const MemRegion* superRegion) {
1096  ID.AddInteger(static_cast<unsigned>(FieldRegionKind));
1097  ID.AddPointer(FD);
1098  ID.AddPointer(superRegion);
1099  }
1100 
1101 public:
1102  LLVM_ATTRIBUTE_RETURNS_NONNULL
1103  const FieldDecl *getDecl() const override { return FD; }
1104 
1105  void Profile(llvm::FoldingSetNodeID &ID) const override;
1106 
1107  QualType getValueType() const override {
1108  // FIXME: We can cache this if needed.
1109  return getDecl()->getType();
1110  }
1111 
1112  void dumpToStream(raw_ostream &os) const override;
1113 
1114  bool canPrintPretty() const override;
1115  void printPretty(raw_ostream &os) const override;
1116  bool canPrintPrettyAsExpr() const override;
1117  void printPrettyAsExpr(raw_ostream &os) const override;
1118 
1119  static bool classof(const MemRegion* R) {
1120  return R->getKind() == FieldRegionKind;
1121  }
1122 };
1123 
1124 class ObjCIvarRegion : public DeclRegion {
1125  friend class MemRegionManager;
1126 
1127  const ObjCIvarDecl *IVD;
1128 
1129  ObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *sReg);
1130 
1131  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const ObjCIvarDecl *ivd,
1132  const MemRegion* superRegion);
1133 
1134 public:
1135  LLVM_ATTRIBUTE_RETURNS_NONNULL
1136  const ObjCIvarDecl *getDecl() const override;
1137 
1138  void Profile(llvm::FoldingSetNodeID& ID) const override;
1139 
1140  QualType getValueType() const override;
1141 
1142  bool canPrintPrettyAsExpr() const override;
1143  void printPrettyAsExpr(raw_ostream &os) const override;
1144 
1145  void dumpToStream(raw_ostream &os) const override;
1146 
1147  static bool classof(const MemRegion* R) {
1148  return R->getKind() == ObjCIvarRegionKind;
1149  }
1150 };
1151 
1152 //===----------------------------------------------------------------------===//
1153 // Auxiliary data classes for use with MemRegions.
1154 //===----------------------------------------------------------------------===//
1155 
1157  friend class ElementRegion;
1158 
1159  const MemRegion *Region;
1160  CharUnits Offset;
1161 
1162  RegionRawOffset(const MemRegion* reg, CharUnits offset = CharUnits::Zero())
1163  : Region(reg), Offset(offset) {}
1164 
1165 public:
1166  // FIXME: Eventually support symbolic offsets.
1167  CharUnits getOffset() const { return Offset; }
1168 
1169  // It might return null.
1170  const MemRegion *getRegion() const { return Region; }
1171 
1172  void dumpToStream(raw_ostream &os) const;
1173  void dump() const;
1174 };
1175 
1176 /// ElementRegion is used to represent both array elements and casts.
1178  friend class MemRegionManager;
1179 
1180  QualType ElementType;
1181  NonLoc Index;
1182 
1183  ElementRegion(QualType elementType, NonLoc Idx, const SubRegion *sReg)
1184  : TypedValueRegion(sReg, ElementRegionKind), ElementType(elementType),
1185  Index(Idx) {
1186  assert((!isa<nonloc::ConcreteInt>(Idx) ||
1187  Idx.castAs<nonloc::ConcreteInt>().getValue().isSigned()) &&
1188  "The index must be signed");
1189  assert(!elementType.isNull() && !elementType->isVoidType() &&
1190  "Invalid region type!");
1191  }
1192 
1193  static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType elementType,
1194  SVal Idx, const MemRegion* superRegion);
1195 
1196 public:
1197  NonLoc getIndex() const { return Index; }
1198 
1199  QualType getValueType() const override { return ElementType; }
1200 
1201  QualType getElementType() const { return ElementType; }
1202 
1203  /// Compute the offset within the array. The array might also be a subobject.
1205 
1206  void dumpToStream(raw_ostream &os) const override;
1207 
1208  void Profile(llvm::FoldingSetNodeID& ID) const override;
1209 
1210  static bool classof(const MemRegion* R) {
1211  return R->getKind() == ElementRegionKind;
1212  }
1213 };
1214 
1215 // C++ temporary object associated with an expression.
1217  friend class MemRegionManager;
1218 
1219  Expr const *Ex;
1220 
1221  CXXTempObjectRegion(Expr const *E, MemSpaceRegion const *sReg)
1222  : TypedValueRegion(sReg, CXXTempObjectRegionKind), Ex(E) {
1223  assert(E);
1224  assert(isa<StackLocalsSpaceRegion>(sReg) ||
1225  isa<GlobalInternalSpaceRegion>(sReg));
1226  }
1227 
1228  static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1229  Expr const *E, const MemRegion *sReg);
1230 
1231 public:
1232  LLVM_ATTRIBUTE_RETURNS_NONNULL
1233  const Expr *getExpr() const { return Ex; }
1234 
1235  QualType getValueType() const override { return Ex->getType(); }
1236 
1237  void dumpToStream(raw_ostream &os) const override;
1238 
1239  void Profile(llvm::FoldingSetNodeID &ID) const override;
1240 
1241  static bool classof(const MemRegion* R) {
1242  return R->getKind() == CXXTempObjectRegionKind;
1243  }
1244 };
1245 
1246 // CXXBaseObjectRegion represents a base object within a C++ object. It is
1247 // identified by the base class declaration and the region of its parent object.
1249  friend class MemRegionManager;
1250 
1251  llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> Data;
1252 
1253  CXXBaseObjectRegion(const CXXRecordDecl *RD, bool IsVirtual,
1254  const SubRegion *SReg)
1255  : TypedValueRegion(SReg, CXXBaseObjectRegionKind), Data(RD, IsVirtual) {
1256  assert(RD);
1257  }
1258 
1259  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const CXXRecordDecl *RD,
1260  bool IsVirtual, const MemRegion *SReg);
1261 
1262 public:
1263  LLVM_ATTRIBUTE_RETURNS_NONNULL
1264  const CXXRecordDecl *getDecl() const { return Data.getPointer(); }
1265  bool isVirtual() const { return Data.getInt(); }
1266 
1267  QualType getValueType() const override;
1268 
1269  void dumpToStream(raw_ostream &os) const override;
1270 
1271  void Profile(llvm::FoldingSetNodeID &ID) const override;
1272 
1273  bool canPrintPrettyAsExpr() const override;
1274 
1275  void printPrettyAsExpr(raw_ostream &os) const override;
1276 
1277  static bool classof(const MemRegion *region) {
1278  return region->getKind() == CXXBaseObjectRegionKind;
1279  }
1280 };
1281 
1282 // CXXDerivedObjectRegion represents a derived-class object that surrounds
1283 // a C++ object. It is identified by the derived class declaration and the
1284 // region of its parent object. It is a bit counter-intuitive (but not otherwise
1285 // unseen) that this region represents a larger segment of memory that its
1286 // super-region.
1288  friend class MemRegionManager;
1289 
1290  const CXXRecordDecl *DerivedD;
1291 
1292  CXXDerivedObjectRegion(const CXXRecordDecl *DerivedD, const SubRegion *SReg)
1293  : TypedValueRegion(SReg, CXXDerivedObjectRegionKind), DerivedD(DerivedD) {
1294  assert(DerivedD);
1295  // In case of a concrete region, it should always be possible to model
1296  // the base-to-derived cast by undoing a previous derived-to-base cast,
1297  // otherwise the cast is most likely ill-formed.
1298  assert(SReg->getSymbolicBase() &&
1299  "Should have unwrapped a base region instead!");
1300  }
1301 
1302  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const CXXRecordDecl *RD,
1303  const MemRegion *SReg);
1304 
1305 public:
1306  LLVM_ATTRIBUTE_RETURNS_NONNULL
1307  const CXXRecordDecl *getDecl() const { return DerivedD; }
1308 
1309  QualType getValueType() const override;
1310 
1311  void dumpToStream(raw_ostream &os) const override;
1312 
1313  void Profile(llvm::FoldingSetNodeID &ID) const override;
1314 
1315  bool canPrintPrettyAsExpr() const override;
1316 
1317  void printPrettyAsExpr(raw_ostream &os) const override;
1318 
1319  static bool classof(const MemRegion *region) {
1320  return region->getKind() == CXXDerivedObjectRegionKind;
1321  }
1322 };
1323 
1324 template<typename RegionTy>
1325 const RegionTy* MemRegion::getAs() const {
1326  if (const auto *RT = dyn_cast<RegionTy>(this))
1327  return RT;
1328 
1329  return nullptr;
1330 }
1331 
1332 template <typename RegionTy>
1333 LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy *MemRegion::castAs() const {
1334  return cast<RegionTy>(this);
1335 }
1336 
1337 //===----------------------------------------------------------------------===//
1338 // MemRegionManager - Factory object for creating regions.
1339 //===----------------------------------------------------------------------===//
1340 
1342  ASTContext &Ctx;
1343  llvm::BumpPtrAllocator& A;
1344 
1345  llvm::FoldingSet<MemRegion> Regions;
1346 
1347  GlobalInternalSpaceRegion *InternalGlobals = nullptr;
1348  GlobalSystemSpaceRegion *SystemGlobals = nullptr;
1349  GlobalImmutableSpaceRegion *ImmutableGlobals = nullptr;
1350 
1351  llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *>
1352  StackLocalsSpaceRegions;
1353  llvm::DenseMap<const StackFrameContext *, StackArgumentsSpaceRegion *>
1354  StackArgumentsSpaceRegions;
1355  llvm::DenseMap<const CodeTextRegion *, StaticGlobalSpaceRegion *>
1356  StaticsGlobalSpaceRegions;
1357 
1358  HeapSpaceRegion *heap = nullptr;
1359  UnknownSpaceRegion *unknown = nullptr;
1360  CodeSpaceRegion *code = nullptr;
1361 
1362 public:
1363  MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a) : Ctx(c), A(a) {}
1365 
1366  ASTContext &getContext() { return Ctx; }
1367 
1368  llvm::BumpPtrAllocator &getAllocator() { return A; }
1369 
1370  /// \returns The static size in bytes of the region \p MR.
1371  /// \note The region \p MR must be a 'SubRegion'.
1373  SValBuilder &SVB) const;
1374 
1375  /// getStackLocalsRegion - Retrieve the memory region associated with the
1376  /// specified stack frame.
1377  const StackLocalsSpaceRegion *
1379 
1380  /// getStackArgumentsRegion - Retrieve the memory region associated with
1381  /// function/method arguments of the specified stack frame.
1384 
1385  /// getGlobalsRegion - Retrieve the memory region associated with
1386  /// global variables.
1388  MemRegion::Kind K = MemRegion::GlobalInternalSpaceRegionKind,
1389  const CodeTextRegion *R = nullptr);
1390 
1391  /// getHeapRegion - Retrieve the memory region associated with the
1392  /// generic "heap".
1393  const HeapSpaceRegion *getHeapRegion();
1394 
1395  /// getUnknownRegion - Retrieve the memory region associated with unknown
1396  /// memory space.
1398 
1399  const CodeSpaceRegion *getCodeRegion();
1400 
1401  /// getAllocaRegion - Retrieve a region associated with a call to alloca().
1402  const AllocaRegion *getAllocaRegion(const Expr *Ex, unsigned Cnt,
1403  const LocationContext *LC);
1404 
1405  /// getCompoundLiteralRegion - Retrieve the region associated with a
1406  /// given CompoundLiteral.
1407  const CompoundLiteralRegion*
1409  const LocationContext *LC);
1410 
1411  /// getCXXThisRegion - Retrieve the [artificial] region associated with the
1412  /// parameter 'this'.
1413  const CXXThisRegion *getCXXThisRegion(QualType thisPointerTy,
1414  const LocationContext *LC);
1415 
1416  /// Retrieve or create a "symbolic" memory region.
1417  /// If no memory space is specified, `UnknownSpaceRegion` will be used.
1418  const SymbolicRegion *
1419  getSymbolicRegion(SymbolRef Sym, const MemSpaceRegion *MemSpace = nullptr);
1420 
1421  /// Return a unique symbolic region belonging to heap memory space.
1423 
1424  const StringRegion *getStringRegion(const StringLiteral *Str);
1425 
1427 
1428  /// getVarRegion - Retrieve or create the memory region associated with
1429  /// a specified VarDecl and LocationContext.
1430  const VarRegion *getVarRegion(const VarDecl *VD, const LocationContext *LC);
1431 
1432  /// getVarRegion - Retrieve or create the memory region associated with
1433  /// a specified VarDecl and LocationContext.
1435  const MemRegion *superR);
1436 
1437  /// getParamVarRegion - Retrieve or create the memory region
1438  /// associated with a specified CallExpr, Index and LocationContext.
1439  const ParamVarRegion *getParamVarRegion(const Expr *OriginExpr,
1440  unsigned Index,
1441  const LocationContext *LC);
1442 
1443  /// getElementRegion - Retrieve the memory region associated with the
1444  /// associated element type, index, and super region.
1445  const ElementRegion *getElementRegion(QualType elementType, NonLoc Idx,
1446  const SubRegion *superRegion,
1447  ASTContext &Ctx);
1448 
1450  const SubRegion *superRegion) {
1451  return getElementRegion(ER->getElementType(), ER->getIndex(),
1452  superRegion, ER->getContext());
1453  }
1454 
1455  /// getFieldRegion - Retrieve or create the memory region associated with
1456  /// a specified FieldDecl. 'superRegion' corresponds to the containing
1457  /// memory region (which typically represents the memory representing
1458  /// a structure or class).
1459  const FieldRegion *getFieldRegion(const FieldDecl *fd,
1460  const SubRegion* superRegion);
1461 
1463  const SubRegion *superRegion) {
1464  return getFieldRegion(FR->getDecl(), superRegion);
1465  }
1466 
1467  /// getObjCIvarRegion - Retrieve or create the memory region associated with
1468  /// a specified Objective-c instance variable. 'superRegion' corresponds
1469  /// to the containing region (which typically represents the Objective-C
1470  /// object).
1471  const ObjCIvarRegion *getObjCIvarRegion(const ObjCIvarDecl *ivd,
1472  const SubRegion* superRegion);
1473 
1475  LocationContext const *LC);
1476 
1477  /// Create a CXXBaseObjectRegion with the given base class for region
1478  /// \p Super.
1479  ///
1480  /// The type of \p Super is assumed be a class deriving from \p BaseClass.
1481  const CXXBaseObjectRegion *
1482  getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super,
1483  bool IsVirtual);
1484 
1485  /// Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different
1486  /// super region.
1487  const CXXBaseObjectRegion *
1489  const SubRegion *superRegion) {
1490  return getCXXBaseObjectRegion(baseReg->getDecl(), superRegion,
1491  baseReg->isVirtual());
1492  }
1493 
1494  /// Create a CXXDerivedObjectRegion with the given derived class for region
1495  /// \p Super. This should not be used for casting an existing
1496  /// CXXBaseObjectRegion back to the derived type; instead, CXXBaseObjectRegion
1497  /// should be removed.
1498  const CXXDerivedObjectRegion *
1499  getCXXDerivedObjectRegion(const CXXRecordDecl *BaseClass,
1500  const SubRegion *Super);
1501 
1503  const BlockCodeRegion *getBlockCodeRegion(const BlockDecl *BD,
1504  CanQualType locTy,
1505  AnalysisDeclContext *AC);
1506 
1507  /// getBlockDataRegion - Get the memory region associated with an instance
1508  /// of a block. Unlike many other MemRegions, the LocationContext*
1509  /// argument is allowed to be NULL for cases where we have no known
1510  /// context.
1512  const LocationContext *lc,
1513  unsigned blockCount);
1514 
1515  /// Create a CXXTempObjectRegion for temporaries which are lifetime-extended
1516  /// by static references. This differs from getCXXTempObjectRegion in the
1517  /// super-region used.
1519 
1520 private:
1521  template <typename RegionTy, typename SuperTy,
1522  typename Arg1Ty>
1523  RegionTy* getSubRegion(const Arg1Ty arg1,
1524  const SuperTy* superRegion);
1525 
1526  template <typename RegionTy, typename SuperTy,
1527  typename Arg1Ty, typename Arg2Ty>
1528  RegionTy* getSubRegion(const Arg1Ty arg1, const Arg2Ty arg2,
1529  const SuperTy* superRegion);
1530 
1531  template <typename RegionTy, typename SuperTy,
1532  typename Arg1Ty, typename Arg2Ty, typename Arg3Ty>
1533  RegionTy* getSubRegion(const Arg1Ty arg1, const Arg2Ty arg2,
1534  const Arg3Ty arg3,
1535  const SuperTy* superRegion);
1536 
1537  template <typename REG>
1538  const REG* LazyAllocate(REG*& region);
1539 
1540  template <typename REG, typename ARG>
1541  const REG* LazyAllocate(REG*& region, ARG a);
1542 };
1543 
1544 //===----------------------------------------------------------------------===//
1545 // Out-of-line member definitions.
1546 //===----------------------------------------------------------------------===//
1547 
1549  return getMemRegionManager().getContext();
1550 }
1551 
1552 //===----------------------------------------------------------------------===//
1553 // Means for storing region/symbol handling traits.
1554 //===----------------------------------------------------------------------===//
1555 
1556 /// Information about invalidation for a particular region/symbol.
1558  using StorageTypeForKinds = unsigned char;
1559 
1560  llvm::DenseMap<const MemRegion *, StorageTypeForKinds> MRTraitsMap;
1561  llvm::DenseMap<SymbolRef, StorageTypeForKinds> SymTraitsMap;
1562 
1563  using const_region_iterator =
1564  llvm::DenseMap<const MemRegion *, StorageTypeForKinds>::const_iterator;
1565  using const_symbol_iterator =
1566  llvm::DenseMap<SymbolRef, StorageTypeForKinds>::const_iterator;
1567 
1568 public:
1569  /// Describes different invalidation traits.
1571  /// Tells that a region's contents is not changed.
1573 
1574  /// Suppress pointer-escaping of a region.
1576 
1577  // Do not invalidate super region.
1579 
1580  /// When applied to a MemSpaceRegion, indicates the entire memory space
1581  /// should be invalidated.
1583 
1584  // Do not forget to extend StorageTypeForKinds if number of traits exceed
1585  // the number of bits StorageTypeForKinds can store.
1586  };
1587 
1588  void setTrait(SymbolRef Sym, InvalidationKinds IK);
1589  void setTrait(const MemRegion *MR, InvalidationKinds IK);
1590  bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const;
1591  bool hasTrait(const MemRegion *MR, InvalidationKinds IK) const;
1592 };
1593 
1594 //===----------------------------------------------------------------------===//
1595 // Pretty-printing regions.
1596 //===----------------------------------------------------------------------===//
1597 inline raw_ostream &operator<<(raw_ostream &os, const MemRegion *R) {
1598  R->dumpToStream(os);
1599  return os;
1600 }
1601 
1602 } // namespace ento
1603 
1604 } // namespace clang
1605 
1606 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
clang::ento::MemRegionManager::getNonParamVarRegion
const NonParamVarRegion * getNonParamVarRegion(const VarDecl *VD, const MemRegion *superR)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
Definition: MemRegion.cpp:1049
clang::ento::TypedValueRegion::getDesugaredValueType
QualType getDesugaredValueType(ASTContext &Context) const
Definition: MemRegion.h:551
clang::ento::ObjCStringRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:860
clang::ento::CXXThisRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:277
clang::ento::ObjCStringRegion
The region associated with an ObjCStringLiteral.
Definition: MemRegion.h:841
clang::ento::StringRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:827
clang::ento::DeclRegion::DeclRegion
DeclRegion(const MemRegion *sReg, Kind k)
Definition: MemRegion.h:914
max
__DEVICE__ int max(int __a, int __b)
Definition: __clang_cuda_math.h:196
clang::ento::MemRegionManager::getObjCIvarRegion
const ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
Definition: MemRegion.cpp:1167
clang::ento::ObjCIvarRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:1147
clang::ento::FunctionCodeRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:460
clang::ento::MemRegionManager::getStackArgumentsRegion
const StackArgumentsSpaceRegion * getStackArgumentsRegion(const StackFrameContext *STC)
getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the...
Definition: MemRegion.cpp:856
clang::ento::FieldRegion::canPrintPretty
bool canPrintPretty() const override
Returns true if this region can be printed in a user-friendly way.
Definition: MemRegion.cpp:635
clang::ento::CXXTempObjectRegion::getExpr
const LLVM_ATTRIBUTE_RETURNS_NONNULL Expr * getExpr() const
Definition: MemRegion.h:1233
clang::Type::isBlockPointerType
bool isBlockPointerType() const
Definition: Type.h:6815
clang::LocationContext
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Definition: AnalysisDeclContext.h:215
clang::ento::CXXBaseObjectRegion::canPrintPrettyAsExpr
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
Definition: MemRegion.cpp:659
SVals.h
clang::ento::MemRegionManager::getCodeRegion
const CodeSpaceRegion * getCodeRegion()
Definition: MemRegion.cpp:898
clang::ento::CXXDerivedObjectRegion::classof
static bool classof(const MemRegion *region)
Definition: MemRegion.h:1319
clang::ento::CompoundLiteralRegion::getLiteralExpr
const LLVM_ATTRIBUTE_RETURNS_NONNULL CompoundLiteralExpr * getLiteralExpr() const
Definition: MemRegion.h:905
clang::ento::MemRegion::Profile
virtual void Profile(llvm::FoldingSetNodeID &ID) const =0
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::ento::DeclRegion::getDecl
virtual const ValueDecl * getDecl() const =0
clang::ento::MemRegion::getMemRegionManager
virtual MemRegionManager & getMemRegionManager() const =0
clang::ento::CXXDerivedObjectRegion::getDecl
const LLVM_ATTRIBUTE_RETURNS_NONNULL CXXRecordDecl * getDecl() const
Definition: MemRegion.h:1307
clang::ento::GlobalsSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:250
clang::ento::SVal::castAs
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition: SVals.h:101
clang::ento::FieldRegion::canPrintPrettyAsExpr
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
Definition: MemRegion.cpp:639
clang::ento::CXXTempObjectRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:1235
clang::ento::MemRegionManager::getCompoundLiteralRegion
const CompoundLiteralRegion * getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC)
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
Definition: MemRegion.cpp:1099
clang::ento::NonLoc
Definition: SVals.h:262
clang::ento::BlockDataRegion::referenced_vars_begin
referenced_vars_iterator referenced_vars_begin() const
Definition: MemRegion.cpp:1668
clang::ento::SymbolicRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:791
clang::ento::MemRegion::dump
void dump() const
Definition: MemRegion.cpp:441
AnalysisDeclContext.h
clang::ento::DefinedOrUnknownSVal
Definition: SVals.h:217
clang::ento::FunctionCodeRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:352
clang::ento::MemRegion::StripCasts
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
Definition: MemRegion.cpp:1323
clang::ento::MemRegion::hasStackParametersStorage
bool hasStackParametersStorage() const
Definition: MemRegion.cpp:1277
clang::ento::ObjCStringRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:870
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::ento::MemRegionManager::getElementRegionWithSuper
const ElementRegion * getElementRegionWithSuper(const ElementRegion *ER, const SubRegion *superRegion)
Definition: MemRegion.h:1449
clang::ento::RegionAndSymbolInvalidationTraits::TK_SuppressEscape
@ TK_SuppressEscape
Suppress pointer-escaping of a region.
Definition: MemRegion.h:1575
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:731
clang::ento::StringRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:835
clang::ento::BlockDataRegion::referenced_vars_iterator::getOriginalRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL VarRegion * getOriginalRegion() const
Definition: MemRegion.h:723
clang::AnalysisDeclContext
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Definition: AnalysisDeclContext.h:72
clang::ento::MemRegionManager::getSymbolicHeapRegion
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
Definition: MemRegion.cpp:1156
clang::ento::TypedRegion::getDesugaredLocationType
QualType getDesugaredLocationType(ASTContext &Context) const
Definition: MemRegion.h:518
clang::ento::ElementRegion::getIndex
NonLoc getIndex() const
Definition: MemRegion.h:1197
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2862
clang::ento::FieldRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:1107
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1680
clang::ento::BlockDataRegion::getLocationType
QualType getLocationType() const override
Definition: MemRegion.h:706
clang::ento::CompoundLiteralRegion
CompoundLiteralRegion - A memory region representing a compound literal.
Definition: MemRegion.h:878
clang::ento::CompoundLiteralRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:896
clang::ento::NonParamVarRegion::canPrintPrettyAsExpr
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
Definition: MemRegion.cpp:612
clang::ento::CXXDerivedObjectRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:415
clang::ento::CompoundLiteralRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:257
clang::ento::MemSpaceRegion
MemSpaceRegion - A memory region that represents a "memory space"; for example, the set of global var...
Definition: MemRegion.h:204
clang::ento::StaticGlobalSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:549
clang::ento::MemRegionManager::getBlockDataRegion
const BlockDataRegion * getBlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount)
getBlockDataRegion - Get the memory region associated with an instance of a block.
Definition: MemRegion.cpp:1065
clang::ento::BlockDataRegion::getCodeRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL BlockCodeRegion * getCodeRegion() const
Definition: MemRegion.h:701
clang::ento::ObjCIvarRegion
Definition: MemRegion.h:1124
llvm::Optional
Definition: LLVM.h:40
clang::ento::MemRegion::hasGlobalsOrParametersStorage
bool hasGlobalsOrParametersStorage() const
Definition: MemRegion.cpp:1281
clang::ento::MemRegionManager::getUnknownRegion
const UnknownSpaceRegion * getUnknownRegion()
getUnknownRegion - Retrieve the memory region associated with unknown memory space.
Definition: MemRegion.cpp:894
clang::ento::SubRegion::isSubRegionOf
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
Definition: MemRegion.cpp:134
clang::ento::GlobalSystemSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:557
clang::StackFrameContext
It represents a stack frame of the call stack (based on CallEvent).
Definition: AnalysisDeclContext.h:299
clang::ento::MemRegionManager::getHeapRegion
const HeapSpaceRegion * getHeapRegion()
getHeapRegion - Retrieve the memory region associated with the generic "heap".
Definition: MemRegion.cpp:890
clang::Type::isVoidType
bool isVoidType() const
Definition: Type.h:7096
clang::ento::StackSpaceRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:218
clang::ento::nonloc::ConcreteInt
Value representing integer constant.
Definition: SVals.h:326
clang::ento::MemRegionManager::getCXXDerivedObjectRegion
const CXXDerivedObjectRegion * getCXXDerivedObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super)
Create a CXXDerivedObjectRegion with the given derived class for region Super.
Definition: MemRegion.cpp:1223
clang::ento::StackLocalsSpaceRegion
Definition: MemRegion.h:411
clang::ento::MemRegionManager::getFunctionCodeRegion
const FunctionCodeRegion * getFunctionCodeRegion(const NamedDecl *FD)
Definition: MemRegion.cpp:1137
clang::ento::RegionOffset::getRegion
const MemRegion * getRegion() const
It might return null.
Definition: MemRegion.h:78
clang::ento::VarRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:954
clang::ento::ElementRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:341
clang::ento::RegionOffset::RegionOffset
RegionOffset(const MemRegion *r, int64_t off)
Definition: MemRegion.h:75
clang::ento::MemRegionManager::getVarRegion
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
Definition: MemRegion.cpp:948
clang::ento::StaticGlobalSpaceRegion::getCodeRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL CodeTextRegion * getCodeRegion() const
Definition: MemRegion.h:277
clang::ento::CXXThisRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:497
clang::ento::BlockDataRegion::referenced_vars_iterator::operator==
bool operator==(const referenced_vars_iterator &I) const
Definition: MemRegion.h:727
clang::ento::SymbolicRegion::getSymbol
SymbolRef getSymbol() const
It might return null.
Definition: MemRegion.h:789
clang::ento::ElementRegion::getElementType
QualType getElementType() const
Definition: MemRegion.h:1201
clang::ento::CodeTextRegion::CodeTextRegion
CodeTextRegion(const MemSpaceRegion *sreg, Kind k)
Definition: MemRegion.h:566
clang::ento::HeapSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:565
clang::ento::DeclRegion
Definition: MemRegion.h:912
clang::ento::CXXBaseObjectRegion
Definition: MemRegion.h:1248
clang::ento::BlockCodeRegion
BlockCodeRegion - A region that represents code texts of blocks (closures).
Definition: MemRegion.h:627
clang::ento::FunctionCodeRegion::getDecl
const NamedDecl * getDecl() const
Definition: MemRegion.h:608
clang::ento::BlockDataRegion::referenced_vars_iterator::getCapturedRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL VarRegion * getCapturedRegion() const
Definition: MemRegion.h:718
Decl.h
clang::ento::MemRegionManager::getCXXBaseObjectRegion
const CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
Definition: MemRegion.cpp:1203
clang::ObjCObjectType
Represents a class type in Objective C.
Definition: Type.h:5951
DeclObjC.h
Offset
unsigned Offset
Definition: Format.cpp:2574
clang::ento::BlockDataRegion::referenced_vars_iterator::referenced_vars_iterator
referenced_vars_iterator(const MemRegion *const *r, const MemRegion *const *originalR)
Definition: MemRegion.h:713
clang::ento::ParamVarRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:317
clang::ento::MemRegion
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:95
clang::ento::RegionOffset
Represent a region's offset within the top level base region.
Definition: MemRegion.h:62
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::ento::CXXThisRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:1070
clang::CanQual::getTypePtr
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition: CanonicalType.h:83
clang::ento::RegionAndSymbolInvalidationTraits::TK_EntireMemSpace
@ TK_EntireMemSpace
When applied to a MemSpaceRegion, indicates the entire memory space should be invalidated.
Definition: MemRegion.h:1582
clang::ento::ElementRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:1199
clang::CompoundLiteralExpr::isFileScope
bool isFileScope() const
Definition: Expr.h:3432
clang::ento::MemRegionManager::getAllocaRegion
const AllocaRegion * getAllocaRegion(const Expr *Ex, unsigned Cnt, const LocationContext *LC)
getAllocaRegion - Retrieve a region associated with a call to alloca().
Definition: MemRegion.cpp:1250
clang::ento::MemRegionManager::getFieldRegion
const FieldRegion * getFieldRegion(const FieldDecl *fd, const SubRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl.
Definition: MemRegion.cpp:1161
clang::ento::NonStaticGlobalSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:300
clang::ento::UnknownSpaceRegion
Definition: MemRegion.h:373
clang::ento::CodeSpaceRegion
CodeSpaceRegion - The memory space that holds the executable code of functions and blocks.
Definition: MemRegion.h:227
clang::ento::BlockCodeRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:364
clang::ento::CXXBaseObjectRegion::getDecl
const LLVM_ATTRIBUTE_RETURNS_NONNULL CXXRecordDecl * getDecl() const
Definition: MemRegion.h:1264
SymExpr.h
clang::ento::CXXBaseObjectRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.cpp:175
clang::ento::CXXBaseObjectRegion::printPrettyAsExpr
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Definition: MemRegion.cpp:663
clang::ento::CompoundLiteralRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:479
clang::ento::RegionAndSymbolInvalidationTraits::hasTrait
bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const
Definition: MemRegion.cpp:1727
clang::ento::MemRegion::getContext
ASTContext & getContext() const
Definition: MemRegion.h:1548
clang::ento::FieldRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:281
clang::ento::MemRegionManager::getCXXThisRegion
const CXXThisRegion * getCXXThisRegion(QualType thisPointerTy, const LocationContext *LC)
getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'.
Definition: MemRegion.cpp:1229
clang::ento::MemRegion::isBoundable
virtual bool isBoundable() const
Definition: MemRegion.h:179
clang::ento::ObjCIvarRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.cpp:171
clang::ento::MemRegion::getSymbolicBase
const SymbolicRegion * getSymbolicBase() const
If this is a symbolic region, returns the region.
Definition: MemRegion.cpp:1346
clang::BlockDecl
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4208
clang::ento::ParamVarRegion::canPrintPrettyAsExpr
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
Definition: MemRegion.cpp:618
clang::ento::BlockDataRegion::referenced_vars_iterator
Definition: MemRegion.h:708
clang::ento::NonParamVarRegion
Definition: MemRegion.h:960
clang::ento::MemRegionManager::MemRegionManager
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a)
Definition: MemRegion.h:1363
clang::ento::FieldRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:1119
clang::ento::TypedRegion::getLocationType
virtual QualType getLocationType() const =0
clang::ento::ParamVarRegion::printPrettyAsExpr
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Definition: MemRegion.cpp:620
clang::ento::BlockCodeRegion::getAnalysisDeclContext
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
Definition: MemRegion.h:657
clang::ento::CXXTempObjectRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:1241
clang::ento::MemRegionManager::getBlockCodeRegion
const BlockCodeRegion * getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
Definition: MemRegion.cpp:1143
clang::ObjCStringLiteral
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:52
clang::ento::GlobalImmutableSpaceRegion
The region containing globals which are considered not to be modified or point to data which could be...
Definition: MemRegion.h:328
clang::ento::AllocaRegion
AllocaRegion - A region that represents an untyped blob of bytes created by a call to 'alloca'.
Definition: MemRegion.h:474
clang::ento::RegionAndSymbolInvalidationTraits::setTrait
void setTrait(SymbolRef Sym, InvalidationKinds IK)
Definition: MemRegion.cpp:1713
clang::ento::MemRegionManager::getStaticSize
DefinedOrUnknownSVal getStaticSize(const MemRegion *MR, SValBuilder &SVB) const
Definition: MemRegion.cpp:736
clang::ento::AllocaRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:253
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
clang::ento::SymExpr
Symbolic value.
Definition: SymExpr.h:29
clang::ento::ObjCStringRegion::getObjCStringLiteral
const LLVM_ATTRIBUTE_RETURNS_NONNULL ObjCStringLiteral * getObjCStringLiteral() const
Definition: MemRegion.h:858
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7302
clang::ento::RegionAndSymbolInvalidationTraits::InvalidationKinds
InvalidationKinds
Describes different invalidation traits.
Definition: MemRegion.h:1570
clang::ento::CXXTempObjectRegion
Definition: MemRegion.h:1216
clang::ento::SubRegion::SubRegion
SubRegion(const MemRegion *sReg, Kind k)
Definition: MemRegion.h:448
clang::ento::MemRegion::isSubRegionOf
virtual bool isSubRegionOf(const MemRegion *R) const
Check if the region is a subregion of the given region.
Definition: MemRegion.cpp:1315
clang::ento::MemSpaceRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:214
clang::ento::CodeSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:236
clang::ento::MemSpaceRegion::getMemRegionManager
MemRegionManager & getMemRegionManager() const override
Definition: MemRegion.h:212
clang::ento::MemRegionManager::getElementRegion
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type,...
Definition: MemRegion.cpp:1115
clang::ento::TypedValueRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:556
clang::ento::BlockDataRegion
BlockDataRegion - A region that represents a block instance.
Definition: MemRegion.h:674
clang::ento::VarRegion
Definition: MemRegion.h:928
clang::ento::NonParamVarRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:530
clang::ento::MemSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:219
Type.h
clang::ento::StringRegion
StringRegion - Region associated with a StringLiteral.
Definition: MemRegion.h:807
Expr.h
clang::ento::CXXTempObjectRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:484
ASTContext.h
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::ento::NonStaticGlobalSpaceRegion::NonStaticGlobalSpaceRegion
NonStaticGlobalSpaceRegion(MemRegionManager &mgr, Kind k)
Definition: MemRegion.h:294
clang::ento::FieldRegion::getDecl
const LLVM_ATTRIBUTE_RETURNS_NONNULL FieldDecl * getDecl() const override
Definition: MemRegion.h:1103
clang::StringLiteral
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1767
clang::ento::BlockDataRegion::referenced_vars_iterator::operator++
referenced_vars_iterator & operator++()
Definition: MemRegion.h:737
clang::ento::SubRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:463
clang::ento::UnknownSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:569
clang::ento::CodeSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:545
clang::ento::MemRegion::printPretty
virtual void printPretty(raw_ostream &os) const
Print the region for use in diagnostics.
Definition: MemRegion.cpp:601
clang::Type::getAsCXXRecordDecl
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1759
clang::ento::BlockCodeRegion::getDecl
const LLVM_ATTRIBUTE_RETURNS_NONNULL BlockDecl * getDecl() const
Definition: MemRegion.h:652
clang::ento::RegionRawOffset::getOffset
CharUnits getOffset() const
Definition: MemRegion.h:1167
clang::ento::MemRegion::getKind
Kind getKind() const
Definition: MemRegion.h:173
clang::ento::StringRegion::getStringLiteral
const LLVM_ATTRIBUTE_RETURNS_NONNULL StringLiteral * getStringLiteral() const
Definition: MemRegion.h:823
clang::ento::BlockCodeRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:663
clang::ento::MemRegion::hasStackNonParametersStorage
bool hasStackNonParametersStorage() const
Definition: MemRegion.cpp:1273
ExprObjC.h
clang::CharUnits::Zero
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Definition: CharUnits.h:53
clang::CanQual< Type >
clang::ento::FunctionCodeRegion::getLocationType
QualType getLocationType() const override
Definition: MemRegion.h:594
clang::ento::ElementRegion
ElementRegion is used to represent both array elements and casts.
Definition: MemRegion.h:1177
clang::ento::FieldRegion
Definition: MemRegion.h:1084
clang::ento::CXXTempObjectRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:391
clang::ento::RegionRawOffset::dump
void dump() const
Definition: MemRegion.cpp:537
clang::ento::DeclRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:922
clang::ento::MemRegion::getAsOffset
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
Definition: MemRegion.cpp:1595
clang::ento::MemRegion::Kind
Kind
Definition: MemRegion.h:97
clang::ento::RegionOffset::isValid
bool isValid() const
Definition: MemRegion.h:87
clang::ento::BlockDataRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:755
clang::ento::CodeTextRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:571
clang::ento::NonParamVarRegion::printPrettyAsExpr
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Definition: MemRegion.cpp:614
clang::ento::FunctionCodeRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:616
clang::ento::SymbolicRegion
SymbolicRegion - A special, "non-concrete" region.
Definition: MemRegion.h:770
clang::ento::ObjCIvarRegion::printPrettyAsExpr
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Definition: MemRegion.cpp:631
clang::ento::AllocaRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:495
clang::ento::StaticGlobalSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:279
clang::ento::TypedRegion::TypedRegion
TypedRegion(const MemRegion *sReg, Kind k)
Definition: MemRegion.h:511
clang::ento::MemRegion::castAs
const LLVM_ATTRIBUTE_RETURNS_NONNULL RegionTy * castAs() const
Definition: MemRegion.h:1333
clang::ento::MemRegion::canPrintPrettyAsExpr
virtual bool canPrintPrettyAsExpr() const
Returns true if this region's textual representation can be used as part of a larger expression.
Definition: MemRegion.cpp:597
CharUnits.h
clang::ento::NonStaticGlobalSpaceRegion
The region for all the non-static global variables.
Definition: MemRegion.h:290
clang::ento::NonParamVarRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:305
clang::ento::ObjCStringRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:519
clang::ento::MemRegionManager::getParamVarRegion
const ParamVarRegion * getParamVarRegion(const Expr *OriginExpr, unsigned Index, const LocationContext *LC)
getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr,...
Definition: MemRegion.cpp:1056
clang::ento::RegionOffset::getOffset
int64_t getOffset() const
Definition: MemRegion.h:82
clang::ento::SValBuilder
Definition: SValBuilder.h:53
clang::ento::CXXBaseObjectRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:489
clang::CompoundLiteralExpr
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3405
clang::QualType::getDesugaredType
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
Definition: Type.h:1043
clang::ento::StackArgumentsSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:573
clang::ento::MemRegion::getAs
const RegionTy * getAs() const
Definition: MemRegion.h:1325
clang::ento::StackArgumentsSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:435
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::ento::HeapSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:368
SourceLocation.h
clang::ento::AllocaRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:501
clang::ento::MemRegion::getMemorySpace
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemSpaceRegion * getMemorySpace() const
Definition: MemRegion.cpp:1257
clang::ento::MemRegion::hasStackStorage
bool hasStackStorage() const
Definition: MemRegion.cpp:1269
clang::ento::CXXDerivedObjectRegion::canPrintPrettyAsExpr
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
Definition: MemRegion.cpp:667
clang::ento::RegionOffset::Symbolic
static const int64_t Symbolic
Definition: MemRegion.h:72
clang::ento::NonParamVarRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:997
clang::ento::GlobalsSpaceRegion::GlobalsSpaceRegion
GlobalsSpaceRegion(MemRegionManager &mgr, Kind k)
Definition: MemRegion.h:245
clang::ento::ElementRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:501
clang::ento::CodeTextRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:573
clang::ento::GlobalSystemSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:318
clang::ento::HeapSpaceRegion
Definition: MemRegion.h:359
clang::ento::MemRegion::MemRegion
MemRegion(Kind k)
Definition: MemRegion.h:108
clang::ento::GlobalsSpaceRegion
Definition: MemRegion.h:241
clang::ento::CodeTextRegion
Definition: MemRegion.h:562
clang::ento::MemRegionManager::getAllocator
llvm::BumpPtrAllocator & getAllocator()
Definition: MemRegion.h:1368
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:674
clang::ento::TypedRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:522
clang::ento::VarRegion::VarRegion
VarRegion(const MemRegion *sReg, Kind k)
Definition: MemRegion.h:933
clang::ento::MemRegionManager::getCXXTempObjectRegion
const CXXTempObjectRegion * getCXXTempObjectRegion(Expr const *Ex, LocationContext const *LC)
Definition: MemRegion.cpp:1173
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:796
clang::ento::ParamVarRegion::getIndex
unsigned getIndex() const
Definition: MemRegion.h:1030
clang::ento::StackArgumentsSpaceRegion
Definition: MemRegion.h:425
clang::ento::StackSpaceRegion
Definition: MemRegion.h:387
clang::ento::FunctionCodeRegion
FunctionCodeRegion - A region that represents code texts of function.
Definition: MemRegion.h:580
clang::ento::StringRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:514
clang::ento::MemRegionManager::getStackLocalsRegion
const StackLocalsSpaceRegion * getStackLocalsRegion(const StackFrameContext *STC)
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame.
Definition: MemRegion.cpp:843
clang::ento::StringRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:825
clang::ento::MemRegionManager::getStringRegion
const StringRegion * getStringRegion(const StringLiteral *Str)
Definition: MemRegion.cpp:906
LLVM.h
clang::ento::MemRegionManager::getFieldRegionWithSuper
const FieldRegion * getFieldRegionWithSuper(const FieldRegion *FR, const SubRegion *superRegion)
Definition: MemRegion.h:1462
clang::ento::BlockDataRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:468
clang::ento::RegionRawOffset
Definition: MemRegion.h:1156
clang::ento::BlockDataRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:380
clang::ento::VarRegion::getStackFrame
const StackFrameContext * getStackFrame() const
It might return null.
Definition: MemRegion.cpp:159
clang::ento::CompoundLiteralRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:898
clang::ento::MemRegionManager::getCXXBaseObjectRegionWithSuper
const CXXBaseObjectRegion * getCXXBaseObjectRegionWithSuper(const CXXBaseObjectRegion *baseReg, const SubRegion *superRegion)
Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different super region.
Definition: MemRegion.h:1488
clang::ento::ParamVarRegion::getOriginExpr
const LLVM_ATTRIBUTE_RETURNS_NONNULL Expr * getOriginExpr() const
Definition: MemRegion.h:1029
clang::ento::BlockDataRegion::getDecl
const LLVM_ATTRIBUTE_RETURNS_NONNULL BlockDecl * getDecl() const
Definition: MemRegion.h:704
clang::ento::GlobalInternalSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:553
clang::ento::SymbolicRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:328
clang::ento::BlockDataRegion::referenced_vars_end
referenced_vars_iterator referenced_vars_end() const
Definition: MemRegion.cpp:1684
clang::ento::VarRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:949
clang::ento::StackSpaceRegion::getStackFrame
const LLVM_ATTRIBUTE_RETURNS_NONNULL StackFrameContext * getStackFrame() const
Definition: MemRegion.h:401
clang::ento::nonloc::ConcreteInt::getValue
const llvm::APSInt & getValue() const
Definition: SVals.h:330
clang::ento::UnknownSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:382
clang::ento::StringRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.h:829
clang::ento::MemRegion::getMostDerivedObjectRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemRegion * getMostDerivedObjectRegion() const
Recursively retrieve the region of the most derived class instance of regions of C++ base class insta...
Definition: MemRegion.cpp:1308
clang::ento::FieldRegion::printPrettyAsExpr
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Definition: MemRegion.cpp:643
clang::ento::MemRegionManager::getObjCStringRegion
const ObjCStringRegion * getObjCStringRegion(const ObjCStringLiteral *Str)
Definition: MemRegion.cpp:912
int64_t
long int64_t
Definition: hlsl_basic_types.h:25
clang::ento::AllocaRegion::getExpr
const LLVM_ATTRIBUTE_RETURNS_NONNULL Expr * getExpr() const
Definition: MemRegion.h:493
clang::ento::SymbolicRegion::ProfileRegion
static void ProfileRegion(llvm::FoldingSetNodeID &ID, SymbolRef sym, const MemRegion *superRegion)
Definition: MemRegion.cpp:321
clang::ento::MemRegionManager
Definition: MemRegion.h:1341
clang::ento::GlobalImmutableSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:561
clang::ento::RegionRawOffset::getRegion
const MemRegion * getRegion() const
Definition: MemRegion.h:1170
DeclarationName.h
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2712
clang::ento::NonParamVarRegion::getDecl
const LLVM_ATTRIBUTE_RETURNS_NONNULL VarDecl * getDecl() const override
Definition: MemRegion.h:984
clang::ento::ElementRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:1210
clang::ento::RegionAndSymbolInvalidationTraits::TK_PreserveContents
@ TK_PreserveContents
Tells that a region's contents is not changed.
Definition: MemRegion.h:1572
clang::ento::TypedValueRegion::getValueType
virtual QualType getValueType() const =0
clang::ento::ParamVarRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:581
clang::ento::operator<<
raw_ostream & operator<<(raw_ostream &Out, const CheckerBase &Checker)
Dump checker name to stream.
Definition: Checker.cpp:35
clang::ento::BlockCodeRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:464
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang
Definition: CalledOnceCheck.h:17
clang::ento::FieldRegion::printPretty
void printPretty(raw_ostream &os) const override
Print the region for use in diagnostics.
Definition: MemRegion.cpp:649
clang::ento::RegionOffset::hasSymbolicOffset
bool hasSymbolicOffset() const
Definition: MemRegion.h:80
clang::ento::GlobalInternalSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:354
clang::ento::TypedRegion
TypedRegion - An abstract class representing regions that are typed.
Definition: MemRegion.h:507
clang::ento::MemRegionManager::getCXXStaticTempObjectRegion
const CXXTempObjectRegion * getCXXStaticTempObjectRegion(const Expr *Ex)
Create a CXXTempObjectRegion for temporaries which are lifetime-extended by static references.
Definition: MemRegion.cpp:1093
clang::ento::StackLocalsSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:420
clang::ObjCIvarDecl
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1923
clang::ento::StackSpaceRegion::StackSpaceRegion
StackSpaceRegion(MemRegionManager &mgr, Kind k, const StackFrameContext *sfc)
Definition: MemRegion.h:393
clang::ento::SubRegion::getMemRegionManager
MemRegionManager & getMemRegionManager() const override
Definition: MemRegion.cpp:147
clang::ento::MemRegion::printPrettyAsExpr
virtual void printPrettyAsExpr(raw_ostream &os) const
Print the region as expression.
Definition: MemRegion.cpp:608
clang::ento::MemRegionManager::getContext
ASTContext & getContext()
Definition: MemRegion.h:1366
clang::ento::RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion
@ TK_DoNotInvalidateSuperRegion
Definition: MemRegion.h:1578
clang::ento::ParamVarRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.cpp:183
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::ento::CXXBaseObjectRegion::isVirtual
bool isVirtual() const
Definition: MemRegion.h:1265
clang::ento::StaticGlobalSpaceRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:223
clang::ento::SubRegion::getSuperRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemRegion * getSuperRegion() const
Definition: MemRegion.h:455
clang::ento::ObjCStringRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.h:864
s
__device__ __2f16 float bool s
Definition: __clang_hip_libdevice_declares.h:315
clang::ento::MemSpaceRegion::Mgr
MemRegionManager & Mgr
Definition: MemRegion.h:206
clang::ento::MemRegion::getDescriptiveName
std::string getDescriptiveName(bool UseQuotes=true) const
Get descriptive name for memory region.
Definition: MemRegion.cpp:675
clang::ento::CXXDerivedObjectRegion::printPrettyAsExpr
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Definition: MemRegion.cpp:671
clang::ento::MemSpaceRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:215
clang::QualType::getTypePtrOrNull
const Type * getTypePtrOrNull() const
Definition: Type.h:6563
clang::ento::BlockDataRegion::referenced_vars_iterator::operator!=
bool operator!=(const referenced_vars_iterator &I) const
Definition: MemRegion.h:732
clang::ento::MemRegion::dumpToStream
virtual void dumpToStream(raw_ostream &os) const
Definition: MemRegion.cpp:452
clang::ento::TypedRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:524
clang::ento::StaticGlobalSpaceRegion
The region of the static variables within the current CodeTextRegion scope.
Definition: MemRegion.h:261
c
__device__ __2f16 float c
Definition: __clang_hip_libdevice_declares.h:315
clang::ento::CXXThisRegion
CXXThisRegion - Represents the region for the implicit 'this' parameter in a call to a C++ method.
Definition: MemRegion.h:1052
clang::ento::MemRegion::~MemRegion
virtual ~MemRegion()
clang::ASTContext::getPointerType
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
Definition: ASTContext.cpp:3285
clang::ento::SVal
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition: SVals.h:74
clang::CharUnits
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
clang::ento::ObjCIvarRegion::canPrintPrettyAsExpr
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
Definition: MemRegion.cpp:627
clang::PointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2722
clang::ento::MemRegionManager::getGlobalsRegion
const GlobalsSpaceRegion * getGlobalsRegion(MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
getGlobalsRegion - Retrieve the memory region associated with global variables.
Definition: MemRegion.cpp:869
clang::ento::GlobalInternalSpaceRegion
The region containing globals which can be modified by calls to "internally" defined functions - (for...
Definition: MemRegion.h:345
clang::ento::RegionRawOffset::dumpToStream
void dumpToStream(raw_ostream &os) const
Definition: MemRegion.cpp:541
clang::ento::CXXDerivedObjectRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.cpp:179
clang::ento::TypedValueRegion
TypedValueRegion - An abstract class representing regions having a typed value.
Definition: MemRegion.h:531
clang::ento::SubRegion
SubRegion - A region that subsets another larger region.
Definition: MemRegion.h:442
clang::ento::CXXDerivedObjectRegion
Definition: MemRegion.h:1287
clang::ento::GlobalSystemSpaceRegion
The region containing globals which are defined in system/external headers and are considered modifia...
Definition: MemRegion.h:309
clang::ento::MemRegionManager::getSymbolicRegion
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym, const MemSpaceRegion *MemSpace=nullptr)
Retrieve or create a "symbolic" memory region.
Definition: MemRegion.cpp:1149
clang::ento::StackLocalsSpaceRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:577
clang::ento::AllocaRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:456
clang::ento::MemRegion::getBaseRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemRegion * getBaseRegion() const
Definition: MemRegion.cpp:1287
clang::ento::CXXBaseObjectRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:404
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:685
clang::ento::ObjCIvarRegion::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: MemRegion.cpp:293
clang::ento::CompoundLiteralRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:907
clang::ento::RegionAndSymbolInvalidationTraits
Information about invalidation for a particular region/symbol.
Definition: MemRegion.h:1557
clang::ento::NonParamVarRegion::getValueType
QualType getValueType() const override
Definition: MemRegion.h:986
clang::ento::MemSpaceRegion::MemSpaceRegion
MemSpaceRegion(MemRegionManager &mgr, Kind k)
Definition: MemRegion.h:208
clang::ento::MemRegionManager::~MemRegionManager
~MemRegionManager()
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::ento::SymbolicRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:801
clang::ento::CXXDerivedObjectRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:493
clang::ento::CXXThisRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:1076
clang::ento::TypedValueRegion::getLocationType
QualType getLocationType() const override
Definition: MemRegion.h:542
clang::ento::SymbolicRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:524
clang::ento::BlockDataRegion::getOriginalRegion
const VarRegion * getOriginalRegion(const VarRegion *VR) const
Return the original region for a captured region, if one exists.
Definition: MemRegion.cpp:1699
clang::ento::MemRegion::getString
std::string getString() const
Get a string representation of a region for debug use.
Definition: MemRegion.cpp:445
clang::ento::MemRegion::canPrintPretty
virtual bool canPrintPretty() const
Returns true if this region can be printed in a user-friendly way.
Definition: MemRegion.cpp:593
clang::ento::BlockCodeRegion::getLocationType
QualType getLocationType() const override
Definition: MemRegion.h:647
clang::ASTContext::getObjCObjectPointerType
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Definition: ASTContext.cpp:5511
clang::ento::GlobalImmutableSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:337
clang::ento::TypedValueRegion::TypedValueRegion
TypedValueRegion(const MemRegion *sReg, Kind k)
Definition: MemRegion.h:535
clang::ento::ObjCIvarRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:510
clang::ento::FieldRegion::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: MemRegion.cpp:506
clang::ento::ObjCIvarRegion::getDecl
const LLVM_ATTRIBUTE_RETURNS_NONNULL ObjCIvarDecl * getDecl() const override
Definition: MemRegion.cpp:169
clang::ento::SubRegion::superRegion
const MemRegion * superRegion
Definition: MemRegion.h:446
clang::ento::ParamVarRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:1044
clang::ento::VarRegion::getDecl
const VarDecl * getDecl() const override=0
clang::ento::MemRegion::sourceRange
SourceRange sourceRange() const
Retrieve source range from memory region.
Definition: MemRegion.cpp:714
clang::ento::StackSpaceRegion::classof
static bool classof(const MemRegion *R)
Definition: MemRegion.h:405
clang::ento::ObjCStringRegion::isBoundable
bool isBoundable() const override
Definition: MemRegion.h:862
clang::ento::ElementRegion::getAsArrayOffset
RegionRawOffset getAsArrayOffset() const
Compute the offset within the array. The array might also be a subobject.
Definition: MemRegion.cpp:1357
clang::ento::CXXBaseObjectRegion::classof
static bool classof(const MemRegion *region)
Definition: MemRegion.h:1277
clang::ento::ParamVarRegion::getDecl
const ParmVarDecl * getDecl() const override
TODO: What does this return?
Definition: MemRegion.cpp:190
clang::ento::ParamVarRegion
ParamVarRegion - Represents a region for paremters.
Definition: MemRegion.h:1012
clang::ento::RegionOffset::RegionOffset
RegionOffset()=default