summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-01 09:08:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-03 11:56:43 +0200
commit4969f4c0d3e2581aaa8a5b5a5769840fa6b6f8ea (patch)
treeeb42ab5be5d8c5ca3d23b686a8781c28822381b4 /compilerplugins
parentd5cc52fec12e3c8d1c3561f172d3e1c5434290b3 (diff)
loplugin:constfields in sw
Change-Id: I1eb6583bb9ec815bc0564b0d7c676f5b1fb9045f Reviewed-on: https://gerrit.libreoffice.org/61177 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/staticconstfield.cxx21
1 files changed, 14 insertions, 7 deletions
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;
}