[PATCH] D29877: Warn about unused static file scope function template declarations.
Richard Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 10 14:19:13 PDT 2017
rsmith added inline comments.
================
Comment at: lib/Sema/Sema.cpp:473
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ // If this is a function template and neither of its specs is used, warn.
+ if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
----------------
neither -> none, specs -> specializations ("specs" makes me think "specifications").
================
Comment at: lib/Sema/Sema.cpp:503
+ if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
+ // If this is a variable template and neither of its specs is used, warn.
+ for (const auto *Spec : Template->specializations())
----------------
As above.
================
Comment at: lib/Sema/SemaDecl.cpp:1496
return false;
+ // 'static operator' functions are defined in headers; don't warn.
+ if (FD->isOverloadedOperator() &&
----------------
v.g.vassilev wrote:
> rsmith wrote:
> > Why? Defining a static operator in a header sounds like a bug to me.
> It seems we have some of these here:
>
> include/llvm/ADT/PointerUnion.h:static bool operator==(PointerUnion<PT1, PT2> lhs, PointerUnion<PT1, PT2> rhs) {
> include/llvm/ADT/PointerUnion.h:static bool operator!=(PointerUnion<PT1, PT2> lhs, PointerUnion<PT1, PT2> rhs) {
> include/llvm/ADT/PointerUnion.h:static bool operator<(PointerUnion<PT1, PT2> lhs, PointerUnion<PT1, PT2> rhs) {
> include/llvm/Transforms/Utils/ValueMapper.h:static inline RemapFlags operator|(RemapFlags LHS, RemapFlags RHS) {
>
> If that's a bug, I will remove this check.
Yes, those are bugs.
https://reviews.llvm.org/D29877
More information about the cfe-commits
mailing list