[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -4368,7 +4368,7 @@ bool Sema::DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, Diag(Loc, diag::err_using_placeholder_variable) << Name; for (DeclContextLookupResult::iterator It = Found; It != Result.end(); It++) { const NamedDecl *ND = *It; -if (ND->getDeclContext() != ND->getDeclContext()) +if (ND->getDeclContext() != ClassDecl->getDeclContext()) xgupta wrote: I am not familiar with this part of code to add a testcase, and not even sure it is right fix. I will just remove this changes from this PR. https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt, if (FirstStmt == SecondStmt) return true; - if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass()) + if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass()) xgupta wrote: @PiotrZSL If I removed this condition and ninja target still passes. Shall I remove this or can you provide a test case or guidance? I have this function is used in BranchCloneCheck.cpp but I am not sure how the test case look like. https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt, if (FirstStmt == SecondStmt) return true; - if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass()) + if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass()) PiotrZSL wrote: Thx for info, that were a bug. https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/95715 >From f80cc3b6ee218e954d68e867637c38211f344d83 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Sun, 16 Jun 2024 23:39:47 +0530 Subject: [PATCH 1/3] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) This is actually reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8 V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the left and to the right of the '!=' operator. ASTUtils.cpp:99 V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). SemaOverload.cpp:10190 V501 There are identical sub-expressions to the left and to the right of the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:585 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:646 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:650 V501 There are identical sub-expressions 'EltRange.getEnd() >= Range.getEnd()' to the left and to the right of the '||' operator. HTMLLogger.cpp:421 V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' to the left and to the right of the '||' operator. SemaCast.cpp:2938 V501 There are identical sub-expressions 'ND->getDeclContext()' to the left and to the right of the '!=' operator. SemaDeclCXX.cpp:4391 V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' to the left and to the right of the '&&' operator. SemaOpenMP.cpp:24348 V501 There are identical sub-expressions '!OldMethod->isStatic()' to the left and to the right of the '&&' operator. SemaOverload.cpp:1425 V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the left and to the right of the '|' operator. JSONUtils.cpp:139 V501 There are identical sub-expressions to the left and to the right of the '&&' operator: !BFI &&!BFI. JumpThreading.cpp:2531 V501 There are identical sub-expressions 'BI->isConditional()' to the left and to the right of the '&&' operator. VPlanHCFGBuilder.cpp:401 V501 There are identical sub-expressions to the left and to the right of the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108 --- clang-tools-extra/clang-tidy/utils/ASTUtils.cpp| 2 +- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp| 7 +++ clang/lib/Sema/SemaCast.cpp| 3 +-- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- clang/lib/Sema/SemaOpenMP.cpp | 3 +-- llvm/lib/Transforms/Scalar/JumpThreading.cpp | 2 +- llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp | 2 +- mlir/lib/Analysis/Presburger/Simplex.cpp | 3 ++- mlir/lib/Interfaces/ValueBoundsOpInterface.cpp | 12 ++-- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp index fd5dadc9b01db..0cdc7d08abc99 100644 --- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp @@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt, if (FirstStmt == SecondStmt) return true; - if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass()) + if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass()) return false; if (isa(FirstStmt) && isa(SecondStmt)) { diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp index a36cb41a63dfb..323f9698dc2aa 100644 --- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp +++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp @@ -430,11 +430,10 @@ class HTMLLogger : public Logger { AST.getSourceManager(), AST.getLangOpts()); if (EltRange.isInvalid()) continue; - if (EltRange.getBegin() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd() || - EltRange.getEnd() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd()) + if
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/95715 >From f80cc3b6ee218e954d68e867637c38211f344d83 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Sun, 16 Jun 2024 23:39:47 +0530 Subject: [PATCH 1/2] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) This is actually reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8 V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the left and to the right of the '!=' operator. ASTUtils.cpp:99 V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). SemaOverload.cpp:10190 V501 There are identical sub-expressions to the left and to the right of the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:585 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:646 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:650 V501 There are identical sub-expressions 'EltRange.getEnd() >= Range.getEnd()' to the left and to the right of the '||' operator. HTMLLogger.cpp:421 V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' to the left and to the right of the '||' operator. SemaCast.cpp:2938 V501 There are identical sub-expressions 'ND->getDeclContext()' to the left and to the right of the '!=' operator. SemaDeclCXX.cpp:4391 V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' to the left and to the right of the '&&' operator. SemaOpenMP.cpp:24348 V501 There are identical sub-expressions '!OldMethod->isStatic()' to the left and to the right of the '&&' operator. SemaOverload.cpp:1425 V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the left and to the right of the '|' operator. JSONUtils.cpp:139 V501 There are identical sub-expressions to the left and to the right of the '&&' operator: !BFI &&!BFI. JumpThreading.cpp:2531 V501 There are identical sub-expressions 'BI->isConditional()' to the left and to the right of the '&&' operator. VPlanHCFGBuilder.cpp:401 V501 There are identical sub-expressions to the left and to the right of the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108 --- clang-tools-extra/clang-tidy/utils/ASTUtils.cpp| 2 +- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp| 7 +++ clang/lib/Sema/SemaCast.cpp| 3 +-- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- clang/lib/Sema/SemaOpenMP.cpp | 3 +-- llvm/lib/Transforms/Scalar/JumpThreading.cpp | 2 +- llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp | 2 +- mlir/lib/Analysis/Presburger/Simplex.cpp | 3 ++- mlir/lib/Interfaces/ValueBoundsOpInterface.cpp | 12 ++-- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp index fd5dadc9b01db..0cdc7d08abc99 100644 --- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp @@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt, if (FirstStmt == SecondStmt) return true; - if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass()) + if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass()) return false; if (isa(FirstStmt) && isa(SecondStmt)) { diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp index a36cb41a63dfb..323f9698dc2aa 100644 --- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp +++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp @@ -430,11 +430,10 @@ class HTMLLogger : public Logger { AST.getSourceManager(), AST.getLangOpts()); if (EltRange.isInvalid()) continue; - if (EltRange.getBegin() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd() || - EltRange.getEnd() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd()) + if
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
https://github.com/Superty edited https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -104,8 +104,9 @@ Simplex::Unknown ::unknownFromRow(unsigned row) { unsigned SimplexBase::addZeroRow(bool makeRestricted) { // Resize the tableau to accommodate the extra row. + unsigned oldNumRows = getNumRows(); unsigned newRow = tableau.appendExtraRow(); - assert(getNumRows() == getNumRows() && "Inconsistent tableau size"); + assert(getNumRows() == oldNumRows + 1 && "Inconsistent tableau size"); Superty wrote: Thanks for catching this! https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -104,8 +104,9 @@ Simplex::Unknown ::unknownFromRow(unsigned row) { unsigned SimplexBase::addZeroRow(bool makeRestricted) { // Resize the tableau to accommodate the extra row. + unsigned oldNumRows = getNumRows(); unsigned newRow = tableau.appendExtraRow(); - assert(getNumRows() == getNumRows() && "Inconsistent tableau size"); + assert(getNumRows() == oldNumRows + 1 && "Inconsistent tableau size"); Superty wrote: you can just delete the assert. it's a vestige of an earlier time when there was an extra variable tracking the number of rows that had to be kept in sync with the Matrix internal count. https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt, if (FirstStmt == SecondStmt) return true; - if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass()) + if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass()) AaronBallman wrote: This looks like a functional change, it would be good to have a test for it. https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -4368,7 +4368,7 @@ bool Sema::DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, Diag(Loc, diag::err_using_placeholder_variable) << Name; for (DeclContextLookupResult::iterator It = Found; It != Result.end(); It++) { const NamedDecl *ND = *It; -if (ND->getDeclContext() != ND->getDeclContext()) +if (ND->getDeclContext() != ClassDecl->getDeclContext()) AaronBallman wrote: This looks like a functional change to me; if no tests broke, we should probably figure out a test to add for this change. https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
@@ -430,11 +430,10 @@ class HTMLLogger : public Logger { AST.getSourceManager(), AST.getLangOpts()); if (EltRange.isInvalid()) continue; - if (EltRange.getBegin() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd() || - EltRange.getEnd() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd()) + if (EltRange.getEnd() <= Range.getBegin() || AaronBallman wrote: This looks like it misses the case where `EltRange.getBegin() < Range.getBegin()`; shouldn't this be: ``` if (EltRange.getBegin() < Range.getBegin() || EltRange.getEnd() >= Range.getEnd()) ``` https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
AaronBallman wrote: Note, this fixes #95670 https://github.com/llvm/llvm-project/pull/95715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
llvmbot wrote: @llvm/pr-subscribers-mlir @llvm/pr-subscribers-clang Author: Shivam Gupta (xgupta) Changes This is reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8 V501 There are identical sub-expressions 'FirstStmt-getStmtClass()' to the left and to the right of the '!=' operator. ASTUtils.cpp:99 V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Fn1-isVariadic() != Fn1-isVariadic(). SemaOverload.cpp:10190 V501 There are identical sub-expressions to the left and to the right of the '' operator: G1-Rank G1-Rank. SCCIterator.h:285 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:585 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:646 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:650 V501 There are identical sub-expressions 'EltRange.getEnd() = Range.getEnd()' to the left and to the right of the '||' operator. HTMLLogger.cpp:421 V501 There are identical sub-expressions 'SrcExpr.get()-containsErrors()' to the left and to the right of the '||' operator. SemaCast.cpp:2938 V501 There are identical sub-expressions 'ND-getDeclContext()' to the left and to the right of the '!=' operator. SemaDeclCXX.cpp:4391 V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' to the left and to the right of the '' operator. SemaOpenMP.cpp:24348 V501 There are identical sub-expressions '!OldMethod-isStatic()' to the left and to the right of the '' operator. SemaOverload.cpp:1425 V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the left and to the right of the '|' operator. JSONUtils.cpp:139 V501 There are identical sub-expressions to the left and to the right of the '' operator: !BFI !BFI. JumpThreading.cpp:2531 V501 There are identical sub-expressions 'BI-isConditional()' to the left and to the right of the '' operator. VPlanHCFGBuilder.cpp:401 V501 There are identical sub-expressions to the left and to the right of the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108 --- Full diff: https://github.com/llvm/llvm-project/pull/95715.diff 9 Files Affected: - (modified) clang-tools-extra/clang-tidy/utils/ASTUtils.cpp (+1-1) - (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp (+3-4) - (modified) clang/lib/Sema/SemaCast.cpp (+1-2) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1) - (modified) clang/lib/Sema/SemaOpenMP.cpp (+1-2) - (modified) llvm/lib/Transforms/Scalar/JumpThreading.cpp (+1-1) - (modified) llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp (+1-1) - (modified) mlir/lib/Analysis/Presburger/Simplex.cpp (+2-1) - (modified) mlir/lib/Interfaces/ValueBoundsOpInterface.cpp (+6-6) ``diff diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp index fd5dadc9b01db..0cdc7d08abc99 100644 --- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp @@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt, if (FirstStmt == SecondStmt) return true; - if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass()) + if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass()) return false; if (isa(FirstStmt) && isa(SecondStmt)) { diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp index a36cb41a63dfb..323f9698dc2aa 100644 --- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp +++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp @@ -430,11 +430,10 @@ class HTMLLogger : public Logger { AST.getSourceManager(), AST.getLangOpts()); if (EltRange.isInvalid()) continue; - if (EltRange.getBegin() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd() || - EltRange.getEnd() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd()) + if (EltRange.getEnd() <= Range.getBegin() || + EltRange.getBegin() >= Range.getEnd()) continue; + unsigned Off = EltRange.getBegin().getRawEncoding() - Range.getBegin().getRawEncoding();
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: Shivam Gupta (xgupta) Changes This is reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8 V501 There are identical sub-expressions 'FirstStmt-getStmtClass()' to the left and to the right of the '!=' operator. ASTUtils.cpp:99 V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Fn1-isVariadic() != Fn1-isVariadic(). SemaOverload.cpp:10190 V501 There are identical sub-expressions to the left and to the right of the '' operator: G1-Rank G1-Rank. SCCIterator.h:285 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:585 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:646 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:650 V501 There are identical sub-expressions 'EltRange.getEnd() = Range.getEnd()' to the left and to the right of the '||' operator. HTMLLogger.cpp:421 V501 There are identical sub-expressions 'SrcExpr.get()-containsErrors()' to the left and to the right of the '||' operator. SemaCast.cpp:2938 V501 There are identical sub-expressions 'ND-getDeclContext()' to the left and to the right of the '!=' operator. SemaDeclCXX.cpp:4391 V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' to the left and to the right of the '' operator. SemaOpenMP.cpp:24348 V501 There are identical sub-expressions '!OldMethod-isStatic()' to the left and to the right of the '' operator. SemaOverload.cpp:1425 V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the left and to the right of the '|' operator. JSONUtils.cpp:139 V501 There are identical sub-expressions to the left and to the right of the '' operator: !BFI !BFI. JumpThreading.cpp:2531 V501 There are identical sub-expressions 'BI-isConditional()' to the left and to the right of the '' operator. VPlanHCFGBuilder.cpp:401 V501 There are identical sub-expressions to the left and to the right of the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108 --- Full diff: https://github.com/llvm/llvm-project/pull/95715.diff 9 Files Affected: - (modified) clang-tools-extra/clang-tidy/utils/ASTUtils.cpp (+1-1) - (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp (+3-4) - (modified) clang/lib/Sema/SemaCast.cpp (+1-2) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1) - (modified) clang/lib/Sema/SemaOpenMP.cpp (+1-2) - (modified) llvm/lib/Transforms/Scalar/JumpThreading.cpp (+1-1) - (modified) llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp (+1-1) - (modified) mlir/lib/Analysis/Presburger/Simplex.cpp (+2-1) - (modified) mlir/lib/Interfaces/ValueBoundsOpInterface.cpp (+6-6) ``diff diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp index fd5dadc9b01db..0cdc7d08abc99 100644 --- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp @@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt, if (FirstStmt == SecondStmt) return true; - if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass()) + if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass()) return false; if (isa(FirstStmt) && isa(SecondStmt)) { diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp index a36cb41a63dfb..323f9698dc2aa 100644 --- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp +++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp @@ -430,11 +430,10 @@ class HTMLLogger : public Logger { AST.getSourceManager(), AST.getLangOpts()); if (EltRange.isInvalid()) continue; - if (EltRange.getBegin() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd() || - EltRange.getEnd() < Range.getBegin() || - EltRange.getEnd() >= Range.getEnd()) + if (EltRange.getEnd() <= Range.getBegin() || + EltRange.getBegin() >= Range.getEnd()) continue; + unsigned Off = EltRange.getBegin().getRawEncoding() - Range.getBegin().getRawEncoding(); unsigned
[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)
https://github.com/xgupta created https://github.com/llvm/llvm-project/pull/95715 This is reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8 V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the left and to the right of the '!=' operator. ASTUtils.cpp:99 V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). SemaOverload.cpp:10190 V501 There are identical sub-expressions to the left and to the right of the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:585 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:646 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:650 V501 There are identical sub-expressions 'EltRange.getEnd() >= Range.getEnd()' to the left and to the right of the '||' operator. HTMLLogger.cpp:421 V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' to the left and to the right of the '||' operator. SemaCast.cpp:2938 V501 There are identical sub-expressions 'ND->getDeclContext()' to the left and to the right of the '!=' operator. SemaDeclCXX.cpp:4391 V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' to the left and to the right of the '&&' operator. SemaOpenMP.cpp:24348 V501 There are identical sub-expressions '!OldMethod->isStatic()' to the left and to the right of the '&&' operator. SemaOverload.cpp:1425 V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the left and to the right of the '|' operator. JSONUtils.cpp:139 V501 There are identical sub-expressions to the left and to the right of the '&&' operator: !BFI &&!BFI. JumpThreading.cpp:2531 V501 There are identical sub-expressions 'BI->isConditional()' to the left and to the right of the '&&' operator. VPlanHCFGBuilder.cpp:401 V501 There are identical sub-expressions to the left and to the right of the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108 >From f80cc3b6ee218e954d68e867637c38211f344d83 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Sun, 16 Jun 2024 23:39:47 +0530 Subject: [PATCH] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) This is actually reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8 V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the left and to the right of the '!=' operator. ASTUtils.cpp:99 V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). SemaOverload.cpp:10190 V501 There are identical sub-expressions to the left and to the right of the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:585 V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:646 V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648 V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:650 V501 There are identical sub-expressions 'EltRange.getEnd() >= Range.getEnd()' to the left and to the right of the '||' operator. HTMLLogger.cpp:421 V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' to the left and to the right of the '||' operator. SemaCast.cpp:2938 V501 There are identical sub-expressions 'ND->getDeclContext()' to the left and to the right of the '!=' operator. SemaDeclCXX.cpp:4391 V501 There are identical