From 4969f4c0d3e2581aaa8a5b5a5769840fa6b6f8ea Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 1 Oct 2018 09:08:12 +0200 Subject: loplugin:constfields in sw Change-Id: I1eb6583bb9ec815bc0564b0d7c676f5b1fb9045f Reviewed-on: https://gerrit.libreoffice.org/61177 Tested-by: Jenkins Reviewed-by: Noel Grandin --- compilerplugins/clang/staticconstfield.cxx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/staticconstfield.cxx b/compilerplugins/clang/staticconstfield.cxx index bfc32a8c059f..79fda38531e9 100644 --- a/compilerplugins/clang/staticconstfield.cxx +++ b/compilerplugins/clang/staticconstfield.cxx @@ -84,13 +84,20 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init) return true; } - if (found) - { - report(DiagnosticsEngine::Warning, "field can be static const", init->getSourceLocation()) - << init->getSourceRange(); - report(DiagnosticsEngine::Note, "field here", init->getMember()->getLocation()) - << init->getMember()->getSourceRange(); - } + if (!found) + return true; + + std::string fn = handler.getMainFileName(); + loplugin::normalizeDotDotInFilePath(fn); + + // unusual case where a user constructor sets a field to one value, and a copy constructor sets it to a different value + if (fn == SRCDIR "/sw/source/core/attr/hints.cxx") + return true; + + report(DiagnosticsEngine::Warning, "field can be static const", init->getSourceLocation()) + << init->getSourceRange(); + report(DiagnosticsEngine::Note, "field here", init->getMember()->getLocation()) + << init->getMember()->getSourceRange(); return true; } -- cgit