compilerplugins/clang/external.cxx | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
New commits: commit c9a6d4bee737c3c39fc61d265dba0460b09c906f Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Dec 5 09:51:05 2019 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Dec 5 14:40:14 2019 +0100 loplugin:external: Check for DLLExportAttr also in VisitTagDecl ...to fix false clang-cl warnings like > C:/lo-clang/core/cppuhelper/source/compat.cxx(113,29): error: externally available entity 'ClassData' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external] > struct SAL_DLLPUBLIC_EXPORT ClassData { > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ Change-Id: Iacf96569e27772aa9e27221619516b1fb84dd665 Reviewed-on: https://gerrit.libreoffice.org/84514 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/external.cxx b/compilerplugins/clang/external.cxx index b31f620cf5ef..6ec2cfdb1c8d 100644 --- a/compilerplugins/clang/external.cxx +++ b/compilerplugins/clang/external.cxx @@ -121,6 +121,15 @@ bool mentions(QualType type1, QualType type2) return false; } +bool hasSalDllpublicExportAttr(Decl const* decl) +{ + if (auto const attr = decl->getAttr<VisibilityAttr>()) + { + return attr->getVisibility() == VisibilityAttr::Default; + } + return decl->hasAttr<DLLExportAttr>(); +} + class External : public loplugin::FilteringPlugin<External> { public: @@ -155,15 +164,12 @@ public: { return true; } - if (auto const attr = d->getAttr<VisibilityAttr>()) + if (hasSalDllpublicExportAttr(d)) { - if (attr->getVisibility() == VisibilityAttr::Default) - { - // If the class definition has explicit default visibility, then assume that it - // needs to be present (e.g., a backwards-compatibility stub like in - // cppuhelper/source/compat.cxx): - return true; - } + // If the class definition has explicit default visibility, then assume that it + // needs to be present (e.g., a backwards-compatibility stub like in + // cppuhelper/source/compat.cxx): + return true; } if (derivesFromTestFixture(d)) { @@ -202,14 +208,7 @@ public: // If the function definition is explicit marked SAL_DLLPUBLIC_EXPORT or similar, then // assume that it needs to be present (e.g., only called via dlopen, or a backwards- // compatibility stub like in sal/osl/all/compat.cxx): - if (auto const attr = decl->getAttr<VisibilityAttr>()) - { - if (attr->getVisibility() == VisibilityAttr::Default) - { - return true; - } - } - else if (decl->hasAttr<DLLExportAttr>()) + if (hasSalDllpublicExportAttr(decl)) { return true; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits