diff options
author | w0rp <devw0rp@gmail.com> | 2017-04-11 21:05:41 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-04-11 21:05:41 +0100 |
commit | 65fe914fb88fa99d0bb1059a08bc40de5f8ac243 (patch) | |
tree | 3ebc4bb09a9cfd92e3b769bfda2e1f9994fe68d2 | |
parent | b06b832447253404180ce6a97927755e4ae68c22 (diff) | |
download | ale-65fe914fb88fa99d0bb1059a08bc40de5f8ac243.zip |
#392 Handle clang header errors too
-rw-r--r-- | autoload/ale/handlers/gcc.vim | 18 | ||||
-rw-r--r-- | test/handler/test_clang_handler.vader | 23 |
2 files changed, 37 insertions, 4 deletions
diff --git a/autoload/ale/handlers/gcc.vim b/autoload/ale/handlers/gcc.vim index 9084d0d4..0755e951 100644 --- a/autoload/ale/handlers/gcc.vim +++ b/autoload/ale/handlers/gcc.vim @@ -14,8 +14,12 @@ function! s:AddIncludedErrors(output, include_lnum, include_lines) abort endif endfunction +function! s:IsHeaderFile(filename) abort + return a:filename =~? '\v\.(h|hpp)$' +endfunction + function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort - let l:include_pattern = '\v^(In file included | *)from [^:]*:(\d+)' + let l:include_pattern = '\v^(In file included | *)from ([^:]*):(\d+)' let l:include_lnum = 0 let l:include_lines = [] let l:included_filename = '' @@ -41,9 +45,15 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort " need to collect it. call add(l:include_lines, l:line) else - " Get the line number out of the parsed include line, - " and reset the other variables. - let l:include_lnum = str2nr(l:include_match[2]) + " GCC and clang return the lists of files in different orders, + " so we'll only grab the line number from lines which aren't + " header files. + if !s:IsHeaderFile(l:include_match[2]) + " Get the line number out of the parsed include line, + " and reset the other variables. + let l:include_lnum = str2nr(l:include_match[3]) + endif + let l:include_lines = [] let l:included_filename = '' endif diff --git a/test/handler/test_clang_handler.vader b/test/handler/test_clang_handler.vader new file mode 100644 index 00000000..d28b9eb8 --- /dev/null +++ b/test/handler/test_clang_handler.vader @@ -0,0 +1,23 @@ +Execute(clang errors from included files should be parsed correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 3, + \ 'type': 'E', + \ 'text': 'Problems were found in the header (See :ALEDetail)', + \ 'detail': join([ + \ './b.h:1:1: error: expected identifier or ''(''', + \ '{{{', + \ '^', + \ '1 error generated.', + \ ], "\n"), + \ }, + \ ], + \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ 'In file included from test.c:3:', + \ 'In file included from ./a.h:1:', + \ './b.h:1:1: error: expected identifier or ''(''', + \ '{{{', + \ '^', + \ '1 error generated.', + \ ]) |