1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #ifndef LO_CLANG_SHARED_PLUGINS
17 #include "config_clang.h"
21 class ConstexprLiteral final
: public loplugin::FilteringPlugin
<ConstexprLiteral
>
24 explicit ConstexprLiteral(loplugin::InstantiationData
const& data
)
25 : FilteringPlugin(data
)
29 bool VisitVarDecl(const VarDecl
* varDecl
)
31 if (ignoreLocation(varDecl
))
33 if (varDecl
->isConstexpr())
35 if (!loplugin::TypeCheck(varDecl
->getType())
36 .Class("OUStringLiteral")
40 report(DiagnosticsEngine::Warning
, "OUStringLiteral should be declared constexpr",
41 varDecl
->getBeginLoc())
42 << varDecl
->getSourceRange();
46 bool preRun() override
48 if (!compiler
.getLangOpts().CPlusPlus
)
58 TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl());
63 loplugin::Plugin::Registration
<ConstexprLiteral
> constexprliteral("constexprliteral");
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */