benhamilton accepted this revision.
benhamilton added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:123
+  size_t Start = PropertyName.find_first_of('_');
+  assert(Start != llvm::StringRef::npos);
+  auto Prefix = PropertyName.substr(0, Start);
----------------
Can you also check that Start + 1 < PropertyName.length() (e.g., the string 
doesn't end with a _)?

I know the regular expression shouldn't match this, so an assert is probably 
good. (There is logic later which tries to access Start + 1 without checking.)


================
Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:129
+  auto RegexExp =
+      llvm::Regex(llvm::StringRef(validPropertyNameRegex(Acronyms, false)));
+  return RegexExp.match(llvm::StringRef(PropertyName.substr(Start + 1)));
----------------
Don't need to explicitly wrap in llvm::StringRef, that class has an implicit 
constructor from std::string.

https://github.com/llvm-mirror/llvm/blob/master/include/llvm/ADT/StringRef.h#L95



================
Comment at: test/clang-tidy/objc-property-declaration.m:15-31
+@interface Foo (Bar)
+@property(assign, nonatomic) int abc_NotCamelCase;
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_NotCamelCase' 
not using lowerCamelCase style or not prefixed in a category, according to the 
Apple Coding Guidelines [objc-property-declaration]
+@property(assign, nonatomic) int abCD_camelCase;
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abCD_camelCase' 
not using lowerCamelCase style or not prefixed in a category, according to the 
Apple Coding Guidelines [objc-property-declaration]
+// CHECK-FIXES: @property(assign, nonatomic) int abcd_camelCase;
+@property(assign, nonatomic) int abCD_NotCamelCase;
----------------
Can we add checks for properties whose names end with _?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42464



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to