mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 22:02:51 +01:00
Mainly because "sorting_diagnostic_consumer" is legacy, since `SortingDiagnosticConsumer` became `SortingConsumer`. Also better reflecting contents of these files. Where I'm not renaming, I'm less positive about dropping "diagnostics" from "file_diagnostics" and "null_diagnostics" (which contain both a consumer and emitter, and "null.h" seems like poor naming), so not doing that here. Also "diagnostic.h" contains `struct Diagnostic`, so is a decent fit. Assisted-by: Google Antigravity with Gemini 3 Flash
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_KIND_H_
|
|
#define CARBON_TOOLCHAIN_DIAGNOSTICS_KIND_H_
|
|
|
|
#include <cstdint>
|
|
|
|
#include "common/enum_base.h"
|
|
|
|
namespace Carbon::Diagnostics {
|
|
|
|
// Although this currently fits into int8_t, it shouldn't be expected to
|
|
// long-term.
|
|
CARBON_DEFINE_RAW_ENUM_CLASS(Kind, uint16_t) {
|
|
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_RAW_ENUM_ENUMERATOR(Name)
|
|
#include "toolchain/diagnostics/kind.def"
|
|
};
|
|
|
|
// An enumeration of all diagnostics provided by the toolchain. Diagnostics must
|
|
// be added to kind.def, and defined locally to where they're used using the
|
|
// `DIAGNOSTIC` macro in emitter.h.
|
|
//
|
|
// Diagnostic definitions are decentralized because placing all diagnostic
|
|
// definitions centrally is expected to create a compilation bottleneck
|
|
// long-term, and we also see value to keeping diagnostic format strings close
|
|
// to the consuming code.
|
|
class Kind : public CARBON_ENUM_BASE(Kind) {
|
|
public:
|
|
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
|
|
#include "toolchain/diagnostics/kind.def"
|
|
};
|
|
|
|
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_ENUM_CONSTANT_DEFINITION(Kind, Name)
|
|
#include "toolchain/diagnostics/kind.def"
|
|
|
|
// We expect Kind to fit into 2 bits.
|
|
static_assert(sizeof(Kind) == 2, "Kind includes padding!");
|
|
|
|
} // namespace Carbon::Diagnostics
|
|
|
|
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_KIND_H_
|