dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.38k stars 1.42k forks source link

clang++ command not getting correct include paths #4783

Open rksouthee opened 1 month ago

rksouthee commented 1 month ago

Information

VIM version

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Nov 19 2023 18:05:09) MS-Windows 64-bit GUI version

Operating System: Windows 10

What went wrong

clang++ check is not using the correct include paths. Looks like it's joining the build directory (absolute) and the actual path for headers (also absolute). Looks like this might be an issue in autoload/ale/c.vim in the function ale#c#ParseCFLags where we try and fix relative paths. If call ale#path#Simplify(l:arg) on the path then I see the correct behaviour and my header files are found.

Example of joining the paths together

-isystem D:\Repos\perfaware\build\D:Libraries\cxxopts-3.2.1-win64\include

Reproducing the bug

  1. Open a file with header files that should be covered by an include path set on the command line
  2. There will be an error next to the include file: /* E: 'cxxopts.hpp' file not found for example.

:ALEInfo

Expand Current Filetype: cpp Available Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder'] Linter Aliases: 'cc' -> ['gcc', 'clang', 'g++', 'clang++'] Enabled Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder'] Ignored Linters: [] Suggested Fixers: 'astyle' - Fix C/C++ with astyle. 'clang-format' - Fix C, C++, C#, CUDA, Java, JavaScript, JSON, ObjectiveC and Protobuf 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: " Press Space to read :help for a setting let g:ale_cpp_cc_executable = '' let g:ale_cpp_cc_header_exts = ['h', 'hpp'] let g:ale_cpp_cc_options = '-std=c++14 -Wall' let g:ale_cpp_cc_use_header_lang_flag = -1 let g:ale_cpp_ccls_executable = 'ccls' let g:ale_cpp_ccls_init_options = {} let g:ale_cpp_clangcheck_executable = 'clang-check' let g:ale_cpp_clangcheck_options = '' let g:ale_cpp_clangd_executable = 'clangd' let g:ale_cpp_clangd_options = '' let g:ale_cpp_clangtidy_checks = [] let g:ale_cpp_clangtidy_executable = 'clang-tidy' let g:ale_cpp_clangtidy_extra_options = '' let g:ale_cpp_clangtidy_options = '' let g:ale_cpp_clazy_checks = ['level1'] let g:ale_cpp_clazy_executable = 'clazy-standalone' let g:ale_cpp_clazy_options = '' let g:ale_cpp_cppcheck_executable = 'cppcheck' let g:ale_cpp_cppcheck_options = '--enable=style' let g:ale_cpp_cpplint_executable = 'cpplint' let g:ale_cpp_cpplint_options = '' let g:ale_cpp_cquery_cache_directory = 'C:\Users\rksou\.cache\cquery' let g:ale_cpp_cquery_executable = 'cquery' let g:ale_cpp_flawfinder_executable = 'flawfinder' let g:ale_cpp_flawfinder_minlevel = 1 let g:ale_cpp_flawfinder_options = '' Global Variables: " Press Space to read :help for a setting 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 = v:null let g:ale_completion_enabled = 0 let g:ale_completion_max_suggestions = v:null let g:ale_disable_lsp = 'auto' 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 = {} let g:ale_history_enabled = 1 let g:ale_info_default_mode = 'preview' 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 = {} 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 = 1 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 = 'E' let g:ale_sign_info = 'I' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = 'E' let g:ale_sign_style_warning = 'W' let g:ale_sign_warning = 'W' let g:ale_sign_highlight_linenrs = 0 let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = 0 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'all' 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 1) 'cmd /s/c "clang++ -S -x c++ -o nul -iquote D:\Repos\perfaware\source\sim86 -DCMAKE_INTDIR=\"Debug\" -isystem D:\Repos\perfaware\build\D:Libraries\cxxopts-3.2.1-win64\include -O0 -std=gnu++20 -D_DEBUG -D_DLL -D_MT -Wall -Wall - < C:\Users\rksou\AppData\Local\Temp\VIIB74E.tmp\main.cpp"' <<>> :12:10: fatal error: 'cxxopts.hpp' file not found 12 | #include | ^~~~~~~~~~~~~ 1 error generated. <<>> (executable check - failure) ccls (executable check - success) clang-check (started) 'cmd /s/c "clang-check -analyze D:\Repos\perfaware\source\sim86\main.cpp -p D:\Repos\perfaware\build"' (executable check - success) clangd (executable check - success) clang-tidy (started) 'cmd /s/c "clang-tidy D:\Repos\perfaware\source\sim86\main.cpp -p D:\Repos\perfaware\build"' (executable check - failure) clazy-standalone (executable check - failure) cppcheck (executable check - failure) cpplint (executable check - failure) cquery (executable check - failure) cspell (executable check - failure) flawfinder (started) 'cmd /s/c "clangd -compile-commands-dir=D:\Repos\perfaware\build"'