// 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 #include "toolchain/diagnostics/mocks.h" #include namespace Carbon::Diagnostics { auto PrintTo(const Diagnostic& diagnostic, std::ostream* os) -> void { *os << "Diagnostic{"; PrintTo(diagnostic.level, os); const Loc& loc = diagnostic.message.loc; *os << ", {" << loc.filename << ":" << loc.line_number << ":" << loc.column_number << ", \"" << diagnostic.message.Format() << "\"}"; for (const auto& range : diagnostic.message.ranges) { *os << ", {Range " << range.filename << ":" << range.line_number << ":" << range.column_number << "+" << range.length << "}"; } for (const auto& label : diagnostic.labels) { *os << ", {Label " << label.loc.filename << ":" << label.loc.line_number << ":" << label.loc.column_number << ", \"" << label.Format() << "\"}"; } *os << "}"; } auto PrintTo(Level level, std::ostream* os) -> void { switch (level) { case Level::Warning: *os << "Warning"; break; case Level::Error: *os << "Error"; break; } } } // namespace Carbon::Diagnostics