Skip to content

Commit e670c97

Browse files
authored
Slang verilog Linter: set default searchpath and output filename (#4999)
* Sets module search path to file directory for slang/verilog linter Similar to iverilog behaviour. See 699c0db Reasonable default behaviour, can be changed by adding '-y%s:h' to `b:ale_verilog_slang_options` buffer variable. * Adds filename to slang/verilog linter output slang can parse other files based on the modules instances names find in the current file and returns warning/error messages related to those files that have the same pattern. Adding the file name to the outputs avoid polluting the active buffer with those messages. * Absolute paths in slang/verilog linter messages Otherwise temp files are not correctly detected
1 parent 0d1d0a9 commit e670c97

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

ale_linters/verilog/slang.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ endif
99
" --lint-only
1010
function! ale_linters#verilog#slang#GetCommand(buffer) abort
1111
return 'slang -Weverything '
12+
\ . '--diag-abs-paths '
1213
\ . '-I%s:h '
14+
\ . '-y%s:h '
1315
\ . ale#Var(a:buffer, 'verilog_slang_options') .' '
1416
\ . '%t'
1517
endfunction
@@ -28,6 +30,7 @@ function! ale_linters#verilog#slang#Handle(buffer, lines) abort
2830

2931
for l:match in ale#util#GetMatches(a:lines, l:pattern)
3032
let l:item = {
33+
\ 'filename': l:match[1],
3134
\ 'lnum': str2nr(l:match[2]),
3235
\ 'type': (l:match[4] is# 'error') ? 'E' : 'W',
3336
\ 'text': s:RemoveUnicodeQuotes(l:match[5]),

test/handler/test_slang_handler.vader

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ Execute(The slang handler should parse lines correctly):
88
AssertEqual
99
\ [
1010
\ {
11+
\ 'filename' : 'foo.sv',
1112
\ 'lnum': 11,
1213
\ 'col': 1,
1314
\ 'type': 'W',
1415
\ 'text': 'extra '';'' has no effect [-Wempty-member]',
1516
\ },
1617
\ {
18+
\ 'filename' : 'bar.sv',
1719
\ 'lnum': 24,
1820
\ 'col': 12,
1921
\ 'type': 'E',
@@ -22,5 +24,5 @@ Execute(The slang handler should parse lines correctly):
2224
\ ],
2325
\ ale_linters#verilog#slang#Handle(bufnr(''), [
2426
\ 'foo.sv:11:1: warning: extra '';'' has no effect [-Wempty-member]',
25-
\ 'foo.sv:24:12: error: cannot mix continuous and procedural assignments to variable ''data_o''',
27+
\ 'bar.sv:24:12: error: cannot mix continuous and procedural assignments to variable ''data_o''',
2628
\ ])

test/linter/test_slang.vader

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ After:
55
call ale#assert#TearDownLinterTest()
66

77
Execute(The default slang command should be correct):
8-
AssertLinter 'slang', 'slang -Weverything -I%s:h %t'
8+
AssertLinter 'slang', 'slang -Weverything --diag-abs-paths -I%s:h -y%s:h %t'
99

1010
Execute(slang options should be configurable):
1111
" Additional args for the linter
1212
let g:ale_verilog_slang_options = '--define-macro DWIDTH=12'
1313

14-
AssertLinter 'slang', 'slang -Weverything -I%s:h --define-macro DWIDTH=12 %t'
14+
AssertLinter 'slang', 'slang -Weverything --diag-abs-paths -I%s:h -y%s:h --define-macro DWIDTH=12 %t'

0 commit comments

Comments
 (0)