blob: 49946c25580193ea64938aa7dc46c2dede5149aa [file] [log] [blame]
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate diagnostic_control.h
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
#ifndef SRC_TINT_AST_DIAGNOSTIC_CONTROL_H_
#define SRC_TINT_AST_DIAGNOSTIC_CONTROL_H_
#include <ostream>
#include <string>
#include <unordered_map>
#include "src/tint/ast/node.h"
// Forward declarations
namespace tint::ast {
class IdentifierExpression;
} // namespace tint::ast
namespace tint::ast {
/// The diagnostic severity control.
{{ Eval "DeclareEnum" (Sem.Enum "diagnostic_severity") }}
/// The diagnostic rule.
{{ Eval "DeclareEnum" (Sem.Enum "diagnostic_rule") }}
/// Convert a DiagnosticSeverity to the corresponding diag::Severity.
diag::Severity ToSeverity(DiagnosticSeverity sc);
/// DiagnosticRuleSeverities is a map from diagnostic rule to diagnostic severity.
using DiagnosticRuleSeverities = std::unordered_map<DiagnosticRule, DiagnosticSeverity>;
/// A diagnostic control used for diagnostic directives and attributes.
class DiagnosticControl : public Castable<DiagnosticControl, Node> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param sev the diagnostic severity
/// @param rule the diagnostic rule name
DiagnosticControl(ProgramID pid,
NodeID nid,
const Source& src,
DiagnosticSeverity sev,
const IdentifierExpression* rule)
: Base(pid, nid, src), severity(sev), rule_name(rule) {}
~DiagnosticControl() override;
/// Clones this node and all transitive child nodes using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned node
const DiagnosticControl* Clone(CloneContext* ctx) const override;
/// The diagnostic severity control.
DiagnosticSeverity severity;
/// The diagnostic rule name.
const IdentifierExpression* rule_name;
};
} // namespace tint::ast
#endif // SRC_TINT_AST_DIAGNOSTIC_CONTROL_H_