clang  8.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  /// 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  /// 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  /// 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 
185  return getLocationContext()->getStackFrame();
186  }
187 
188  // For use with DenseMap. This hash is probably slow.
189  unsigned getHashValue() const {
190  llvm::FoldingSetNodeID ID;
191  Profile(ID);
192  return ID.ComputeHash();
193  }
194 
195  bool operator==(const ProgramPoint & RHS) const {
196  return Data1 == RHS.Data1 &&
197  Data2 == RHS.Data2 &&
198  L == RHS.L &&
199  Tag == RHS.Tag;
200  }
201 
202  bool operator!=(const ProgramPoint &RHS) const {
203  return Data1 != RHS.Data1 ||
204  Data2 != RHS.Data2 ||
205  L != RHS.L ||
206  Tag != RHS.Tag;
207  }
208 
209  void Profile(llvm::FoldingSetNodeID& ID) const {
210  ID.AddInteger((unsigned) getKind());
211  ID.AddPointer(getData1());
212  ID.AddPointer(getData2());
213  ID.AddPointer(getLocationContext());
214  ID.AddPointer(getTag());
215  }
216 
217  static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K,
218  const LocationContext *LC,
219  const ProgramPointTag *tag);
220 };
221 
222 class BlockEntrance : public ProgramPoint {
223 public:
225  const ProgramPointTag *tag = nullptr)
226  : ProgramPoint(B, BlockEntranceKind, L, tag) {
227  assert(B && "BlockEntrance requires non-null block");
228  }
229 
230  const CFGBlock *getBlock() const {
231  return reinterpret_cast<const CFGBlock*>(getData1());
232  }
233 
235  const CFGBlock *B = getBlock();
236  return B->empty() ? Optional<CFGElement>() : B->front();
237  }
238 
239 private:
240  friend class ProgramPoint;
241  BlockEntrance() = default;
242  static bool isKind(const ProgramPoint &Location) {
243  return Location.getKind() == BlockEntranceKind;
244  }
245 };
246 
247 class BlockExit : public ProgramPoint {
248 public:
249  BlockExit(const CFGBlock *B, const LocationContext *L)
250  : ProgramPoint(B, BlockExitKind, L) {}
251 
252  const CFGBlock *getBlock() const {
253  return reinterpret_cast<const CFGBlock*>(getData1());
254  }
255 
256  const Stmt *getTerminator() const {
257  return getBlock()->getTerminator();
258  }
259 
260 private:
261  friend class ProgramPoint;
262  BlockExit() = default;
263  static bool isKind(const ProgramPoint &Location) {
264  return Location.getKind() == BlockExitKind;
265  }
266 };
267 
268 class StmtPoint : public ProgramPoint {
269 public:
270  StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L,
271  const ProgramPointTag *tag)
272  : ProgramPoint(S, p2, k, L, tag) {
273  assert(S);
274  }
275 
276  const Stmt *getStmt() const { return (const Stmt*) getData1(); }
277 
278  template <typename T>
279  const T* getStmtAs() const { return dyn_cast<T>(getStmt()); }
280 
281 protected:
282  StmtPoint() = default;
283 private:
284  friend class ProgramPoint;
285  static bool isKind(const ProgramPoint &Location) {
286  unsigned k = Location.getKind();
287  return k >= PreStmtKind && k <= MaxPostStmtKind;
288  }
289 };
290 
291 
292 class PreStmt : public StmtPoint {
293 public:
294  PreStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag,
295  const Stmt *SubStmt = nullptr)
296  : StmtPoint(S, SubStmt, PreStmtKind, L, tag) {}
297 
298  const Stmt *getSubStmt() const { return (const Stmt*) getData2(); }
299 
300 private:
301  friend class ProgramPoint;
302  PreStmt() = default;
303  static bool isKind(const ProgramPoint &Location) {
304  return Location.getKind() == PreStmtKind;
305  }
306 };
307 
308 class PostStmt : public StmtPoint {
309 protected:
310  PostStmt() = default;
311  PostStmt(const Stmt *S, const void *data, Kind k, const LocationContext *L,
312  const ProgramPointTag *tag = nullptr)
313  : StmtPoint(S, data, k, L, tag) {}
314 
315 public:
316  explicit PostStmt(const Stmt *S, Kind k, const LocationContext *L,
317  const ProgramPointTag *tag = nullptr)
318  : StmtPoint(S, nullptr, k, L, tag) {}
319 
320  explicit PostStmt(const Stmt *S, const LocationContext *L,
321  const ProgramPointTag *tag = nullptr)
322  : StmtPoint(S, nullptr, PostStmtKind, L, tag) {}
323 
324 private:
325  friend class ProgramPoint;
326  static bool isKind(const ProgramPoint &Location) {
327  unsigned k = Location.getKind();
328  return k >= MinPostStmtKind && k <= MaxPostStmtKind;
329  }
330 };
331 
332 // PostCondition represents the post program point of a branch condition.
333 class PostCondition : public PostStmt {
334 public:
335  PostCondition(const Stmt *S, const LocationContext *L,
336  const ProgramPointTag *tag = nullptr)
337  : PostStmt(S, PostConditionKind, L, tag) {}
338 
339 private:
340  friend class ProgramPoint;
341  PostCondition() = default;
342  static bool isKind(const ProgramPoint &Location) {
343  return Location.getKind() == PostConditionKind;
344  }
345 };
346 
347 class LocationCheck : public StmtPoint {
348 protected:
349  LocationCheck() = default;
350  LocationCheck(const Stmt *S, const LocationContext *L,
351  ProgramPoint::Kind K, const ProgramPointTag *tag)
352  : StmtPoint(S, nullptr, K, L, tag) {}
353 
354 private:
355  friend class ProgramPoint;
356  static bool isKind(const ProgramPoint &location) {
357  unsigned k = location.getKind();
358  return k == PreLoadKind || k == PreStoreKind;
359  }
360 };
361 
362 class PreLoad : public LocationCheck {
363 public:
364  PreLoad(const Stmt *S, const LocationContext *L,
365  const ProgramPointTag *tag = nullptr)
366  : LocationCheck(S, L, PreLoadKind, tag) {}
367 
368 private:
369  friend class ProgramPoint;
370  PreLoad() = default;
371  static bool isKind(const ProgramPoint &location) {
372  return location.getKind() == PreLoadKind;
373  }
374 };
375 
376 class PreStore : public LocationCheck {
377 public:
378  PreStore(const Stmt *S, const LocationContext *L,
379  const ProgramPointTag *tag = nullptr)
380  : LocationCheck(S, L, PreStoreKind, tag) {}
381 
382 private:
383  friend class ProgramPoint;
384  PreStore() = default;
385  static bool isKind(const ProgramPoint &location) {
386  return location.getKind() == PreStoreKind;
387  }
388 };
389 
390 class PostLoad : public PostStmt {
391 public:
392  PostLoad(const Stmt *S, const LocationContext *L,
393  const ProgramPointTag *tag = nullptr)
394  : PostStmt(S, PostLoadKind, L, tag) {}
395 
396 private:
397  friend class ProgramPoint;
398  PostLoad() = default;
399  static bool isKind(const ProgramPoint &Location) {
400  return Location.getKind() == PostLoadKind;
401  }
402 };
403 
404 /// Represents a program point after a store evaluation.
405 class PostStore : public PostStmt {
406 public:
407  /// Construct the post store point.
408  /// \param Loc can be used to store the information about the location
409  /// used in the form it was uttered in the code.
410  PostStore(const Stmt *S, const LocationContext *L, const void *Loc,
411  const ProgramPointTag *tag = nullptr)
412  : PostStmt(S, PostStoreKind, L, tag) {
413  assert(getData2() == nullptr);
414  setData2(Loc);
415  }
416 
417  /// Returns the information about the location used in the store,
418  /// how it was uttered in the code.
419  const void *getLocationValue() const {
420  return getData2();
421  }
422 
423 private:
424  friend class ProgramPoint;
425  PostStore() = default;
426  static bool isKind(const ProgramPoint &Location) {
427  return Location.getKind() == PostStoreKind;
428  }
429 };
430 
431 class PostLValue : public PostStmt {
432 public:
433  PostLValue(const Stmt *S, const LocationContext *L,
434  const ProgramPointTag *tag = nullptr)
435  : PostStmt(S, PostLValueKind, L, tag) {}
436 
437 private:
438  friend class ProgramPoint;
439  PostLValue() = default;
440  static bool isKind(const ProgramPoint &Location) {
441  return Location.getKind() == PostLValueKind;
442  }
443 };
444 
445 /// Represents a point after we ran remove dead bindings BEFORE
446 /// processing the given statement.
448 public:
450  const ProgramPointTag *tag = nullptr)
451  : StmtPoint(S, nullptr, PreStmtPurgeDeadSymbolsKind, L, tag) { }
452 
453 private:
454  friend class ProgramPoint;
455  PreStmtPurgeDeadSymbols() = default;
456  static bool isKind(const ProgramPoint &Location) {
457  return Location.getKind() == PreStmtPurgeDeadSymbolsKind;
458  }
459 };
460 
461 /// Represents a point after we ran remove dead bindings AFTER
462 /// processing the given statement.
464 public:
466  const ProgramPointTag *tag = nullptr)
467  : StmtPoint(S, nullptr, PostStmtPurgeDeadSymbolsKind, L, tag) { }
468 
469 private:
470  friend class ProgramPoint;
471  PostStmtPurgeDeadSymbols() = default;
472  static bool isKind(const ProgramPoint &Location) {
473  return Location.getKind() == PostStmtPurgeDeadSymbolsKind;
474  }
475 };
476 
477 class BlockEdge : public ProgramPoint {
478 public:
479  BlockEdge(const CFGBlock *B1, const CFGBlock *B2, const LocationContext *L)
480  : ProgramPoint(B1, B2, BlockEdgeKind, L) {
481  assert(B1 && "BlockEdge: source block must be non-null");
482  assert(B2 && "BlockEdge: destination block must be non-null");
483  }
484 
485  const CFGBlock *getSrc() const {
486  return static_cast<const CFGBlock*>(getData1());
487  }
488 
489  const CFGBlock *getDst() const {
490  return static_cast<const CFGBlock*>(getData2());
491  }
492 
493 private:
494  friend class ProgramPoint;
495  BlockEdge() = default;
496  static bool isKind(const ProgramPoint &Location) {
497  return Location.getKind() == BlockEdgeKind;
498  }
499 };
500 
502 public:
503  /// Construct a PostInitializer point that represents a location after
504  /// CXXCtorInitializer expression evaluation.
505  ///
506  /// \param I The initializer.
507  /// \param Loc The location of the field being initialized.
509  const void *Loc,
510  const LocationContext *L)
511  : ProgramPoint(I, Loc, PostInitializerKind, L) {}
512 
514  return static_cast<const CXXCtorInitializer *>(getData1());
515  }
516 
517  /// Returns the location of the field.
518  const void *getLocationValue() const {
519  return getData2();
520  }
521 
522 private:
523  friend class ProgramPoint;
524  PostInitializer() = default;
525  static bool isKind(const ProgramPoint &Location) {
526  return Location.getKind() == PostInitializerKind;
527  }
528 };
529 
530 /// Represents an implicit call event.
531 ///
532 /// The nearest statement is provided for diagnostic purposes.
534 public:
536  const LocationContext *L, const ProgramPointTag *Tag)
537  : ProgramPoint(Loc.getPtrEncoding(), D, K, L, Tag) {}
538 
539  const Decl *getDecl() const { return static_cast<const Decl *>(getData2()); }
541  return SourceLocation::getFromPtrEncoding(getData1());
542  }
543 
544 protected:
545  ImplicitCallPoint() = default;
546 private:
547  friend class ProgramPoint;
548  static bool isKind(const ProgramPoint &Location) {
549  return Location.getKind() >= MinImplicitCallKind &&
550  Location.getKind() <= MaxImplicitCallKind;
551  }
552 };
553 
554 /// Represents a program point just before an implicit call event.
555 ///
556 /// Explicit calls will appear as PreStmt program points.
558 public:
560  const ProgramPointTag *Tag = nullptr)
561  : ImplicitCallPoint(D, Loc, PreImplicitCallKind, L, Tag) {}
562 
563 private:
564  friend class ProgramPoint;
565  PreImplicitCall() = default;
566  static bool isKind(const ProgramPoint &Location) {
567  return Location.getKind() == PreImplicitCallKind;
568  }
569 };
570 
571 /// Represents a program point just after an implicit call event.
572 ///
573 /// Explicit calls will appear as PostStmt program points.
575 public:
577  const ProgramPointTag *Tag = nullptr)
578  : ImplicitCallPoint(D, Loc, PostImplicitCallKind, L, Tag) {}
579 
580 private:
581  friend class ProgramPoint;
582  PostImplicitCall() = default;
583  static bool isKind(const ProgramPoint &Location) {
584  return Location.getKind() == PostImplicitCallKind;
585  }
586 };
587 
588 class PostAllocatorCall : public StmtPoint {
589 public:
591  const ProgramPointTag *Tag = nullptr)
592  : StmtPoint(S, nullptr, PostAllocatorCallKind, L, Tag) {}
593 
594 private:
595  friend class ProgramPoint;
596  PostAllocatorCall() = default;
597  static bool isKind(const ProgramPoint &Location) {
598  return Location.getKind() == PostAllocatorCallKind;
599  }
600 };
601 
602 /// Represents a point when we begin processing an inlined call.
603 /// CallEnter uses the caller's location context.
604 class CallEnter : public ProgramPoint {
605 public:
606  CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx,
607  const LocationContext *callerCtx)
608  : ProgramPoint(stmt, calleeCtx, CallEnterKind, callerCtx, nullptr) {}
609 
610  const Stmt *getCallExpr() const {
611  return static_cast<const Stmt *>(getData1());
612  }
613 
615  return static_cast<const StackFrameContext *>(getData2());
616  }
617 
618  /// Returns the entry block in the CFG for the entered function.
619  const CFGBlock *getEntry() const {
620  const StackFrameContext *CalleeCtx = getCalleeContext();
621  const CFG *CalleeCFG = CalleeCtx->getCFG();
622  return &(CalleeCFG->getEntry());
623  }
624 
625 private:
626  friend class ProgramPoint;
627  CallEnter() = default;
628  static bool isKind(const ProgramPoint &Location) {
629  return Location.getKind() == CallEnterKind;
630  }
631 };
632 
633 /// Represents a point when we start the call exit sequence (for inlined call).
634 ///
635 /// The call exit is simulated with a sequence of nodes, which occur between
636 /// CallExitBegin and CallExitEnd. The following operations occur between the
637 /// two program points:
638 /// - CallExitBegin
639 /// - Bind the return value
640 /// - Run Remove dead bindings (to clean up the dead symbols from the callee).
641 /// - CallExitEnd
642 class CallExitBegin : public ProgramPoint {
643 public:
644  // CallExitBegin uses the callee's location context.
646  : ProgramPoint(RS, CallExitBeginKind, L, nullptr) { }
647 
648  const ReturnStmt *getReturnStmt() const {
649  return static_cast<const ReturnStmt *>(getData1());
650  }
651 
652 private:
653  friend class ProgramPoint;
654  CallExitBegin() = default;
655  static bool isKind(const ProgramPoint &Location) {
656  return Location.getKind() == CallExitBeginKind;
657  }
658 };
659 
660 /// Represents a point when we finish the call exit sequence (for inlined call).
661 /// \sa CallExitBegin
662 class CallExitEnd : public ProgramPoint {
663 public:
664  // CallExitEnd uses the caller's location context.
665  CallExitEnd(const StackFrameContext *CalleeCtx,
666  const LocationContext *CallerCtx)
667  : ProgramPoint(CalleeCtx, CallExitEndKind, CallerCtx, nullptr) {}
668 
670  return static_cast<const StackFrameContext *>(getData1());
671  }
672 
673 private:
674  friend class ProgramPoint;
675  CallExitEnd() = default;
676  static bool isKind(const ProgramPoint &Location) {
677  return Location.getKind() == CallExitEndKind;
678  }
679 };
680 
681 /// Represents a point when we exit a loop.
682 /// When this ProgramPoint is encountered we can be sure that the symbolic
683 /// execution of the corresponding LoopStmt is finished on the given path.
684 /// Note: It is possible to encounter a LoopExit element when we haven't even
685 /// encountered the loop itself. At the current state not all loop exits will
686 /// result in a LoopExit program point.
687 class LoopExit : public ProgramPoint {
688 public:
689  LoopExit(const Stmt *LoopStmt, const LocationContext *LC)
690  : ProgramPoint(LoopStmt, nullptr, LoopExitKind, LC) {}
691 
692  const Stmt *getLoopStmt() const {
693  return static_cast<const Stmt *>(getData1());
694  }
695 
696 private:
697  friend class ProgramPoint;
698  LoopExit() = default;
699  static bool isKind(const ProgramPoint &Location) {
700  return Location.getKind() == LoopExitKind;
701  }
702 };
703 
704 /// This is a meta program point, which should be skipped by all the diagnostic
705 /// reasoning etc.
706 class EpsilonPoint : public ProgramPoint {
707 public:
708  EpsilonPoint(const LocationContext *L, const void *Data1,
709  const void *Data2 = nullptr,
710  const ProgramPointTag *tag = nullptr)
711  : ProgramPoint(Data1, Data2, EpsilonKind, L, tag) {}
712 
713  const void *getData() const { return getData1(); }
714 
715 private:
716  friend class ProgramPoint;
717  EpsilonPoint() = default;
718  static bool isKind(const ProgramPoint &Location) {
719  return Location.getKind() == EpsilonKind;
720  }
721 };
722 
723 } // end namespace clang
724 
725 
726 namespace llvm { // Traits specialization for DenseMap
727 
728 template <> struct DenseMapInfo<clang::ProgramPoint> {
729 
731  uintptr_t x =
732  reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
733  return clang::BlockEntrance(reinterpret_cast<clang::CFGBlock*>(x), nullptr);
734 }
735 
737  uintptr_t x =
738  reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getTombstoneKey()) & ~0x7;
739  return clang::BlockEntrance(reinterpret_cast<clang::CFGBlock*>(x), nullptr);
740 }
741 
742 static unsigned getHashValue(const clang::ProgramPoint &Loc) {
743  return Loc.getHashValue();
744 }
745 
746 static bool isEqual(const clang::ProgramPoint &L,
747  const clang::ProgramPoint &R) {
748  return L == R;
749 }
750 
751 };
752 
753 template <>
754 struct isPodLike<clang::ProgramPoint> { static const bool value = true; };
755 
756 } // end namespace llvm
757 
758 #endif
static unsigned getHashValue(const clang::ProgramPoint &Loc)
Definition: ProgramPoint.h:742
PreLoad(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:364
bool empty() const
Definition: CFG.h:714
LoopExit(const Stmt *LoopStmt, const LocationContext *LC)
Definition: ProgramPoint.h:689
const T * getStmtAs() const
Definition: ProgramPoint.h:279
static clang::ProgramPoint getTombstoneKey()
Definition: ProgramPoint.h:736
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:645
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
Stmt - This represents one statement.
Definition: Stmt.h:66
CFGElement front() const
Definition: CFG.h:700
CFGBlock & getEntry()
Definition: CFG.h:1093
BlockEdge(const CFGBlock *B1, const CFGBlock *B2, const LocationContext *L)
Definition: ProgramPoint.h:479
PreStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag, const Stmt *SubStmt=nullptr)
Definition: ProgramPoint.h:294
PostLValue(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:433
const CFGBlock * getSrc() const
Definition: ProgramPoint.h:485
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:604
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:447
Represents a program point just before an implicit call event.
Definition: ProgramPoint.h:557
const Stmt * getSubStmt() const
Definition: ProgramPoint.h:298
Optional< CFGElement > getFirstElement() const
Definition: ProgramPoint.h:234
Represents a point when we exit a loop.
Definition: ProgramPoint.h:687
BlockEntrance(const CFGBlock *B, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:224
Represents an implicit call event.
Definition: ProgramPoint.h:533
const void * getLocationValue() const
Returns the location of the field.
Definition: ProgramPoint.h:518
CallExitEnd(const StackFrameContext *CalleeCtx, const LocationContext *CallerCtx)
Definition: ProgramPoint.h:665
ProgramPoint(const void *P, Kind k, const LocationContext *l, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:102
static clang::ProgramPoint getEmptyKey()
Definition: ProgramPoint.h:730
const CFGBlock * getEntry() const
Returns the entry block in the CFG for the entered function.
Definition: ProgramPoint.h:619
const Stmt * getCallExpr() const
Definition: ProgramPoint.h:610
PostStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:320
Represents a program point after a store evaluation.
Definition: ProgramPoint.h:405
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:508
const StackFrameContext * getStackFrame() const
Definition: ProgramPoint.h:184
PostLoad(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:392
Represents a point when we start the call exit sequence (for inlined call).
Definition: ProgramPoint.h:642
SourceLocation getLocation() const
Definition: ProgramPoint.h:540
This is a meta program point, which should be skipped by all the diagnostic reasoning etc...
Definition: ProgramPoint.h:706
PostStmt(const Stmt *S, Kind k, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:316
const void * getLocationValue() const
Returns the information about the location used in the store, how it was uttered in the code...
Definition: ProgramPoint.h:419
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: ProgramPoint.h:209
static bool isEqual(const clang::ProgramPoint &L, const clang::ProgramPoint &R)
Definition: ProgramPoint.h:746
const void * getData() const
Definition: ProgramPoint.h:713
Represents a point after we ran remove dead bindings AFTER processing the given statement.
Definition: ProgramPoint.h:463
PostAllocatorCall(const Stmt *S, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
Definition: ProgramPoint.h:590
const CFGBlock * getBlock() const
Definition: ProgramPoint.h:252
const CXXCtorInitializer * getInitializer() const
Definition: ProgramPoint.h:513
Represents a single basic block in a source-level CFG.
Definition: CFG.h:552
Represents a point when we finish the call exit sequence (for inlined call).
Definition: ProgramPoint.h:662
const CFGBlock * getBlock() const
Definition: ProgramPoint.h:230
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
Definition: CFG.h:1003
StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L, const ProgramPointTag *tag)
Definition: ProgramPoint.h:270
EpsilonPoint(const LocationContext *L, const void *Data1, const void *Data2=nullptr, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:708
Kind getKind() const
Definition: ProgramPoint.h:161
virtual StringRef getTagDescription() const =0
const Stmt * getTerminator() const
Definition: ProgramPoint.h:256
const CFGBlock * getDst() const
Definition: ProgramPoint.h:489
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1588
PreStore(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:378
__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:449
PostImplicitCall(const Decl *D, SourceLocation Loc, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
Definition: ProgramPoint.h:576
const Stmt * getStmt() const
Definition: ProgramPoint.h:276
unsigned getHashValue() const
Definition: ProgramPoint.h:189
PostStmt(const Stmt *S, const void *data, Kind k, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:311
const Stmt * getLoopStmt() const
Definition: ProgramPoint.h:692
PostStore(const Stmt *S, const LocationContext *L, const void *Loc, const ProgramPointTag *tag=nullptr)
Construct the post store point.
Definition: ProgramPoint.h:410
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:606
const Decl * getDecl() const
Definition: ProgramPoint.h:539
BlockExit(const CFGBlock *B, const LocationContext *L)
Definition: ProgramPoint.h:249
const ReturnStmt * getReturnStmt() const
Definition: ProgramPoint.h:648
Dataflow Directional Tag Classes.
Represents a program point just after an implicit call event.
Definition: ProgramPoint.h:574
const StackFrameContext * getCalleeContext() const
Definition: ProgramPoint.h:614
const StackFrameContext * getCalleeContext() const
Definition: ProgramPoint.h:669
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:335
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:535
PostStmtPurgeDeadSymbols(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Definition: ProgramPoint.h:465
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2258
const void * getData2() const
Definition: ProgramPoint.h:127
LocationCheck(const Stmt *S, const LocationContext *L, ProgramPoint::Kind K, const ProgramPointTag *tag)
Definition: ProgramPoint.h:350
const LocationContext * getLocationContext() const
Definition: ProgramPoint.h:180
const StackFrameContext * getStackFrame() const
PreImplicitCall(const Decl *D, SourceLocation Loc, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
Definition: ProgramPoint.h:559
bool operator!=(const ProgramPoint &RHS) const
Definition: ProgramPoint.h:202
bool operator==(const ProgramPoint &RHS) const
Definition: ProgramPoint.h:195
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.