2 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of the LibreOffice project.
8 * This file is distributed under the University of Illinois Open Source
9 * License. See LICENSE.TXT for details.
12 #ifndef LO_CLANG_SHARED_PLUGINS
19 #include <unordered_set>
24 Check for places where we end up with more than one copy of cppu::OweakObject in a class, which
25 really should not happen - we should be using one of the AggImplInheritanceHelper classes then
31 class WeakObject
: public loplugin::FilteringPlugin
<WeakObject
>
34 explicit WeakObject(loplugin::InstantiationData
const& data
)
35 : FilteringPlugin(data
)
39 virtual bool preRun() override
44 virtual void run() override
47 TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl());
50 bool VisitCXXRecordDecl( const CXXRecordDecl
* decl
);
54 bool WeakObject::VisitCXXRecordDecl(const CXXRecordDecl
* decl
)
56 if (ignoreLocation(decl
))
58 if (!decl
->hasDefinition())
60 if (decl
->hasAnyDependentBases())
64 [&cnt
] (const CXXRecordDecl
*BaseDefinition
) -> bool
66 if (loplugin::DeclCheck(BaseDefinition
).Class("OWeakObject").Namespace("cppu").GlobalNamespace())
73 report(DiagnosticsEngine::Warning
, "more than one copy of cppu::OWeakObject inherited",
75 << decl
->getSourceRange();
79 loplugin::Plugin::Registration
<WeakObject
> weakobject("weakobject", false);
83 #endif // LO_CLANG_SHARED_PLUGINS
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */