[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈
Stephane Moore via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 20 16:35:19 PST 2019
This revision was automatically updated to reflect the committed changes.
stephanemoore marked an inline comment as done.
Closed by commit rCTE354534: [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈 (authored by stephanemoore, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D58095?vs=187512&id=187693#toc
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58095/new/
https://reviews.llvm.org/D58095
Files:
clang-tidy/google/FunctionNamingCheck.cpp
test/clang-tidy/Inputs/Headers/stdio.h
test/clang-tidy/google-objc-function-naming.m
Index: clang-tidy/google/FunctionNamingCheck.cpp
===================================================================
--- clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
if (!getLangOpts().ObjC)
return;
- // Match function declarations that are not in system headers and are not
- // main.
+ // Enforce Objective-C function naming conventions on all functions except:
+ // • Functions defined in system headers.
+ // • C++ member functions.
+ // • Namespaced functions.
+ // • Implicitly defined functions.
+ // • The main function.
Finder->addMatcher(
functionDecl(
unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
- hasAncestor(namespaceDecl()), isMain(),
+ hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
matchesName(validFunctionNameRegex(false))))))
Index: test/clang-tidy/google-objc-function-naming.m
===================================================================
--- test/clang-tidy/google-objc-function-naming.m
+++ test/clang-tidy/google-objc-function-naming.m
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy %s google-objc-function-naming %t
+// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem %S/Inputs/Headers
+
+#include <stdio.h>
+
+static void TestImplicitFunctionDeclaration(int a) {
+ // Call a builtin function so that the compiler generates an implicit
+ // function declaration.
+ printf("%d", a);
+}
typedef _Bool bool;
Index: test/clang-tidy/Inputs/Headers/stdio.h
===================================================================
--- test/clang-tidy/Inputs/Headers/stdio.h
+++ test/clang-tidy/Inputs/Headers/stdio.h
@@ -0,0 +1,18 @@
+//===--- stdio.h - Stub header for tests ------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+// A header intended to contain C standard input and output library
+// declarations.
+
+int printf(const char *, ...);
+
+#endif // _STDIO_H_
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58095.187693.patch
Type: text/x-patch
Size: 2475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190221/c5656db8/attachment-0001.bin>
More information about the cfe-commits
mailing list