Fix #556 Remove duplicate error messages from clang++

This commit is contained in:
w0rp 2017-05-17 10:10:25 +01:00
parent 5790df1272
commit 164c4efb32
2 changed files with 33 additions and 2 deletions

View File

@ -99,12 +99,17 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
continue
endif
call add(l:output, {
let l:obj = {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:match[4] =~# 'error' ? 'E' : 'W',
\ 'text': s:RemoveUnicodeQuotes(l:match[5]),
\})
\}
" clang++ and some other tools can output duplicated errors.
if empty(l:output) || l:output[-1] != l:obj
call add(l:output, l:obj)
endif
endif
endfor

View File

@ -94,3 +94,29 @@ Execute(The GCC handler shouldn't complain about #pragma once for headers):
\ ale#handlers#gcc#HandleGCCFormat(347, [
\ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]',
\ ])
Execute(The GCC handler should eliminate duplicated clang errors):
AssertEqual
\ [
\ {'lnum': 2, 'col': 10, 'type': 'E', 'text': '''a.h'' file not found'},
\ {'lnum': 4, 'col': 10, 'type': 'E', 'text': 'empty filename'},
\ ],
\ ale#handlers#gcc#HandleGCCFormat(347, [
\ '<stdin>:2:10: fatal error: ''a.h'' file not found',
\ '#include "a.h"',
\ ' ^~~~~',
\ '',
\ '<stdin>:2:10: fatal error: ''a.h'' file not found',
\ '#include "a.h"',
\ ' ^~~~~',
\ '',
\ '<stdin>:4:10: error: empty filename',
\ '',
\ '<stdin>:4:10: error: empty filename',
\ '#include ""',
\ ' ^',
\ '',
\ '<stdin>:4:10: error: empty filename',
\ '#include ""',
\ ' ^',
\ ])