scan-build.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/sh
  2. # Copyright 2014 The Tor Project, Inc
  3. # See LICENSE for licensing information
  4. #
  5. # This script is used for running a bunch of clang scan-build checkers
  6. # on Tor.
  7. # These don't seem to cause false positives in our code, so let's turn
  8. # them on.
  9. CHECKERS="\
  10. -enable-checker alpha.core.CallAndMessageUnInitRefArg \
  11. -enable-checker alpha.core.CastToStruct \
  12. -enable-checker alpha.core.Conversion \
  13. -enable-checker alpha.core.FixedAddr \
  14. -enable-checker alpha.core.IdenticalExpr \
  15. -enable-checker alpha.core.PointerArithm \
  16. -enable-checker alpha.core.SizeofPtr \
  17. -enable-checker alpha.core.TestAfterDivZero \
  18. -enable-checker alpha.security.MallocOverflow \
  19. -enable-checker alpha.security.ReturnPtrRange \
  20. -enable-checker alpha.unix.BlockInCriticalSection \
  21. -enable-checker alpha.unix.Chroot \
  22. -enable-checker alpha.unix.PthreadLock \
  23. -enable-checker alpha.unix.PthreadLock \
  24. -enable-checker alpha.unix.SimpleStream \
  25. -enable-checker alpha.unix.Stream \
  26. -enable-checker alpha.unix.cstring.BufferOverlap \
  27. -enable-checker alpha.unix.cstring.NotNullTerminated \
  28. -enable-checker valist.CopyToSelf \
  29. -enable-checker valist.Uninitialized \
  30. -enable-checker valist.Unterminated \
  31. -enable-checker security.FloatLoopCounter \
  32. -enable-checker security.insecureAPI.strcpy \
  33. "
  34. # shellcheck disable=SC2034
  35. # These have high false-positive rates.
  36. EXTRA_CHECKERS="\
  37. -enable-checker alpha.security.ArrayBoundV2 \
  38. -enable-checker alpha.unix.cstring.OutOfBounds \
  39. -enable-checker alpha.core.CastSize \
  40. "
  41. # shellcheck disable=SC2034
  42. # These don't seem to generate anything useful
  43. NOISY_CHECKERS="\
  44. -enable-checker alpha.clone.CloneChecker \
  45. -enable-checker alpha.deadcode.UnreachableCode \
  46. "
  47. if test "x$SCAN_BUILD_OUTPUT" != "x"; then
  48. OUTPUTARG="-o $SCAN_BUILD_OUTPUT"
  49. else
  50. OUTPUTARG=""
  51. fi
  52. # shellcheck disable=SC2086
  53. scan-build \
  54. $CHECKERS \
  55. ./configure
  56. scan-build \
  57. make clean
  58. # Make this not get scanned for dead assignments, since it has lots of
  59. # dead assignments we don't care about.
  60. # shellcheck disable=SC2086
  61. scan-build \
  62. $CHECKERS \
  63. -disable-checker deadcode.DeadStores \
  64. make -j5 -k ./src/ext/ed25519/ref10/libed25519_ref10.a
  65. # shellcheck disable=SC2086
  66. scan-build \
  67. $CHECKERS $OUTPUTARG \
  68. make -j5 -k
  69. CHECKERS="\
  70. "
  71. # This one gives a false positive on every strcmp.
  72. # -enable-checker alpha.core.PointerSub
  73. # Needs work
  74. # -enable-checker alpha.unix.MallocWithAnnotations