[Libreoffice-commits] core.git: compilerplugins/clang
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Mar 6 10:06:50 UTC 2019
compilerplugins/clang/staticconstfield.cxx | 5 ++++-
compilerplugins/clang/test/staticconstfield.cxx | 12 ++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
New commits:
commit cfd080d00af43c4650c7ed1e9bf68626edcac944
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Mar 6 10:49:36 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Mar 6 11:06:22 2019 +0100
loplugin:staticconstfield improve warning message
Change-Id: I000dff6b1b6e33e1b2c5aa337c027c1edd7b1003
Reviewed-on: https://gerrit.libreoffice.org/68795
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/compilerplugins/clang/staticconstfield.cxx b/compilerplugins/clang/staticconstfield.cxx
index 5a9e7adf52ef..91a798daa5bd 100644
--- a/compilerplugins/clang/staticconstfield.cxx
+++ b/compilerplugins/clang/staticconstfield.cxx
@@ -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())
diff --git a/compilerplugins/clang/test/staticconstfield.cxx b/compilerplugins/clang/test/staticconstfield.cxx
index d0d6939a3619..fd36a6452bfb 100644
--- a/compilerplugins/clang/test/staticconstfield.cxx
+++ b/compilerplugins/clang/test/staticconstfield.cxx
@@ -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 at -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 at -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 at -1 {{init here [loplugin:staticconstfield]}}
More information about the Libreoffice-commits
mailing list