38 auto Name = Decl->getName();
39 auto NewName = Decl->getName().str();
41 if (Style == CategoryProperty) {
42 size_t UnderScorePos = Name.find_first_of(
'_');
43 if (UnderScorePos != llvm::StringRef::npos) {
44 Index = UnderScorePos + 1;
45 NewName.replace(0, Index - 1, Name.substr(0, Index - 1).lower());
48 if (Index < Name.size()) {
49 NewName[Index] = tolower(NewName[Index]);
50 if (NewName != Name) {
51 return FixItHint::CreateReplacement(
52 CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
53 llvm::StringRef(NewName));
88 size_t Start = PropertyName.find_first_of(
'_');
89 assert(Start != llvm::StringRef::npos && Start + 1 < PropertyName.size());
90 auto Prefix = PropertyName.substr(0, Start);
91 if (Prefix.lower() != Prefix) {
95 return RegexExp.match(PropertyName.substr(Start + 1));
108 const auto *MatchedDecl =
109 Result.Nodes.getNodeAs<ObjCPropertyDecl>(
"property");
110 assert(!MatchedDecl->getName().empty());
111 auto *DeclContext = MatchedDecl->getDeclContext();
112 auto *CategoryDecl = llvm::dyn_cast<ObjCCategoryDecl>(DeclContext);
114 if (CategoryDecl !=
nullptr &&
117 CategoryDecl->IsClassExtension()) {
118 NamingStyle Style = CategoryDecl->IsClassExtension() ? StandardProperty
120 diag(MatchedDecl->getLocation(),
121 "property name '%0' not using lowerCamelCase style or not prefixed "
122 "in a category, according to the Apple Coding Guidelines")
127 diag(MatchedDecl->getLocation(),
128 "property name '%0' not using lowerCamelCase style or not prefixed in "
129 "a category, according to the Apple Coding Guidelines")
130 << MatchedDecl->getName()