[PATCH] D121328: Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"""

Dean Sturtevant via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 06:31:37 PDT 2022


deansturtevant added a comment.

Note that some fix is important to make if we think that the -Wmissing-prototypes warning is valuable, because there are cases where it currently would fire where the function cannot explicitly be given internal linkage, e.g.
namespace {
struct Initialized {};
}  // namespace
void* operator new(size_t size, const Initialized&) {

  void* p = malloc(size);
  memset(p, 0, size);
  return p;

}
operator new is only allowed to be defined in the global namespace.
Currently this will cause the warning to be emitted, even though there is no way to declare it outside the TU.

jyknight clarified that what he was proposing was that instead of calling FD->isExternallyVisible() as currently written, call a function which does the same thing except that it doesn't check whether the struct has a visible name (because that can be assumed here).
This function *could* be isExternallyVisible with a new boolean argument (WDYT?)
Another approach would be to move the call to ShouldWarnAboutMissingPrototypes() to a different point in the process, where calling isExternallyVisible() is *not* problematic. WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121328/new/

https://reviews.llvm.org/D121328



More information about the cfe-commits mailing list