//==- ObjCPropertyChecker.cpp - Check ObjC properties ------------*- C++ -*-==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This checker finds issues with Objective-C properties. // Currently finds only one kind of issue: // - Find synthesized properties with copy attribute of mutable NS collection // types. Calling -copy on such collections produces an immutable copy, // which contradicts the type of the property. // //===----------------------------------------------------------------------===// #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/Checker.h" usingnamespaceclang; usingnamespaceento; namespace { class ObjCPropertyChecker : public Checker<check::ASTDecl<ObjCPropertyDecl>> { … }; } // end anonymous namespace. void ObjCPropertyChecker::checkASTDecl(const ObjCPropertyDecl *D, AnalysisManager &Mgr, BugReporter &BR) const { … } void ObjCPropertyChecker::checkCopyMutable(const ObjCPropertyDecl *D, BugReporter &BR) const { … } void ento::registerObjCPropertyChecker(CheckerManager &Mgr) { … } bool ento::shouldRegisterObjCPropertyChecker(const CheckerManager &mgr) { … }