diff options
| author | Chih-Hung Hsieh <chh@google.com> | 2018-08-15 11:28:38 -0700 |
|---|---|---|
| committer | Chih-Hung Hsieh <chh@google.com> | 2018-08-22 09:21:45 -0700 |
| commit | a7aa958e6e2df55af86c9ee7d1d570c2dcce6224 (patch) | |
| tree | afca202d317a501d4c7587b20dccf6da6e05c1da /scripts | |
| parent | 158f2d9eafeb8419430c9da5791b8fa57d226975 (diff) | |
| download | build_soong-a7aa958e6e2df55af86c9ee7d1d570c2dcce6224.tar.gz build_soong-a7aa958e6e2df55af86c9ee7d1d570c2dcce6224.tar.bz2 build_soong-a7aa958e6e2df55af86c9ee7d1d570c2dcce6224.zip | |
Add clang-tidy.sh to filter out troublesome flags.
* Some flags are accepted by clang but not clang-tidy.
They could cause the diagnostic-unused-command-line-argument warning.
Flag -flto messed up the -I flags.
* Add clang-diagnostic-unused-command-line-argument to
default clang-tidy checks.
* Move CLANG_TIDY_UNKNOWN_CFLAGS to build/make/core/clang/tidy.mk.
Bug: 111850071
Bug: 111885396
Test: build with WITH_TIDY=1
Change-Id: Iabeeb27715acf83ef6aafe3e77206b9a01a0d889
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/clang-tidy.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/clang-tidy.sh b/scripts/clang-tidy.sh new file mode 100755 index 00000000..04d0bdd9 --- /dev/null +++ b/scripts/clang-tidy.sh @@ -0,0 +1,37 @@ +#!/bin/bash -e + +# Copyright 2018 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Wrapper script to remove clang compiler flags rejected by clang-tidy. +# Inputs: +# Environment: +# CLANG_TIDY: path to the real clang-tidy program + +# clang-tidy doesn't recognize every flag that clang compiler does. +# It gives clang-diagnostic-unused-command-line-argument warnings +# to -Wa,* flags. +# The -flto flags caused clang-tidy to ignore the -I flags, +# see https://bugs.llvm.org/show_bug.cgi?id=38332. +# -fsanitize and -fwhole-program-vtables need -flto. +args=("${@}") +n=${#args[@]} +for ((i=0; i<$n; ++i)); do + case ${args[i]} in + -Wa,*|-flto|-flto=*|-fsanitize=*|-fsanitize-*|-fwhole-program-vtables) + unset args[i] + ;; + esac +done +${CLANG_TIDY} "${args[@]}" |
