summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/external.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-11-15 16:16:21 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-11-15 23:29:41 +0100
commitd04eef858250f97690f32dba17f42d157a8767fc (patch)
tree82dccfc772158b25e38a356fd0292a5e63e98e76 /compilerplugins/clang/external.cxx
parent1a137ef35d67a4aff7b2a6f1d3aa3c944c7a0b41 (diff)
loplugin:external: Don't warn for injected friend functions
Change-Id: I35c0930f6ab8ae5d96e433958cf29791c78d5e31 Reviewed-on: https://gerrit.libreoffice.org/82802 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/external.cxx')
-rw-r--r--compilerplugins/clang/external.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/compilerplugins/clang/external.cxx b/compilerplugins/clang/external.cxx
index 3248df5db078..2b6b689ea315 100644
--- a/compilerplugins/clang/external.cxx
+++ b/compilerplugins/clang/external.cxx
@@ -32,6 +32,19 @@ bool derivesFromTestFixture(CXXRecordDecl const* decl)
|| std::any_of(decl->vbases_begin(), decl->vbases_end(), pred);
}
+bool isInjectedFunction(FunctionDecl const* decl)
+{
+ for (auto d = decl->redecls_begin(); d != decl->redecls_end(); ++d)
+ {
+ auto const c = d->getLexicalDeclContext();
+ if (!(c->isFunctionOrMethod() || c->isRecord()))
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
class External : public loplugin::FilteringPlugin<External>
{
public:
@@ -146,6 +159,10 @@ public:
// #pragma GCC diagnostic ignored "-Wunused-function"
return true;
}
+ if (isInjectedFunction(decl))
+ {
+ return true;
+ }
return handleDeclaration(decl);
}
@@ -195,6 +212,10 @@ public:
{
return true;
}
+ if (isInjectedFunction(decl->getTemplatedDecl()))
+ {
+ return true;
+ }
return handleDeclaration(decl);
}