bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / privatebase.cxx
blob6819647f88c559674aa0883245ce2a89207fc0fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #ifndef LO_CLANG_SHARED_PLUGINS
12 #include "plugin.hxx"
14 namespace {
16 class PrivateBase:
17 public loplugin::FilteringPlugin<PrivateBase>
19 public:
20 explicit PrivateBase(loplugin::InstantiationData const & data): FilteringPlugin(data)
23 void run() override;
25 bool VisitCXXRecordDecl(CXXRecordDecl const * decl);
28 void PrivateBase::run() {
29 if (compiler.getLangOpts().CPlusPlus) {
30 TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
34 bool PrivateBase::VisitCXXRecordDecl(CXXRecordDecl const * decl) {
35 if (ignoreLocation(decl) || !decl->isThisDeclarationADefinition()
36 || decl->getTagKind() != TTK_Class)
38 return true;
40 for (auto i = decl->bases_begin(); i != decl->bases_end(); ++i) {
41 if (i->getAccessSpecifierAsWritten() == AS_none) {
42 report(
43 DiagnosticsEngine::Warning,
44 "base class is private by default; explicitly give an access"
45 " specifier",
46 compat::getBeginLoc(i))
47 << i->getSourceRange();
50 return true;
53 loplugin::Plugin::Registration<PrivateBase> privatebase("privatebase");
57 #endif // LO_CLANG_SHARED_PLUGINS
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */