2017-10-10 05:13:09 -04:00
|
|
|
" 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#GetExecutable(buffer) abort
|
|
|
|
return ale#Var(a:buffer, 'llvm_llc_executable')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#llvm#llc#GetCommand(buffer) abort
|
|
|
|
return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer))
|
2018-07-15 13:24:53 -04:00
|
|
|
\ . ' -filetype=null -o=' . g:ale#util#nul_file
|
2017-10-10 05:13:09 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
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+): (.+)$'
|
|
|
|
let l:matches = ale#util#GetMatches(a:lines, l:pattern)
|
|
|
|
|
|
|
|
return map(l:matches, "{
|
|
|
|
\ '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_linters#llvm#llc#GetExecutable',
|
|
|
|
\ 'output_stream': 'stderr',
|
|
|
|
\ 'command_callback': 'ale_linters#llvm#llc#GetCommand',
|
|
|
|
\ 'callback': 'ale_linters#llvm#llc#HandleErrors',
|
|
|
|
\})
|