1/* Interface between analyzer and frontends.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_ANALYZER_LANGUAGE_H
22#define GCC_ANALYZER_LANGUAGE_H
23
24#include "analyzer/analyzer-logging.h"
25
26#if ENABLE_ANALYZER
27
28namespace ana {
29
30/* Abstract base class for representing a specific TU
31 to the analyzer. */
32
33class translation_unit
34{
35 public:
36 /* Attempt to look up an value for identifier ID (e.g. in the headers that
37 have been seen). If it is defined and an integer (e.g. either as a
38 macro or enum), return the INTEGER_CST value, otherwise return NULL. */
39 virtual tree lookup_constant_by_id (tree id) const = 0;
40 virtual tree lookup_type_by_id (tree id) const = 0;
41 virtual tree lookup_global_var_by_id (tree id) const = 0;
42};
43
44typedef void (*finish_translation_unit_callback)
45 (logger *, const translation_unit &);
46void register_finish_translation_unit_callback (
47 finish_translation_unit_callback callback);
48
49/* Analyzer hook for frontends to call at the end of the TU. */
50
51void on_finish_translation_unit (const translation_unit &tu);
52
53} // namespace ana
54
55#endif /* #if ENABLE_ANALYZER */
56
57#endif /* GCC_ANALYZER_LANGUAGE_H */
58

source code of gcc/analyzer/analyzer-language.h