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

clang-tidy can't find some header files using compile_commands.json #2111

Closed embedded-kyle closed 4 years ago

embedded-kyle commented 5 years ago

Information

VIM version

NVIM v0.3.1 Build type: RelWithDebInfo Features: -acl +iconv -jemalloc +tui

Operating System: Windows 10 Pro 10.0.17134 Build 17134

What went wrong

I open a file in Neovim with ale configured to use clang-tidy and a compile_commands.json in the correct place. I receive one error, "file not found", on one of my header files. The header file is in a separate included project, but other include files from that project are found or at least not given errors.

Reproducing the bug

File Structure:

C:.
+---CustomApplication
|       compile_commands.json
|       NG_menu.c
|       NG_menu.h
|
+---Primary
|   +---include
|   |       display_UoM.h
|   |       general_defs.h
|   |       pushbuttons.h
|   |
|   +---RTE
|       +---Graphics
|               GUI_Type.h
|

init.vim:

"Configure linting
let g:ale_linters={
\   'c': ['clangtidy'],
\}
let g:ale_fixers={
\   '*': ['remove_trailing_lines', 'trim_whitespace'],
\   'c': ['clang-format'],
\}
let g:ale_linters_explicit=1
let g:ale_c_parse_compile_commands=1
let g:ale_set_balloons=1
let g:airline#extensions#ale#enabled=1

NG_menu.c include section:

#include    <stddef.h>
#include    <stdint.h>
#include    <stdbool.h>
#include    "GUI_Type.h"            //NG_menu.c|14 col 13 error| 'Gui_Type.h' file not found [clang-diagnostic-error]
#include    "general_defs.h"
#include    "display_UoM.h"
#include    "pushbuttons.h"
#include    "NG_menu.h"

compile_commands.json: (emphasis on the -I directive in question)

{ "directory": "C:\\Users\\kyle\\Workspace\\e4\\Trunk&Std\\MenuRedesign\\CustomApplication", "file": "C:\\Users\\kyle\\Workspace\\e4\\Trunk&Std\\MenuRedesign\\CustomApplication\\NG_menu.c", "output": "C:\\Users\\kyle\\Workspace\\e4\\Trunk&Std\\MenuRedesign\\CustomApplication\\NG_menu.c", "arguments": ["clang", "-xc", "C:\\Users\\kyle\\Workspace\\e4\\Trunk&Std\\MenuRedesign\\CustomApplication\\NG_menu.c", "-fno-spell-checking", "-std=c99", "--target=arm-arm-none-eabi", "-mcpu=cortex-m4", "-mfpu=fpv4-sp-d16", "-mfloat-abi=hard", "-fno-rtti", "-funsigned-char", "-fshort-enums", "-fshort-wchar", "-Oz", "-ffunction-sections", "-Wno-packed", "-Wno-missing-variable-declarations", "-Wno-missing-prototypes", "-Wno-missing-noreturn", "-Wno-sign-conversion", "-Wno-nonportable-include-path", "-Wno-reserved-id-macro", "-Wno-unused-macros", "-Wno-documentation-unknown-command", "-Wno-documentation", "-Wno-license-management", "-Wno-parentheses-equality", "-ferror-limit=1000", "-fsyntax-only", "-D", "__RTX", "-D", "__UVISION_VERSION=525", "-D", "_RTE_", "-D", "CPU_MK22FX512AVLL12", "-I", "./", "-I", "../Primary/include", "-I", "../Primary/CMSIS","-I", "../Primary/RTE/Graphics", "-I", "../Primary/utilities", "-I", "../Primary/drivers", "-I", "../Primary/VCLComm/Include", "-I", "../CustomApplication/C2iTgenerated", "-I", "../Primary/board", "-I", "./Display", "-I", "../CustomApplication", "-I", "C:/Keil_v5/ARM/ARMCLANG/include", "-I", "./RTE/Device/MK22FX512AVLL12", "-I", "./RTE/_customApplication", "-I", "C:/Keil_v5/ARM/PACK/ARM/CMSIS/5.3.0/CMSIS/Include", "-I", "C:/Keil_v5/ARM/PACK/ARM/CMSIS/5.3.0/CMSIS/RTOS/RTX/INC", "-I", "C:/Keil_v5/ARM/PACK/ARM/minar/1.0.0/core-util", "-I", "C:/Keil_v5/ARM/PACK/ARM/minar/1.0.0/minar", "-I", "C:/Keil_v5/ARM/PACK/ARM/minar/1.0.0/minar/minar", "-I", "C:/Keil_v5/ARM/PACK/Keil/MDK-Middleware/7.6.0/emWin/Include", "-I", "C:/Keil_v5/ARM/PACK/NXP/MK22FA12_DFP/10.0.1", "-Xclang", "-detailed-preprocessing-record", "-fallow-editor-placeholders", "-fsyntax-only", "--target=thumbv7em-arm-none-eabi"]},

:ALEInfo

 Current Filetype: c
Available Linters: ['ccls', 'clang', 'clangd', 'clangtidy', 'cppcheck', 'cquery', 'flawfinder', 'gcc']
  Enabled Linters: ['clangtidy']
 Suggested Fixers:
  'clang-format' - Fix C/C++ files with clang-format.
  '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_clangtidy_checks = []
let g:ale_c_clangtidy_executable = 'clang-tidy'
let g:ale_c_clangtidy_options = ''
 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 = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
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 = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'c': ['clangtidy']}
let g:ale_linters_explicit = 1
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_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 = '>>'
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_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-tidy
(finished - exit code 1) 'cmd /s/c "clang-tidy C:\Users\kyle\Workspace\e4\Trunk^&Std\MenuRedesign\CustomApplication\NG_menu.c -p C:\Users\kyle\Workspace\e4\Trunk^&Std\MenuRedesign\CustomApplication"'

<<<OUTPUT STARTS>>>
C:\Users\kyle\Workspace\e4\Trunk&Std\MenuRedesign\CustomApplication\NG_menu.c:14:13: error: 'GUI_Type.h' file not found [clang-diagnostic-error]
#include    "GUI_Type.h"
            ^
<<<OUTPUT ENDS>>>
w0rp commented 4 years ago

Almost all C/C++ issues with flags should now be discussed in #3276, so a comprehensive solution can be found for most people, for automatically detecting flags.