https://github.com/JOE1994 updated https://github.com/llvm/llvm-project/pull/90625
>From 0a1598d0e00cbbfd0320ea72491500957ddb6b52 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim <youngsuk....@hpe.com> Date: Tue, 30 Apr 2024 11:18:15 -0500 Subject: [PATCH 1/2] [clang][Sema] Re-use existing BinaryOperator if possible First round of Sema checks were run at initial parsing step. Creating a new BinaryOperator instance (with the re-built LHS or RHS) will trigger another round of Sema checks, which can lead to duplicate diagnostic warning messages. All we want here is to replace the LHS or RHS with a NonOdrUse version. Don't create a new BinaryOperator, but simply replace the LHS or RHS of the given BinaryOperator. Fixes #45783 --- clang/lib/Sema/SemaExpr.cpp | 7 +++---- clang/test/CXX/drs/dr7xx.cpp | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 0c37f43f75401b..0cca02c338954a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -19707,18 +19707,17 @@ static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E, ExprResult Sub = Rebuild(LHS); if (!Sub.isUsable()) return Sub; - LHS = Sub.get(); + BO->setLHS(Sub.get()); // -- If e is a comma expression, ... } else if (BO->getOpcode() == BO_Comma) { ExprResult Sub = Rebuild(RHS); if (!Sub.isUsable()) return Sub; - RHS = Sub.get(); + BO->setRHS(Sub.get()); } else { break; } - return S.BuildBinOp(nullptr, BO->getOperatorLoc(), BO->getOpcode(), - LHS, RHS); + return ExprResult(BO); } // -- If e has the form (e1)... diff --git a/clang/test/CXX/drs/dr7xx.cpp b/clang/test/CXX/drs/dr7xx.cpp index 69ee6d6d4e6ae0..0300dae08d6d31 100644 --- a/clang/test/CXX/drs/dr7xx.cpp +++ b/clang/test/CXX/drs/dr7xx.cpp @@ -28,10 +28,8 @@ namespace cwg712 { // cwg712: partial use(a); use((a)); use(cond ? a : a); - // FIXME: should only warn once use((cond, a)); // expected-warning@-1 {{left operand of comma operator has no effect}} - // expected-warning@-2 {{left operand of comma operator has no effect}} (void)a; // expected-error@-1 {{reference to local variable 'a' declared in enclosing function 'cwg712::f'}} FIXME >From a7ea985860e0905b1904d58b188a66b94f236fb6 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim <youngsuk....@hpe.com> Date: Wed, 1 May 2024 14:32:10 -0500 Subject: [PATCH 2/2] Add release-note item --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2c5308fbcb319a..ee2387245b6495 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -502,6 +502,9 @@ Bug Fixes in This Version The values of 0 and 1 block any unrolling of the loop. This keeps the same behavior with GCC. Fixes (`#88624 <https://github.com/llvm/llvm-project/issues/88624>`_). +- Clang will no longer emit a duplicate -Wunused-value warning for an expression + `(A, B)` which evaluates to glvalue `B` that can be converted to non ODR-use. (#GH45783) + Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits