diff options
Diffstat (limited to 'include/clang/Analysis/ProgramPoint.h')
-rw-r--r-- | include/clang/Analysis/ProgramPoint.h | 89 |
1 files changed, 56 insertions, 33 deletions
diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index 2d59dec48a880..e8f0d61617eb7 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -73,8 +73,9 @@ public: PostStoreKind, PostConditionKind, PostLValueKind, + PostAllocatorCallKind, MinPostStmtKind = PostStmtKind, - MaxPostStmtKind = PostLValueKind, + MaxPostStmtKind = PostAllocatorCallKind, PostInitializerKind, CallEnterKind, CallExitBeginKind, @@ -97,7 +98,7 @@ private: llvm::PointerIntPair<const ProgramPointTag *, 2, unsigned> Tag; protected: - ProgramPoint() {} + ProgramPoint() = default; ProgramPoint(const void *P, Kind k, const LocationContext *l, @@ -134,7 +135,7 @@ public: getLocationContext(), tag); } - /// \brief Convert to the specified ProgramPoint type, asserting that this + /// Convert to the specified ProgramPoint type, asserting that this /// ProgramPoint is of the desired type. template<typename T> T castAs() const { @@ -145,7 +146,7 @@ public: return t; } - /// \brief Convert to the specified ProgramPoint type, returning None if this + /// Convert to the specified ProgramPoint type, returning None if this /// ProgramPoint is not of the desired type. template<typename T> Optional<T> getAs() const { @@ -166,7 +167,7 @@ public: return (Kind) x; } - /// \brief Is this a program point corresponding to purge/removal of dead + /// Is this a program point corresponding to purge/removal of dead /// symbols and bindings. bool isPurgeKind() { Kind K = getKind(); @@ -180,6 +181,10 @@ public: return L.getPointer(); } + const StackFrameContext *getStackFrame() const { + return getLocationContext()->getStackFrame(); + } + // For use with DenseMap. This hash is probably slow. unsigned getHashValue() const { llvm::FoldingSetNodeID ID; @@ -233,7 +238,7 @@ public: private: friend class ProgramPoint; - BlockEntrance() {} + BlockEntrance() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == BlockEntranceKind; } @@ -254,7 +259,7 @@ public: private: friend class ProgramPoint; - BlockExit() {} + BlockExit() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == BlockExitKind; } @@ -274,7 +279,7 @@ public: const T* getStmtAs() const { return dyn_cast<T>(getStmt()); } protected: - StmtPoint() {} + StmtPoint() = default; private: friend class ProgramPoint; static bool isKind(const ProgramPoint &Location) { @@ -294,7 +299,7 @@ public: private: friend class ProgramPoint; - PreStmt() {} + PreStmt() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PreStmtKind; } @@ -302,7 +307,7 @@ private: class PostStmt : public StmtPoint { protected: - PostStmt() {} + PostStmt() = default; PostStmt(const Stmt *S, const void *data, Kind k, const LocationContext *L, const ProgramPointTag *tag = nullptr) : StmtPoint(S, data, k, L, tag) {} @@ -333,7 +338,7 @@ public: private: friend class ProgramPoint; - PostCondition() {} + PostCondition() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PostConditionKind; } @@ -341,7 +346,7 @@ private: class LocationCheck : public StmtPoint { protected: - LocationCheck() {} + LocationCheck() = default; LocationCheck(const Stmt *S, const LocationContext *L, ProgramPoint::Kind K, const ProgramPointTag *tag) : StmtPoint(S, nullptr, K, L, tag) {} @@ -362,7 +367,7 @@ public: private: friend class ProgramPoint; - PreLoad() {} + PreLoad() = default; static bool isKind(const ProgramPoint &location) { return location.getKind() == PreLoadKind; } @@ -376,7 +381,7 @@ public: private: friend class ProgramPoint; - PreStore() {} + PreStore() = default; static bool isKind(const ProgramPoint &location) { return location.getKind() == PreStoreKind; } @@ -390,13 +395,13 @@ public: private: friend class ProgramPoint; - PostLoad() {} + PostLoad() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PostLoadKind; } }; -/// \brief Represents a program point after a store evaluation. +/// Represents a program point after a store evaluation. class PostStore : public PostStmt { public: /// Construct the post store point. @@ -409,7 +414,7 @@ public: setData2(Loc); } - /// \brief Returns the information about the location used in the store, + /// Returns the information about the location used in the store, /// how it was uttered in the code. const void *getLocationValue() const { return getData2(); @@ -417,7 +422,7 @@ public: private: friend class ProgramPoint; - PostStore() {} + PostStore() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PostStoreKind; } @@ -431,7 +436,7 @@ public: private: friend class ProgramPoint; - PostLValue() {} + PostLValue() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PostLValueKind; } @@ -447,7 +452,7 @@ public: private: friend class ProgramPoint; - PreStmtPurgeDeadSymbols() {} + PreStmtPurgeDeadSymbols() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PreStmtPurgeDeadSymbolsKind; } @@ -463,7 +468,7 @@ public: private: friend class ProgramPoint; - PostStmtPurgeDeadSymbols() {} + PostStmtPurgeDeadSymbols() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PostStmtPurgeDeadSymbolsKind; } @@ -487,7 +492,7 @@ public: private: friend class ProgramPoint; - BlockEdge() {} + BlockEdge() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == BlockEdgeKind; } @@ -495,7 +500,7 @@ private: class PostInitializer : public ProgramPoint { public: - /// \brief Construct a PostInitializer point that represents a location after + /// Construct a PostInitializer point that represents a location after /// CXXCtorInitializer expression evaluation. /// /// \param I The initializer. @@ -509,14 +514,14 @@ public: return static_cast<const CXXCtorInitializer *>(getData1()); } - /// \brief Returns the location of the field. + /// Returns the location of the field. const void *getLocationValue() const { return getData2(); } private: friend class ProgramPoint; - PostInitializer() {} + PostInitializer() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PostInitializerKind; } @@ -537,7 +542,7 @@ public: } protected: - ImplicitCallPoint() {} + ImplicitCallPoint() = default; private: friend class ProgramPoint; static bool isKind(const ProgramPoint &Location) { @@ -557,7 +562,7 @@ public: private: friend class ProgramPoint; - PreImplicitCall() {} + PreImplicitCall() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PreImplicitCallKind; } @@ -574,12 +579,26 @@ public: private: friend class ProgramPoint; - PostImplicitCall() {} + PostImplicitCall() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == PostImplicitCallKind; } }; +class PostAllocatorCall : public StmtPoint { +public: + PostAllocatorCall(const Stmt *S, const LocationContext *L, + const ProgramPointTag *Tag = nullptr) + : StmtPoint(S, nullptr, PostAllocatorCallKind, L, Tag) {} + +private: + friend class ProgramPoint; + PostAllocatorCall() = default; + static bool isKind(const ProgramPoint &Location) { + return Location.getKind() == PostAllocatorCallKind; + } +}; + /// Represents a point when we begin processing an inlined call. /// CallEnter uses the caller's location context. class CallEnter : public ProgramPoint { @@ -605,7 +624,7 @@ public: private: friend class ProgramPoint; - CallEnter() {} + CallEnter() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == CallEnterKind; } @@ -626,9 +645,13 @@ public: CallExitBegin(const StackFrameContext *L, const ReturnStmt *RS) : ProgramPoint(RS, CallExitBeginKind, L, nullptr) { } + const ReturnStmt *getReturnStmt() const { + return static_cast<const ReturnStmt *>(getData1()); + } + private: friend class ProgramPoint; - CallExitBegin() {} + CallExitBegin() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == CallExitBeginKind; } @@ -649,7 +672,7 @@ public: private: friend class ProgramPoint; - CallExitEnd() {} + CallExitEnd() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == CallExitEndKind; } @@ -672,7 +695,7 @@ public: private: friend class ProgramPoint; - LoopExit() {} + LoopExit() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == LoopExitKind; } @@ -691,7 +714,7 @@ public: private: friend class ProgramPoint; - EpsilonPoint() {} + EpsilonPoint() = default; static bool isKind(const ProgramPoint &Location) { return Location.getKind() == EpsilonKind; } |