25 std::optional<bool> isUnsafeType(QualType QT)
const override {
28 std::optional<bool> isUnsafePtr(QualType QT,
bool)
const override {
34 bool isSafePtrType(QualType
T)
const override {
37 bool isPtrType(
const std::string &Name)
const override {
40 const char *typeName()
const override {
return "RefPtr-capable type"; }
45 std::optional<bool> isUnsafeType(QualType QT)
const override {
48 std::optional<bool> isUnsafePtr(QualType QT,
bool)
const override {
54 bool isSafePtrType(QualType
T)
const override {
57 bool isPtrType(
const std::string &Name)
const override {
60 bool isSafeExpr(
const Expr *E,
bool)
const override {
63 const char *typeName()
const override {
return "CheckedPtr-capable type"; }
67 mutable RetainTypeChecker RTC;
70 std::optional<bool> isUnsafeType(QualType QT)
const override {
71 return RTC.isUnretained(QT);
73 std::optional<bool> isUnsafePtr(QualType QT,
bool IgnoreARC)
const override {
74 return RTC.isUnretained(QT, IgnoreARC);
79 bool isSafePtrType(QualType
T)
const override {
82 bool isPtrType(
const std::string &Name)
const override {
85 bool isSafeExpr(
const Expr *E,
bool)
const override {
89 bool isSafeDecl(
const Decl *D,
const SourceManager &SM)
const override {
93 void describeHazard(llvm::raw_ostream &Os,
const Expr *Origin,
94 QualType SinkType)
const override {
97 Os << typeName() <<
" ";
98 if (
auto *Decl = RTC.getCanonicalDecl(SinkType)) {
101 const auto *
Typedef = VarType->getAs<TypedefType>();
109 const char *typeName()
const override {
return "RetainPtr-capable type"; }
110 RetainTypeChecker *retainTypeChecker()
const override {
return &RTC; }
115 std::optional<bool> isUnsafeType(QualType QT)
const override {
118 std::optional<bool> isUnsafePtr(QualType QT,
bool)
const override {
124 bool isSafePtrType(QualType
T)
const override {
return isBorrowType(
T); }
125 bool isPtrType(
const std::string &Name)
const override {
129 bool isSafeExpr(
const Expr *Origin,
130 bool PtrIsLifetimeBoundToOrigin)
const override {
131 if (!PtrIsLifetimeBoundToOrigin)
147 return !Borrowable || !*Borrowable;
150 bool checksForInteriorDestruction()
const override {
return true; }
151 bool recognizesIndirectStores()
const override {
return true; }
152 const char *typeName()
const override {
return "CanBorrow type"; }
154 void describeHazard(llvm::raw_ostream &Os,
const Expr *Origin,
155 QualType)
const override {
165 Os <<
"CanBorrow type ";
166 printTypeName(Os, OriginType);
168 Os <<
"a CanBorrow object";
169 Os <<
" that is not guarded by a Borrow";
180 if (Model.retainTypeChecker() &&
T.hasStrongOrWeakObjCLifetime())
182 return Model.isUnsafePtr(
T, IgnoreARC);
186 return std::make_unique<RefCountedSafetyModel>();
190 return std::make_unique<CheckedPtrSafetyModel>();
194 return std::make_unique<RetainPtrSafetyModel>();
198 return std::make_unique<BorrowSafetyModel>();
llvm::MachO::Record Record
Defines the SourceManager interface.
C Language Family Type Representation.
SourceLocation getLocation() const
Models one WebKit pointer-safety policy: ref-counted (RefPtr), checked (CheckedPtr),...
virtual void describeHazard(llvm::raw_ostream &Os, const Expr *, QualType SinkType) const
Prints a phrase describing why the reported value is unsafe, completing a sentence of the form "Local...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
QualType getCanonicalType() const
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isCocoaObjectRef(QualType T)
constexpr bool isPtrType(PrimType T)
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
std::unique_ptr< PtrRefSafetyModel > makeBorrowSafetyModel()
bool isExprToGetCheckedPtrCapableMember(const clang::Expr *E)
QualType pointeeType(QualType T)
std::optional< bool > isUnchecked(const QualType T)
QualType borrowedType(QualType T)
bool isRefOrCheckedPtrType(const clang::QualType T)
bool isView(const clang::QualType T)
std::unique_ptr< PtrRefSafetyModel > makeCheckedPtrSafetyModel()
void printQuotedQualifiedName(llvm::raw_ostream &Os, const NamedDeclDerivedT &D)
bool isRetainPtrOrOSPtrType(const clang::QualType T)
std::optional< bool > isUnsafePtrForStorage(const PtrRefSafetyModel &Model, QualType T, bool IgnoreARC=false)
Applies the memory-management exemptions that hold for a variable, member, or lambda capture (but not...
bool isBorrow(const clang::CXXRecordDecl *R)
std::optional< bool > isBorrowable(const clang::CXXRecordDecl *R)
const FunctionProtoType * T
bool isRefCounted(const CXXRecordDecl *R)
bool isRetainPtrOrOSPtr(const std::string &Name)
bool isRefType(const std::string &Name)
std::optional< bool > isUncountedPtr(const QualType T)
bool isSafePtr(clang::CXXRecordDecl *Decl)
bool isCheckedPtr(const std::string &Name)
bool isBorrowType(const clang::QualType T)
std::unique_ptr< PtrRefSafetyModel > makeRefPtrSafetyModel()
std::unique_ptr< PtrRefSafetyModel > makeRetainPtrSafetyModel()
std::optional< bool > isUncounted(const QualType T)
std::optional< bool > isUncheckedPtr(const QualType T)