summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/external.cxx
diff options
context:
space:
mode:
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);
}