fixed parsing errors when certain options are used in glslangValidator (#4540)

* fixed parsing errors when certain options are used in glslang

* Update glslang.vim

set column number to 0 like it is always set by glslangValidator

* Added a test for the handler of glslangValidator
This commit is contained in:
JoseGRuiz 2023-07-24 07:43:13 -05:00 committed by GitHub
parent 93a4f70414
commit 481c5cccbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View File

@ -17,13 +17,15 @@ function! ale_linters#glsl#glslang#Handle(buffer, lines) abort
" Matches patterns like the following:
"
" ERROR: 0:5: 'foo' : undeclared identifier
let l:pattern = '^\(.\+\): \(\d\+\):\(\d\+\): \(.\+\)'
" or when using options like -V or -G or --target-env
" ERROR: filename:5: 'foo' : undeclared identifier
let l:pattern = '^\(.\+\): \(.\+\):\(\d\+\): \(.\+\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[3]),
\ 'col': str2nr(l:match[2]),
\ 'col' : 0,
\ 'text': l:match[4],
\ 'type': l:match[1] is# 'ERROR' ? 'E' : 'W',
\})

View File

@ -22,3 +22,27 @@ Execute(The glsl glslang handler should parse lines correctly):
\ 'WARNING: 0:121: ''switch'' : last case/default label not followed by statements',
\ 'ERROR: 2 compilation errors. No code generated.',
\ ])
Execute(The glsl glslang handler should parse lines with options -V or -G correctly):
AssertEqual
\ [
\ {
\ 'lnum': 7,
\ 'col': 0,
\ 'type': 'E',
\ 'text': '''non-opaque uniforms outside a block'' : not allowed when using GLSL for Vulkan',
\ },
\ {
\ 'lnum': 14,
\ 'col': 0,
\ 'type': 'W',
\ 'text': '''__shininess'' : identifiers containing consecutive underscores ("__") are reserved',
\ },
\ ],
\ ale_linters#glsl#glslang#Handle(bufnr(''), [
\ 'shader.vert',
\ 'ERROR: shader.vert:7: ''non-opaque uniforms outside a block'' : not allowed when using GLSL for Vulkan',
\ 'WARNING: shader.vert:14: ''__shininess'' : identifiers containing consecutive underscores ("__") are reserved',
\ 'ERROR: 1 compilation errors. No code generated.',
\ 'SPIR-V is not generated for failed compile or link',
\ ])