[PATCH] D51575: [clang-tidy] Implement a clang-tidy check to verify Google Objective-C function naming conventions 📜

Stephane Moore via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 3 00:08:56 PDT 2018


stephanemoore marked an inline comment as done.
stephanemoore added inline comments.


================
Comment at: clang-tidy/google/FunctionNamingCheck.cpp:57
+      functionDecl(
+          isDefinition(),
+          unless(anyOf(isMain(), matchesName(validFunctionNameRegex(true)),
----------------
hokein wrote:
> any reason why we restrict to definitions only? I think we can consider declarations too.
I restricted the check to function definitions because function declarations are sometimes associated with functions outside the control of the author. I have personally observed unfortunate cases where functions declared in the iOS SDK had incorrect—or seemingly incorrect—availability attributes that caused fatal dyld assertions during application startup. The check currently intends to avoid flagging function declarations because of the rare circumstances where an inflexible function declaration without a corresponding function definition is required.

I have added a comment explaining why only function definitions are flagged.

I am still open to discussion though.


================
Comment at: unittests/clang-tidy/GoogleModuleTest.cpp:109
 
+TEST(ObjCFunctionNaming, AllowedStaticFunctionName) {
+  std::vector<ClangTidyError> Errors;
----------------
hokein wrote:
> nit: we don't need unittest for the check here, as it is well covered in the littest.
Removed the unit tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51575





More information about the cfe-commits mailing list