mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:40:10 +01:00
Add -Wmissing-prototypes and fix issues it finds. (#4019)
Most of these are places where we failed to include a header file and simply never got an error about this. The fix is to include the header file. Most other cases are functions that should have been marked `static` but were not. Finding all of these was a main motivation for me enabling the warning despite how much work it is. One complicating factor was that we weren't including the `handle.h` for all the state-based handler functions. While this isn't a tiny amount of code, it is just declarations and doesn't add any extra dependencies. It also lets us have the checking for which functions need to be `static` and which don't. For the `parse` library I had to add the `handle.h` header as well, I tried to match the design of it in `check`. I have also had to work around a bug in the warning, but given the value it seems to be providing, that seems reasonable. I've filed the bug upstream: https://github.com/llvm/llvm-project/issues/94138 I also had to use some hacks to work around limitations of Bazel rules that wrap `cc_library` rules and don't expose `copts`. I filed a bug for `cc_proto_library` specifically: ~https://github.com/bazelbuild/bazel/issues/22610~ https://github.com/bazelbuild/bazel/issues/4446
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<char*>(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -1042,7 +1042,7 @@ auto TypeEqual(Nonnull<const Value*> t1, Nonnull<const Value*> 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<const Value*> v1, Nonnull<const Value*> v2,
|
||||
std::optional<Nonnull<const EqualityContext*>> equality_ctx) -> bool {
|
||||
if (v1 == v2) {
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace Carbon::Testing {
|
||||
|
||||
auto Main(int argc, char** argv) -> ErrorOr<Success> {
|
||||
static auto Main(int argc, char** argv) -> ErrorOr<Success> {
|
||||
SetWorkingDirForBazel();
|
||||
|
||||
if (argc != 2) {
|
||||
|
||||
@@ -170,8 +170,9 @@ static auto ResolveControlFlow(Nonnull<TraceStream*> trace_stream,
|
||||
}
|
||||
}
|
||||
|
||||
auto ResolveControlFlow(Nonnull<TraceStream*> trace_stream,
|
||||
Nonnull<Declaration*> declaration) -> ErrorOr<Success> {
|
||||
static auto ResolveControlFlow(Nonnull<TraceStream*> trace_stream,
|
||||
Nonnull<Declaration*> declaration)
|
||||
-> ErrorOr<Success> {
|
||||
switch (declaration->kind()) {
|
||||
case DeclarationKind::DestructorDeclaration:
|
||||
case DeclarationKind::FunctionDeclaration: {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 <cstddef>
|
||||
|
||||
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_
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
auto Main(int argc, char** argv) -> ErrorOr<Success> {
|
||||
static auto Main(int argc, char** argv) -> ErrorOr<Success> {
|
||||
Carbon::SetWorkingDirForBazel();
|
||||
|
||||
if (argc != 2) {
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<SemIR::IntLiteral>(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<SemIR::IntLiteral>(result.bit_width_id);
|
||||
if (!bit_width) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/handle.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/handle.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/handle.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/handle.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/handle.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "testing/fuzzing/libfuzzer.h"
|
||||
#include "toolchain/diagnostics/null_diagnostics.h"
|
||||
#include "toolchain/lex/numeric_literal.h"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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_
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/lex/token_kind.h"
|
||||
#include "toolchain/parse/context.h"
|
||||
#include "toolchain/parse/handle.h"
|
||||
|
||||
namespace Carbon::Parse {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/lex/token_kind.h"
|
||||
#include "toolchain/parse/context.h"
|
||||
#include "toolchain/parse/handle.h"
|
||||
|
||||
namespace Carbon::Parse {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#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"
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user