summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-02-21 15:17:47 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-02-23 11:10:18 +0100
commitfed87058ac80ca6223c0e8221debc96c274383a9 (patch)
tree87409015f02676fd8f1ed8b78a3076f7427d6cab /compilerplugins
parent74c882c39ebeb5b9de531271a6d757cbe8780691 (diff)
Revert "loplugin:sequenceloop improve rvalue detection"
This reverts commit 3aca35f1505fa552eaa316a2d47a60ef52646525. Reason for revert: see commentary at https://gerrit.libreoffice.org/c/core/+/89184 I misunderstood - even though this is a local copy, we will still call non-const begin()/end() and cause further allocations internal to the Sequence Change-Id: Ia9ecacc6312afc2c9c80ca72afe6182d9b70241b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89137 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/sequenceloop.cxx6
-rw-r--r--compilerplugins/clang/test/sequenceloop.cxx9
2 files changed, 0 insertions, 15 deletions
diff --git a/compilerplugins/clang/sequenceloop.cxx b/compilerplugins/clang/sequenceloop.cxx
index 9a620f26be52..7f14d6c4d951 100644
--- a/compilerplugins/clang/sequenceloop.cxx
+++ b/compilerplugins/clang/sequenceloop.cxx
@@ -63,12 +63,6 @@ bool SequenceLoop::VisitCXXForRangeStmt(CXXForRangeStmt const* forStmt)
if (!tc2.LvalueReference().Const())
return true;
- // bit awkward, but the only way to sniff out if we're being passed a value or a reference
- auto rangeDeclStmt = dyn_cast<DeclStmt>(forStmt->getRangeStmt());
- auto rangeVarDecl = dyn_cast<VarDecl>(rangeDeclStmt->getSingleDecl());
- if (rangeVarDecl->getType()->isRValueReferenceType())
- return true;
-
report(DiagnosticsEngine::Warning,
("use std::as_const, or otherwise make the for-range-initializer expression const, to"
" avoid creating a copy of the Sequence"),
diff --git a/compilerplugins/clang/test/sequenceloop.cxx b/compilerplugins/clang/test/sequenceloop.cxx
index 41cb32f0495a..e124fda27093 100644
--- a/compilerplugins/clang/test/sequenceloop.cxx
+++ b/compilerplugins/clang/test/sequenceloop.cxx
@@ -30,15 +30,6 @@ void foo2(const css::uno::Sequence<css::uno::Reference<css::uno::XInterface>>& a
for (const auto& x : aSeq)
x.get();
}
-
-css::uno::Sequence<css::uno::Reference<css::uno::XInterface>> getSequenceByValue();
-
-// no warning expected
-void foo3()
-{
- for (const auto& x : getSequenceByValue())
- x.get();
-}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */