diff --git a/.bazelrc b/.bazelrc index 6d6c7453b338..44cb9ec2dcb4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -28,6 +28,21 @@ build --experimental_guard_against_concurrent_changes build --per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w build --host_per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w +# The `rules_treesitter` synthesized libraries don't allow us to inject flags, +# and compile generated code where we can't fix warnings. +build --per_file_copt=utils/treesitter/_treesitter.tree_sitter/.*\.c$@-w +build --host_per_file_copt=utils/treesitter/_treesitter.tree_sitter/.*\.c$@-w + +# The `cc_proto_library` rule doesn't allow providing `copts`: +# https://github.com/bazelbuild/bazel/issues/22610 +# +# We unfortunately need to work around issues with `-Wmissing-prototypes` in +# generated protobuf code, so pass the `copt` manually here. The warning issue +# is likely part of: +# https://github.com/llvm/llvm-project/issues/94138 +build --per_file_copt=.*\.pb\.cc$@-Wno-missing-prototypes +build --host_per_file_copt=.*\.pb\.cc$@-Wno-missing-prototypes + # Default dynamic linking to off. While this can help build performance in some # edge cases with very large linked executables and a slow linker, between using # fast linkers on all platforms (LLD and the Apple linker), as well as having diff --git a/bazel/cc_toolchains/clang_cc_toolchain_config.bzl b/bazel/cc_toolchains/clang_cc_toolchain_config.bzl index e971a24d6f63..215d4fb31066 100644 --- a/bazel/cc_toolchains/clang_cc_toolchain_config.bzl +++ b/bazel/cc_toolchains/clang_cc_toolchain_config.bzl @@ -142,6 +142,7 @@ def _impl(ctx): "-Wimplicit-fallthrough", "-Wctad-maybe-unsupported", "-Wextra-semi", + "-Wmissing-prototypes", "-Wzero-as-null-pointer-constant", # Don't warn on external code as we can't # necessarily patch it easily. Note that these have diff --git a/common/check_internal.cpp b/common/check_internal.cpp index 68e5e4544e24..b8b95248c5a2 100644 --- a/common/check_internal.cpp +++ b/common/check_internal.cpp @@ -10,7 +10,7 @@ namespace Carbon::Internal { // Prints the buffered message. -auto PrintAfterStackTrace(void* str) -> void { +static auto PrintAfterStackTrace(void* str) -> void { llvm::errs() << reinterpret_cast(str); } diff --git a/explorer/ast/value.cpp b/explorer/ast/value.cpp index d8a81f0606d4..bbd87ab7c1dc 100644 --- a/explorer/ast/value.cpp +++ b/explorer/ast/value.cpp @@ -1042,7 +1042,7 @@ auto TypeEqual(Nonnull t1, Nonnull t2, // Returns true if the two values are known to be equal and are written in the // same way at the top level. -auto ValueStructurallyEqual( +static auto ValueStructurallyEqual( Nonnull v1, Nonnull v2, std::optional> equality_ctx) -> bool { if (v1 == v2) { diff --git a/explorer/fuzzing/BUILD b/explorer/fuzzing/BUILD index ef189daa7eed..7e8fa46ecb51 100644 --- a/explorer/fuzzing/BUILD +++ b/explorer/fuzzing/BUILD @@ -110,6 +110,9 @@ cc_fuzz_test( name = "explorer_fuzzer", size = "small", srcs = ["explorer_fuzzer.cpp"], + # Uses a macro-based fuzzing library that triggers this warning. And + # explorer is currently feature frozen, so just disable the warning. + copts = ["-Wno-missing-prototypes"], corpus = glob(["fuzzer_corpus/*"]), shard_count = 8, tags = [ diff --git a/explorer/fuzzing/ast_to_proto_main.cpp b/explorer/fuzzing/ast_to_proto_main.cpp index 7a62fb5139a8..1c3e090fc172 100644 --- a/explorer/fuzzing/ast_to_proto_main.cpp +++ b/explorer/fuzzing/ast_to_proto_main.cpp @@ -21,7 +21,7 @@ namespace Carbon::Testing { -auto Main(int argc, char** argv) -> ErrorOr { +static auto Main(int argc, char** argv) -> ErrorOr { SetWorkingDirForBazel(); if (argc != 2) { diff --git a/explorer/interpreter/resolve_control_flow.cpp b/explorer/interpreter/resolve_control_flow.cpp index acfcd522f4e4..99072aa845de 100644 --- a/explorer/interpreter/resolve_control_flow.cpp +++ b/explorer/interpreter/resolve_control_flow.cpp @@ -170,8 +170,9 @@ static auto ResolveControlFlow(Nonnull trace_stream, } } -auto ResolveControlFlow(Nonnull trace_stream, - Nonnull declaration) -> ErrorOr { +static auto ResolveControlFlow(Nonnull trace_stream, + Nonnull declaration) + -> ErrorOr { switch (declaration->kind()) { case DeclarationKind::DestructorDeclaration: case DeclarationKind::FunctionDeclaration: { diff --git a/testing/fuzzing/BUILD b/testing/fuzzing/BUILD index c81cf812a208..b8f44e832aef 100644 --- a/testing/fuzzing/BUILD +++ b/testing/fuzzing/BUILD @@ -18,6 +18,14 @@ cc_proto_library( deps = [":carbon_proto"], ) +# Header for LibFuzzer, does not provide the implementation which should come +# from some other source such as a fuzz test target. +cc_library( + name = "libfuzzer_header", + testonly = 1, + hdrs = ["libfuzzer.h"], +) + cc_library( name = "proto_to_carbon_lib", testonly = 1, diff --git a/testing/fuzzing/libfuzzer.h b/testing/fuzzing/libfuzzer.h new file mode 100644 index 000000000000..f58b24db852e --- /dev/null +++ b/testing/fuzzing/libfuzzer.h @@ -0,0 +1,22 @@ +// 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 + +#ifndef CARBON_TESTING_FUZZING_LIBFUZZER_H_ +#define CARBON_TESTING_FUZZING_LIBFUZZER_H_ + +#include + +namespace Carbon::Testing { + +// Declaration for the LLVM libfuzzer API that we implement in our fuzz tests. +// This is useful to ensure we get the API correct and avoid warnings about +// defining an undeclared extern function due to a Clang warning bug: +// https://github.com/llvm/llvm-project/issues/94138 +// NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style. +extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, + std::size_t size); + +} // namespace Carbon::Testing + +#endif // CARBON_TESTING_FUZZING_LIBFUZZER_H_ diff --git a/testing/fuzzing/proto_to_carbon_main.cpp b/testing/fuzzing/proto_to_carbon_main.cpp index 0483ad7269bd..a8af59c928cd 100644 --- a/testing/fuzzing/proto_to_carbon_main.cpp +++ b/testing/fuzzing/proto_to_carbon_main.cpp @@ -17,7 +17,7 @@ namespace Carbon { -auto Main(int argc, char** argv) -> ErrorOr { +static auto Main(int argc, char** argv) -> ErrorOr { Carbon::SetWorkingDirForBazel(); if (argc != 2) { diff --git a/toolchain/check/BUILD b/toolchain/check/BUILD index 92f03d41c523..faff4877731a 100644 --- a/toolchain/check/BUILD +++ b/toolchain/check/BUILD @@ -152,6 +152,7 @@ cc_fuzz_test( srcs = ["check_fuzzer.cpp"], corpus = glob(["fuzzer_corpus/*"]), deps = [ + "//testing/fuzzing:libfuzzer_header", "//toolchain/driver", "@llvm-project//llvm:Support", ], diff --git a/toolchain/check/check_fuzzer.cpp b/toolchain/check/check_fuzzer.cpp index e7113865fa8a..33b98a83ce5d 100644 --- a/toolchain/check/check_fuzzer.cpp +++ b/toolchain/check/check_fuzzer.cpp @@ -5,6 +5,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/VirtualFileSystem.h" +#include "testing/fuzzing/libfuzzer.h" #include "toolchain/driver/driver.h" namespace Carbon::Testing { diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 85d0d6e8dd83..1d71c98f030b 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -317,8 +317,8 @@ static auto PerformAggregateIndex(Context& context, SemIR::Inst inst) } // Enforces that an integer type has a valid bit width. -auto ValidateIntType(Context& context, SemIRLoc loc, SemIR::IntType result) - -> bool { +static auto ValidateIntType(Context& context, SemIRLoc loc, + SemIR::IntType result) -> bool { auto bit_width = context.insts().TryGetAs(result.bit_width_id); if (!bit_width) { @@ -381,8 +381,8 @@ static auto ValidateFloatBitWidth(Context& context, SemIRLoc loc, } // Enforces that a float type has a valid bit width. -auto ValidateFloatType(Context& context, SemIRLoc loc, SemIR::FloatType result) - -> bool { +static auto ValidateFloatType(Context& context, SemIRLoc loc, + SemIR::FloatType result) -> bool { auto bit_width = context.insts().TryGetAs(result.bit_width_id); if (!bit_width) { diff --git a/toolchain/check/handle_alias.cpp b/toolchain/check/handle_alias.cpp index 0325886e8a38..66cb7642898c 100644 --- a/toolchain/check/handle_alias.cpp +++ b/toolchain/check/handle_alias.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" #include "toolchain/check/modifiers.h" #include "toolchain/check/name_component.h" #include "toolchain/parse/node_ids.h" diff --git a/toolchain/check/handle_array.cpp b/toolchain/check/handle_array.cpp index 8b0e907b8d3e..629f3f88f012 100644 --- a/toolchain/check/handle_array.cpp +++ b/toolchain/check/handle_array.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" #include "toolchain/parse/node_kind.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_binding_pattern.cpp b/toolchain/check/handle_binding_pattern.cpp index 618fdcaf8f91..70b2ea13798e 100644 --- a/toolchain/check/handle_binding_pattern.cpp +++ b/toolchain/check/handle_binding_pattern.cpp @@ -4,14 +4,15 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" #include "toolchain/check/return.h" #include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/inst.h" namespace Carbon::Check { -auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, - bool is_generic) -> bool { +static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, + bool is_generic) -> bool { auto [type_node, parsed_type_id] = context.node_stack().PopExprWithNodeId(); auto cast_type_id = ExprAsType(context, type_node, parsed_type_id); diff --git a/toolchain/check/handle_call_expr.cpp b/toolchain/check/handle_call_expr.cpp index 913a06522e53..1408dc40e5ff 100644 --- a/toolchain/check/handle_call_expr.cpp +++ b/toolchain/check/handle_call_expr.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/call.h" #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" #include "toolchain/sem_ir/inst.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_choice.cpp b/toolchain/check/handle_choice.cpp index c51e0988c4e3..0e607da1b159 100644 --- a/toolchain/check/handle_choice.cpp +++ b/toolchain/check/handle_choice.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_class.cpp b/toolchain/check/handle_class.cpp index cc5965843ffb..ffe481438f8a 100644 --- a/toolchain/check/handle_class.cpp +++ b/toolchain/check/handle_class.cpp @@ -7,6 +7,7 @@ #include "toolchain/check/convert.h" #include "toolchain/check/decl_name_stack.h" #include "toolchain/check/eval.h" +#include "toolchain/check/handle.h" #include "toolchain/check/merge.h" #include "toolchain/check/modifiers.h" #include "toolchain/check/name_component.h" diff --git a/toolchain/check/handle_codeblock.cpp b/toolchain/check/handle_codeblock.cpp index 52da182b2f0c..bd74235cf8c5 100644 --- a/toolchain/check/handle_codeblock.cpp +++ b/toolchain/check/handle_codeblock.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_export.cpp b/toolchain/check/handle_export.cpp index 5724a0ddced4..fff79f45f29c 100644 --- a/toolchain/check/handle_export.cpp +++ b/toolchain/check/handle_export.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/decl_name_stack.h" +#include "toolchain/check/handle.h" #include "toolchain/check/modifiers.h" #include "toolchain/check/name_component.h" #include "toolchain/parse/typed_nodes.h" diff --git a/toolchain/check/handle_expr_statement.cpp b/toolchain/check/handle_expr_statement.cpp index 37443ee053c7..7e0e0e0ee2ad 100644 --- a/toolchain/check/handle_expr_statement.cpp +++ b/toolchain/check/handle_expr_statement.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" #include "toolchain/sem_ir/inst.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_file.cpp b/toolchain/check/handle_file.cpp index 836af05e4f24..e8677067f571 100644 --- a/toolchain/check/handle_file.cpp +++ b/toolchain/check/handle_file.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_function.cpp b/toolchain/check/handle_function.cpp index 59b3cf608d7e..02144ca85d1f 100644 --- a/toolchain/check/handle_function.cpp +++ b/toolchain/check/handle_function.cpp @@ -8,6 +8,7 @@ #include "toolchain/check/decl_name_stack.h" #include "toolchain/check/decl_state.h" #include "toolchain/check/function.h" +#include "toolchain/check/handle.h" #include "toolchain/check/interface.h" #include "toolchain/check/merge.h" #include "toolchain/check/modifiers.h" @@ -378,10 +379,10 @@ auto HandleFunctionDefinitionSuspend(Context& context, auto HandleFunctionDefinitionResume(Context& context, Parse::FunctionDefinitionStartId node_id, - SuspendedFunction sus_fn) -> void { - context.decl_name_stack().Restore(sus_fn.saved_name_state); - HandleFunctionDefinitionAfterSignature(context, node_id, sus_fn.function_id, - sus_fn.decl_id); + SuspendedFunction suspended_fn) -> void { + context.decl_name_stack().Restore(suspended_fn.saved_name_state); + HandleFunctionDefinitionAfterSignature( + context, node_id, suspended_fn.function_id, suspended_fn.decl_id); } auto HandleFunctionDefinitionStart(Context& context, diff --git a/toolchain/check/handle_if_expr.cpp b/toolchain/check/handle_if_expr.cpp index 1d9177bd2b6c..fa762b346f99 100644 --- a/toolchain/check/handle_if_expr.cpp +++ b/toolchain/check/handle_if_expr.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_if_statement.cpp b/toolchain/check/handle_if_statement.cpp index d611e5e75ccd..bcc7a008aadb 100644 --- a/toolchain/check/handle_if_statement.cpp +++ b/toolchain/check/handle_if_statement.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_impl.cpp b/toolchain/check/handle_impl.cpp index 251a6d8553dd..4cc02b251a8d 100644 --- a/toolchain/check/handle_impl.cpp +++ b/toolchain/check/handle_impl.cpp @@ -5,6 +5,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" #include "toolchain/check/decl_name_stack.h" +#include "toolchain/check/handle.h" #include "toolchain/check/impl.h" #include "toolchain/check/modifiers.h" #include "toolchain/parse/typed_nodes.h" diff --git a/toolchain/check/handle_import_and_package.cpp b/toolchain/check/handle_import_and_package.cpp index ecbb171a73a6..883c71a4cf74 100644 --- a/toolchain/check/handle_import_and_package.cpp +++ b/toolchain/check/handle_import_and_package.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/decl_state.h" +#include "toolchain/check/handle.h" #include "toolchain/check/modifiers.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_index.cpp b/toolchain/check/handle_index.cpp index 0daa60cb0c56..a9e3ea0bdb1a 100644 --- a/toolchain/check/handle_index.cpp +++ b/toolchain/check/handle_index.cpp @@ -5,6 +5,7 @@ #include "toolchain/base/kind_switch.h" #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" #include "toolchain/sem_ir/inst.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_interface.cpp b/toolchain/check/handle_interface.cpp index 3b37cb7a6eb8..139976c81180 100644 --- a/toolchain/check/handle_interface.cpp +++ b/toolchain/check/handle_interface.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" #include "toolchain/check/interface.h" #include "toolchain/check/modifiers.h" #include "toolchain/check/name_component.h" diff --git a/toolchain/check/handle_let.cpp b/toolchain/check/handle_let.cpp index 65ed717ca6fc..491ac968ac0d 100644 --- a/toolchain/check/handle_let.cpp +++ b/toolchain/check/handle_let.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" #include "toolchain/check/interface.h" #include "toolchain/check/modifiers.h" #include "toolchain/diagnostics/diagnostic_emitter.h" diff --git a/toolchain/check/handle_literal.cpp b/toolchain/check/handle_literal.cpp index 2dd1d2a493d4..9eebc1a47c85 100644 --- a/toolchain/check/handle_literal.cpp +++ b/toolchain/check/handle_literal.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/call.h" #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" #include "toolchain/sem_ir/typed_insts.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_loop_statement.cpp b/toolchain/check/handle_loop_statement.cpp index 36574e77bf98..57de7dd004a6 100644 --- a/toolchain/check/handle_loop_statement.cpp +++ b/toolchain/check/handle_loop_statement.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_match.cpp b/toolchain/check/handle_match.cpp index df3d554af31c..5ed24c6b030a 100644 --- a/toolchain/check/handle_match.cpp +++ b/toolchain/check/handle_match.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_modifier.cpp b/toolchain/check/handle_modifier.cpp index ca256fbae73e..9a0558d9ce35 100644 --- a/toolchain/check/handle_modifier.cpp +++ b/toolchain/check/handle_modifier.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/decl_state.h" +#include "toolchain/check/handle.h" #include "toolchain/lex/token_kind.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_name.cpp b/toolchain/check/handle_name.cpp index 3335de86c6d9..e1e35632401c 100644 --- a/toolchain/check/handle_name.cpp +++ b/toolchain/check/handle_name.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" #include "toolchain/check/member_access.h" #include "toolchain/check/name_component.h" #include "toolchain/check/pointer_dereference.h" diff --git a/toolchain/check/handle_named_constraint.cpp b/toolchain/check/handle_named_constraint.cpp index de2a6e683aa4..0d6e9bced634 100644 --- a/toolchain/check/handle_named_constraint.cpp +++ b/toolchain/check/handle_named_constraint.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_namespace.cpp b/toolchain/check/handle_namespace.cpp index 4992052f16b8..53fef7ff4b84 100644 --- a/toolchain/check/handle_namespace.cpp +++ b/toolchain/check/handle_namespace.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/decl_state.h" +#include "toolchain/check/handle.h" #include "toolchain/check/modifiers.h" #include "toolchain/check/name_component.h" #include "toolchain/sem_ir/ids.h" diff --git a/toolchain/check/handle_noop.cpp b/toolchain/check/handle_noop.cpp index 5e79243e56e4..2b1910464405 100644 --- a/toolchain/check/handle_noop.cpp +++ b/toolchain/check/handle_noop.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_operator.cpp b/toolchain/check/handle_operator.cpp index 1a65a3e8a315..f4cac0dfba8a 100644 --- a/toolchain/check/handle_operator.cpp +++ b/toolchain/check/handle_operator.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" #include "toolchain/check/operator.h" #include "toolchain/check/pointer_dereference.h" #include "toolchain/diagnostics/diagnostic_emitter.h" diff --git a/toolchain/check/handle_paren_expr.cpp b/toolchain/check/handle_paren_expr.cpp index 9137e3ea30af..4e4769a1f763 100644 --- a/toolchain/check/handle_paren_expr.cpp +++ b/toolchain/check/handle_paren_expr.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_pattern_list.cpp b/toolchain/check/handle_pattern_list.cpp index 7146c9cb5540..de7da5110c1f 100644 --- a/toolchain/check/handle_pattern_list.cpp +++ b/toolchain/check/handle_pattern_list.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_return_statement.cpp b/toolchain/check/handle_return_statement.cpp index 58f24b4c3577..7845158a7aad 100644 --- a/toolchain/check/handle_return_statement.cpp +++ b/toolchain/check/handle_return_statement.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" #include "toolchain/check/return.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_struct.cpp b/toolchain/check/handle_struct.cpp index cd28630e7167..41554c76b94e 100644 --- a/toolchain/check/handle_struct.cpp +++ b/toolchain/check/handle_struct.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_tuple_literal.cpp b/toolchain/check/handle_tuple_literal.cpp index 3082aa2811ac..e580868d5b8f 100644 --- a/toolchain/check/handle_tuple_literal.cpp +++ b/toolchain/check/handle_tuple_literal.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/handle.h" namespace Carbon::Check { diff --git a/toolchain/check/handle_variable.cpp b/toolchain/check/handle_variable.cpp index 06eee71c61aa..c132008c3e91 100644 --- a/toolchain/check/handle_variable.cpp +++ b/toolchain/check/handle_variable.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/handle.h" #include "toolchain/check/modifiers.h" namespace Carbon::Check { diff --git a/toolchain/check/member_access.cpp b/toolchain/check/member_access.cpp index 8aa3e77f11d2..6a140f236e14 100644 --- a/toolchain/check/member_access.cpp +++ b/toolchain/check/member_access.cpp @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "toolchain/check/member_access.h" + #include "llvm/ADT/STLExtras.h" #include "toolchain/base/kind_switch.h" #include "toolchain/check/context.h" diff --git a/toolchain/check/pointer_dereference.cpp b/toolchain/check/pointer_dereference.cpp index 1087094f3fb6..f1abf5370fa8 100644 --- a/toolchain/check/pointer_dereference.cpp +++ b/toolchain/check/pointer_dereference.cpp @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "toolchain/check/pointer_dereference.h" + #include "llvm/ADT/STLFunctionalExtras.h" #include "toolchain/check/context.h" #include "toolchain/check/convert.h" diff --git a/toolchain/check/return.cpp b/toolchain/check/return.cpp index 4145c45cf87e..b3a456292145 100644 --- a/toolchain/check/return.cpp +++ b/toolchain/check/return.cpp @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "toolchain/check/return.h" + #include "toolchain/check/context.h" #include "toolchain/check/convert.h" diff --git a/toolchain/driver/BUILD b/toolchain/driver/BUILD index 7e1a9a90d7eb..d7db992bf0a2 100644 --- a/toolchain/driver/BUILD +++ b/toolchain/driver/BUILD @@ -110,6 +110,7 @@ cc_fuzz_test( deps = [ ":driver", "//testing/base:test_raw_ostream", + "//testing/fuzzing:libfuzzer_header", "//toolchain/install:install_paths", "@llvm-project//llvm:Support", ], diff --git a/toolchain/driver/driver_fuzzer.cpp b/toolchain/driver/driver_fuzzer.cpp index 4d8cad1ae345..6be6ec2008d6 100644 --- a/toolchain/driver/driver_fuzzer.cpp +++ b/toolchain/driver/driver_fuzzer.cpp @@ -9,6 +9,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" #include "testing/base/test_raw_ostream.h" +#include "testing/fuzzing/libfuzzer.h" #include "toolchain/driver/driver.h" #include "toolchain/install/install_paths.h" diff --git a/toolchain/lex/BUILD b/toolchain/lex/BUILD index 7480e652d024..3b144b8b5f35 100644 --- a/toolchain/lex/BUILD +++ b/toolchain/lex/BUILD @@ -115,6 +115,7 @@ cc_fuzz_test( corpus = glob(["fuzzer_corpus/numeric_literal/*"]), deps = [ ":numeric_literal", + "//testing/fuzzing:libfuzzer_header", "//toolchain/diagnostics:diagnostic_emitter", "//toolchain/diagnostics:null_diagnostics", "@llvm-project//llvm:Support", @@ -170,6 +171,7 @@ cc_fuzz_test( deps = [ ":string_literal", "//common:check", + "//testing/fuzzing:libfuzzer_header", "//toolchain/diagnostics:diagnostic_emitter", "//toolchain/diagnostics:null_diagnostics", "@llvm-project//llvm:Support", @@ -269,6 +271,7 @@ cc_fuzz_test( deps = [ ":lex", "//common:check", + "//testing/fuzzing:libfuzzer_header", "//toolchain/base:value_store", "//toolchain/diagnostics:diagnostic_emitter", "//toolchain/diagnostics:null_diagnostics", diff --git a/toolchain/lex/numeric_literal_fuzzer.cpp b/toolchain/lex/numeric_literal_fuzzer.cpp index 28804ed571a7..371dfe25abf7 100644 --- a/toolchain/lex/numeric_literal_fuzzer.cpp +++ b/toolchain/lex/numeric_literal_fuzzer.cpp @@ -5,6 +5,7 @@ #include #include "llvm/ADT/StringRef.h" +#include "testing/fuzzing/libfuzzer.h" #include "toolchain/diagnostics/null_diagnostics.h" #include "toolchain/lex/numeric_literal.h" diff --git a/toolchain/lex/string_literal_fuzzer.cpp b/toolchain/lex/string_literal_fuzzer.cpp index 8c0d141d09bc..c38ec1d6de16 100644 --- a/toolchain/lex/string_literal_fuzzer.cpp +++ b/toolchain/lex/string_literal_fuzzer.cpp @@ -6,6 +6,7 @@ #include "common/check.h" #include "llvm/ADT/StringRef.h" +#include "testing/fuzzing/libfuzzer.h" #include "toolchain/diagnostics/null_diagnostics.h" #include "toolchain/lex/string_literal.h" diff --git a/toolchain/lex/tokenized_buffer_fuzzer.cpp b/toolchain/lex/tokenized_buffer_fuzzer.cpp index 99cbf8659e39..56fa689a91a1 100644 --- a/toolchain/lex/tokenized_buffer_fuzzer.cpp +++ b/toolchain/lex/tokenized_buffer_fuzzer.cpp @@ -6,6 +6,7 @@ #include "common/check.h" #include "llvm/ADT/StringRef.h" +#include "testing/fuzzing/libfuzzer.h" #include "toolchain/base/value_store.h" #include "toolchain/diagnostics/null_diagnostics.h" #include "toolchain/lex/lex.h" diff --git a/toolchain/lower/constant.cpp b/toolchain/lower/constant.cpp index cf134a611b98..c70496431c18 100644 --- a/toolchain/lower/constant.cpp +++ b/toolchain/lower/constant.cpp @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "toolchain/lower/constant.h" + #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/Constants.h" diff --git a/toolchain/lower/handle_aggregates.cpp b/toolchain/lower/handle_aggregates.cpp index 6577ccdcdb0b..d56f40b108ec 100644 --- a/toolchain/lower/handle_aggregates.cpp +++ b/toolchain/lower/handle_aggregates.cpp @@ -167,8 +167,9 @@ auto HandleStructLiteral(FunctionContext& /*context*/, // Emits the value representation for a struct or tuple whose elements are the // contents of `refs_id`. -auto EmitAggregateValueRepr(FunctionContext& context, SemIR::TypeId type_id, - SemIR::InstBlockId refs_id) -> llvm::Value* { +static auto EmitAggregateValueRepr(FunctionContext& context, + SemIR::TypeId type_id, + SemIR::InstBlockId refs_id) -> llvm::Value* { auto value_rep = SemIR::GetValueRepr(context.sem_ir(), type_id); switch (value_rep.kind) { case SemIR::ValueRepr::Unknown: diff --git a/toolchain/parse/BUILD b/toolchain/parse/BUILD index c3d45e2156d7..93cbddadccfb 100644 --- a/toolchain/parse/BUILD +++ b/toolchain/parse/BUILD @@ -75,7 +75,10 @@ cc_library( glob([ "handle_*.cpp", ]), - hdrs = ["parse.h"], + hdrs = [ + "handle.h", + "parse.h", + ], deps = [ ":context", ":node_kind", @@ -147,6 +150,7 @@ cc_fuzz_test( deps = [ ":parse", "//common:check", + "//testing/fuzzing:libfuzzer_header", "//toolchain/base:value_store", "//toolchain/diagnostics:diagnostic_emitter", "//toolchain/diagnostics:null_diagnostics", diff --git a/toolchain/parse/handle.h b/toolchain/parse/handle.h new file mode 100644 index 000000000000..c42782b2f955 --- /dev/null +++ b/toolchain/parse/handle.h @@ -0,0 +1,18 @@ +// 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 + +#ifndef CARBON_TOOLCHAIN_PARSE_HANDLE_H_ +#define CARBON_TOOLCHAIN_PARSE_HANDLE_H_ + +#include "toolchain/parse/context.h" + +namespace Carbon::Parse { + +// Declare handlers for each parse state. +#define CARBON_PARSE_STATE(Name) auto Handle##Name(Context& context) -> void; +#include "toolchain/parse/state.def" + +} // namespace Carbon::Parse + +#endif // CARBON_TOOLCHAIN_PARSE_HANDLE_H_ diff --git a/toolchain/parse/handle_adapt.cpp b/toolchain/parse/handle_adapt.cpp index 0db847728ec4..2f88be9cfd72 100644 --- a/toolchain/parse/handle_adapt.cpp +++ b/toolchain/parse/handle_adapt.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_alias.cpp b/toolchain/parse/handle_alias.cpp index 8d0c5557ccc6..e92279431fca 100644 --- a/toolchain/parse/handle_alias.cpp +++ b/toolchain/parse/handle_alias.cpp @@ -5,6 +5,7 @@ #include "toolchain/lex/token_kind.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" #include "toolchain/parse/node_kind.h" #include "toolchain/parse/state.h" diff --git a/toolchain/parse/handle_array_expr.cpp b/toolchain/parse/handle_array_expr.cpp index 50fc4ebee261..5111003ebff1 100644 --- a/toolchain/parse/handle_array_expr.cpp +++ b/toolchain/parse/handle_array_expr.cpp @@ -5,6 +5,7 @@ #include "toolchain/lex/token_kind.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" #include "toolchain/parse/node_kind.h" #include "toolchain/parse/state.h" diff --git a/toolchain/parse/handle_base.cpp b/toolchain/parse/handle_base.cpp index 095a9cd0fe50..c66198656b65 100644 --- a/toolchain/parse/handle_base.cpp +++ b/toolchain/parse/handle_base.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_binding_pattern.cpp b/toolchain/parse/handle_binding_pattern.cpp index bb6a608e5f63..2a8e6bdfaf9b 100644 --- a/toolchain/parse/handle_binding_pattern.cpp +++ b/toolchain/parse/handle_binding_pattern.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_brace_expr.cpp b/toolchain/parse/handle_brace_expr.cpp index f24290486f36..fb8ef801706c 100644 --- a/toolchain/parse/handle_brace_expr.cpp +++ b/toolchain/parse/handle_brace_expr.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_call_expr.cpp b/toolchain/parse/handle_call_expr.cpp index 62bae20a0977..c480ff27ca37 100644 --- a/toolchain/parse/handle_call_expr.cpp +++ b/toolchain/parse/handle_call_expr.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_choice.cpp b/toolchain/parse/handle_choice.cpp index abd365c482a4..a8a646055b70 100644 --- a/toolchain/parse/handle_choice.cpp +++ b/toolchain/parse/handle_choice.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { auto HandleChoiceIntroducer(Context& context) -> void { diff --git a/toolchain/parse/handle_code_block.cpp b/toolchain/parse/handle_code_block.cpp index e679028368cd..2772ead4f2ab 100644 --- a/toolchain/parse/handle_code_block.cpp +++ b/toolchain/parse/handle_code_block.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_decl_definition.cpp b/toolchain/parse/handle_decl_definition.cpp index 4d33f978e4a0..822a9703a94e 100644 --- a/toolchain/parse/handle_decl_definition.cpp +++ b/toolchain/parse/handle_decl_definition.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_decl_name_and_params.cpp b/toolchain/parse/handle_decl_name_and_params.cpp index 4c3e5214a86c..0706ee93970f 100644 --- a/toolchain/parse/handle_decl_name_and_params.cpp +++ b/toolchain/parse/handle_decl_name_and_params.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_decl_scope_loop.cpp b/toolchain/parse/handle_decl_scope_loop.cpp index 9fb20a148e92..45d899bfc069 100644 --- a/toolchain/parse/handle_decl_scope_loop.cpp +++ b/toolchain/parse/handle_decl_scope_loop.cpp @@ -4,6 +4,7 @@ #include "toolchain/lex/token_kind.h" #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" #include "toolchain/parse/node_kind.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_expr.cpp b/toolchain/parse/handle_expr.cpp index 28bb235e6048..890f0b303916 100644 --- a/toolchain/parse/handle_expr.cpp +++ b/toolchain/parse/handle_expr.cpp @@ -4,6 +4,7 @@ #include "toolchain/lex/token_kind.h" #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_function.cpp b/toolchain/parse/handle_function.cpp index c52d67431dbe..14fe977b7fd8 100644 --- a/toolchain/parse/handle_function.cpp +++ b/toolchain/parse/handle_function.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_impl.cpp b/toolchain/parse/handle_impl.cpp index e348111d8de6..e186e0a60c52 100644 --- a/toolchain/parse/handle_impl.cpp +++ b/toolchain/parse/handle_impl.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_import_and_package.cpp b/toolchain/parse/handle_import_and_package.cpp index e0921e419f0f..4ccba7b1ad7c 100644 --- a/toolchain/parse/handle_import_and_package.cpp +++ b/toolchain/parse/handle_import_and_package.cpp @@ -6,6 +6,7 @@ #include "toolchain/lex/token_kind.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" #include "toolchain/parse/node_ids.h" #include "toolchain/parse/node_kind.h" diff --git a/toolchain/parse/handle_index_expr.cpp b/toolchain/parse/handle_index_expr.cpp index c6ca25a7c633..6a03633fabb7 100644 --- a/toolchain/parse/handle_index_expr.cpp +++ b/toolchain/parse/handle_index_expr.cpp @@ -4,6 +4,7 @@ #include "toolchain/lex/token_kind.h" #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_let.cpp b/toolchain/parse/handle_let.cpp index 7a71a18024f2..5a529bec6d74 100644 --- a/toolchain/parse/handle_let.cpp +++ b/toolchain/parse/handle_let.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_match.cpp b/toolchain/parse/handle_match.cpp index 0136df85a4ed..05d93f6d90d0 100644 --- a/toolchain/parse/handle_match.cpp +++ b/toolchain/parse/handle_match.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_namespace.cpp b/toolchain/parse/handle_namespace.cpp index 14bfb7e475e1..b69f74f1432e 100644 --- a/toolchain/parse/handle_namespace.cpp +++ b/toolchain/parse/handle_namespace.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_paren_condition.cpp b/toolchain/parse/handle_paren_condition.cpp index c75805f0e05d..dba288becc90 100644 --- a/toolchain/parse/handle_paren_condition.cpp +++ b/toolchain/parse/handle_paren_condition.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_paren_expr.cpp b/toolchain/parse/handle_paren_expr.cpp index 7a495c465102..b09b8eae48d8 100644 --- a/toolchain/parse/handle_paren_expr.cpp +++ b/toolchain/parse/handle_paren_expr.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_pattern.cpp b/toolchain/parse/handle_pattern.cpp index f0b89c8a602c..55a785d76d05 100644 --- a/toolchain/parse/handle_pattern.cpp +++ b/toolchain/parse/handle_pattern.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_pattern_list.cpp b/toolchain/parse/handle_pattern_list.cpp index a63cf01c03c7..20cf25a23dc8 100644 --- a/toolchain/parse/handle_pattern_list.cpp +++ b/toolchain/parse/handle_pattern_list.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_period.cpp b/toolchain/parse/handle_period.cpp index 420a61ae4cc9..0c5890e6573c 100644 --- a/toolchain/parse/handle_period.cpp +++ b/toolchain/parse/handle_period.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_statement.cpp b/toolchain/parse/handle_statement.cpp index 0d0f60693152..7b8da294241d 100644 --- a/toolchain/parse/handle_statement.cpp +++ b/toolchain/parse/handle_statement.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_type.cpp b/toolchain/parse/handle_type.cpp index cf5db348e8e0..0c41daa335ca 100644 --- a/toolchain/parse/handle_type.cpp +++ b/toolchain/parse/handle_type.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/handle_var.cpp b/toolchain/parse/handle_var.cpp index a98f43915249..90712cff0d3b 100644 --- a/toolchain/parse/handle_var.cpp +++ b/toolchain/parse/handle_var.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" namespace Carbon::Parse { diff --git a/toolchain/parse/parse.cpp b/toolchain/parse/parse.cpp index a9f437063f33..8a1a546de785 100644 --- a/toolchain/parse/parse.cpp +++ b/toolchain/parse/parse.cpp @@ -2,17 +2,16 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "toolchain/parse/parse.h" + #include "common/check.h" #include "toolchain/base/pretty_stack_trace_function.h" #include "toolchain/parse/context.h" +#include "toolchain/parse/handle.h" #include "toolchain/parse/node_kind.h" namespace Carbon::Parse { -// Declare handlers for each parse state. -#define CARBON_PARSE_STATE(Name) auto Handle##Name(Context& context) -> void; -#include "toolchain/parse/state.def" - auto HandleInvalid(Context& context) -> void { CARBON_FATAL() << "The Invalid state shouldn't be on the stack: " << context.PopState(); diff --git a/toolchain/parse/parse_fuzzer.cpp b/toolchain/parse/parse_fuzzer.cpp index 9b473a7fcc58..27c513d94314 100644 --- a/toolchain/parse/parse_fuzzer.cpp +++ b/toolchain/parse/parse_fuzzer.cpp @@ -6,6 +6,7 @@ #include #include "llvm/ADT/StringRef.h" +#include "testing/fuzzing/libfuzzer.h" #include "toolchain/base/value_store.h" #include "toolchain/diagnostics/null_diagnostics.h" #include "toolchain/lex/lex.h" diff --git a/utils/treesitter/src/scanner.c b/utils/treesitter/src/scanner.c index 65fd3a26bb52..77d3b03552e4 100644 --- a/utils/treesitter/src/scanner.c +++ b/utils/treesitter/src/scanner.c @@ -10,6 +10,12 @@ enum TokenType { STRING, }; +// This is part of a special rule that doesn't allow `copts` in Bazel, so we +// disable warnings using `#pragma`s here. +#pragma clang diagnostic push +// The tree_sitter build uses C functions without prototypes. +#pragma clang diagnostic ignored "-Wmissing-prototypes" + // our scanner is stateless void* tree_sitter_carbon_external_scanner_create(void) { return NULL; }