Kaydet (Commit) cfd080d0 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:staticconstfield improve warning message

Change-Id: I000dff6b1b6e33e1b2c5aa337c027c1edd7b1003
Reviewed-on: https://gerrit.libreoffice.org/68795Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7e2a4f53
......@@ -15,6 +15,9 @@
#include <unordered_set>
#include <vector>
/**
Look for fields which are const, which can be made static const
*/
namespace
{
class StaticConstField : public loplugin::FilteringPlugin<StaticConstField>
......@@ -56,7 +59,7 @@ void StaticConstField::run()
for (auto const& pair : m_potentials)
{
report(DiagnosticsEngine::Error, "field can be static const", pair.first->getLocation())
report(DiagnosticsEngine::Error, "const field can be static", pair.first->getLocation())
<< pair.first->getSourceRange();
for (CXXCtorInitializer const* init : pair.second.inits)
if (pair.first->getLocation() != init->getSourceLocation())
......
......@@ -15,7 +15,7 @@
class Class1
{
OUString const
m_field1; // expected-error {{field can be static const [loplugin:staticconstfield]}}
m_field1; // expected-error {{const field can be static [loplugin:staticconstfield]}}
Class1()
: m_field1("xxxx")
// expected-note@-1 {{init here [loplugin:staticconstfield]}}
......@@ -27,7 +27,7 @@ class Class1
class Class2
{
OString const
m_field2; // expected-error {{field can be static const [loplugin:staticconstfield]}}
m_field2; // expected-error {{const field can be static [loplugin:staticconstfield]}}
Class2()
: m_field2("yyyy")
// expected-note@-1 {{init here [loplugin:staticconstfield]}}
......@@ -54,12 +54,12 @@ class Class5
ONE
};
float const
m_fielda1; // expected-error {{field can be static const [loplugin:staticconstfield]}}
int const m_fielda2; // expected-error {{field can be static const [loplugin:staticconstfield]}}
m_fielda1; // expected-error {{const field can be static [loplugin:staticconstfield]}}
int const m_fielda2; // expected-error {{const field can be static [loplugin:staticconstfield]}}
bool const
m_fielda3; // expected-error {{field can be static const [loplugin:staticconstfield]}}
m_fielda3; // expected-error {{const field can be static [loplugin:staticconstfield]}}
Enum const
m_fielda4; // expected-error {{field can be static const [loplugin:staticconstfield]}}
m_fielda4; // expected-error {{const field can be static [loplugin:staticconstfield]}}
Class5()
: m_fielda1(1.0)
// expected-note@-1 {{init here [loplugin:staticconstfield]}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment