analyzer: stash values for CPython plugin [PR107646]
commitfafe2d18f791c6b97b49af7c84b1b5703681c3af
authorEric Feng <ef2648@columbia.edu>
Wed, 2 Aug 2023 20:54:55 +0000 (2 16:54 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 2 Aug 2023 20:58:58 +0000 (2 16:58 -0400)
tree2024b0d26ed3b846b9b6958004081dcb5a7459ed
parent41ef5a34161356817807be3a2e51fbdbe575ae85
analyzer: stash values for CPython plugin [PR107646]

This patch adds a hook to the end of ana::on_finish_translation_unit
which calls relevant stashing-related callbacks registered during plugin
initialization. This feature is used to stash named types and global
variables for a CPython analyzer plugin [PR107646].

gcc/analyzer/ChangeLog:
PR analyzer/107646
* analyzer-language.cc (run_callbacks): New function.
(on_finish_translation_unit): New function.
* analyzer-language.h (GCC_ANALYZER_LANGUAGE_H): New include.
(class translation_unit): New vfuncs.

gcc/c/ChangeLog:
PR analyzer/107646
* c-parser.cc: New functions on stashing values for the
analyzer.

gcc/testsuite/ChangeLog:
PR analyzer/107646
* gcc.dg/plugin/plugin.exp: Add new plugin and test.
* gcc.dg/plugin/analyzer_cpython_plugin.c: New plugin.
* gcc.dg/plugin/cpython-plugin-test-1.c: New test.

Signed-off-by: Eric Feng <ef2648@columbia.edu>
gcc/analyzer/analyzer-language.cc
gcc/analyzer/analyzer-language.h
gcc/c/c-parser.cc
gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/plugin.exp