Files
carbon-lang/explorer/fuzzing/BUILD
T
Chandler Carruth 8c64f0bfdd 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
2024-06-04 20:04:45 +00:00

129 lines
3.7 KiB
Python

# 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
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
cc_library(
name = "ast_to_proto_lib",
testonly = 1,
srcs = ["ast_to_proto.cpp"],
hdrs = ["ast_to_proto.h"],
# Running clang-tidy is slow, and explorer is currently feature frozen, so
# don't spend time linting it.
tags = ["no-clang-tidy"],
deps = [
"//explorer/ast",
"//testing/fuzzing:carbon_cc_proto",
"@llvm-project//llvm:Support",
],
)
cc_binary(
name = "ast_to_proto",
testonly = 1,
srcs = ["ast_to_proto_main.cpp"],
# Running clang-tidy is slow, and explorer is currently feature frozen, so
# don't spend time linting it.
tags = ["no-clang-tidy"],
deps = [
":ast_to_proto_lib",
"//common:bazel_working_dir",
"//common:error",
"//explorer/ast",
"//explorer/base:arena",
"//explorer/syntax",
"//testing/fuzzing:carbon_cc_proto",
"@protobuf//:protobuf_headers",
],
)
cc_test(
name = "ast_to_proto_test",
size = "small",
srcs = ["ast_to_proto_test.cpp"],
args = [
"$(locations //explorer:standard_libraries)",
"$(locations //explorer:carbon_files)",
],
data = [
"//explorer:carbon_files",
"//explorer:standard_libraries",
],
# Running clang-tidy is slow, and explorer is currently feature frozen, so
# don't spend time linting it.
tags = ["no-clang-tidy"],
deps = [
":ast_to_proto_lib",
"//explorer/syntax",
"//testing/base:test_raw_ostream",
"//testing/fuzzing:carbon_cc_proto",
"//testing/fuzzing:proto_to_carbon_lib",
"@googletest//:gtest",
"@protobuf//:protobuf_headers",
],
)
cc_library(
name = "fuzzer_util",
testonly = 1,
srcs = ["fuzzer_util.cpp"],
hdrs = ["fuzzer_util.h"],
# Running clang-tidy is slow, and explorer is currently feature frozen, so
# don't spend time linting it.
tags = ["no-clang-tidy"],
deps = [
"//common:check",
"//common:error",
"//explorer/ast",
"//explorer/parse_and_execute",
"//testing/fuzzing:carbon_cc_proto",
"//testing/fuzzing:proto_to_carbon_lib",
"@bazel_tools//tools/cpp/runfiles",
"@llvm-project//llvm:Support",
"@protobuf//:protobuf_headers",
],
)
cc_test(
name = "fuzzer_util_test",
size = "small",
srcs = ["fuzzer_util_test.cpp"],
data = [
"//explorer:standard_libraries",
],
# Running clang-tidy is slow, and explorer is currently feature frozen, so
# don't spend time linting it.
tags = ["no-clang-tidy"],
deps = [
":fuzzer_util",
"//testing/base:gtest_main",
"//testing/fuzzing:proto_to_carbon_lib",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
"@protobuf//:protobuf_headers",
],
)
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 = [
"no-clang-tidy",
"proto-fuzzer",
],
deps = [
":fuzzer_util",
"//common:error",
"@com_google_libprotobuf_mutator//:libprotobuf_mutator",
"@llvm-project//llvm:Support",
],
)