summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-25 10:10:55 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-25 18:21:24 +0200
commite63e769bd30800b72f4a1cdfc7222c0b64f3c770 (patch)
tree05aba98bba30dc1a22fdd57ffebce5a637d04923 /sc
parent176021427fece6363df56022b63813e93505fdc2 (diff)
Introduce a better mechanism to suppress false loplugin warnings
...by annotating occurrences of false warnings with [-loplugin:<name>] comments in source files and letting individual plugins opt-in to watch out for such suppression annotations, rather than maintaining lists of excluded source files in the individual plugins. (See the new loplugin::Plugin::suppressWarningsAt.) Instead of making all calls to loplugin::Plugin::report check for suppression annotations, the intent is that this check will only be added opt-in to those places in the plugins that are prone to emitting false warnings. In general it is better to have plugins that don't produce false warnings in the first place, or at least let those warnings be addressed with trivial and harmless source code modifications, avoiding the need for any suppression mechanism. As a proof of concept, I have removed the exclude list from loplugin:redundantfcast and instead annotated the relevant source code. (And thereby found that three of the six originally excluded files didn't need to be excluded any more at all?) For now, this mechanism looks for comments (both //... and /*...*/, even documentation-style /**...*/) that overlap the current and/or the preceding line, because at least for code controlled by clang-format it is often easier to move comments to a line of their own, preceding the commented code. Looking also at the current line (and not only at the preceding one) opens the door for erroneous over-eager annotation, where an annotation that was meant to address a false warning on the current line would also silence a potentially true warning on the following line. This probably doesn't cause much trouble in practice, but is up for potential change. Change-Id: I91ce7a0e5248886a60b471b1a153867f16bb5cea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133365 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table2.cxx2
1 files changed, 2 insertions, 0 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index e9b5bb371a85..55c11a3ce065 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2891,6 +2891,7 @@ void ScTable::SetAttrEntries( SCCOL nStartCol, SCCOL nEndCol, std::vector<ScAttr
// If we would like set all columns to same attrs, then change only attrs for not existing columns
nEndCol = aCol.size() - 1;
for (SCCOL i = nStartCol; i <= nEndCol; i++)
+ // [-loplugin:redundantfcast] false positive:
aCol[i].SetAttrEntries( std::vector<ScAttrEntry>(vNewData));
aDefaultColData.SetAttrEntries(std::move(vNewData));
}
@@ -2904,6 +2905,7 @@ void ScTable::SetAttrEntries( SCCOL nStartCol, SCCOL nEndCol, std::vector<ScAttr
{
CreateColumnIfNotExists( nEndCol );
for (SCCOL i = nStartCol; i < nEndCol; i++) // all but last need a copy
+ // [-loplugin:redundantfcast] false positive:
aCol[i].SetAttrEntries( std::vector<ScAttrEntry>(vNewData));
aCol[nEndCol].SetAttrEntries( std::move(vNewData));
}