dense-analysis / dense-analysis/ale
g:ale_c_clangtidy_extra_options won't correctly pass options to clang-tidy (it adds an extra double-quotation mark)
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
## Information
**VIM version**
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 15 2019 23:09:58)
MS-Windows 32-bit console version
Included patches: 1-12
**Operating System:**
Windows 10
## What went wrong
In my `_vimrc` I have
`let g:ale_c_clangtidy_extra_options = '--extra-arg=-I --extra-arg=C:\MinGW64\mingw\include'`
When I work on a `.c` file, then the linter won't really work. Inspection of `ALEInfo` shows that the command called is
`clang-tidy -checks=* "--extra-arg=-I --extra-arg=C:\MinGW64\mingw\include" C:\Users\yt75534\c_tutorial\Unions\Unions.c`
i.e. there is a double quotation mark around `--extra-arg=-I --extra-arg=C:\MinGW64\mingw\include`.
If open the Powershell and run
`clang-tidy -checks=* --extra-arg=-I --extra-arg=C:\MinGW64\mingw\include C:\Users\yt75534\c_tutorial\Unions\Unions.c`
then I have no problems, but if I add the double quotation mark, i.e. if I run
`clang-tidy -checks=* "--extra-arg=-I --extra-arg=C:\MinGW64\mingw\include" C:\Users\yt75534\c_tutorial\Unions\Unions.c`
then, I get the same error as `ALEInfo`.
This means that (at least under Windows 10) the `--extra-arg` options shall be passed without the double quotation mark.
## Reproducing the bug
Add any `clang-tidy `extra option in the `_vimrc` file in the form:
`let g:ale_c_clangtidy_extra_options = '--extra-arg= --extra-arg='`
Then open any `.c` file and run `ALEInfo`.
You should see the double quotation mark around the options `--extra-arg`. like, e.g
```
Command History:
(executable check - success) clang-tidy
(finished - exit code 1) 'cmd /s/c "clang-tidy -checks=* "--extra-arg= --extra-arg=" C:\\.c -p C:\"'
```
### :ALEInfo
```
Current Filetype: c
Available Linters: ['cc', 'ccls', 'clangd', 'clangtidy', 'cppcheck', 'cquery', 'flawfinder']
Linter Aliases:
'cc' -> ['gcc', 'clang']
Enabled Linters: ['cc', 'clangtidy', 'cppcheck']
Ignored Linters: []
Suggested Fixers:
'astyle' - Fix C/C++ with astyle.
'clang-format' - Fix C/C++ and cuda files with clang-format.
'clangtidy' - Fix C/C++ and ObjectiveC files with clang-tidy.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
'uncrustify' - Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.
Linter Variables:
let g:ale_c_always_make = 0
let g:ale_c_build_dir = ''
let g:ale_c_build_dir_names = ['build', 'bin']
let g:ale_c_cc_executable = ''
let g:ale_c_cc_options = '-Wall -I C:\MinGW64\mingw\include '
let g:ale_c_clangtidy_checks = ['*']
let g:ale_c_clangtidy_executable = 'clang-tidy'
let g:ale_c_clangtidy_extra_options = '--extra-arg=-I --extra-arg=C:\MinGW64\mingw\include'
let g:ale_c_clangtidy_options = ''
let g:ale_c_cppcheck_executable = 'cppcheck'
let g:ale_c_cppcheck_options = '--enable=style -I C:\MinGW64\mingw\include'
let g:ale_c_parse_compile_commands = 1
let g:ale_c_parse_makefile = 0
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {'c': ['clang-format', 'remove_trailing_lines', 'trim_whitespace']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'c': ['clangtidy', 'cppcheck', 'gcc'], 'python': ['flake8']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - success) clang
(finished - exit code 0) 'cmd /s/c "clang -S -x c -o nul -iquote C:\Users\yt75534\c_tutorial\Unions -Wall -I C:/PE_Builds/sw-ecu/BSW/_out/P_AMTG_MC_TEA2P_T2/bin/all_inc -I C:\MinGW64\mingw\include -I C:\PE_Builds\sw-ecu\BSW\_out\P_AMTG_MC_TEA2P_T2\bin\software\devices\inclination_sensor_tcm5\src - < C:\Users\yt75534\AppData\Local\Temp\VYE821A.tmp\Unions.c"'
<<>>
In file included from :1:
C:\MinGW64\mingw\include\stdio.h:399:7: warning: unused function 'vfscanf' [-Wunused-function]
int vfscanf (FILE *__stream, const char *__format, __builtin_va_list __local_argv)
^
C:\MinGW64\mingw\include\stdio.h:406:7: warning: unused function 'vsscanf' [-Wunused-function]
int vsscanf (const char * __restrict__ __source, const char * __restrict__ __format, __builtin_va_list __local_argv)
^
C:\MinGW64\mingw\include\stdio.h:412:7: warning: unused function 'vscanf' [-Wunused-function]
int vscanf(const char *__format, __builtin_va_list __local_argv)
^
C:\MinGW64\mingw\include\stdio.h:543:7: warning: unused function 'vsnprintf' [-Wunused-function]
int vsnprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, va_list __local_argv)
^
C:\MinGW64\mingw\include\stdio.h:553:5: warning: unused function 'snprintf' [-Wunused-function]
int snprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, ...)
^
C:\MinGW64\mingw\include\stdio.h:735:7: warning: unused function 'vfwscanf' [-Wunused-function]
int vfwscanf (FILE *__stream, const wchar_t *__format, __builtin_va_list __local_argv)
^
C:\MinGW64\mingw\include\stdio.h:742:7: warning: unused function 'vswscanf' [-Wunused-function]
int vswscanf (const wchar_t * __restrict__ __source, const wchar_t * __restrict__ __format, __builtin_va_list __local_argv)
^
C:\MinGW64\mingw\include\stdio.h:748:7: warning: unused function 'vwscanf' [-Wunused-function]
int vwscanf(const wchar_t *__format, __builtin_va_list __local_argv)
^
C:\MinGW64\mingw\include\stdio.h:801:7: warning: unused function 'snwprintf' [-Wunused-function]
int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...)
^
In file included from :1:
In file included from C:\MinGW64\mingw\include\stdio.h:824:
C:\MinGW64\mingw\include\swprintf.inl:30:5: warning: unused function 'swprintf' [-Wunused-function]
int swprintf (wchar_t *__stream, size_t __count, const wchar_t *__format, ...)
^
10 warnings generated.
<<>>
(executable check - success) clang-tidy
(finished - exit code 1) 'cmd /s/c "clang-tidy -checks=* "--extra-arg=-I --extra-arg=C:\MinGW64\mingw\include" C:\Users\yt75534\c_tutorial\Unions\Unions.c"'
<<>>
C:\Users\yt75534\c_tutorial\Unions\Unions.c:1:10: error: 'stdio.h' file not found [clang-diagnostic-error]
#include
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:8:9: warning: accessing fields in struct '' is inefficient due to poor alignment; currently aligned to 4 bytes, but recommended alignment is 32 bytes [altera-struct-pack-align]
struct{
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:8:9: note: use "__attribute__((aligned(32)))" to align struct '' to 32 bytes
C:\Users\yt75534\c_tutorial\Unions\Unions.c:22:25: warning: 0x8DF2AD8F is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
receivedFrame.val = 0x8DF2AD8F;
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:24:18: warning: narrowing conversion from 'uint32' (aka 'unsigned int') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
if (RS_OKAY==receivedFrame.fields.RS){
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:25:32: warning: narrowing conversion from 'uint32' (aka 'unsigned int') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
printf("RS OKAY\nRS: %x\n",receivedFrame.fields.RS);
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:26:25: warning: narrowing conversion from 'uint32' (aka 'unsigned int') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
}else if (RS_ERROR==receivedFrame.fields.RS){
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:27:29: warning: narrowing conversion from 'uint32' (aka 'unsigned int') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
printf("RS ERROR\nRS: %x\n",receivedFrame.fields.RS);
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:29:55: warning: narrowing conversion from 'uint32' (aka 'unsigned int') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
printf("RS Unknown\nRS: %x\nSuperframe: %x\n",receivedFrame.fields.RS,receivedFrame.val);
^
C:\Users\yt75534\c_tutorial\Unions\Unions.c:33:20: warning: narrowing conversion from 'uint32' (aka 'unsigned int') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
A = (RS_ERROR==receivedFrame.fields.RS);
^
<<>>
(executable check - success) cppcheck
(finished - exit code 0) 'cmd /s/c "cppcheck -q --language=c --template="{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}" --enable=style -I C:\MinGW64\mingw\include -IC:\Users\yt75534\c_tutorial\Unions C:\Users\yt75534\AppData\Local\Temp\VZ78259.tmp\Unions.c"'
<<>>
C:\Users\yt75534\AppData\Local\Temp\VZ78259.tmp\Unions.c:9:20: style: struct member 'Anonymous0::CRC' is never used. [unusedStructMember]\
uint32 CRC:8;
^
C:\Users\yt75534\AppData\Local\Temp\VZ78259.tmp\Unions.c:10:20: style: struct member 'Anonymous0::DATA' is never used. [unusedStructMember]\
uint32 DATA:16;
^
C:\Users\yt75534\AppData\Local\Temp\VZ78259.tmp\Unions.c:12:20: style: struct member 'Anonymous0::ADDR' is never used. [unusedStructMember]\
uint32 ADDR:5;
^
C:\Users\yt75534\AppData\Local\Temp\VZ78259.tmp\Unions.c:13:20: style: struct member 'Anonymous0::RW' is never used. [unusedStructMember]\
uint32 RW:1;
^
nofile:0:0: information: Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information. [toomanyconfigs]\
<<>>
```
**NOTE:** I previously place this in the Discussion Sessions, but then I realized that it looks like a bug instead. Hence, the post in the Discussion section can be removed (I don't have the privilege for removing it).
Contributor guide
Assessment
This issue has not been assessed yet.