diff options
author | Linda_pp <rhysd@users.noreply.github.com> | 2017-10-10 18:13:09 +0900 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-10-10 10:13:09 +0100 |
commit | 70177480ba1f9968409709442fc4be4e9a69d564 (patch) | |
tree | ea1971f3903f98831d4868e2ef2f54a3c79064a9 /ale_linters/llvm | |
parent | a809c4fa3a781af7401d2f11ee5155caef081457 (diff) | |
download | ale-70177480ba1f9968409709442fc4be4e9a69d564.zip |
Add llc integration for LLVM IR (#979)
Check LLVM IR with llc
Diffstat (limited to 'ale_linters/llvm')
-rw-r--r-- | ale_linters/llvm/llc.vim | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ale_linters/llvm/llc.vim b/ale_linters/llvm/llc.vim new file mode 100644 index 00000000..0a4903eb --- /dev/null +++ b/ale_linters/llvm/llc.vim @@ -0,0 +1,35 @@ +" 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)) + \ . ' -filetype=null -o=' + \ . ale#Escape(g:ale#util#nul_file) +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', +\}) |