Ben Clayton | 7883a0c | 2023-04-20 23:51:53 +0000 | [diff] [blame] | 1 | // Copyright 2023 The Tint Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef SRC_TINT_AST_DIAGNOSTIC_RULE_NAME_H_ |
| 16 | #define SRC_TINT_AST_DIAGNOSTIC_RULE_NAME_H_ |
| 17 | |
| 18 | #include <string> |
| 19 | |
| 20 | #include "src/tint/ast/node.h" |
| 21 | |
| 22 | // Forward declarations |
| 23 | namespace tint::ast { |
| 24 | class Identifier; |
| 25 | } // namespace tint::ast |
| 26 | |
| 27 | namespace tint::ast { |
| 28 | |
| 29 | /// A diagnostic rule name used for diagnostic directives and attributes. |
| 30 | class DiagnosticRuleName final : public utils::Castable<DiagnosticRuleName, Node> { |
| 31 | public: |
| 32 | /// Constructor |
| 33 | /// @param pid the identifier of the program that owns this node |
| 34 | /// @param nid the unique node identifier |
| 35 | /// @param src the source of this node |
| 36 | /// @param name the rule name |
| 37 | DiagnosticRuleName(ProgramID pid, NodeID nid, const Source& src, const Identifier* name); |
| 38 | |
| 39 | /// Constructor |
| 40 | /// @param pid the identifier of the program that owns this node |
| 41 | /// @param nid the unique node identifier |
| 42 | /// @param src the source of this node |
| 43 | /// @param category the rule category. |
| 44 | /// @param name the rule name |
| 45 | DiagnosticRuleName(ProgramID pid, |
| 46 | NodeID nid, |
| 47 | const Source& src, |
| 48 | const Identifier* category, |
| 49 | const Identifier* name); |
| 50 | |
| 51 | /// Clones this node and all transitive child nodes using the `CloneContext` `ctx`. |
| 52 | /// @param ctx the clone context |
| 53 | /// @return the newly cloned node |
| 54 | const DiagnosticRuleName* Clone(CloneContext* ctx) const override; |
| 55 | |
| 56 | /// @return the full name of this diagnostic rule, either as `name` or `category.name`. |
| 57 | std::string String() const; |
| 58 | |
| 59 | /// The diagnostic rule category (category.name) |
| 60 | Identifier const* const category = nullptr; |
| 61 | |
| 62 | /// The diagnostic rule name. |
| 63 | Identifier const* const name; |
| 64 | }; |
| 65 | |
| 66 | } // namespace tint::ast |
| 67 | |
| 68 | #endif // SRC_TINT_AST_DIAGNOSTIC_RULE_NAME_H_ |