splint.vim 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. " Vim compiler file
  2. " Compiler: splint/lclint (C source code checker)
  3. " Maintainer: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
  4. " Splint Home: http://www.splint.org/
  5. " Last Change: 2019 Jul 23
  6. " $Revision: 1.3 $
  7. if exists("current_compiler")
  8. finish
  9. endif
  10. let current_compiler = "splint"
  11. if exists(":CompilerSet") != 2 " older Vim always used :setlocal
  12. command -nargs=* CompilerSet setlocal <args>
  13. endif
  14. let s:cpo_save = &cpo
  15. set cpo-=C
  16. " adapt this if you want to check more than one file at a time.
  17. " put command line options in .splintrc or ~/.splintrc
  18. CompilerSet makeprg=splint\ %:S
  19. " Note: when using the new array bounds checking flags: Each warning
  20. " usually has several lines and several references to source code mostly
  21. " within one or two lines (see sample warning below). The easiest way
  22. " not to mess up file name detection and not to jump to all positions is
  23. " to add something like
  24. " -linelen 500 +boundscompacterrormessages
  25. " to your .splintrc and 'set cmdheight=4' or more.
  26. " TODO: reliable way to distinguish file names and constraints.
  27. "
  28. " sample warning (generic):
  29. "
  30. "foo.c:1006:12: Clauses exit with var referencing local storage in one
  31. " case, fresh storage in other case
  32. " foo.c:1003:2: Fresh storage var allocated
  33. "
  34. " sample warning (bounds checking):
  35. "
  36. "bounds.c: (in function updateEnv)
  37. "bounds.c:10:5: Possible out-of-bounds store:
  38. " strcpy(str, tmp)
  39. " Unable to resolve constraint:
  40. " requires maxSet(str @ bounds.c:10:13) >= maxRead(getenv("MYENV") @
  41. " bounds.c:6:9)
  42. " needed to satisfy precondition:
  43. " requires maxSet(str @ bounds.c:10:13) >= maxRead(tmp @ bounds.c:10:18)
  44. " derived from strcpy precondition: requires maxSet(<parameter 1>) >=
  45. " maxRead(<parameter 2>)
  46. " A memory write may write to an address beyond the allocated buffer. (Use
  47. " -boundswrite to inhibit warning)
  48. CompilerSet errorformat=%OLCLint*m,
  49. \%OSplint*m,
  50. \%f(%l\\,%c):\ %m,
  51. \%*[\ ]%f:%l:%c:\ %m,
  52. \%*[\ ]%f:%l:\ %m,
  53. \%*[^\"]\"%f\"%*\\D%l:\ %m,
  54. \\"%f\"%*\\D%l:\ %m,
  55. \%A%f:%l:%c:\ %m,
  56. \%A%f:%l:%m,
  57. \\"%f\"\\,
  58. \\ line\ %l%*\\D%c%*[^\ ]\ %m,
  59. \%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',
  60. \%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',
  61. \%DMaking\ %*\\a\ in\ %f,
  62. \%C\ %#%m
  63. let &cpo = s:cpo_save
  64. unlet s:cpo_save