https://gcc.gnu.org/g:13f4b12393fa9813b57f5d2dff0753945a2812ce
commit r16-263-g13f4b12393fa9813b57f5d2dff0753945a2812ce Author: David Malcolm <dmalc...@redhat.com> Date: Mon Apr 28 18:21:23 2025 -0400 analyzer,c++: add placeholder implementation of ana::translation_unit for C++ Implement ana::translation_unit for the C++ frontend with a no-op placeholder implementation, for now. No functional change intended; a follow-up may implement things further. gcc/cp/ChangeLog: * parser.cc: Include "analyzer/analyzer-language.h". (ana::cp_translation_unit): New class. (cp_parser_translation_unit): Add call to ana::on_finish_translation_unit. Signed-off-by: David Malcolm <dmalc...@redhat.com> Diff: --- gcc/cp/parser.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index e165b2a0b1b3..1fb9e7fd8729 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "contracts.h" #include "bitmap.h" #include "builtins.h" +#include "analyzer/analyzer-language.h" /* The lexer. */ @@ -286,6 +287,37 @@ static FILE *cp_lexer_debug_stream; sizeof, typeof, or alignof. */ int cp_unevaluated_operand; +#if ENABLE_ANALYZER + +namespace ana { + +/* Concrete implementation of ana::translation_unit for the C++ frontend. */ + +class cp_translation_unit : public translation_unit +{ +public: + tree lookup_constant_by_id (tree /*id*/) const final override + { + return NULL_TREE; + } + + tree + lookup_type_by_id (tree /*id*/) const final override + { + return NULL_TREE; + } + + tree + lookup_global_var_by_id (tree /*id*/) const final override + { + return NULL_TREE; + } +}; + +} // namespace ana + +#endif /* #if ENABLE_ANALYZER */ + /* Dump up to NUM tokens in BUFFER to FILE starting with token START_TOKEN. If START_TOKEN is NULL, the dump starts with the first token in BUFFER. If NUM is 0, dump all the tokens. If @@ -5471,6 +5503,14 @@ cp_parser_translation_unit (cp_parser* parser) cp_parser_toplevel_declaration (parser); } +#if ENABLE_ANALYZER + if (flag_analyzer) + { + ana::cp_translation_unit tu; + ana::on_finish_translation_unit (tu); + } +#endif + /* Get rid of the token array; we don't need it any more. */ cp_lexer_destroy (parser->lexer); parser->lexer = NULL;