summaryrefslogtreecommitdiff
path: root/clang-tools-extra/docs
diff options
context:
space:
mode:
authorStephane Moore <mog@google.com>2018-11-17 02:37:21 +0000
committerStephane Moore <mog@google.com>2018-11-17 02:37:21 +0000
commit9186181960483b4e010d3500c722db5279ed1ecd (patch)
tree175c73ecd57ee80138f3782c99b67ec59b9a4cca /clang-tools-extra/docs
parentfb6328569792e6ceef2386f734f59921564ced78 (diff)
[clang-tidy/checks] Implement a clang-tidy check to verify Google Objective-C function naming conventions 📜
Summary: §1 Description This check finds function names in function declarations in Objective-C files that do not follow the naming pattern described in the Google Objective-C Style Guide. Function names should be in UpperCamelCase and functions that are not of static storage class should have an appropriate prefix as described in the Google Objective-C Style Guide. The function `main` is a notable exception. Function declarations in expansions in system headers are ignored. Example conforming function definitions: ``` static bool IsPositive(int i) { return i > 0; } static bool ABIsPositive(int i) { return i > 0; } bool ABIsNegative(int i) { return i < 0; } ``` A fixit hint is generated for functions of static storage class but otherwise the check does not generate a fixit hint because an appropriate prefix for the function cannot be determined. §2 Test Notes * Verified clang-tidy tests pass successfully. * Used check_clang_tidy.py to verify expected output of processing google-objc-function-naming.m Reviewers: benhamilton, hokein, Wizard, aaron.ballman Reviewed By: benhamilton Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D51575
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r--clang-tools-extra/docs/ReleaseNotes.rst6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/google-objc-function-naming.rst27
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst1
3 files changed, 34 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index c8355523ae0..1d49c81aba9 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -123,6 +123,12 @@ Improvements to clang-tidy
Finds macro usage that is considered problematic because better language
constructs exist for the task.
+- New :doc:`google-objc-function-naming
+ <clang-tidy/checks/google-objc-function-naming>` check.
+
+ Checks that function names in function declarations comply with the naming
+ conventions described in the Google Objective-C Style Guide.
+
- New :doc:`misc-non-private-member-variables-in-classes
<clang-tidy/checks/misc-non-private-member-variables-in-classes>` check.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/google-objc-function-naming.rst b/clang-tools-extra/docs/clang-tidy/checks/google-objc-function-naming.rst
new file mode 100644
index 00000000000..6a4043c0ec1
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/google-objc-function-naming.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - google-objc-function-naming
+
+google-objc-function-naming
+===========================
+
+Finds function declarations in Objective-C files that do not follow the pattern
+described in the Google Objective-C Style Guide.
+
+The corresponding style guide rule can be found here:
+https://google.github.io/styleguide/objcguide.html#function-names
+
+All function names should be in Pascal case. Functions whose storage class is
+not static should have an appropriate prefix.
+
+The following code sample does not follow this pattern:
+
+.. code-block:: objc
+
+ static bool is_positive(int i) { return i > 0; }
+ bool IsNegative(int i) { return i < 0; }
+
+The sample above might be corrected to the following code:
+
+.. code-block:: objc
+
+ static bool IsPositive(int i) { return i > 0; }
+ bool *ABCIsNegative(int i) { return i < 0; }
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index e3e7ba9875e..f33af36ed58 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -124,6 +124,7 @@ Clang-Tidy Checks
google-explicit-constructor
google-global-names-in-headers
google-objc-avoid-throwing-exception
+ google-objc-function-naming
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) <google-readability-braces-around-statements>
google-readability-casting