From f666e61f5cc8a55855591df926d64747a1d586fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 19 May 2021 15:49:39 +0200 Subject: sanity: Warn when using __OBJC__ in non-Objective-C/C++ source files The define will never be defined (unless someone explicitly passes -x to change the language the compiler uses, but we don't do that), so using the define in C/C++ source files is most likely an error and will result in dead code. Change-Id: I1eb578b76b0294ce415fce67e6665388812ae651 Reviewed-by: Alexandru Croitor --- git-hooks/sanitize-commit | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'git-hooks') diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index e41cbfb..573ab9d 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -822,7 +822,15 @@ while () { } } check_spelling() if ($spell_check); - check_apple_terminology() if ($apple_check); + if ($apple_check) { + check_apple_terminology(); + if ($file =~ /\.(c|cpp)$/i) { + if (/\b__OBJC__\b/) { + complain_ln("__OBJC__ will never be defined for non-Objective-C/C++ source files", + "objc"); + } + } + } } else { flushChunk() if ($chunk); if (/^ /) { -- cgit v1.2.1