[en_US] Added 13 autocorrect words
[LibreOffice.git] / compilerplugins / clang / inlinevisible.cxx
blobeb3e249f5835ae9c44d7050c68c55b4df523039d
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 */
9 #ifndef LO_CLANG_SHARED_PLUGINS
11 #include <cassert>
12 #include <string>
14 #include "clang/AST/Attr.h"
15 #include "clang/Sema/SemaInternal.h" // warn_unused_function
17 #include "plugin.hxx"
19 namespace {
21 class InlineVisible:
22 public loplugin::FilteringPlugin<InlineVisible>
24 public:
25 explicit InlineVisible(loplugin::InstantiationData const & data):
26 FilteringPlugin(data) {}
28 void run() override
29 { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
31 bool VisitFunctionDecl(FunctionDecl const * decl);
34 bool InlineVisible::VisitFunctionDecl(FunctionDecl const * decl) {
35 if (!ignoreLocation(decl) && decl->isInlineSpecified()) {
36 VisibilityAttr * attr = decl->getAttr<VisibilityAttr>();
37 if (attr != nullptr && attr->getVisibility() == VisibilityAttr::Default)
39 report(
40 DiagnosticsEngine::Warning,
41 ("Function explicitly declared both inline and "
42 " visibility=default"),
43 decl->getLocation())
44 << decl->getSourceRange();
47 return true;
50 loplugin::Plugin::Registration<InlineVisible> inlinevisible("inlinevisible");
54 #endif // LO_CLANG_SHARED_PLUGINS
56 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */