[PATCH] D29877: Warn about unused static file scope function template declarations.
Vassil Vassilev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 5 15:27:54 PDT 2017
v.g.vassilev added inline comments.
================
Comment at: lib/Sema/SemaDecl.cpp:1496
return false;
+ // 'static operator' functions are defined in headers; don't warn.
+ if (FD->isOverloadedOperator() &&
----------------
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.
================
Comment at: lib/Sema/SemaDecl.cpp:6679
NewTemplate->setInvalidDecl();
+ MarkUnusedFileScopedDecl(NewVD);
ActOnDocumentableDecl(NewTemplate);
----------------
@rsmith, this forces the linkage to be computed and for some invalid code such as:
```
namespace { struct Internal {}; }
template<typename T> __declspec(dllimport) auto InternalAutoTypeVarTmpl = Internal();
```
we hit an assertion in (Sema::DeduceVariableDeclarationType, SemaDecl.cpp:9991) `assert(VDecl->isLinkageValid())` which assumes that the linkage wasn't computed. Should we relax/remove the assert there?
https://reviews.llvm.org/D29877
More information about the cfe-commits
mailing list