Go to the documentation of this file.
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/Optional.h"
22 #include "llvm/ADT/PointerIntPair.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Support/Casting.h"
25 #include "llvm/Support/DataTypes.h"
32 class AnalysisDeclContext;
33 class LocationContext;
48 const void *
const TagKind;
90 llvm::PointerIntPair<const void *, 2, unsigned> Data2;
94 llvm::PointerIntPair<const LocationContext *, 2, unsigned> L;
96 llvm::PointerIntPair<const ProgramPointTag *, 2, unsigned> Tag;
105 Data2(nullptr, (((
unsigned) k) >> 0) & 0x3),
107 Tag(tag, (((
unsigned) k) >> 4) & 0x3) {
119 Data2(P2, (((
unsigned) k) >> 0) & 0x3),
121 Tag(tag, (((
unsigned) k) >> 4) & 0x3) {}
125 const void *
getData2()
const {
return Data2.getPointer(); }
126 void setData2(
const void *d) { Data2.setPointer(d); }
140 assert(T::isKind(*
this));
151 if (!T::isKind(*
this))
160 unsigned x = Tag.getInt();
179 return L.getPointer();
188 llvm::FoldingSetNodeID
ID;
190 return ID.ComputeHash();
194 return Data1 == RHS.Data1 &&
195 Data2 == RHS.Data2 &&
201 return Data1 != RHS.Data1 ||
202 Data2 != RHS.Data2 ||
215 void printJson(llvm::raw_ostream &Out,
const char *NL =
"\n")
const;
217 LLVM_DUMP_METHOD
void dump()
const;
229 assert(B &&
"BlockEntrance requires non-null block");
280 template <
typename T>
288 unsigned k = Location.
getKind();
297 const Stmt *SubStmt =
nullptr)
329 unsigned k = Location.
getKind();
382 unsigned k = location.
getKind();
506 assert(B1 &&
"BlockEdge: source block must be non-null");
507 assert(B2 &&
"BlockEdge: destination block must be non-null");
646 const CFG *CalleeCFG = CalleeCtx->
getCFG();
734 const void *Data2 =
nullptr,
753 template <>
struct DenseMapInfo<
clang::ProgramPoint> {
757 reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
763 reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getTombstoneKey()) & ~0x7;
Represents a point when we start the call exit sequence (for inlined call).
StringRef getTagDescription() const override
bool operator==(const ProgramPoint &RHS) const
const void * getData1() 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 ...
YAML serialization mapping.
PostCondition(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const StackFrameContext * getStackFrame() const
PreLoad(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
static SourceLocation getFromPtrEncoding(const void *Encoding)
Turn a pointer encoding of a SourceLocation object back into a real SourceLocation.
PostStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx, const LocationContext *callerCtx)
Encodes a location in the source.
ProgramPointTag(void *tagKind=nullptr)
CallExitBegin(const StackFrameContext *L, const ReturnStmt *RS)
ImplicitCallPoint(const Decl *D, SourceLocation Loc, Kind K, const LocationContext *L, const ProgramPointTag *Tag)
LoopExit(const Stmt *LoopStmt, const LocationContext *LC)
bool isPurgeKind()
Is this a program point corresponding to purge/removal of dead symbols and bindings.
static clang::ProgramPoint getEmptyKey()
EpsilonPoint(const LocationContext *L, const void *Data1, const void *Data2=nullptr, const ProgramPointTag *tag=nullptr)
const void * getData() const
const StackFrameContext * getCalleeContext() const
BlockExit(const CFGBlock *B, const LocationContext *L)
It represents a stack frame of the call stack (based on CallEvent).
PostImplicitCall(const Decl *D, SourceLocation Loc, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
This is a meta program point, which should be skipped by all the diagnostic reasoning etc.
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Represents a program point just after an implicit call event.
PreImplicitCall(const Decl *D, SourceLocation Loc, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
const LocationContext * getLocationContext() const
bool operator!=(const ProgramPoint &RHS) const
const CFGBlock * getBlock() const
const CFGBlock * getSrc() const
Represents a point when we exit a loop.
Represents a single basic block in a source-level CFG.
ImplicitCallPoint()=default
SourceLocation getLocation() const
const T * getStmtAs() const
PostStmt(const Stmt *S, Kind k, const LocationContext *L, const ProgramPointTag *tag=nullptr)
void printJson(llvm::raw_ostream &Out, const char *NL="\n") const
PostLoad(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Represents a point after we ran remove dead bindings AFTER processing the given statement.
Optional< T > getAs() const
Convert to the specified ProgramPoint type, returning None if this ProgramPoint is not of the desired...
const ProgramPointTag * getTag() const
static clang::ProgramPoint getTombstoneKey()
Represents a point when we finish the call exit sequence (for inlined call).
Represents a program point after a store evaluation.
void Profile(llvm::FoldingSetNodeID &ID) const
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
T castAs() const
Convert to the specified ProgramPoint type, asserting that this ProgramPoint is of the desired type.
PostInitializer(const CXXCtorInitializer *I, const void *Loc, const LocationContext *L)
Construct a PostInitializer point that represents a location after CXXCtorInitializer expression eval...
PostAllocatorCall(const Stmt *S, const LocationContext *L, const ProgramPointTag *Tag=nullptr)
const Stmt * getStmt() const
const Stmt * getCallExpr() const
unsigned getHashValue() const
void setData2(const void *d)
PostStmt(const Stmt *S, const void *data, Kind k, const LocationContext *L, const ProgramPointTag *tag=nullptr)
const CFGBlock * getDst() const
@ PreStmtPurgeDeadSymbolsKind
const Stmt * getSubStmt() const
virtual ~ProgramPointTag()
const CFGBlock * getEntry() const
Returns the entry block in the CFG for the entered function.
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg)
const ReturnStmt * getReturnStmt() const
IRgen optimization opportunities The common pattern of short x
PreStore(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
Represents an implicit call event.
const CXXCtorInitializer * getInitializer() const
PostStmtPurgeDeadSymbols(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
BlockEdge(const CFGBlock *B1, const CFGBlock *B2, const LocationContext *L)
Decl - This represents one declaration (or definition), e.g.
Optional< CFGElement > getFirstElement() const
static unsigned getHashValue(const clang::ProgramPoint &Loc)
static bool isEqual(const clang::ProgramPoint &L, const clang::ProgramPoint &R)
Represents a program point just before an implicit call event.
const Stmt * getLoopStmt() const
BlockEntrance(const CFGBlock *B, const LocationContext *L, const ProgramPointTag *tag=nullptr)
const ReturnStmt * getStmt() const
const StackFrameContext * getCalleeContext() const
virtual StringRef getTagDescription() const =0
ProgramPoint(const void *P, Kind k, const LocationContext *l, const ProgramPointTag *tag=nullptr)
PreStmt(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag, const Stmt *SubStmt=nullptr)
const void * getTagKind() const
Used to implement 'isKind' in subclasses.
const void * getData2() const
Stmt - This represents one statement.
LocationCheck(const Stmt *S, const LocationContext *L, ProgramPoint::Kind K, const ProgramPointTag *tag)
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const LocationContext *LC, const ProgramPointTag *tag)
FunctionExitPoint(const ReturnStmt *S, const LocationContext *LC, const ProgramPointTag *tag=nullptr)
const Decl * getDecl() const
Stmt * getTerminatorStmt()
Represents a point when we begin processing an inlined call.
const void * getLocationValue() const
Returns the location of the field.
LLVM_DUMP_METHOD void dump() const
PostLValue(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
const Stmt * getTerminator() const
const CFGBlock * getBlock() const
PreStmtPurgeDeadSymbols(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag=nullptr)
const StackFrameContext * getStackFrame() const
const CFGBlock * getBlock() const
Represents a C++ base or member initializer.
PostStore(const Stmt *S, const LocationContext *L, const void *Loc, const ProgramPointTag *tag=nullptr)
Construct the post store point.
ProgramPoint(const void *P1, const void *P2, Kind k, const LocationContext *l, const ProgramPointTag *tag=nullptr)
CallExitEnd(const StackFrameContext *CalleeCtx, const LocationContext *CallerCtx)
@ PostStmtPurgeDeadSymbolsKind
const void * getLocationValue() const
Returns the information about the location used in the store, how it was uttered in the code.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Represents a point after we ran remove dead bindings BEFORE processing the given statement.
StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L, const ProgramPointTag *tag)