diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-09 09:55:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-10 12:59:38 +0200 |
commit | e4ff847fe0796420ba8023b70cad8589f5f19e9f (patch) | |
tree | 136786200de69f70dde4190c9725f35fe14b33e0 /compilerplugins | |
parent | 5a89496ffcfcd561b3e595e01f35e0302fa00841 (diff) |
loplugin:stringview check for getToken and trim
since we now have o3tl versions of those that work on
string_view.
Also improve those o3tl functions to support both string_view
and u16string_view
Change-Id: Iacab2996becec62aa78a5597c52d983bb784749a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132755
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/stringview.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx index 94ba6f150f1b..d7b48a43a4b8 100644 --- a/compilerplugins/clang/stringview.cxx +++ b/compilerplugins/clang/stringview.cxx @@ -282,6 +282,31 @@ void StringView::handleCXXMemberCallExpr(CXXMemberCallExpr const* expr) } return; } + if (auto const dc2 = dc1.Function("getToken")) + { + if (dc2.Class("OString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()) + { + report(DiagnosticsEngine::Warning, + "rather than getToken, pass with a view using o3tl::getToken()", + expr->getExprLoc()) + << expr->getSourceRange(); + } + return; + } + if (auto const dc2 = dc1.Function("trim")) + { + if (dc2.Class("OString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()) + { + report(DiagnosticsEngine::Warning, + "rather than trim, pass with a view using o3tl::trim()", expr->getExprLoc()) + << expr->getSourceRange(); + } + return; + } if (auto const dc2 = dc1.Function("makeStringAndClear")) { if (dc2.Class("OStringBuffer").Namespace("rtl").GlobalNamespace() |