From 164c4efb323f77e27942a824bd84fae91eb16db4 Mon Sep 17 00:00:00 2001 From: w0rp Date: Wed, 17 May 2017 10:10:25 +0100 Subject: [PATCH] Fix #556 Remove duplicate error messages from clang++ --- autoload/ale/handlers/gcc.vim | 9 +++++++-- test/handler/test_gcc_handler.vader | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/autoload/ale/handlers/gcc.vim b/autoload/ale/handlers/gcc.vim index eb42b27a..09a1848d 100644 --- a/autoload/ale/handlers/gcc.vim +++ b/autoload/ale/handlers/gcc.vim @@ -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 diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader index 72b7c541..2934bbee 100644 --- a/test/handler/test_gcc_handler.vader +++ b/test/handler/test_gcc_handler.vader @@ -94,3 +94,29 @@ Execute(The GCC handler shouldn't complain about #pragma once for headers): \ ale#handlers#gcc#HandleGCCFormat(347, [ \ ':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, [ + \ ':2:10: fatal error: ''a.h'' file not found', + \ '#include "a.h"', + \ ' ^~~~~', + \ '', + \ ':2:10: fatal error: ''a.h'' file not found', + \ '#include "a.h"', + \ ' ^~~~~', + \ '', + \ ':4:10: error: empty filename', + \ '', + \ ':4:10: error: empty filename', + \ '#include ""', + \ ' ^', + \ '', + \ ':4:10: error: empty filename', + \ '#include ""', + \ ' ^', + \ ])