[clang][analyzer] Add checker for bad use of 'errno'.
authorBalázs Kéri <1.int32@gmail.com>
Mon, 20 Jun 2022 07:42:19 +0000 (09:42 +0200)
committerBalázs Kéri <1.int32@gmail.com>
Mon, 20 Jun 2022 08:07:31 +0000 (10:07 +0200)
commit60f3b071185bf4be32d5c3376856c573975c912a
tree13aa870a76127cef21404decc035f8cb7916f5d7
parent0ad4f29b545d849820f0025736c9559c5c439032
[clang][analyzer] Add checker for bad use of 'errno'.

Extend checker 'ErrnoModeling' with a state of 'errno' to indicate
the importance of the 'errno' value and how it should be used.
Add a new checker 'ErrnoChecker' that observes use of 'errno' and
finds possible wrong uses, based on the "errno state".
The "errno state" should be set (together with value of 'errno')
by other checkers (that perform modeling of the given function)
in the future. Currently only a test function can set this value.
The new checker has no user-observable effect yet.

Reviewed By: martong, steakhal

Differential Revision: https://reviews.llvm.org/D122150
12 files changed:
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp [new file with mode: 0644]
clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
clang/lib/StaticAnalyzer/Checkers/ErrnoTesterChecker.cpp
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/errno-notes.c [new file with mode: 0644]
clang/test/Analysis/errno-options.c [new file with mode: 0644]
clang/test/Analysis/errno.c