14#ifndef LLVM_CLANG_ANALYSIS_PROGRAMPOINT_H
15#define LLVM_CLANG_ANALYSIS_PROGRAMPOINT_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"
50 const void *
const TagKind;
95 llvm::PointerIntPair<const void *, 2, unsigned> Data2;
99 llvm::PointerIntPair<const StackFrame *, 2, unsigned> S;
101 llvm::PointerIntPair<const ProgramPointTag *, 2, unsigned> Tag;
121 : Data1(P1), Data2(P2, (((
unsigned)k) >> 0) & 0x3),
127 const void *
getData2()
const {
return Data2.getPointer(); }
128 void setData2(
const void *d) { Data2.setPointer(d); }
143 assert(T::isKind(*
this));
152 template <
typename T> std::optional<T>
getAs()
const {
153 if (!T::isKind(*
this))
162 unsigned x = Tag.getInt();
184 llvm::FoldingSetNodeID ID;
186 return ID.ComputeHash();
190 return Data1 == RHS.Data1 && Data2 == RHS.Data2 && S == RHS.S &&
191 Tag == RHS.Tag && ElemRef == RHS.ElemRef;
195 return Data1 != RHS.Data1 || Data2 != RHS.Data2 || S != RHS.S ||
196 Tag != RHS.Tag || ElemRef != RHS.ElemRef;
199 void Profile(llvm::FoldingSetNodeID& ID)
const {
200 ID.AddInteger((
unsigned)
getKind());
205 ID.AddPointer(ElemRef.getParent());
206 ID.AddInteger(ElemRef.getIndexInBlock());
209 void printJson(llvm::raw_ostream &Out,
const char *NL =
"\n")
const;
211 LLVM_DUMP_METHOD
void dump()
const;
223 assert(CurrBlock &&
"BlockEntrance requires non-null block");
236 return B->
empty() ? std::optional<CFGElement>() : B->
front();
279 template <
typename T>
287 unsigned k = Location.getKind();
296 const Stmt *SubStmt =
nullptr)
328 unsigned k = Location.getKind();
380 unsigned k = location.
getKind();
504 assert(B1 &&
"BlockEdge: source block must be non-null");
505 assert(B2 &&
"BlockEdge: destination block must be non-null");
560 :
ProgramPoint(Loc.getPtrEncoding(), D, K, SF, Tag, ElemRef) {}
646 const CFG *CalleeCFG = CalleeSF->
getCFG();
733 const void *Data2 =
nullptr,
752template <>
struct DenseMapInfo<
clang::ProgramPoint> {
756 reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
763 reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getTombstoneKey()) & ~0x7;
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.
ElementRefImpl< true > ConstCFGElementRef
Stmt * getTerminatorStmt()
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Represents a C++ base or member initializer.
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.
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
ImplicitCallPoint()=default
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.
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)
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)
virtual ~ProgramPointTag()
const ProgramPointTag * getTag() 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)
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 ...
@ PreStmtPurgeDeadSymbolsKind
@ PostStmtPurgeDeadSymbolsKind
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;.
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.
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.
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.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
static bool isEqual(const clang::ProgramPoint &L, const clang::ProgramPoint &R)
static clang::ProgramPoint getTombstoneKey()
static unsigned getHashValue(const clang::ProgramPoint &Loc)
static clang::ProgramPoint getEmptyKey()