analyzer: introduce a set of known async-signal-unsafe functions
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 19 Dec 2019 20:50:29 +0000 (15:50 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 14 Jan 2020 23:55:00 +0000 (18:55 -0500)
commit4804c5fe965eef2f346de53d9e896ea2cd88f0b9
tree76c4abc5bfcbe0daa782d729afabba990b77dc42
parenta6b5f19c37001d7c9974248ffcb65aadba33283c
analyzer: introduce a set of known async-signal-unsafe functions

This patch uses the class function_set from the previous patch to
generalize the test for an fprintf inside a signal handler to
check for a set of known async-signal-unsafe functions.

gcc/analyzer/ChangeLog:
* analyzer-selftests.cc (selftest::run_analyzer_selftests): Call
selftest::analyzer_sm_signal_cc_tests.
* analyzer-selftests.h (selftest::analyzer_sm_signal_cc_tests):
New decl.
* sm-signal.cc: Include "analyzer/function-set.h" and
"analyzer/analyzer-selftests.h".
(get_async_signal_unsafe_fns): New function.
(signal_unsafe_p): Reimplement in terms of the above.
(selftest::analyzer_sm_signal_cc_tests): New function.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/signal-5.c: New test.
gcc/analyzer/ChangeLog
gcc/analyzer/analyzer-selftests.cc
gcc/analyzer/analyzer-selftests.h
gcc/analyzer/sm-signal.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/analyzer/signal-5.c [new file with mode: 0644]