dense-analysis / ale

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

C++ headers' location are not taken into account when parsed from Makefile #3520

Open Groctel opened 3 years ago

Groctel commented 3 years ago

Information

VIM version

NVIM v0.4.4
Build type: Release

Same error with regular vim:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Nov 15 2020 16:46:37)
Included patches: 1-1989

Operating System: Linux grocpc 5.10.4-arch2-1 #1 SMP PREEMPT Fri, 01 Jan 2021 05:29:53 +0000 x86_64 GNU/Linux

What went wrong

I'm writing a C++ project where files are organised in different directoried. Include directories are specified in the Makefile and ALE reads them well as you can see in the ALEInfo. However, the linter doesn't take them into account and throws a no such file or directory error on their #include statement. ALEInfo also shows that the -I option isn't used when linting the file.

Reproducing the bug

  1. I divided a project into folders
  2. I set the relevant -I options in the Makefile
  3. I made sure Makefile parsing was on
  4. The linter didn't recognise the include directories and threw an error

:ALEInfo

 Current Filetype: cpp
Available Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'flawfinder']
   Linter Aliases:
'cc' -> ['gcc', 'clang', 'g++', 'clang++']
  Enabled Linters: ['cc']
  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_cpp_cc_executable = '<auto>'
let g:ale_cpp_cc_options = '-std=c++17 -Wall -Wextra -Wpedantic -Wfloat-equal'
let g:ale_cpp_parse_makefile = 1
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 1
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 = 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 = {}
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': ['gcc'], 'cpp': ['g++']}
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_lsp_root = {}
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_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 - failure) clang++
(finished - exit code 0) ['/usr/bin/zsh', '-c', 'cd ''/home/groctel/Documents/Repositorios/ugr-informatica/3º 1er cuatrimestre/Informática gráfica/Prácticas'' && make -n --always-make']

<<<OUTPUT STARTS>>>
mkdir -p ./obj
mkdir -p ./bin
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c libig/globals.cpp -o obj/globals.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c libig/ply.cpp -o obj/ply.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c mallas/malla.cpp -o obj/malla.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c mallas/obj_revolucion.cpp -o obj/obj_revolucion.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c mallas/cilindro.cpp -o obj/cilindro.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c mallas/cono.cpp -o obj/cono.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c mallas/cubo.cpp -o obj/cubo.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c src/ejes.cpp -o obj/ejes.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c src/escena.cpp -o obj/escena.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c mallas/esfera.cpp -o obj/esfera.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c luces/luz.cpp -o obj/luz.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c luces/luz_direccional.cpp -o obj/luz_direccional.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c luces/luz_posicional.cpp -o obj/luz_posicional.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c src/material.cpp -o obj/material.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -c mallas/tetraedro.cpp -o obj/tetraedro.o
g++ -std=c++17 -g -Wall -Wextra -Wpedantic -Wfloat-equal -I./libig -ljpeg  -lGLEW -lGLU -lglut -lGL  -DLINUX -o bin/practicas src/practicas.cpp obj/cilindro.o obj/cono.o obj/cubo.o obj/ejes.o obj/escena.o obj/esfera.o obj/globals.o obj/luz.o obj/luz_direccional.o obj/luz_posicional.o obj/malla.o obj/material.o obj/obj_revolucion.o obj/ply.o obj/tetraedro.o
<<<OUTPUT ENDS>>>

(finished - exit code 1) ['/usr/bin/zsh', '-c', '''gcc'' -S -x c++ -o /dev/null -iquote ''/home/groctel/Documents/Repositorios/ugr-informatica/3º 1er cuatrimestre/Informática gráfica/Prácticas/mallas'' -std=c++17 -Wall -Wextra -Wpedantic -Wfloat-equal - < ''/tmp/nvimdnZFv8/3/malla.hpp''']

<<<OUTPUT STARTS>>>
<stdin>:12:10: fatal error: colores.hpp: No such file or directory
compilation terminated.
<<<OUTPUT ENDS>>>

Of course:

➜ find . -name "*colores*"                 
./libig/colores.hpp
BioBox commented 2 years ago

Yep, I'm also suffering from a very similar issue. Say you're using header files from a library like /usr/include/poppler and do #include <poppler/Annot.h>. That header will include other headers in it's directory (e.g. #include "foo.h"), which is totally normal behavior. However, since ale isn't smart enough to recognize this; it will search your project directory for the foo.h instead of /usr/include/poppler as one would expect.