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