mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
Move diagnostics into a namespace (#5173)
What this really does is avoids shadowing names, so that we can comfortable have things like `Check::DiagnosticEmitter` or `Check::DiagnosticLoc` without shadowing being a concern. Note, down this path I'm also thinking about: - Renaming misc DiagnosticConsumer/DiagnosticEmitter classes, possibly just to DiagnosticConsumer/DiagnosticEmitter (so `Check::DiagnosticEmitter` instead of `SemIRLocDiagnosticEmitter`). - Dropping `Diagnostic` from `Emitter::DiagnosticBuilder`. - But not for `Check::DiagnosticBuilder`, because `Check::Builder` would be ambiguous. - Renaming diagnostics/diagnostic_* to drop "diagnostic". [Discussion about SemIRLoc -> DiagnosticLoc](https://discord.com/channels/655572317891461132/655578254970716160/1353771570463768698) reminded me of this (in particular the older [Check::DiagnosticBuilder discussion](https://discord.com/channels/655572317891461132/655578254970716160/1344363562608627763)), but I'd only do that rename if there's matching consensus about a path forward where we keep SemIRLoc, and in a way that it's only ever used for diagnostics (the divergence from which is at the root of current LocId discussion). I'm trying to keep that separate from a namespace addition for clarity.
This commit is contained in:
@@ -36,19 +36,19 @@ class SourceBuffer {
|
||||
public:
|
||||
// Opens and reads the contents of stdin. Returns a SourceBuffer on success.
|
||||
// Prints an error and returns nullopt on failure.
|
||||
static auto MakeFromStdin(DiagnosticConsumer& consumer)
|
||||
static auto MakeFromStdin(Diagnostics::Consumer& consumer)
|
||||
-> std::optional<SourceBuffer>;
|
||||
|
||||
// Opens the requested file. Returns a SourceBuffer on success. Prints an
|
||||
// error and returns nullopt on failure.
|
||||
static auto MakeFromFile(llvm::vfs::FileSystem& fs, llvm::StringRef filename,
|
||||
DiagnosticConsumer& consumer)
|
||||
Diagnostics::Consumer& consumer)
|
||||
-> std::optional<SourceBuffer>;
|
||||
|
||||
// Handles conditional use of stdin based on the filename being "-".
|
||||
static auto MakeFromFileOrStdin(llvm::vfs::FileSystem& fs,
|
||||
llvm::StringRef filename,
|
||||
DiagnosticConsumer& consumer)
|
||||
Diagnostics::Consumer& consumer)
|
||||
-> std::optional<SourceBuffer> {
|
||||
if (filename == "-") {
|
||||
return MakeFromStdin(consumer);
|
||||
@@ -60,7 +60,7 @@ class SourceBuffer {
|
||||
// Returns a source buffer with the provided text content. Copies `filename`
|
||||
// and `text` to take ownership.
|
||||
static auto MakeFromStringCopy(llvm::StringRef filename, llvm::StringRef text,
|
||||
DiagnosticConsumer& consumer)
|
||||
Diagnostics::Consumer& consumer)
|
||||
-> std::optional<SourceBuffer>;
|
||||
|
||||
// Use one of the factory functions above to create a source buffer.
|
||||
@@ -80,7 +80,7 @@ class SourceBuffer {
|
||||
static auto MakeFromMemoryBuffer(
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer,
|
||||
llvm::StringRef filename, bool is_regular_file,
|
||||
DiagnosticConsumer& consumer) -> std::optional<SourceBuffer>;
|
||||
Diagnostics::Consumer& consumer) -> std::optional<SourceBuffer>;
|
||||
|
||||
explicit SourceBuffer(std::string filename,
|
||||
std::unique_ptr<llvm::MemoryBuffer> text,
|
||||
|
||||
Reference in New Issue
Block a user