diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-05-19 15:49:39 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-05-19 16:11:06 +0000 |
commit | f666e61f5cc8a55855591df926d64747a1d586fb (patch) | |
tree | 1ae57d8e01480a02ada98dc97190883360eabd6b | |
parent | a9592e2bdefd97be8544f9319fe85b56258d0d94 (diff) | |
download | qtrepotools-f666e61f5cc8a55855591df926d64747a1d586fb.tar.gz |
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 <alexandru.croitor@qt.io>
-rwxr-xr-x | git-hooks/sanitize-commit | 10 |
1 files changed, 9 insertions, 1 deletions
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 (<DIFF>) { } } 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 (/^ /) { |