[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 11 15:45:25 UTC 2020
compilerplugins/clang/unnecessaryparen.cxx | 5 +++++
1 file changed, 5 insertions(+)
New commits:
commit 88629b55041b9e7ff5c94afeb2aae725a5898687
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Sat Apr 11 16:55:25 2020 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sat Apr 11 17:44:54 2020 +0200
Adapt loplugin:unnecessaryparen to C++20 CXXRewrittenBinaryOperator
...as is used by GCC trunk libstdc++ std::unique_ptr since <https://gcc.gnu.org/
git/?p=gcc.git;a=commitdiff;h=5b074864f8c593fd4bccee788a023a37b446b2ed>
"libstdc++: Add comparison operators to std::unique_ptr", which caused
unexpected warnings like
> sfx2/source/dialog/tabdlg.cxx:1057:17: error: parentheses immediately inside vardecl statement [loplugin:unnecessaryparen]
> bool bSet = ( m_pSet != nullptr );
> ^~~~~~~~~~~~~~~~~~~~~
(CXXRewrittenBinaryOperator was introduced with <https://github.com/llvm/
llvm-project/commit/778dc0f1d49230f53401ae0c190fe460bda4ffd1> "[c++20] Add
CXXRewrittenBinaryOperator to represent a comparison", which first appeared in
LLVM 10.)
Change-Id: I68024d975dc4accbfa9da855baa37bf9f990b99c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92061
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx
index 106f2d2b3352..e93dfa64b5ec 100644
--- a/compilerplugins/clang/unnecessaryparen.cxx
+++ b/compilerplugins/clang/unnecessaryparen.cxx
@@ -468,6 +468,11 @@ bool UnnecessaryParen::VisitVarDecl(const VarDecl* varDecl)
// Sometimes parentheses make the RHS of an assignment easier to read by
// visually disambiguating the = from a call to ==
auto sub = parenExpr->getSubExpr();
+#if CLANG_VERSION >= 100000
+ if (auto const e = dyn_cast<CXXRewrittenBinaryOperator>(sub)) {
+ sub = e->getDecomposedForm().InnerBinOp;
+ }
+#endif
if (auto subBinOp = dyn_cast<BinaryOperator>(sub))
{
if (!(subBinOp->isMultiplicativeOp() || subBinOp->isAdditiveOp() || subBinOp->isPtrMemOp()))
More information about the Libreoffice-commits
mailing list