clang  7.0.0svn
ProgramPoint.h
Go to the documentation of this file.
1 //==- ProgramPoint.h - Program Points for Path-Sensitive Analysis --*- C++ -*-//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interface ProgramPoint, which identifies a
11 // distinct location in a function.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_ANALYSIS_PROGRAMPOINT_H
16 #define LLVM_CLANG_ANALYSIS_PROGRAMPOINT_H
17 
19 #include "clang/Analysis/CFG.h"
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/FoldingSet.h"
22 #include "llvm/ADT/Optional.h"
23 #include "llvm/ADT/PointerIntPair.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/Support/Casting.h"
26 #include "llvm/Support/DataTypes.h"
27 #include <cassert>
28 #include <string>
29 #include <utility>
30 
31 namespace clang {
32 
33 class AnalysisDeclContext;
34 class FunctionDecl;
35 class LocationContext;
36 
37 /// ProgramPoints can be "tagged" as representing points specific to a given
38 /// analysis entity. Tags are abstract annotations, with an associated
39 /// description and potentially other information.
41 public:
42  ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
43  virtual ~ProgramPointTag();
44  virtual StringRef getTagDescription() const = 0;
45 
46 protected:
47  /// Used to implement 'isKind' in subclasses.
48  const void *getTagKind() { return TagKind; }
49 
50 private:
51  const void *TagKind;
52 };
53 
55  std::string Desc;
56 public:
57  SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
58  StringRef getTagDescription() const override;
59 };
60 
61 class ProgramPoint {
62 public:
63  enum Kind { BlockEdgeKind,
77  MinPostStmtKind = PostStmtKind,
78  MaxPostStmtKind = PostAllocatorCallKind,
85  MinImplicitCallKind = PreImplicitCallKind,
86  MaxImplicitCallKind = PostImplicitCallKind,
88  EpsilonKind};
89 
90 private:
91  const void *Data1;
92  llvm::PointerIntPair<const void *, 2, unsigned> Data2;
93 
94  // The LocationContext could be NULL to allow ProgramPoint to be used in
95  // context insensitive analysis.
96  llvm::PointerIntPair<const LocationContext *, 2, unsigned> L;
97 
98  llvm::PointerIntPair<const ProgramPointTag *, 2, unsigned> Tag;
99 
100 protected:
101  ProgramPoint() = default;
102  ProgramPoint(const void *P,
103  Kind k,
104  const LocationContext *l,
105  const ProgramPointTag *tag = nullptr)
106  : Data1(P),
107  Data2(nullptr, (((unsigned) k) >> 0) & 0x3),
108  L(l, (((unsigned) k) >> 2) & 0x3),
109  Tag(tag, (((unsigned) k) >> 4) & 0x3) {
110  assert(getKind() == k);
111  assert(getLocationContext() == l);
112  assert(getData1() == P);
113  }
114 
115  ProgramPoint(const void *P1,
116  const void *P2,
117  Kind k,
118  const LocationContext *l,
119  const ProgramPointTag *tag = nullptr)
120  : Data1(P1),
121  Data2(P2, (((unsigned) k) >> 0) & 0x3),
122  L(l, (((unsigned) k) >> 2) & 0x3),
123  Tag(tag, (((unsigned) k) >> 4) & 0x3) {}
124 
125 protected:
126  const void *getData1() const { return Data1; }
127  const void *getData2() const { return Data2.getPointer(); }
128  void setData2(const void *d) { Data2.setPointer(d); }
129 
130 public:
131  /// Create a new ProgramPoint object that is the same as the original
132  /// except for using the specified tag value.
134  return ProgramPoint(getData1(), getData2(), getKind(),
135  getLocationContext(), tag);
136  }
137 
138  /// \brief Convert to the specified ProgramPoint type, asserting that this
139  /// ProgramPoint is of the desired type.
140  template<typename T>
141  T castAs() const {
142  assert(T::isKind(*this));
143  T t;
144  ProgramPoint& PP = t;
145  PP = *this;
146  return t;
147  }
148 
149  /// \brief Convert to the specified ProgramPoint type, returning None if this
150  /// ProgramPoint is not of the desired type.
151  template<typename T>
152  Optional<T> getAs() const {
153  if (!T::isKind(*this))
154  return None;
155  T t;
156  ProgramPoint& PP = t;
157  PP = *this;
158  return t;
159  }
160 
161  Kind getKind() const {
162  unsigned x = Tag.getInt();
163  x <<= 2;
164  x |= L.getInt();
165  x <<= 2;
166  x |= Data2.getInt();
167  return (Kind) x;
168  }
169 
170  /// \brief Is this a program point corresponding to purge/removal of dead
171  /// symbols and bindings.
172  bool isPurgeKind() {
173  Kind K = getKind();
174  return (K == PostStmtPurgeDeadSymbolsKind ||
175  K == PreStmtPurgeDeadSymbolsKind);
176  }
177 
178  const ProgramPointTag *getTag() const { return Tag.getPointer(); }
179 
181  return L.getPointer();
182  }
183 
184  // For use with DenseMap. This hash is probably slow.
185  unsigned getHashValue() const {
186  llvm::FoldingSetNodeID ID;
187  Profile(ID);
188  return ID.ComputeHash();
189  }
190 
191  bool operator==(const ProgramPoint & RHS) const {
192  return Data1 == RHS.Data1 &&
193  Data2 == RHS.Data2 &&
194  L == RHS.L &&
195  Tag == RHS.Tag;
196  }
197 
198  bool operator!=(const ProgramPoint &RHS) const {
199  return Data1 != RHS.Data1 ||
200  Data2 != RHS.Data2 ||
201  L != RHS.L ||
202  Tag != RHS.Tag;
203  }
204 
205  void Profile(llvm::FoldingSetNodeID& ID) const {
206  ID.AddInteger((unsigned) getKind());
207  ID.AddPointer(getData1());
208  ID.AddPointer(getData2());
209  ID.AddPointer(getLocationContext());
210  ID.AddPointer(getTag());
211  }
212 
213  static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K,
214  const LocationContext *LC,
215  const ProgramPointTag *tag);
216 };
217 
218 class BlockEntrance : public ProgramPoint {
219 public:
221  const ProgramPointTag *tag = nullptr)
222  : ProgramPoint(B, BlockEntranceKind, L, tag) {
223  assert(B && "BlockEntrance requires non-null block");
224  }
225 
226  const CFGBlock *getBlock() const {
227  return reinterpret_cast<const CFGBlock*>(getData1());
228  }
229 
231  const CFGBlock *B = getBlock();
232  return B->empty() ? Optional<CFGElement>() : B->front();
233  }
234 
235 private:
236  friend class ProgramPoint;
237  BlockEntrance() = default;
238  static bool isKind(const ProgramPoint &Location) {
239  return Location.getKind() == BlockEntranceKind;
240  }
241 };
242 
243 class BlockExit : public ProgramPoint {
244 public:
245  BlockExit(const CFGBlock *B, const LocationContext *L)
246  : ProgramPoint(B, BlockExitKind, L) {}
247 
248  const CFGBlock *getBlock() const {
249  return reinterpret_cast<const CFGBlock*>(getData1());
250  }
251 
252  const Stmt *getTerminator() const {
253  return getBlock()->getTerminator();
254  }
255 
256 private:
257  friend class ProgramPoint;
258  BlockExit() = default;
259  static bool isKind(const ProgramPoint &Location) {
260  return Location.getKind() == BlockExitKind;
261  }
262 };
263 
264 class StmtPoint : public ProgramPoint {
265 public:
266  StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L,
267  const ProgramPointTag *tag)
268  : ProgramPoint(S, p2, k, L, tag) {
269  assert(S);
270  }
271 
272  const Stmt *getStmt() const { return (const Stmt*) getData1(); }
273 
274  template <typename T>
275  const T* getStmtAs() const { return dyn_cast<T>(getStmt()); }
276 
277 protected:
278  StmtPoint() = default;
279 private:
280  friend class ProgramPoint;
281  static bool isKind(const ProgramPoint &Location) {
282  unsigned k = Location.getKind();
283  return k >= PreStmtKind && k <= MaxPostStmtKind;
284  }
285 };
286 
287 
288 class PreStmt : public StmtPoint {
289 public:
290  PreStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag,
291  const Stmt *SubStmt = nullptr)
292  : StmtPoint(S, SubStmt, PreStmtKind, L, tag) {}
293 
294  const Stmt *getSubStmt() const { return (const Stmt*) getData2(); }
295 
296 private:
297  friend class ProgramPoint;
298  PreStmt() = default;
299  static bool isKind(const ProgramPoint &Location) {
300  return Location.getKind() == PreStmtKind;
301  }
302 };
303 
304 class PostStmt : public StmtPoint {
305 protected:
306  PostStmt() = default;
307  PostStmt(const Stmt *S, const void *data, Kind k, const LocationContext *L,
308  const ProgramPointTag *tag = nullptr)
309  : StmtPoint(S, data, k, L, tag) {}
310 
311 public:
312  explicit PostStmt(const Stmt *S, Kind k, const LocationContext *L,
313  const ProgramPointTag *tag = nullptr)
314  : StmtPoint(S, nullptr, k, L, tag) {}
315 
316  explicit PostStmt(const Stmt *S, const LocationContext *L,
317  const ProgramPointTag *tag = nullptr)
318  : StmtPoint(S, nullptr, PostStmtKind, L, tag) {}
319 
320 private:
321  friend class ProgramPoint;
322  static bool isKind(const ProgramPoint &Location) {
323  unsigned k = Location.getKind();
324  return k >= MinPostStmtKind && k <= MaxPostStmtKind;
325  }
326 };
327 
328 // PostCondition represents the post program point of a branch condition.
329 class PostCondition : public PostStmt {
330 public:
331  PostCondition(const Stmt *S, const LocationContext *L,
332  const ProgramPointTag *tag = nullptr)
333  : PostStmt(S, PostConditionKind, L, tag) {}
334 
335 private:
336  friend class ProgramPoint;
337  PostCondition() = default;
338  static bool isKind(const ProgramPoint &Location) {
339  return Location.getKind() == PostConditionKind;
340  }
341 };
342 
343 class LocationCheck : public StmtPoint {
344 protected:
345  LocationCheck() = default;
346  LocationCheck(const Stmt *S, const LocationContext *L,
347  ProgramPoint::Kind K, const ProgramPointTag *tag)
348  : StmtPoint(S, nullptr, K, L, tag) {}
349 
350 private:
351  friend class ProgramPoint;
352  static bool isKind(const ProgramPoint &location) {
353  unsigned k = location.getKind();
354  return k == PreLoadKind || k == PreStoreKind;
355  }
356 };
357 
358 class PreLoad : public LocationCheck {
359 public:
360  PreLoad(const Stmt *S, const LocationContext *L,
361  const ProgramPointTag *tag = nullptr)
362  : LocationCheck(S, L, PreLoadKind, tag) {}
363 
364 private:
365  friend class ProgramPoint;
366  PreLoad() = default;
367  static bool isKind(const ProgramPoint &location) {
368  return location.getKind() == PreLoadKind;
369  }
370 };
371 
372 class PreStore : public LocationCheck {
373 public:
374  PreStore(const Stmt *S, const LocationContext *L,
375  const ProgramPointTag *tag = nullptr)
376  : LocationCheck(S, L, PreStoreKind, tag) {}
377 
378 private:
379  friend class ProgramPoint;
380  PreStore() = default;
381  static bool isKind(const ProgramPoint &location) {
382  return location.getKind() == PreStoreKind;
383  }
384 };
385 
386 class PostLoad : public PostStmt {
387 public:
388  PostLoad(const Stmt *S, const LocationContext *L,
389  const ProgramPointTag *tag = nullptr)
390  : PostStmt(S, PostLoadKind, L, tag) {}
391 
392 private:
393  friend class ProgramPoint;
394  PostLoad() = default;
395  static bool isKind(const ProgramPoint &Location) {
396  return Location.getKind() == PostLoadKind;
397  }
398 };
399 
400 /// \brief Represents a program point after a store evaluation.
401 class PostStore : public PostStmt {
402 public:
403  /// Construct the post store point.
404  /// \param Loc can be used to store the information about the location
405  /// used in the form it was uttered in the code.
406  PostStore(const Stmt *S, const LocationContext *L, const void *Loc,
407  const ProgramPointTag *tag = nullptr)
408  : PostStmt(S, PostStoreKind, L, tag) {
409  assert(getData2() == nullptr);
410  setData2(Loc);
411  }
412 
413  /// \brief Returns the information about the location used in the store,
414  /// how it was uttered in the code.
415  const void *getLocationValue() const {
416  return getData2();
417  }
418 
419 private:
420  friend class ProgramPoint;
421  PostStore() = default;
422  static bool isKind(const ProgramPoint &Location) {
423  return Location.getKind() == PostStoreKind;
424  }
425 };
426 
427 class PostLValue : public PostStmt {
428 public:
429  PostLValue(const Stmt *S, const LocationContext *L,
430  const ProgramPointTag *tag = nullptr)
431  : PostStmt(S, PostLValueKind, L, tag) {}
432 
433 private:
434  friend class ProgramPoint;
435  PostLValue() = default;
436  static bool isKind(const ProgramPoint &Location) {
437  return Location.getKind() == PostLValueKind;
438  }
439 };
440 
441 /// Represents a point after we ran remove dead bindings BEFORE
442 /// processing the given statement.
444 public:
446  const ProgramPointTag *tag = nullptr)
447  : StmtPoint(S, nullptr, PreStmtPurgeDeadSymbolsKind, L, tag) { }
448 
449 private:
450  friend class ProgramPoint;
451  PreStmtPurgeDeadSymbols() = default;
452  static bool isKind(const ProgramPoint &Location) {
453  return Location.getKind() == PreStmtPurgeDeadSymbolsKind;
454  }
455 };
456 
457 /// Represents a point after we ran remove dead bindings AFTER
458 /// processing the given statement.
460 public:
462  const ProgramPointTag *tag = nullptr)
463  : StmtPoint(S, nullptr, PostStmtPurgeDeadSymbolsKind, L, tag) { }
464 
465 private:
466  friend class ProgramPoint;
467  PostStmtPurgeDeadSymbols() = default;
468  static bool isKind(const ProgramPoint &Location) {
469  return Location.getKind() == PostStmtPurgeDeadSymbolsKind;
470  }
471 };
472 
473 class BlockEdge : public ProgramPoint {
474 public:
475  BlockEdge(const CFGBlock *B1, const CFGBlock *B2, const LocationContext *L)
476  : ProgramPoint(B1, B2, BlockEdgeKind, L) {
477  assert(B1 && "BlockEdge: source block must be non-null");
478  assert(B2 && "BlockEdge: destination block must be non-null");
479  }
480 
481  const CFGBlock *getSrc() const {
482  return static_cast<const CFGBlock*>(getData1());
483  }
484 
485  const CFGBlock *getDst() const {
486  return static_cast<const CFGBlock*>(getData2());
487  }
488 
489 private:
490  friend class ProgramPoint;
491  BlockEdge() = default;
492  static bool isKind(const ProgramPoint &Location) {
493  return Location.getKind() == BlockEdgeKind;
494  }
495 };
496 
498 public:
499  /// \brief Construct a PostInitializer point that represents a location after
500  /// CXXCtorInitializer expression evaluation.
501  ///
502  /// \param I The initializer.
503  /// \param Loc The location of the field being initialized.
505  const void *Loc,
506  const LocationContext *L)
507  : ProgramPoint(I, Loc, PostInitializerKind, L) {}
508 
510  return static_cast<const CXXCtorInitializer *>(getData1());
511  }
512 
513  /// \brief Returns the location of the field.
514  const void *getLocationValue() const {
515  return getData2();
516  }
517 
518 private:
519  friend class ProgramPoint;
520  PostInitializer() = default;
521  static bool isKind(const ProgramPoint &Location) {
522  return Location.getKind() == PostInitializerKind;
523  }
524 };
525 
526 /// Represents an implicit call event.
527 ///
528 /// The nearest statement is provided for diagnostic purposes.
530 public:
532  const LocationContext *L, const ProgramPointTag *Tag)
533  : ProgramPoint(Loc.getPtrEncoding(), D, K, L, Tag) {}
534 
535  const Decl *getDecl() const { return static_cast<const Decl *>(getData2()); }
537  return SourceLocation::getFromPtrEncoding(getData1());
538  }
539 
540 protected:
541  ImplicitCallPoint() = default;
542 private:
543  friend class ProgramPoint;
544  static bool isKind(const ProgramPoint &Location) {
545  return Location.getKind() >= MinImplicitCallKind &&
546  Location.getKind() <= MaxImplicitCallKind;
547  }
548 };
549 
550 /// Represents a program point just before an implicit call event.
551 ///
552 /// Explicit calls will appear as PreStmt program points.
554 public:
556  const ProgramPointTag *Tag = nullptr)
557  : ImplicitCallPoint(D, Loc, PreImplicitCallKind, L, Tag) {}
558 
559 private:
560  friend class ProgramPoint;
561  PreImplicitCall() = default;
562  static bool isKind(const ProgramPoint &Location) {
563  return Location.getKind() == PreImplicitCallKind;
564  }
565 };
566 
567 /// Represents a program point just after an implicit call event.
568 ///
569 /// Explicit calls will appear as PostStmt program points.
571 public:
573  const ProgramPointTag *Tag = nullptr)
574  : ImplicitCallPoint(D, Loc, PostImplicitCallKind, L, Tag) {}
575 
576 private:
577  friend class ProgramPoint;
578  PostImplicitCall() = default;
579  static bool isKind(const ProgramPoint &Location) {
580  return Location.getKind() == PostImplicitCallKind;
581  }
582 };
583 
584 class PostAllocatorCall : public StmtPoint {
585 public:
587  const ProgramPointTag *Tag = nullptr)
588  : StmtPoint(S, nullptr, PostAllocatorCallKind, L, Tag) {}
589 
590 private:
591  friend class ProgramPoint;
592  PostAllocatorCall() = default;
593  static bool isKind(const ProgramPoint &Location) {
594  return Location.getKind() == PostAllocatorCallKind;
595  }
596 };
597 
598 /// Represents a point when we begin processing an inlined call.
599 /// CallEnter uses the caller's location context.
600 class CallEnter : public ProgramPoint {
601 public:
602  CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx,
603  const LocationContext *callerCtx)
604  : ProgramPoint(stmt, calleeCtx, CallEnterKind, callerCtx, nullptr) {}
605 
606  const Stmt *getCallExpr() const {
607  return static_cast<const Stmt *>(getData1());
608  }
609 
611  return static_cast<const StackFrameContext *>(getData2());
612  }
613 
614  /// Returns the entry block in the CFG for the entered function.
615  const CFGBlock *getEntry() const {
616  const StackFrameContext *CalleeCtx = getCalleeContext();
617  const CFG *CalleeCFG = CalleeCtx->getCFG();
618  return &(CalleeCFG->getEntry());
619  }
620 
621 private:
622  friend class ProgramPoint;
623  CallEnter() = default;
624  static bool isKind(const ProgramPoint &Location) {
625  return Location.getKind() == CallEnterKind;
626  }
627 };
628 
629 /// Represents a point when we start the call exit sequence (for inlined call).
630 ///
631 /// The call exit is simulated with a sequence of nodes, which occur between
632 /// CallExitBegin and CallExitEnd. The following operations occur between the
633 /// two program points:
634 /// - CallExitBegin
635 /// - Bind the return value
636 /// - Run Remove dead bindings (to clean up the dead symbols from the callee).
637 /// - CallExitEnd
638 class CallExitBegin : public ProgramPoint {
639 public:
640  // CallExitBegin uses the callee's location context.
642  : ProgramPoint(RS, CallExitBeginKind, L, nullptr) { }
643 
644  const ReturnStmt *getReturnStmt() const {
645  return static_cast<const ReturnStmt *>(getData1());
646  }
647 
648 private:
649  friend class ProgramPoint;
650  CallExitBegin() = default;
651  static bool isKind(const ProgramPoint &Location) {
652  return Location.getKind() == CallExitBeginKind;
653  }
654 };
655 
656 /// Represents a point when we finish the call exit sequence (for inlined call).
657 /// \sa CallExitBegin
658 class CallExitEnd : public ProgramPoint {
659 public:
660  // CallExitEnd uses the caller's location context.
661  CallExitEnd(const StackFrameContext *CalleeCtx,
662  const LocationContext *CallerCtx)
663  : ProgramPoint(CalleeCtx, CallExitEndKind, CallerCtx, nullptr) {}
664 
666  return static_cast<const StackFrameContext *>(getData1());
667  }
668 
669 private:
670  friend class ProgramPoint;
671  CallExitEnd() = default;
672  static bool isKind(const ProgramPoint &Location) {
673  return Location.getKind() == CallExitEndKind;
674  }
675 };
676 
677 /// Represents a point when we exit a loop.
678 /// When this ProgramPoint is encountered we can be sure that the symbolic
679 /// execution of the corresponding LoopStmt is finished on the given path.
680 /// Note: It is possible to encounter a LoopExit element when we haven't even
681 /// encountered the loop itself. At the current state not all loop exits will
682 /// result in a LoopExit program point.
683 class LoopExit : public ProgramPoint {
684 public:
685  LoopExit(const Stmt *LoopStmt, const LocationContext *LC)
686  : ProgramPoint(LoopStmt, nullptr, LoopExitKind, LC) {}
687 
688  const Stmt *getLoopStmt() const {
689  return static_cast<const Stmt *>(getData1());
690  }
691 
692 private:
693  friend class ProgramPoint;
694  LoopExit() = default;
695  static bool isKind(const ProgramPoint &Location) {
696  return Location.getKind() == LoopExitKind;
697  }
698 };
699 
700 /// This is a meta program point, which should be skipped by all the diagnostic
701 /// reasoning etc.
702 class EpsilonPoint : public ProgramPoint {
703 public:
704  EpsilonPoint(const LocationContext *L, const void *Data1,
705  const void *Data2 = nullptr,
706  const ProgramPointTag *tag = nullptr)
707  : ProgramPoint(Data1, Data2, EpsilonKind, L, tag) {}
708 
709  const void *getData() const { return getData1(); }
710 
711 private:
712  friend class ProgramPoint;
713  EpsilonPoint() = default;
714  static bool isKind(const ProgramPoint &Location) {
715  return Location.getKind() == EpsilonKind;
716  }
717 };
718 
719 } // end namespace clang
720 
721 
722 namespace llvm { // Traits specialization for DenseMap
723 
724 template <> struct DenseMapInfo<clang::ProgramPoint> {
725 
727  uintptr_t x =
728  reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
729  return clang::BlockEntrance(reinterpret_cast<clang::CFGBlock*>(x), nullptr);
730 }
731 
733  uintptr_t x =
734  reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getTombstoneKey()) & ~0x7;
735  return clang::BlockEntrance(reinterpret_cast<clang::CFGBlock*>(x), nullptr);
736 }
737 
738 static unsigned getHashValue(const clang::ProgramPoint &Loc) {
739  return Loc.getHashValue();
740 }
741 
742 static bool isEqual(const clang::ProgramPoint &L,
743  const clang::ProgramPoint &R) {
744  return L == R;
745 }
746 
747 };
748 
749 template <>
750 struct isPodLike<clang::ProgramPoint> { static const bool value = true; };
751 
752 } // end namespace llvm
753 
754 #endif
static unsigned getHashValue(const clang::ProgramPoint &Loc)
Definition: ProgramPoint.h:738
PreLoad(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:360
bool empty() const
Definition: CFG.h:727
LoopExit(const Stmt *LoopStmt, const LocationContext *LC)
Definition: ProgramPoint.h:685
const T * getStmtAs() const
Definition: ProgramPoint.h:275
static clang::ProgramPoint getTombstoneKey()
Definition: ProgramPoint.h:732
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
ProgramPointTag(void *tagKind=nullptr)
Definition: ProgramPoint.h:42
CallExitBegin(const StackFrameContext *L, const ReturnStmt *RS)
Definition: ProgramPoint.h:641
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
Stmt - This represents one statement.
Definition: Stmt.h:66
CFGElement front() const
Definition: CFG.h:713
CFGBlock & getEntry()
Definition: CFG.h:1067
BlockEdge(const CFGBlock *B1, const CFGBlock *B2, const LocationContext *L)
Definition: ProgramPoint.h:475
PreStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag, const Stmt *SubStmt=nullptr)
Definition: ProgramPoint.h:290
PostLValue(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:429
const CFGBlock * getSrc() const
Definition: ProgramPoint.h:481
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Represents a point when we begin processing an inlined call.
Definition: ProgramPoint.h:600
StringRef P
ProgramPoint withTag(const ProgramPointTag *tag) const
Create a new ProgramPoint object that is the same as the original except for using the specified tag ...
Definition: ProgramPoint.h:133
void setData2(const void *d)
Definition: ProgramPoint.h:128
Represents a point after we ran remove dead bindings BEFORE processing the given statement.
Definition: ProgramPoint.h:443
Represents a program point just before an implicit call event.
Definition: ProgramPoint.h:553
const Stmt * getSubStmt() const
Definition: ProgramPoint.h:294
Optional< CFGElement > getFirstElement() const
Definition: ProgramPoint.h:230
Represents a point when we exit a loop.
Definition: ProgramPoint.h:683
BlockEntrance(const CFGBlock *B, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:220
Represents an implicit call event.
Definition: ProgramPoint.h:529
const void * getLocationValue() const
Returns the location of the field.
Definition: ProgramPoint.h:514
CallExitEnd(const StackFrameContext *CalleeCtx, const LocationContext *CallerCtx)
Definition: ProgramPoint.h:661
ProgramPoint(const void *P, Kind k, const LocationContext *l, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:102
static clang::ProgramPoint getEmptyKey()
Definition: ProgramPoint.h:726
const CFGBlock * getEntry() const
Returns the entry block in the CFG for the entered function.
Definition: ProgramPoint.h:615
const Stmt * getCallExpr() const
Definition: ProgramPoint.h:606
PostStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:316
Represents a program point after a store evaluation.
Definition: ProgramPoint.h:401
PostInitializer(const CXXCtorInitializer *I, const void *Loc, const LocationContext *L)
Construct a PostInitializer point that represents a location after CXXCtorInitializer expression eval...
Definition: ProgramPoint.h:504
PostLoad(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:388
Represents a point when we start the call exit sequence (for inlined call).
Definition: ProgramPoint.h:638
SourceLocation getLocation() const
Definition: ProgramPoint.h:536
This is a meta program point, which should be skipped by all the diagnostic reasoning etc...
Definition: ProgramPoint.h:702
PostStmt(const Stmt *S, Kind k, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:312
const void * getLocationValue() const
Returns the information about the location used in the store, how it was uttered in the code...
Definition: ProgramPoint.h:415
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: ProgramPoint.h:205
static bool isEqual(const clang::ProgramPoint &L, const clang::ProgramPoint &R)
Definition: ProgramPoint.h:742
const void * getData() const
Definition: ProgramPoint.h:709
Represents a point after we ran remove dead bindings AFTER processing the given statement.
Definition: ProgramPoint.h:459
PostAllocatorCall(const Stmt *S, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
Definition: ProgramPoint.h:586
const CFGBlock * getBlock() const
Definition: ProgramPoint.h:248
const CXXCtorInitializer * getInitializer() const
Definition: ProgramPoint.h:509
CFGBlock - Represents a single basic block in a source-level CFG.
Definition: CFG.h:562
Represents a point when we finish the call exit sequence (for inlined call).
Definition: ProgramPoint.h:658
const CFGBlock * getBlock() const
Definition: ProgramPoint.h:226
CFG - Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
Definition: CFG.h:979
StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L, const ProgramPointTag *tag)
Definition: ProgramPoint.h:266
const FunctionProtoType * T
EpsilonPoint(const LocationContext *L, const void *Data1, const void *Data2=nullptr, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:704
Kind getKind() const
Definition: ProgramPoint.h:161
virtual StringRef getTagDescription() const =0
const Stmt * getTerminator() const
Definition: ProgramPoint.h:252
const CFGBlock * getDst() const
Definition: ProgramPoint.h:485
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1417
PreStore(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:374
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c.h:82
ProgramPoint(const void *P1, const void *P2, Kind k, const LocationContext *l, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:115
PreStmtPurgeDeadSymbols(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:445
PostImplicitCall(const Decl *D, SourceLocation Loc, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
Definition: ProgramPoint.h:572
const Stmt * getStmt() const
Definition: ProgramPoint.h:272
unsigned getHashValue() const
Definition: ProgramPoint.h:185
PostStmt(const Stmt *S, const void *data, Kind k, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:307
const Stmt * getLoopStmt() const
Definition: ProgramPoint.h:688
PostStore(const Stmt *S, const LocationContext *L, const void *Loc, const ProgramPointTag *tag=nullptr)
Construct the post store point.
Definition: ProgramPoint.h:406
Encodes a location in the source.
T castAs() const
Convert to the specified ProgramPoint type, asserting that this ProgramPoint is of the desired type...
Definition: ProgramPoint.h:141
ProgramPoints can be "tagged" as representing points specific to a given analysis entity...
Definition: ProgramPoint.h:40
CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx, const LocationContext *callerCtx)
Definition: ProgramPoint.h:602
const Decl * getDecl() const
Definition: ProgramPoint.h:535
BlockExit(const CFGBlock *B, const LocationContext *L)
Definition: ProgramPoint.h:245
const ReturnStmt * getReturnStmt() const
Definition: ProgramPoint.h:644
Dataflow Directional Tag Classes.
Represents a program point just after an implicit call event.
Definition: ProgramPoint.h:570
const StackFrameContext * getCalleeContext() const
Definition: ProgramPoint.h:610
const StackFrameContext * getCalleeContext() const
Definition: ProgramPoint.h:665
bool isPurgeKind()
Is this a program point corresponding to purge/removal of dead symbols and bindings.
Definition: ProgramPoint.h:172
const ProgramPointTag * getTag() const
Definition: ProgramPoint.h:178
PostCondition(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:331
const void * getTagKind()
Used to implement &#39;isKind&#39; in subclasses.
Definition: ProgramPoint.h:48
ImplicitCallPoint(const Decl *D, SourceLocation Loc, Kind K, const LocationContext *L, const ProgramPointTag *Tag)
Definition: ProgramPoint.h:531
PostStmtPurgeDeadSymbols(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:461
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2227
const void * getData2() const
Definition: ProgramPoint.h:127
LocationCheck(const Stmt *S, const LocationContext *L, ProgramPoint::Kind K, const ProgramPointTag *tag)
Definition: ProgramPoint.h:346
const LocationContext * getLocationContext() const
Definition: ProgramPoint.h:180
PreImplicitCall(const Decl *D, SourceLocation Loc, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
Definition: ProgramPoint.h:555
bool operator!=(const ProgramPoint &RHS) const
Definition: ProgramPoint.h:198
bool operator==(const ProgramPoint &RHS) const
Definition: ProgramPoint.h:191
const void * getData1() const
Definition: ProgramPoint.h:126
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:930
Optional< T > getAs() const
Convert to the specified ProgramPoint type, returning None if this ProgramPoint is not of the desired...
Definition: ProgramPoint.h:152
static SourceLocation getFromPtrEncoding(const void *Encoding)
Turn a pointer encoding of a SourceLocation object back into a real SourceLocation.