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:
Chandler Carruth
2024-06-04 20:04:45 +00:00
committed by GitHub
parent d9c62b106d
commit 8c64f0bfdd
90 changed files with 181 additions and 23 deletions
+5 -4
View File
@@ -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,