summaryrefslogtreecommitdiff
path: root/ale_linters/llvm/llc.vim
blob: 044f8c4401fb3c018703dbb2763ed18e4b3346be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
" Author: rhysd <https://rhysd.github.io>
" Description: Support for checking LLVM IR with llc

call ale#Set('llvm_llc_executable', 'llc')

function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort
    " Handle '{path}: {file}:{line}:{col}: error: {message}' format
    let l:pattern = '\v^[a-zA-Z]?:?[^:]+: [^:]+:(\d+):(\d+): (.+)$'

    return map(ale#util#GetMatches(a:lines, l:pattern), "{
    \   'lnum': str2nr(v:val[1]),
    \   'col': str2nr(v:val[2]),
    \   'text': v:val[3],
    \   'type': 'E',
    \}")
endfunction

call ale#linter#Define('llvm', {
\   'name': 'llc',
\   'executable_callback': ale#VarFunc('llvm_llc_executable'),
\   'output_stream': 'stderr',
\   'command_callback': {-> '%e -filetype=null -o=' . g:ale#util#nul_file},
\   'callback': 'ale_linters#llvm#llc#HandleErrors',
\})