1#!/bin/bash -e 2 3# Copyright 2018 Google Inc. All rights reserved. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# Wrapper script to remove clang compiler flags rejected by clang-tidy. 18# Inputs: 19# Environment: 20# CLANG_TIDY: path to the real clang-tidy program 21 22# clang-tidy doesn't recognize every flag that clang compiler does. 23# It gives clang-diagnostic-unused-command-line-argument warnings 24# to -Wa,* flags. 25# The -flto flags caused clang-tidy to ignore the -I flags, 26# see https://bugs.llvm.org/show_bug.cgi?id=38332. 27# -fsanitize and -fwhole-program-vtables need -flto. 28args=("${@}") 29n=${#args[@]} 30for ((i=0; i<$n; ++i)); do 31 case ${args[i]} in 32 -Wa,*|-flto|-flto=*|-fsanitize=*|-fsanitize-*|-fwhole-program-vtables) 33 unset args[i] 34 ;; 35 esac 36done 37${CLANG_TIDY} "${args[@]}" 38