bump product version to 5.0.4.1
[LibreOffice.git] / compilerplugins / clang / inlinevisible.cxx
bloba16187307b7d7caf7632b3f752f858ffd46659dd
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 #include <cassert>
11 #include <string>
13 #include "clang/AST/Attr.h"
14 #include "clang/Sema/SemaInternal.h" // warn_unused_function
16 #include "compat.hxx"
17 #include "plugin.hxx"
19 namespace {
21 class InlineVisible:
22 public RecursiveASTVisitor<InlineVisible>, public loplugin::Plugin
24 public:
25 explicit InlineVisible(InstantiationData const & data): Plugin(data) {}
27 void run() override
28 { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
30 bool VisitFunctionDecl(FunctionDecl const * decl);
33 bool InlineVisible::VisitFunctionDecl(FunctionDecl const * decl) {
34 if (!ignoreLocation(decl) && decl->isInlineSpecified()) {
35 VisibilityAttr * attr = decl->getAttr<VisibilityAttr>();
36 if (attr != nullptr && attr->getVisibility() == VisibilityAttr::Default)
38 report(
39 DiagnosticsEngine::Warning,
40 ("Function explicitly declared both inline and "
41 " visibility=default"),
42 decl->getLocation())
43 << decl->getSourceRange();
46 return true;
49 loplugin::Plugin::Registration<InlineVisible> X("inlinevisible");
53 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */