bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / inlinevisible.cxx
blob8e232a33783712ef70ceed9b099f0aacfbdb53f0
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 <cassert>
13 #include <string>
15 #include "clang/AST/Attr.h"
16 #include "clang/Sema/SemaInternal.h" // warn_unused_function
18 #include "plugin.hxx"
20 namespace {
22 class InlineVisible:
23 public loplugin::FilteringPlugin<InlineVisible>
25 public:
26 explicit InlineVisible(loplugin::InstantiationData const & data):
27 FilteringPlugin(data) {}
29 void run() override
30 { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
32 bool VisitFunctionDecl(FunctionDecl const * decl);
35 bool InlineVisible::VisitFunctionDecl(FunctionDecl const * decl) {
36 if (!ignoreLocation(decl) && decl->isInlineSpecified()) {
37 VisibilityAttr * attr = decl->getAttr<VisibilityAttr>();
38 if (attr != nullptr && attr->getVisibility() == VisibilityAttr::Default)
40 report(
41 DiagnosticsEngine::Warning,
42 ("Function explicitly declared both inline and "
43 " visibility=default"),
44 decl->getLocation())
45 << decl->getSourceRange();
48 return true;
51 loplugin::Plugin::Registration<InlineVisible> inlinevisible("inlinevisible");
55 #endif // LO_CLANG_SHARED_PLUGINS
57 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */