diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-12-05 09:51:05 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-12-05 14:40:14 +0100 |
commit | c9a6d4bee737c3c39fc61d265dba0460b09c906f (patch) | |
tree | c276e6d446372e69449ffc53b42e46cc5fcc6c0b /compilerplugins/clang | |
parent | 55eddbecb34f811d5292fe4dc5c568cf5fff2ad4 (diff) |
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 <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/external.cxx | 31 |
1 files changed, 15 insertions, 16 deletions
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; } |