summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2021-01-23 01:55:40 +0900
committerGitHub <noreply@github.com>2021-01-23 01:55:40 +0900
commit33f2f8ddcd9d934c6eef0dc3bf6c434d00aaa734 (patch)
tree4b21e3fe2cbf2f602b12ccb6a8e8187834246559
parent1b010bbabb5b28cc2746ca967941ffdc9240960e (diff)
parent65824feef320f56a9f645cfe1a3107ff8717372a (diff)
downloadale-33f2f8ddcd9d934c6eef0dc3bf6c434d00aaa734.zip
Merge pull request #3551 from fenuks/bugfix-3506
Fix clang-tidy ignoring compile-commands.json
-rw-r--r--ale_linters/cpp/clangtidy.vim10
-rw-r--r--test/command_callback/test_clang_tidy_command_callback.vader1
2 files changed, 6 insertions, 5 deletions
diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim
index 5e062d86..d6944aae 100644
--- a/ale_linters/cpp/clangtidy.vim
+++ b/ale_linters/cpp/clangtidy.vim
@@ -23,11 +23,13 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort
let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options')
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags
- endif
- " Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file.
- if expand('#' . a:buffer) =~# '\.h$'
- let l:options .= !empty(l:options) ? ' -x c++' : '-x c++'
+ " Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file
+ " only when compile-commands.json file is not there. Adding these
+ " flags makes clang-tidy completely ignore compile commmands.
+ if expand('#' . a:buffer) =~# '\.h$'
+ let l:options .= !empty(l:options) ? ' -x c++' : '-x c++'
+ endif
endif
" Get the options to pass directly to clang-tidy
diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader
index f0a07e8c..eb1220be 100644
--- a/test/command_callback/test_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_clang_tidy_command_callback.vader
@@ -68,7 +68,6 @@ Execute(The build directory should be used for header files):
\ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -p ' . ale#Escape('/foo/bar')
- \ . ' -- -x c++'
call ale#test#SetFilename('test.hpp')