[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 25 20:14:56 UTC 2019


 compilerplugins/clang/sequenceloop.cxx      |    3 ++-
 compilerplugins/clang/test/sequenceloop.cxx |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 3a7d479c4c852499e8e4e2bc4273f02aec5051be
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 25 17:26:06 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Sep 25 22:14:02 2019 +0200

    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 at redhat.com>

diff --git a/compilerplugins/clang/sequenceloop.cxx b/compilerplugins/clang/sequenceloop.cxx
index 0e6b23893298..7f14d6c4d951 100644
--- a/compilerplugins/clang/sequenceloop.cxx
+++ b/compilerplugins/clang/sequenceloop.cxx
@@ -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;
diff --git a/compilerplugins/clang/test/sequenceloop.cxx b/compilerplugins/clang/test/sequenceloop.cxx
index 113e8fd588fe..e124fda27093 100644
--- a/compilerplugins/clang/test/sequenceloop.cxx
+++ b/compilerplugins/clang/test/sequenceloop.cxx
@@ -15,7 +15,7 @@ namespace test1
 {
 void foo(css::uno::Sequence<css::uno::Reference<css::uno::XInterface>>& aSeq)
 {
-    // expected-error at +1 {{use std::as_const, or make range var const, to avoid creating a copy of the Sequence [loplugin:sequenceloop]}}
+    // expected-error at +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


More information about the Libreoffice-commits mailing list