[PATCH] D32170: Add a FixItHint for -Wmissing-prototypes to insert 'static '.
Daniel Jasper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 18 14:49:59 PDT 2017
djasper added inline comments.
================
Comment at: lib/Sema/SemaDecl.cpp:11652
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
- const FunctionDecl*& PossibleZeroParamPrototype) {
+ const FunctionDecl*& PossibleZeroParamPrototype,
+ bool *PossibleMissingStatic) {
----------------
Fix the format while here?
================
Comment at: lib/Sema/SemaDecl.cpp:11653
+ const FunctionDecl*& PossibleZeroParamPrototype,
+ bool *PossibleMissingStatic) {
// Don't warn about invalid declarations.
----------------
Maybe s/Possible/Possibly/ ?
================
Comment at: lib/Sema/SemaDecl.cpp:11708
+ FD->getDeclContext()->isTranslationUnit() &&
+ FD->getStorageClass() == SC_None;
+
----------------
Does this exclude templated functions? If not, the "static" might be put into the wrong place.
================
Comment at: lib/Sema/SemaDecl.cpp:12114
+ auto DiagBuilder =
+ Diag(FD->getLocation(), diag::warn_missing_prototype_maybe_static)
+ << FD;
----------------
I wonder whether it is useful to display the changed message here. In the cases I have seen where the function definition is coming from a macro, you'd actually need to surround it with an unnamed namespace to fix. Maybe just add this logic to the outer if statement?
https://reviews.llvm.org/D32170
More information about the cfe-commits
mailing list