1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 class DllPrivate final
:
15 public loplugin::FilteringPlugin
<DllPrivate
>
18 explicit DllPrivate(loplugin::InstantiationData
const & data
): FilteringPlugin(data
)
21 bool VisitNamedDecl(NamedDecl
const * decl
) {
22 if (!decl
->getLocation().isInvalid()&&ignoreLocation(decl
)) {
25 auto a
= decl
->getAttr
<VisibilityAttr
>();
26 if (a
== nullptr || a
->getVisibility() != VisibilityAttr::Hidden
) {
29 if (compiler
.getSourceManager().isMacroBodyExpansion(
31 && (Lexer::getImmediateMacroName(
32 decl
->getLocation(), compiler
.getSourceManager(),
33 compiler
.getLangOpts())
34 == "Q_OBJECT")) // from /usr/include/QtCore/qobjectdefs.h
38 auto p
= dyn_cast
<RecordDecl
>(decl
->getDeclContext());
41 DiagnosticsEngine::Warning
,
42 "top-level declaration redundantly marked as DLLPRIVATE",
44 << decl
->getSourceRange();
45 } else if (p
->getVisibility() == HiddenVisibility
) {
47 DiagnosticsEngine::Warning
,
48 ("declaration nested in DLLPRIVATE declaration redundantly"
49 " marked as DLLPRIVATE"),
51 << decl
->getSourceRange();
53 DiagnosticsEngine::Note
, "parent declaration is here",
55 << p
->getSourceRange();
62 // DISABLE_DYNLOADING makes SAL_DLLPUBLIC_{EXPORT,IMPORT,TEMPLATE} expand
63 // to visibility("hidden") attributes, which would cause bogus warnings
64 // here (e.g., in UBSan builds that explicitly define DISABLE_DYNLOADING
65 // in jurt/source/pipe/staticsalhack.cxx); alternatively, change
66 // include/sal/types.h to make those SAL_DLLPUBLIC_* expand to nothing
67 // for DISABLE_DYNLOADING:
68 if (!compiler
.getPreprocessor().getIdentifierInfo("DISABLE_DYNLOADING")
69 ->hasMacroDefinition())
71 TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl());
76 static loplugin::Plugin::Registration
<DllPrivate
> reg("dllprivate");
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */