21 using namespace clang;
25 class ObjCPropertyChecker
26 :
public Checker<check::ASTDecl<ObjCPropertyDecl>> {
31 BugReporter &BR)
const;
37 BugReporter &BR)
const {
38 checkCopyMutable(D, BR);
42 BugReporter &BR)
const {
53 if (!StringRef(PropTypeName).startswith(
"NSMutable"))
59 ImplD = IntD->getImplementation();
60 }
else if (
auto *CatD = dyn_cast<ObjCCategoryDecl>(D->
getDeclContext())) {
68 llvm::raw_svector_ostream
OS(Str);
69 OS <<
"Property of mutable type '" << PropTypeName
70 <<
"' has 'copy' attribute; an immutable object will be stored instead";
73 D,
this,
"Objective-C property misuse",
"Logic error",
OS.str(),
78 void ento::registerObjCPropertyChecker(CheckerManager &Mgr) {
79 Mgr.registerChecker<ObjCPropertyChecker>();
82 bool ento::shouldRegisterObjCPropertyChecker(
const LangOptions &LO) {
A (possibly-)qualified type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
Represents an ObjC class declaration.
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class, its protocols, its super classes or categories.
DeclContext * getDeclContext()
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM)
Create a location for the beginning of the declaration.
QualType getCanonicalType() const
bool isObjCObjectPointerType() const
Represents one property declaration in an Objective-C interface.
ObjCImplementationDecl * getImplementation() const
const ObjCInterfaceDecl * getClassInterface() const
Dataflow Directional Tag Classes.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Indicates that the tracking object is a descendant of a referenced-counted OSObject, used in the Darwin kernel.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.