blob: 4645d9c5a4ffb4238cfd73e4e959209119d8e87c [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/diagnostic/diagnostic.h"
// Forward declarations
namespace tint::ast {
class Identifier;
} // 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.
struct DiagnosticControl {
public:
/// Default constructor.
DiagnosticControl() {}
/// Constructor
/// @param sev the diagnostic severity
/// @param rule the diagnostic rule name
DiagnosticControl(DiagnosticSeverity sev, const Identifier* rule);
/// The diagnostic severity control.
DiagnosticSeverity severity;
/// The diagnostic rule name.
const Identifier* rule_name;
};
} // namespace tint::ast
#endif // SRC_TINT_AST_DIAGNOSTIC_CONTROL_H_