mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 09:58:10 +00:00
This is a primarily automated change:
- Search & replace for capitalization
-
`(CARBON_DIAGNOSTIC\((?:\n\s+)?\w+,(?:\n\s+)?\s\w+,(?:\n\s+)?\s")([A-Z])`
- `$1\L$2`
- Search & replace for period
-
`(CARBON_DIAGNOSTIC\((?:\n\s+)?\w+,(?:\n\s+)?\s\w+,(?:\n\s+)?\s"(?:[^)]|\n)+)\.("[,)])`
- `$1$2`
- Limited search & replace for `ERROR: ` -> `error: ` in streamed things
- Leaving a TODO for command_line because there's more cleanup that can
be done there
- Modify diagnostic_consumer.cpp
- ERROR -> error
- WARNING -> warning
---------
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
43 lines
1.1 KiB
C++
43 lines
1.1 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
|
|
|
|
#include "toolchain/diagnostics/diagnostic_consumer.h"
|
|
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
|
|
namespace Carbon {
|
|
|
|
auto StreamDiagnosticConsumer::HandleDiagnostic(Diagnostic diagnostic) -> void {
|
|
if (printed_diagnostic_) {
|
|
*stream_ << "\n";
|
|
} else {
|
|
printed_diagnostic_ = true;
|
|
}
|
|
|
|
for (const auto& message : diagnostic.messages) {
|
|
message.loc.FormatLocation(*stream_);
|
|
*stream_ << ": ";
|
|
switch (message.level) {
|
|
case DiagnosticLevel::Error:
|
|
*stream_ << "error: ";
|
|
break;
|
|
case DiagnosticLevel::Warning:
|
|
*stream_ << "warning: ";
|
|
break;
|
|
case DiagnosticLevel::Note:
|
|
break;
|
|
}
|
|
*stream_ << message.format_fn(message) << "\n";
|
|
message.loc.FormatSnippet(*stream_);
|
|
}
|
|
}
|
|
|
|
auto ConsoleDiagnosticConsumer() -> DiagnosticConsumer& {
|
|
static auto* consumer = new StreamDiagnosticConsumer(llvm::errs());
|
|
return *consumer;
|
|
}
|
|
|
|
} // namespace Carbon
|