Improve loplugin:sequenceloop diagnostic advice
"make range var const" sounded to me like it talked about the variable declared in the for-range-declaration, not a variable referenced in the for-range- initializer Change-Id: Ie777e1374ead7f37c8efb022cd87e980d2ee9810 Reviewed-on: https://gerrit.libreoffice.org/79563 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -64,7 +64,8 @@ bool SequenceLoop::VisitCXXForRangeStmt(CXXForRangeStmt const* forStmt)
|
||||
return true;
|
||||
|
||||
report(DiagnosticsEngine::Warning,
|
||||
"use std::as_const, or make range var const, to avoid creating a copy of the Sequence",
|
||||
("use std::as_const, or otherwise make the for-range-initializer expression const, to"
|
||||
" avoid creating a copy of the Sequence"),
|
||||
compat::getBeginLoc(forStmt->getRangeInit()))
|
||||
<< forStmt->getSourceRange();
|
||||
return true;
|
||||
|
@@ -15,7 +15,7 @@ namespace test1
|
||||
{
|
||||
void foo(css::uno::Sequence<css::uno::Reference<css::uno::XInterface>>& aSeq)
|
||||
{
|
||||
// expected-error@+1 {{use std::as_const, or make range var const, to avoid creating a copy of the Sequence [loplugin:sequenceloop]}}
|
||||
// expected-error@+1 {{use std::as_const, or otherwise make the for-range-initializer expression const, to avoid creating a copy of the Sequence [loplugin:sequenceloop]}}
|
||||
for (const auto& x : aSeq)
|
||||
x.get();
|
||||
// no warning expected
|
||||
|
Reference in New Issue
Block a user