Issue 94138
Summary Clang's `-Wmissing-prototypes` isn't helpful for explicitly `extern "C"` function definitions.
Labels clang
Assignees
Reporter chandlerc
    I really like `-Wmissing-prototypes` for a lot of stuff, but it is firing on one pattern where it seems pretty unhelpful:

```
toolchain/parse/parse_fuzzer.cpp:18:16: error: no previous prototype for function 'LLVMFuzzerTestOneInput' [-Werror,-Wmissing-prototypes]
   18 | extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
      | ^
toolchain/parse/parse_fuzzer.cpp:18:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   18 | extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
 |            ^
      |            static
```

The code in question is following LibFuzzer's documented guidance to define the fuzzer entry point:

```cpp
extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
                                      std::size_t size) {
```

The warning is technically correct that this definition has no prior prototype. However, by making it `extern "C"` there is a very clear signal that this is a known C ABI external entry point that we need to define, but may not have a header to declare for us. And suggesting to add `static` when the function is declared explicitly `extern "C"` seems pretty confusing.

Ideally I'd like to just disable this warning for `extern "C"` functions as it seems unlikely to be correct. If folks are specifically interested in retaining that, I'd love a flag to control that narrow behavior.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to