diagnostic_kind.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_KIND_H_
  5. #define TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_KIND_H_
  6. #include "common/ostream.h"
  7. #include "llvm/ADT/StringRef.h"
  8. namespace Carbon {
  9. // An enumeration of all diagnostics provided by the toolchain. Diagnostics must
  10. // be added to diagnostic_registry.def, and defined locally to where they're
  11. // used using the `DIAGNOSTIC` macro in diagnostic_emitter.h.
  12. //
  13. // Diagnostic definitions are decentralized because placing all diagnostic
  14. // definitions centrally is expected to create a compilation bottleneck
  15. // long-term, and we also see value to keeping diagnostic format strings close
  16. // to the consuming code.
  17. enum class DiagnosticKind : int32_t {
  18. #define CARBON_DIAGNOSTIC_KIND(DiagnosticName) DiagnosticName,
  19. #include "toolchain/diagnostics/diagnostic_registry.def"
  20. };
  21. auto operator<<(llvm::raw_ostream& out, DiagnosticKind kind)
  22. -> llvm::raw_ostream&;
  23. inline auto operator<<(std::ostream& out, DiagnosticKind kind)
  24. -> std::ostream& {
  25. llvm::raw_os_ostream(out) << kind;
  26. return out;
  27. }
  28. } // namespace Carbon
  29. #endif // TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_KIND_H_