compilerplugins/clang/rangedforcopy.cxx      |    2 ++
 compilerplugins/clang/test/rangedforcopy.cxx |    9 +++++++++
 2 files changed, 11 insertions(+)

New commits:
commit 55d2fdf4ba40af1369406b7775df643f846836a4
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Nov 12 17:04:15 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Nov 13 08:54:04 2024 +0100

    ignore OUStringChar in loplugin:rangedforcopy
    
    where using a "&" in a for loop is overkill, and may even not be
    the type of range elements
    
    Change-Id: Idba3d84fc52d50a15d917576e07bbac754127126
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176480
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/compilerplugins/clang/rangedforcopy.cxx 
b/compilerplugins/clang/rangedforcopy.cxx
index 7ca859cc3904..3ad407c358bb 100644
--- a/compilerplugins/clang/rangedforcopy.cxx
+++ b/compilerplugins/clang/rangedforcopy.cxx
@@ -69,6 +69,8 @@ bool RangedForCopy::VisitCXXForRangeStmt( const 
CXXForRangeStmt* stmt )
     // trivial class, ignore it
     if (loplugin::TypeCheck(type).Class("TypedWhichId").GlobalNamespace())
         return true;
+    if (loplugin::TypeCheck(type).Typedef("OUStringChar").Namespace("rtl"))
+        return true;
 
     std::string name = type.getAsString();
     report(
diff --git a/compilerplugins/clang/test/rangedforcopy.cxx 
b/compilerplugins/clang/test/rangedforcopy.cxx
index d83090d0a1d1..f9c027bb84f8 100644
--- a/compilerplugins/clang/test/rangedforcopy.cxx
+++ b/compilerplugins/clang/test/rangedforcopy.cxx
@@ -8,6 +8,7 @@
  */
 
 #include <vector>
+#include <rtl/ustring.hxx>
 #include <svl/typedwhich.hxx>
 
 struct S
@@ -47,4 +48,12 @@ void f2()
     for (auto nWhich : { EE_CHAR_FONTINFO1, EE_CHAR_FONTINFO2 })
         (void)nWhich;
 }
+
+// no warning expected
+void f3()
+{
+    for (rtl::OUStringChar c : { 'a', 'b' })
+        (void)c;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to