// 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 und die Messung sind noch experimentell.