1/* Logical location support, without knowledge of "tree".
2 Copyright (C) 2022-2023 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 under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for 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_LOGICAL_LOCATION_H
22#define GCC_LOGICAL_LOCATION_H
23
24/* An enum for discriminating between different kinds of logical location
25 for a diagnostic.
26
27 Roughly corresponds to logicalLocation's "kind" property in SARIF v2.1.0
28 (section 3.33.7). */
29
30enum logical_location_kind
31{
32 LOGICAL_LOCATION_KIND_UNKNOWN,
33
34 LOGICAL_LOCATION_KIND_FUNCTION,
35 LOGICAL_LOCATION_KIND_MEMBER,
36 LOGICAL_LOCATION_KIND_MODULE,
37 LOGICAL_LOCATION_KIND_NAMESPACE,
38 LOGICAL_LOCATION_KIND_TYPE,
39 LOGICAL_LOCATION_KIND_RETURN_TYPE,
40 LOGICAL_LOCATION_KIND_PARAMETER,
41 LOGICAL_LOCATION_KIND_VARIABLE
42};
43
44/* Abstract base class for passing around logical locations in the
45 diagnostics subsystem, such as:
46 - "within function 'foo'", or
47 - "within method 'bar'",
48 but *without* requiring knowledge of trees
49 (see tree-logical-location.h for subclasses relating to trees). */
50
51class logical_location
52{
53public:
54 virtual ~logical_location () {}
55
56 /* Get a string (or NULL) suitable for use by the SARIF logicalLocation
57 "name" property (SARIF v2.1.0 section 3.33.4). */
58 virtual const char *get_short_name () const = 0;
59
60 /* Get a string (or NULL) suitable for use by the SARIF logicalLocation
61 "fullyQualifiedName" property (SARIF v2.1.0 section 3.33.5). */
62 virtual const char *get_name_with_scope () const = 0;
63
64 /* Get a string (or NULL) suitable for use by the SARIF logicalLocation
65 "decoratedName" property (SARIF v2.1.0 section 3.33.6). */
66 virtual const char *get_internal_name () const = 0;
67
68 /* Get what kind of SARIF logicalLocation this is (if any). */
69 virtual enum logical_location_kind get_kind () const = 0;
70};
71
72#endif /* GCC_LOGICAL_LOCATION_H. */
73

source code of gcc/logical-location.h