| 1 |
/* Logical location support, without knowledge of "tree". |
| 2 |
Copyright (C) 2022-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by David Malcolm <[email protected]>. |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 3, or (at your option) any later |
| 10 |
version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along 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 |
#include "label-text.h" |
| 25 |
|
| 26 |
/* An enum for discriminating between different kinds of logical location |
| 27 |
for a diagnostic. |
| 28 |
|
| 29 |
Roughly corresponds to logicalLocation's "kind" property in SARIF v2.1.0 |
| 30 |
(section 3.33.7). */ |
| 31 |
|
| 32 |
enum logical_location_kind |
| 33 |
{ |
| 34 |
LOGICAL_LOCATION_KIND_UNKNOWN, |
| 35 |
|
| 36 |
LOGICAL_LOCATION_KIND_FUNCTION, |
| 37 |
LOGICAL_LOCATION_KIND_MEMBER, |
| 38 |
LOGICAL_LOCATION_KIND_MODULE, |
| 39 |
LOGICAL_LOCATION_KIND_NAMESPACE, |
| 40 |
LOGICAL_LOCATION_KIND_TYPE, |
| 41 |
LOGICAL_LOCATION_KIND_RETURN_TYPE, |
| 42 |
LOGICAL_LOCATION_KIND_PARAMETER, |
| 43 |
LOGICAL_LOCATION_KIND_VARIABLE |
| 44 |
}; |
| 45 |
|
| 46 |
/* Abstract base class for passing around logical locations in the |
| 47 |
diagnostics subsystem, such as: |
| 48 |
- "within function 'foo'", or |
| 49 |
- "within method 'bar'", |
| 50 |
but *without* requiring knowledge of trees |
| 51 |
(see tree-logical-location.h for concrete subclasses relating to trees, |
| 52 |
and selftest-logical-location.h for a concrete subclass for selftests). */ |
| 53 |
|
| 54 |
class logical_location |
| 55 |
{ |
| 56 |
public: |
| 57 |
virtual ~logical_location () {} |
| 58 |
|
| 59 |
/* Get a string (or NULL) suitable for use by the SARIF logicalLocation |
| 60 |
"name" property (SARIF v2.1.0 section 3.33.4). */ |
| 61 |
virtual const char *get_short_name () const = 0; |
| 62 |
|
| 63 |
/* Get a string (or NULL) suitable for use by the SARIF logicalLocation |
| 64 |
"fullyQualifiedName" property (SARIF v2.1.0 section 3.33.5). */ |
| 65 |
virtual const char *get_name_with_scope () const = 0; |
| 66 |
|
| 67 |
/* Get a string (or NULL) suitable for use by the SARIF logicalLocation |
| 68 |
"decoratedName" property (SARIF v2.1.0 section 3.33.6). */ |
| 69 |
virtual const char *get_internal_name () const = 0; |
| 70 |
|
| 71 |
/* Get what kind of SARIF logicalLocation this is (if any). */ |
| 72 |
virtual enum logical_location_kind get_kind () const = 0; |
| 73 |
|
| 74 |
/* Get a string for this location in a form suitable for path output. */ |
| 75 |
virtual label_text get_name_for_path_output () const = 0; |
| 76 |
|
| 77 |
bool function_p () const; |
| 78 |
}; |
| 79 |
|
| 80 |
#endif /* GCC_LOGICAL_LOCATION_H. */ |