Drop "diagnostic" from some filenames in the "diagnostics" folder (#6686)

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
This commit is contained in:
Jon Ross-Perkins
2026-02-04 17:24:55 +00:00
committed by GitHub
parent e5b05a1fac
commit 45ca3d28f5
70 changed files with 158 additions and 158 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ cc_library(
":install_paths",
"//common:check",
"//common:string_helpers",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@llvm-project//clang:basic",
"@llvm-project//clang:driver",
"@llvm-project//clang:frontend",
+1 -1
View File
@@ -13,7 +13,7 @@
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon {
+5 -5
View File
@@ -161,7 +161,7 @@ cc_library(
"//toolchain/base:value_store",
"//toolchain/check:generic_region_stack",
"//toolchain/check:scope_stack",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:format_providers",
"//toolchain/lex:token_info",
"//toolchain/lex:token_kind",
@@ -224,8 +224,8 @@ cc_library(
deps = [
":context",
":core_identifier",
":diagnostic_emitter",
":dump",
":emitter",
":scope_stack",
"//common:check",
"//common:error",
@@ -239,7 +239,7 @@ cc_library(
"//toolchain/base:kind_switch",
"//toolchain/base:shared_value_stores",
"//toolchain/base:timings",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:format_providers",
"//toolchain/lex:token_index",
"//toolchain/lex:token_kind",
@@ -343,14 +343,14 @@ cc_library(
)
cc_library(
name = "diagnostic_emitter",
name = "emitter",
srcs = ["diagnostic_emitter.cpp"],
hdrs = ["diagnostic_emitter.h"],
deps = [
":context",
"//common:ostream",
"//common:raw_string_ostream",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/lex:token_index",
"//toolchain/parse:tree",
"//toolchain/sem_ir:absolute_node_id",
+1 -1
View File
@@ -15,8 +15,8 @@
#include "toolchain/check/cpp/import.h"
#include "toolchain/check/diagnostic_emitter.h"
#include "toolchain/check/diagnostic_helpers.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/diagnostics/diagnostic.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/format_providers.h"
#include "toolchain/lex/token_kind.h"
#include "toolchain/parse/node_ids.h"
+1 -1
View File
@@ -10,7 +10,7 @@
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/base/timings.h"
#include "toolchain/check/diagnostic_emitter.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/parse/tree_and_subtrees.h"
#include "toolchain/sem_ir/file.h"
#include "toolchain/sem_ir/ids.h"
+1 -1
View File
@@ -26,7 +26,7 @@
#include "toolchain/check/param_and_arg_refs_stack.h"
#include "toolchain/check/region_stack.h"
#include "toolchain/check/scope_stack.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/parse/node_ids.h"
#include "toolchain/parse/tree.h"
#include "toolchain/parse/tree_and_subtrees.h"
+1 -1
View File
@@ -25,7 +25,7 @@
#include "llvm/Support/raw_ostream.h"
#include "toolchain/check/context.h"
#include "toolchain/diagnostics/diagnostic.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/format_providers.h"
#include "toolchain/parse/node_ids.h"
#include "toolchain/sem_ir/cpp_file.h"
+1 -1
View File
@@ -12,7 +12,7 @@
#include "toolchain/check/context.h"
#include "toolchain/check/convert.h"
#include "toolchain/check/diagnostic_helpers.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/sem_ir/clang_decl.h"
#include "toolchain/sem_ir/ids.h"
+1 -1
View File
@@ -15,7 +15,7 @@
#include "toolchain/check/cpp/type_mapping.h"
#include "toolchain/check/member_access.h"
#include "toolchain/check/name_lookup.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/sem_ir/function.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/name_scope.h"
+1 -1
View File
@@ -7,7 +7,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "toolchain/check/diagnostic_helpers.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/token_index.h"
#include "toolchain/sem_ir/diagnostic_loc_converter.h"
+1 -1
View File
@@ -23,7 +23,7 @@
#include "toolchain/check/type.h"
#include "toolchain/check/type_completion.h"
#include "toolchain/diagnostics/diagnostic.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/format_providers.h"
#include "toolchain/sem_ir/builtin_function_kind.h"
#include "toolchain/sem_ir/constant.h"
+1 -1
View File
@@ -15,7 +15,7 @@
#include "toolchain/check/modifiers.h"
#include "toolchain/check/pattern.h"
#include "toolchain/check/pattern_match.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/format_providers.h"
#include "toolchain/lex/token_kind.h"
#include "toolchain/parse/node_ids.h"
+1 -1
View File
@@ -11,7 +11,7 @@
#include "toolchain/check/operator.h"
#include "toolchain/check/pointer_dereference.h"
#include "toolchain/check/type.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/parse/typed_nodes.h"
#include "toolchain/sem_ir/expr_info.h"
+1 -1
View File
@@ -24,7 +24,7 @@
#include "toolchain/check/type.h"
#include "toolchain/check/type_completion.h"
#include "toolchain/check/type_structure.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/sem_ir/generic.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/impl.h"
+1 -1
View File
@@ -20,7 +20,7 @@
#include "toolchain/check/name_lookup.h"
#include "toolchain/check/type.h"
#include "toolchain/check/type_completion.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/sem_ir/expr_info.h"
#include "toolchain/sem_ir/function.h"
#include "toolchain/sem_ir/generic.h"
+1 -1
View File
@@ -17,7 +17,7 @@ cc_library(
hdrs = ["codegen.h"],
deps = [
"//common:check",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:file_diagnostics",
"@llvm-project//llvm:Core",
"@llvm-project//llvm:MC",
+1 -1
View File
@@ -13,7 +13,7 @@
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/TargetParser/Host.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/consumer.h"
namespace Carbon {
+1 -1
View File
@@ -7,7 +7,7 @@
#include "llvm/IR/Module.h"
#include "llvm/Target/TargetMachine.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/diagnostics/file_diagnostics.h"
namespace Carbon {
+24 -24
View File
@@ -8,19 +8,19 @@ load("//bazel/manifest:defs.bzl", "manifest")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "diagnostic_emitter",
name = "emitter",
srcs = [
"consumer.cpp",
"diagnostic.cpp",
"diagnostic_consumer.cpp",
],
hdrs = [
"consumer.h",
"diagnostic.h",
"diagnostic_consumer.h",
"diagnostic_emitter.h",
"emitter.h",
],
deps = [
":diagnostic_kind",
":format_providers",
":kind",
"//common:check",
"//common:ostream",
"@llvm-project//llvm:Support",
@@ -28,11 +28,11 @@ cc_library(
)
cc_test(
name = "diagnostic_emitter_test",
name = "emitter_test",
size = "small",
srcs = ["diagnostic_emitter_test.cpp"],
srcs = ["emitter_test.cpp"],
deps = [
":diagnostic_emitter",
":emitter",
":mocks",
"//testing/base:gtest_main",
"@googletest//:gtest",
@@ -41,11 +41,11 @@ cc_test(
)
cc_library(
name = "diagnostic_kind",
srcs = ["diagnostic_kind.cpp"],
hdrs = ["diagnostic_kind.h"],
name = "kind",
srcs = ["kind.cpp"],
hdrs = ["kind.h"],
textual_hdrs = [
"diagnostic_kind.def",
"kind.def",
],
deps = [
"//common:enum_base",
@@ -67,7 +67,7 @@ cc_test(
"//toolchain/testing:all_testdata",
],
deps = [
":diagnostic_kind",
":kind",
"//testing/base:gtest_main",
"//toolchain/testing:coverage_helper",
"@abseil-cpp//absl/flags:flag",
@@ -79,7 +79,7 @@ cc_library(
name = "file_diagnostics",
hdrs = ["file_diagnostics.h"],
deps = [
":diagnostic_emitter",
":emitter",
"@llvm-project//llvm:Support",
],
)
@@ -100,7 +100,7 @@ cc_test(
size = "small",
srcs = ["format_providers_test.cpp"],
deps = [
":diagnostic_emitter",
":emitter",
":format_providers",
":mocks",
"//testing/base:gtest_main",
@@ -114,29 +114,29 @@ cc_library(
testonly = 1,
hdrs = ["null_diagnostics.h"],
deps = [
":diagnostic_emitter",
":emitter",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "sorting_diagnostic_consumer",
hdrs = ["sorting_diagnostic_consumer.h"],
name = "sorting_consumer",
hdrs = ["sorting_consumer.h"],
deps = [
":diagnostic_emitter",
":emitter",
"//common:check",
"@llvm-project//llvm:Support",
],
)
cc_test(
name = "sorting_diagnostic_consumer_test",
name = "sorting_consumer_test",
size = "small",
srcs = ["sorting_diagnostic_consumer_test.cpp"],
srcs = ["sorting_consumer_test.cpp"],
deps = [
":diagnostic_emitter",
":emitter",
":mocks",
":sorting_diagnostic_consumer",
":sorting_consumer",
"//testing/base:gtest_main",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
@@ -149,7 +149,7 @@ cc_library(
srcs = ["mocks.cpp"],
hdrs = ["mocks.h"],
deps = [
":diagnostic_emitter",
":emitter",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
+1 -1
View File
@@ -41,7 +41,7 @@ def load_diagnostic_kind() -> Set[str]:
This isn't validated for uniqueness because the compiler does that.
"""
path = Path("toolchain/diagnostics/diagnostic_kind.def")
path = Path("toolchain/diagnostics/kind.def")
content = path.read_text()
decls = set(re.findall(r"^\s+CARBON_DIAGNOSTIC_KIND\((.+)\)", content))
return decls.difference(IGNORED)
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/consumer.h"
#include <algorithm>
#include <cstdint>
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_CONSUMER_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_CONSUMER_H_
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_CONSUMER_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_CONSUMER_H_
#include "common/ostream.h"
#include "llvm/ADT/StringRef.h"
@@ -89,4 +89,4 @@ class ErrorTrackingConsumer : public Consumer {
} // namespace Carbon::Diagnostics
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_CONSUMER_H_
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_CONSUMER_H_
+2 -2
View File
@@ -5,7 +5,7 @@
#include <gtest/gtest.h>
#include "absl/flags/flag.h"
#include "toolchain/diagnostics/diagnostic_kind.h"
#include "toolchain/diagnostics/kind.h"
#include "toolchain/testing/coverage_helper.h"
ABSL_FLAG(std::string, testdata_manifest, "",
@@ -16,7 +16,7 @@ namespace {
constexpr Kind Kinds[] = {
#define CARBON_DIAGNOSTIC_KIND(Name) Kind::Name,
#include "toolchain/diagnostics/diagnostic_kind.def"
#include "toolchain/diagnostics/kind.def"
};
constexpr Kind UntestedKinds[] = {
+1 -1
View File
@@ -13,7 +13,7 @@
#include "llvm/ADT/Any.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/diagnostics/diagnostic_kind.h"
#include "toolchain/diagnostics/kind.h"
namespace Carbon::Diagnostics {
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_EMITTER_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_EMITTER_H_
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_EMITTER_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_EMITTER_H_
#include <cstdint>
#include <string>
@@ -14,9 +14,9 @@
#include "llvm/ADT/Any.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/FormatVariadic.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/diagnostics/diagnostic.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/diagnostic_kind.h"
#include "toolchain/diagnostics/kind.h"
namespace Carbon::Diagnostics {
@@ -457,4 +457,4 @@ auto Emitter<LocT>::MakeAny(Arg arg) -> llvm::Any {
} // namespace Carbon::Diagnostics
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_EMITTER_H_
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_EMITTER_H_
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+1 -1
View File
@@ -5,7 +5,7 @@
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_FILE_DIAGNOSTICS_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_FILE_DIAGNOSTICS_H_
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon::Diagnostics {
@@ -2,13 +2,13 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/diagnostics/diagnostic_kind.h" // IWYU pragma: keep
#include "toolchain/diagnostics/kind.h" // IWYU pragma: keep
namespace Carbon::Diagnostics {
CARBON_DEFINE_ENUM_CLASS_NAMES(Kind) {
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_ENUM_CLASS_NAME_STRING(Name)
#include "toolchain/diagnostics/diagnostic_kind.def"
#include "toolchain/diagnostics/kind.def"
};
} // namespace Carbon::Diagnostics
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_KIND_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_DIAGNOSTIC_KIND_H_
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_KIND_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_KIND_H_
#include <cstdint>
@@ -15,12 +15,12 @@ namespace Carbon::Diagnostics {
// long-term.
CARBON_DEFINE_RAW_ENUM_CLASS(Kind, uint16_t) {
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_RAW_ENUM_ENUMERATOR(Name)
#include "toolchain/diagnostics/diagnostic_kind.def"
#include "toolchain/diagnostics/kind.def"
};
// An enumeration of all diagnostics provided by the toolchain. Diagnostics must
// be added to diagnostic_kind.def, and defined locally to where they're
// used using the `DIAGNOSTIC` macro in diagnostic_emitter.h.
// 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
@@ -29,15 +29,15 @@ CARBON_DEFINE_RAW_ENUM_CLASS(Kind, uint16_t) {
class Kind : public CARBON_ENUM_BASE(Kind) {
public:
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
#include "toolchain/diagnostics/diagnostic_kind.def"
#include "toolchain/diagnostics/kind.def"
};
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_ENUM_CONSTANT_DEFINITION(Kind, Name)
#include "toolchain/diagnostics/diagnostic_kind.def"
#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_DIAGNOSTIC_KIND_H_
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_KIND_H_
+1 -1
View File
@@ -7,7 +7,7 @@
#include <gmock/gmock.h>
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon::Testing {
+1 -1
View File
@@ -5,7 +5,7 @@
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_NULL_DIAGNOSTICS_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_NULL_DIAGNOSTICS_H_
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon::Diagnostics {
@@ -2,12 +2,12 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_SORTING_DIAGNOSTIC_CONSUMER_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_SORTING_DIAGNOSTIC_CONSUMER_H_
#ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_SORTING_CONSUMER_H_
#define CARBON_TOOLCHAIN_DIAGNOSTICS_SORTING_CONSUMER_H_
#include "common/check.h"
#include "llvm/ADT/STLExtras.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon::Diagnostics {
@@ -60,4 +60,4 @@ class SortingConsumer : public Consumer {
} // namespace Carbon::Diagnostics
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_SORTING_DIAGNOSTIC_CONSUMER_H_
#endif // CARBON_TOOLCHAIN_DIAGNOSTICS_SORTING_CONSUMER_H_
@@ -2,13 +2,13 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/diagnostics/sorting_diagnostic_consumer.h"
#include "toolchain/diagnostics/sorting_consumer.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "llvm/ADT/StringRef.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/mocks.h"
namespace Carbon::Diagnostics {
+19 -19
View File
@@ -28,8 +28,8 @@ The diagnostic code is used by the toolchain to produce output.
## DiagnosticEmitter
[DiagnosticEmitters](/toolchain/diagnostics/diagnostic_emitter.h) handle the
main formatting of a message. It's parameterized on a location type, for which a
[Emitters](/toolchain/diagnostics/emitter.h) handle the main formatting of a
message. It's parameterized on a location type, for which a
DiagnosticLocationTranslator must be provided that can translate the location
type into a standardized DiagnosticLocation of file, line, and column.
@@ -41,25 +41,25 @@ DiagnosticConsumer.
DiagnosticConsumers handle output of diagnostic messages after they've been
formatted by an Emitter. Important consumers are:
- [ConsoleDiagnosticConsumer](/toolchain/diagnostics/diagnostic_consumer.cpp):
prints diagnostics to console.
- [ConsoleConsumer](/toolchain/diagnostics/consumer.cpp): prints diagnostics
to console.
- [ErrorTrackingDiagnosticConsumer](/toolchain/diagnostics/diagnostic_consumer.h):
counts the number of errors produced, particularly so that it can be
determined whether any errors were encountered.
- [ErrorTrackingConsumer](/toolchain/diagnostics/consumer.h): counts the
number of errors produced, particularly so that it can be determined whether
any errors were encountered.
- [SortingDiagnosticConsumer](/toolchain/diagnostics/sorting_diagnostic_consumer.h):
sorts diagnostics by line so that diagnostics are seen in terminal based on
their order in the file rather than the order they were produced.
- [SortingConsumer](/toolchain/diagnostics/sorting_consumer.h): sorts
diagnostics by line so that diagnostics are seen in terminal based on their
order in the file rather than the order they were produced.
- [NullDiagnosticConsumer](/toolchain/diagnostics/null_diagnostics.h):
suppresses diagnostics, particularly for tests.
- [NullConsumer](/toolchain/diagnostics/null_diagnostics.h): suppresses
diagnostics, particularly for tests.
Note that `SortingDiagnosticConsumer` is used by default by `carbon compile`. In
cases where one error leads to another error at an earlier location, for example
if an error in a function call argument leads to an error in the function call,
this can result in confusing diagnostic output where a consequence of the error
is reported before the cause. Usually this should be handled by tracking that an
Note that `SortingConsumer` is used by default by `carbon compile`. In cases
where one error leads to another error at an earlier location, for example if an
error in a function call argument leads to an error in the function call, this
can result in confusing diagnostic output where a consequence of the error is
reported before the cause. Usually this should be handled by tracking that an
error occurred and suppressing the follow-on diagnostic. During toolchain
development, it can be useful to disable the sorting so that the diagnostic
order matches the order in which the file was processed. This can be done using
@@ -96,8 +96,8 @@ message format to `llvm::formatv` to produce the final diagnostic message.
## Diagnostic registry
There is a [registry](/toolchain/diagnostics/diagnostic_kind.def) which all
diagnostics must be added to. Each diagnostic has a line like:
There is a [registry](/toolchain/diagnostics/kind.def) which all diagnostics
must be added to. Each diagnostic has a line like:
```cpp
CARBON_DIAGNOSTIC_KIND(InvalidCode)
+3 -3
View File
@@ -214,8 +214,8 @@ cc_library(
"//toolchain/base:timings",
"//toolchain/check",
"//toolchain/codegen",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:sorting_diagnostic_consumer",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:sorting_consumer",
"//toolchain/format",
"//toolchain/language_server",
"//toolchain/lex",
@@ -251,7 +251,7 @@ cc_test(
"//testing/base:global_exe_path",
"//testing/base:gtest_main",
"//toolchain/base:install_paths",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/lex:tokenized_buffer_test_helpers",
"//toolchain/testing:yaml_test_helpers",
"@googletest//:gtest",
+2 -2
View File
@@ -23,8 +23,8 @@
#include "toolchain/base/timings.h"
#include "toolchain/check/check.h"
#include "toolchain/codegen/codegen.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/sorting_diagnostic_consumer.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/sorting_consumer.h"
#include "toolchain/lex/lex.h"
#include "toolchain/lower/lower.h"
#include "toolchain/parse/parse.h"
+2 -2
View File
@@ -24,9 +24,9 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
#include "toolchain/base/clang_invocation.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/diagnostics/diagnostic.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/driver/clang_runner.h"
#include "toolchain/driver/driver_env.h"
#include "toolchain/driver/driver_subcommand.h"
+1 -1
View File
@@ -13,7 +13,7 @@
#include "llvm/Support/Threading.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/driver/runtimes_cache.h"
namespace Carbon {
+1 -1
View File
@@ -8,7 +8,7 @@
#include "common/raw_string_ostream.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/format/format.h"
#include "toolchain/lex/lex.h"
#include "toolchain/source/source_buffer.h"
@@ -4,7 +4,7 @@
#include "toolchain/driver/language_server_subcommand.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/language_server/language_server.h"
namespace Carbon {
+2 -2
View File
@@ -22,7 +22,7 @@ cc_library(
"//common:ostream",
"//common:raw_string_ostream",
"//toolchain/base:install_paths",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@llvm-project//clang-tools-extra/clangd:ClangDaemon",
],
)
@@ -39,7 +39,7 @@ cc_library(
"//toolchain/base:install_paths",
"//toolchain/base:shared_value_stores",
"//toolchain/check",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:file_diagnostics",
"//toolchain/lex",
"//toolchain/lex:tokenized_buffer",
+2 -2
View File
@@ -14,9 +14,9 @@
#include "toolchain/base/clang_invocation.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/check/check.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/diagnostics/diagnostic.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/lex.h"
#include "toolchain/lex/tokenized_buffer.h"
#include "toolchain/parse/parse.h"
+2 -2
View File
@@ -12,8 +12,8 @@
#include "common/map.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/file_diagnostics.h"
#include "toolchain/lex/tokenized_buffer.h"
#include "toolchain/parse/tree_and_subtrees.h"
@@ -10,7 +10,7 @@
#include "clang-tools-extra/clangd/Transport.h"
#include "clang-tools-extra/clangd/support/Logger.h"
#include "common/raw_string_ostream.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/language_server/context.h"
#include "toolchain/language_server/incoming_messages.h"
#include "toolchain/language_server/outgoing_messages.h"
+1 -1
View File
@@ -7,7 +7,7 @@
#include "common/ostream.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/consumer.h"
namespace Carbon::LanguageServer {
+13 -13
View File
@@ -47,7 +47,7 @@ cc_library(
srcs = ["helpers.cpp"],
hdrs = ["helpers.h"],
deps = [
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@llvm-project//llvm:Support",
],
)
@@ -59,7 +59,7 @@ cc_library(
deps = [
"//common:check",
"//common:string_helpers",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
@@ -73,7 +73,7 @@ cc_library(
":character_set",
":helpers",
"//common:check",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:format_providers",
"@llvm-project//llvm:Support",
],
@@ -102,7 +102,7 @@ cc_test(
"//common:check",
"//common:ostream",
"//testing/base:gtest_main",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
@@ -116,7 +116,7 @@ cc_fuzz_test(
deps = [
":numeric_literal",
"//testing/fuzzing:libfuzzer_header",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:null_diagnostics",
"@llvm-project//llvm:Support",
],
@@ -131,7 +131,7 @@ cc_library(
":helpers",
":token_info",
"//common:check",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@llvm-project//llvm:Support",
],
)
@@ -158,7 +158,7 @@ cc_test(
"//common:check",
"//common:ostream",
"//testing/base:gtest_main",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
@@ -173,7 +173,7 @@ cc_fuzz_test(
":string_literal",
"//common:check",
"//testing/fuzzing:libfuzzer_header",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:null_diagnostics",
"@llvm-project//llvm:Support",
],
@@ -197,7 +197,7 @@ cc_library(
"//common:vlog",
"//toolchain/base:kind_switch",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:format_providers",
"//toolchain/source:source_buffer",
"@llvm-project//llvm:Support",
@@ -256,7 +256,7 @@ cc_library(
"//toolchain/base:index_base",
"//toolchain/base:mem_usage",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/source:source_buffer",
"@llvm-project//llvm:Support",
],
@@ -288,7 +288,7 @@ cc_test(
"//common:raw_string_ostream",
"//testing/base:gtest_main",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:mocks",
"//toolchain/testing:compile_helper",
"//toolchain/testing:yaml_test_helpers",
@@ -307,7 +307,7 @@ cc_fuzz_test(
"//common:check",
"//testing/fuzzing:libfuzzer_header",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:null_diagnostics",
"@llvm-project//llvm:Support",
],
@@ -326,7 +326,7 @@ cc_binary(
"//testing/base:benchmark_main",
"//testing/base:source_gen_lib",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:null_diagnostics",
"@abseil-cpp//absl/random",
"@google_benchmark//:benchmark",
+1 -1
View File
@@ -5,7 +5,7 @@
#ifndef CARBON_TOOLCHAIN_LEX_HELPERS_H_
#define CARBON_TOOLCHAIN_LEX_HELPERS_H_
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon::Lex {
+1 -1
View File
@@ -6,7 +6,7 @@
#define CARBON_TOOLCHAIN_LEX_LEX_H_
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/tokenized_buffer.h"
#include "toolchain/source/source_buffer.h"
+1 -1
View File
@@ -10,7 +10,7 @@
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon::Lex {
+1 -1
View File
@@ -11,7 +11,7 @@
#include <string>
#include "common/check.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/test_helpers.h"
namespace Carbon::Lex {
+1 -1
View File
@@ -9,7 +9,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/token_info.h"
namespace Carbon::Lex {
+1 -1
View File
@@ -12,7 +12,7 @@
#include <utility>
#include "common/check.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/test_helpers.h"
namespace Carbon::Lex {
+1 -1
View File
@@ -11,7 +11,7 @@
#include "common/check.h"
#include "common/string_helpers.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon::Testing {
+1 -1
View File
@@ -16,7 +16,7 @@
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/character_set.h"
#include "toolchain/lex/numeric_literal.h"
#include "toolchain/lex/string_literal.h"
+1 -1
View File
@@ -17,7 +17,7 @@
#include "toolchain/base/index_base.h"
#include "toolchain/base/mem_usage.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/token_index.h"
#include "toolchain/lex/token_info.h"
#include "toolchain/lex/token_kind.h"
+1 -1
View File
@@ -16,7 +16,7 @@
#include "llvm/ADT/StringExtras.h"
#include "testing/base/source_gen.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/null_diagnostics.h"
#include "toolchain/lex/lex.h"
#include "toolchain/lex/token_kind.h"
+1 -1
View File
@@ -17,7 +17,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/FormatVariadic.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/mocks.h"
#include "toolchain/lex/lex.h"
#include "toolchain/lex/tokenized_buffer_test_helpers.h"
+5 -5
View File
@@ -59,7 +59,7 @@ cc_test(
":parse",
":tree",
"//testing/base:gtest_main",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:mocks",
"//toolchain/lex",
"//toolchain/lex:tokenized_buffer",
@@ -80,7 +80,7 @@ cc_library(
"//common:check",
"//common:ostream",
"//common:vlog",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:format_providers",
"//toolchain/lex:token_kind",
"//toolchain/lex:tokenized_buffer",
@@ -109,7 +109,7 @@ cc_library(
"//common:ostream",
"//common:pretty_stack_trace_function",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:format_providers",
"//toolchain/lex:token_index",
"//toolchain/lex:token_kind",
@@ -178,7 +178,7 @@ cc_test(
"//common:raw_string_ostream",
"//testing/base:gtest_main",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:mocks",
"//toolchain/lex",
"//toolchain/lex:tokenized_buffer",
@@ -199,7 +199,7 @@ cc_fuzz_test(
"//common:check",
"//testing/fuzzing:libfuzzer_header",
"//toolchain/base:shared_value_stores",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:null_diagnostics",
"//toolchain/lex",
"@llvm-project//llvm:Support",
+1 -1
View File
@@ -10,7 +10,7 @@
#include "common/check.h"
#include "common/ostream.h"
#include "llvm/ADT/STLExtras.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/format_providers.h"
#include "toolchain/lex/token_kind.h"
#include "toolchain/lex/tokenized_buffer.h"
+1 -1
View File
@@ -6,7 +6,7 @@
#define CARBON_TOOLCHAIN_PARSE_PARSE_H_
#include "common/ostream.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/lex/tokenized_buffer.h"
#include "toolchain/parse/tree.h"
+1 -1
View File
@@ -13,7 +13,7 @@
#include "common/raw_string_ostream.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/diagnostics/mocks.h"
#include "toolchain/lex/lex.h"
#include "toolchain/lex/tokenized_buffer.h"
+2 -2
View File
@@ -33,7 +33,7 @@ cc_library(
"//toolchain/base:index_base",
"//toolchain/base:int",
"//toolchain/base:value_ids",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/parse:node_kind",
"@llvm-project//llvm:Support",
],
@@ -272,7 +272,7 @@ cc_library(
":absolute_node_id",
":file",
":typed_insts",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/parse:tree",
"@llvm-project//clang:frontend",
"@llvm-project//llvm:Support",
+1 -1
View File
@@ -7,7 +7,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/parse/tree_and_subtrees.h"
#include "toolchain/sem_ir/absolute_node_id.h"
#include "toolchain/sem_ir/file.h"
+1 -1
View File
@@ -12,7 +12,7 @@
#include "llvm/ADT/APFloat.h"
#include "toolchain/base/index_base.h"
#include "toolchain/base/value_ids.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
#include "toolchain/parse/node_ids.h"
namespace Carbon::SemIR {
+2 -2
View File
@@ -12,7 +12,7 @@ cc_library(
hdrs = ["source_buffer.h"],
deps = [
"//common:error",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/diagnostics:file_diagnostics",
"//toolchain/diagnostics:format_providers",
"@llvm-project//llvm:Support",
@@ -27,7 +27,7 @@ cc_test(
":source_buffer",
"//common:check",
"//testing/base:gtest_main",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
+1 -1
View File
@@ -11,7 +11,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon {
+1 -1
View File
@@ -8,7 +8,7 @@
#include "common/check.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/emitter.h"
namespace Carbon {
namespace {
+1 -1
View File
@@ -33,7 +33,7 @@ cc_library(
srcs = ["compile_helper.cpp"],
hdrs = ["compile_helper.h"],
deps = [
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:emitter",
"//toolchain/lex",
"//toolchain/parse",
"//toolchain/parse:tree",
+1 -1
View File
@@ -8,7 +8,7 @@
#include <forward_list>
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/consumer.h"
#include "toolchain/lex/lex.h"
#include "toolchain/parse/parse.h"
#include "toolchain/parse/tree_and_subtrees.h"