summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-12-06 08:59:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-12-07 11:25:55 +0100
commitdd0dceb51122b4e8e969f848d9f046e91962d254 (patch)
treef927f0870a54ad7cb887e6e7d5bb7956d44d0665 /compilerplugins
parentcaf1eb15838729e05a70d2fcb8de6834394b5764 (diff)
loplugin:salcall handle static methods
Change-Id: Id6820abec4b8ca8bee26d62b333fd30b42a14aec Reviewed-on: https://gerrit.libreoffice.org/46007 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/salcall.cxx23
1 files changed, 22 insertions, 1 deletions
diff --git a/compilerplugins/clang/salcall.cxx b/compilerplugins/clang/salcall.cxx
index b36bc5cc1db0..36a8635d4f7f 100644
--- a/compilerplugins/clang/salcall.cxx
+++ b/compilerplugins/clang/salcall.cxx
@@ -42,6 +42,9 @@ public:
// ignore this one. I can't get accurate source code from getCharacterData() for it.
if (fn == SRCDIR "/sal/rtl/string.cxx")
return;
+ // clang returns completely bogus source range for something in this file
+ if (fn == SRCDIR "/sd/source/ui/unoidl/unomodel.cxx")
+ return;
m_phase = PluginPhase::FindAddressOf;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
m_phase = PluginPhase::Warning;
@@ -206,7 +209,7 @@ bool SalCall::VisitFunctionDecl(FunctionDecl const* decl)
// @TODO For now, I am ignore free functions, since those are most likely to have their address taken.
// I'll do them later. They are harder to verify since MSVC does not verify when assigning to function pointers
// that the calling convention of the function matches the calling convention of the function pointer!
- if (!methodDecl || methodDecl->isStatic())
+ if (!methodDecl)
return true;
// can only check when we have a definition since this is the most likely time
@@ -268,6 +271,7 @@ bool SalCall::VisitFunctionDecl(FunctionDecl const* decl)
return true;
}
+ // if any of the overridden methods are SAL_CALL, we should be too
if (methodDecl)
{
for (auto iter = methodDecl->begin_overridden_methods();
@@ -279,6 +283,23 @@ bool SalCall::VisitFunctionDecl(FunctionDecl const* decl)
}
}
+ // these often have their address taken
+ if (methodDecl && methodDecl->getIdentifier())
+ {
+ auto name = methodDecl->getName();
+ if (name == "getImplementationName_static" || name == "getSupportedServiceNames_static"
+ || name == "getSupportedServiceNames_Static" || name == "Create" || name == "create"
+ || name == "CreateInstance" || name == "getImplementationName_Static"
+ || name == "getSingletonName_static" || name == "getLdapUserProfileBeName"
+ || name == "getLdapUserProfileBeServiceNames" || name == "impl_staticCreateSelfInstance"
+ || name == "impl_createInstance" || name == "impl_staticGetImplementationName"
+ || name == "impl_staticGetSupportedServiceNames"
+ || name == "impl_getStaticSupportedServiceNames"
+ || name == "impl_getStaticImplementationName" || name == "getBackendName"
+ || name == "getBackendServiceNames")
+ return true;
+ }
+
bool bOK = rewrite(rewriteLoc);
if (bOK && canonicalDecl != decl)
{