/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ #ifndef LO_CLANG_SHARED_PLUGINS
#include <set> #include <stack>
#include"check.hxx" #include"plugin.hxx"
// Find non-const vars of 'char const *' type initialized with a const expr, // that could likely be const (and will then probably trigger further // loplugin:stringconstant findings).
namespace {
class ConstStringVar: public loplugin::FilteringPlugin<ConstStringVar>
{ public: explicit ConstStringVar(loplugin::InstantiationData const & data):
FilteringPlugin(data) {}
bool preRun() override { return compiler.getLangOpts().CPlusPlus; // clang::Expr::isCXX11ConstantExpr only works for C++
}
void postRun() override { for (auto v: vars_) {
report(
DiagnosticsEngine::Warning, "variable is only used as rvalue, should be const",
v->getLocation())
<< v->getSourceRange();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.