mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-14 22:21:52 +08:00
cc: use '-x c*-header' for header files for C and C++ linters. (#4318)
When linting an header file in C or C++, `-x c-header` or `-x c++-header` should be used instead of `-x c` or `-x c++`. Using `-x c` or `-x c++` for headers files can lead to unused variables and functions marked as static inlined as seen in #4096. Using `-x c-header` or `-x c++-header` solve these issues. The list of file extensions that are considered as header files can be configured with the variables `g:ale_c_cc_header_exts` and `g:ale_cpp_cc_header_exts`.
This commit is contained in:
@@ -585,3 +585,14 @@ function! ale#c#IncludeOptions(include_paths) abort
|
||||
|
||||
return join(l:option_list)
|
||||
endfunction
|
||||
|
||||
" Get the language flag depending on if the file is a header or not.
|
||||
function! ale#c#GetLanguageFlag(buffer, header_exts, linter_lang) abort
|
||||
let l:buf_ext = expand('#' . a:buffer . ':e')
|
||||
|
||||
if index(a:header_exts, l:buf_ext) >= 0
|
||||
return a:linter_lang . '-header'
|
||||
endif
|
||||
|
||||
return a:linter_lang
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user