Changeset View
Changeset View
Standalone View
Standalone View
clang/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | enum class ObjKind { | ||||
AnyObj, | AnyObj, | ||||
/// Indicates that the tracked object is a generalized object. | /// Indicates that the tracked object is a generalized object. | ||||
Generalized, | Generalized, | ||||
/// A descendant of OSObject. | /// A descendant of OSObject. | ||||
OS | OS | ||||
}; | }; | ||||
/// An ArgEffect summarizes the retain count behavior on an argument or receiver | enum ArgEffectKind { | ||||
/// to a function or method. | |||||
enum ArgEffect { | |||||
/// There is no effect. | /// There is no effect. | ||||
DoNothing, | DoNothing, | ||||
/// The argument is treated as if an -autorelease message had been sent to | /// The argument is treated as if an -autorelease message had been sent to | ||||
/// the referenced object. | /// the referenced object. | ||||
Autorelease, | Autorelease, | ||||
/// The argument is treated as if an -dealloc message had been sent to | /// The argument is treated as if an -dealloc message had been sent to | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | enum ArgEffectKind { | ||||
/// Performs the combined functionality of DecRefMsg and StopTrackingHard. | /// Performs the combined functionality of DecRefMsg and StopTrackingHard. | ||||
/// | /// | ||||
/// The models the effect that the called function decrements the reference | /// The models the effect that the called function decrements the reference | ||||
/// count of the argument and all typestate tracking on that argument | /// count of the argument and all typestate tracking on that argument | ||||
/// should cease. | /// should cease. | ||||
DecRefMsgAndStopTrackingHard | DecRefMsgAndStopTrackingHard | ||||
}; | }; | ||||
/// An ArgEffect summarizes the retain count behavior on an argument or receiver | |||||
/// to a function or method. | |||||
class ArgEffect { | |||||
private: | |||||
NoQ: This `private` is redundant. | |||||
ArgEffectKind K; | |||||
ObjKind O; | |||||
public: | |||||
ArgEffect(ArgEffectKind K = DoNothing, ObjKind O = ObjKind::AnyObj) | |||||
: K(K), O(O) {} | |||||
ArgEffectKind getKind() const { return K; } | |||||
ObjKind getObjKind() const { return O; } | |||||
ArgEffect withKind(ArgEffectKind NewK) { | |||||
return ArgEffect(NewK, O); | |||||
} | |||||
bool operator==(const ArgEffect &Other) const { | |||||
return K == Other.K && O == Other.O; | |||||
} | |||||
}; | |||||
/// RetEffect summarizes a call's retain/release behavior with respect | /// RetEffect summarizes a call's retain/release behavior with respect | ||||
/// to its return value. | /// to its return value. | ||||
class RetEffect { | class RetEffect { | ||||
public: | public: | ||||
enum Kind { | enum Kind { | ||||
/// Indicates that no retain count information is tracked for | /// Indicates that no retain count information is tracked for | ||||
/// the return value. | /// the return value. | ||||
NoRet, | NoRet, | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
/// The purpose of the API is to provide something simple. The actual | /// The purpose of the API is to provide something simple. The actual | ||||
/// static analyzer checker that implements retain/release typestate | /// static analyzer checker that implements retain/release typestate | ||||
/// tracking uses something more efficient. | /// tracking uses something more efficient. | ||||
class CallEffects { | class CallEffects { | ||||
llvm::SmallVector<ArgEffect, 10> Args; | llvm::SmallVector<ArgEffect, 10> Args; | ||||
RetEffect Ret; | RetEffect Ret; | ||||
ArgEffect Receiver; | ArgEffect Receiver; | ||||
CallEffects(const RetEffect &R) : Ret(R) {} | CallEffects(const RetEffect &R, | ||||
ArgEffect Receiver = ArgEffect(DoNothing, ObjKind::AnyObj)) | |||||
: Ret(R), Receiver(Receiver) {} | |||||
public: | public: | ||||
/// Returns the argument effects for a call. | /// Returns the argument effects for a call. | ||||
ArrayRef<ArgEffect> getArgs() const { return Args; } | ArrayRef<ArgEffect> getArgs() const { return Args; } | ||||
/// Returns the effects on the receiver. | /// Returns the effects on the receiver. | ||||
ArgEffect getReceiver() const { return Receiver; } | ArgEffect getReceiver() const { return Receiver; } | ||||
Show All 28 Lines | |||||
} // end namespace ento | } // end namespace ento | ||||
} // end namespace clang | } // end namespace clang | ||||
namespace llvm { | namespace llvm { | ||||
template <> struct FoldingSetTrait<ArgEffect> { | template <> struct FoldingSetTrait<ArgEffect> { | ||||
static inline void Profile(const ArgEffect X, FoldingSetNodeID &ID) { | static inline void Profile(const ArgEffect X, FoldingSetNodeID &ID) { | ||||
ID.AddInteger((unsigned) X); | ID.AddInteger((unsigned) X.getKind()); | ||||
ID.AddInteger((unsigned) X.getObjKind()); | |||||
} | } | ||||
}; | }; | ||||
template <> struct FoldingSetTrait<RetEffect> { | template <> struct FoldingSetTrait<RetEffect> { | ||||
static inline void Profile(const RetEffect &X, FoldingSetNodeID &ID) { | static inline void Profile(const RetEffect &X, FoldingSetNodeID &ID) { | ||||
ID.AddInteger((unsigned) X.getKind()); | ID.AddInteger((unsigned) X.getKind()); | ||||
ID.AddInteger((unsigned) X.getObjKind()); | ID.AddInteger((unsigned) X.getObjKind()); | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 519 Lines • Show Last 20 Lines |
This private is redundant.