Skip to content

Commit c30bfb6

Browse files
xguptaxgupta
authored andcommitted
[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
1 parent d65f037 commit c30bfb6

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,10 @@ class HTMLLogger : public Logger {
430430
AST.getSourceManager(), AST.getLangOpts());
431431
if (EltRange.isInvalid())
432432
continue;
433-
if (EltRange.getBegin() < Range.getBegin() ||
434-
EltRange.getEnd() >= Range.getEnd() ||
435-
EltRange.getEnd() < Range.getBegin() ||
436-
EltRange.getEnd() >= Range.getEnd())
433+
if (EltRange.getEnd() <= Range.getBegin() ||
434+
EltRange.getBegin() >= Range.getEnd())
437435
continue;
436+
438437
unsigned Off = EltRange.getBegin().getRawEncoding() -
439438
Range.getBegin().getRawEncoding();
440439
unsigned Len = EltRange.getEnd().getRawEncoding() -

clang/lib/Sema/SemaCast.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,8 +2945,7 @@ void CastOperation::CheckCStyleCast() {
29452945
if (Self.getASTContext().isDependenceAllowed() &&
29462946
(DestType->isDependentType() || SrcExpr.get()->isTypeDependent() ||
29472947
SrcExpr.get()->isValueDependent())) {
2948-
assert((DestType->containsErrors() || SrcExpr.get()->containsErrors() ||
2949-
SrcExpr.get()->containsErrors()) &&
2948+
assert((DestType->containsErrors() || SrcExpr.get()->containsErrors()) &&
29502949
"should only occur in error-recovery path.");
29512950
assert(Kind == CK_Dependent);
29522951
return;

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4239,7 +4239,7 @@ bool Sema::DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc,
42394239
Diag(Loc, diag::err_using_placeholder_variable) << Name;
42404240
for (DeclContextLookupResult::iterator It = Found; It != Result.end(); It++) {
42414241
const NamedDecl *ND = *It;
4242-
if (ND->getDeclContext() != ND->getDeclContext())
4242+
if (ND->getDeclContext() != ClassDecl->getDeclContext())
42434243
break;
42444244
if (isa<FieldDecl, IndirectFieldDecl>(ND) &&
42454245
ND->isPlaceholderVar(getLangOpts()))

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23087,8 +23087,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPDoacrossClause(
2308723087
if (DSAStack->getCurrentDirective() == OMPD_ordered &&
2308823088
DepType != OMPC_DOACROSS_source && DepType != OMPC_DOACROSS_sink &&
2308923089
DepType != OMPC_DOACROSS_sink_omp_cur_iteration &&
23090-
DepType != OMPC_DOACROSS_source_omp_cur_iteration &&
23091-
DepType != OMPC_DOACROSS_source) {
23090+
DepType != OMPC_DOACROSS_source_omp_cur_iteration) {
2309223091
Diag(DepLoc, diag::err_omp_unexpected_clause_value)
2309323092
<< "'source' or 'sink'" << getOpenMPClauseName(OMPC_doacross);
2309423093
return nullptr;

llvm/lib/Transforms/Scalar/JumpThreading.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,7 @@ void JumpThreadingPass::updateBlockFreqAndEdgeWeight(BasicBlock *PredBB,
25202520
BlockFrequencyInfo *BFI,
25212521
BranchProbabilityInfo *BPI,
25222522
bool HasProfile) {
2523-
assert(((BFI && BPI) || (!BFI && !BFI)) &&
2523+
assert(((BFI && BPI) || (!BFI && !BPI)) &&
25242524
"Both BFI & BPI should either be set or unset");
25252525

25262526
if (!BFI) {

llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ void PlainCFGBuilder::buildPlainCFG() {
412412
: static_cast<VPBlockBase *>(Successor));
413413
continue;
414414
}
415-
assert(BI->isConditional() && NumSuccs == 2 && BI->isConditional() &&
415+
assert(BI->isConditional() && NumSuccs == 2 &&
416416
"block must have conditional branch with 2 successors");
417417
// Look up the branch condition to get the corresponding VPValue
418418
// representing the condition bit in VPlan (which may be in another VPBB).

mlir/lib/Analysis/Presburger/Simplex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ Simplex::Unknown &SimplexBase::unknownFromRow(unsigned row) {
106106

107107
unsigned SimplexBase::addZeroRow(bool makeRestricted) {
108108
// Resize the tableau to accommodate the extra row.
109+
unsigned oldNumRows = getNumRows();
109110
unsigned newRow = tableau.appendExtraRow();
110-
assert(getNumRows() == getNumRows() && "Inconsistent tableau size");
111111
rowUnknown.emplace_back(~con.size());
112112
con.emplace_back(Orientation::Row, makeRestricted, newRow);
113113
undoLog.emplace_back(UndoLogEntry::RemoveLastConstraint);

mlir/lib/Interfaces/ValueBoundsOpInterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,11 @@ FailureOr<bool>
778778
ValueBoundsConstraintSet::areOverlappingSlices(MLIRContext *ctx,
779779
HyperrectangularSlice slice1,
780780
HyperrectangularSlice slice2) {
781-
assert(slice1.getMixedOffsets().size() == slice1.getMixedOffsets().size() &&
781+
assert(slice1.getMixedOffsets().size() == slice2.getMixedOffsets().size() &&
782782
"expected slices of same rank");
783-
assert(slice1.getMixedSizes().size() == slice1.getMixedSizes().size() &&
783+
assert(slice1.getMixedSizes().size() == slice2.getMixedSizes().size() &&
784784
"expected slices of same rank");
785-
assert(slice1.getMixedStrides().size() == slice1.getMixedStrides().size() &&
785+
assert(slice1.getMixedStrides().size() == slice2.getMixedStrides().size() &&
786786
"expected slices of same rank");
787787

788788
Builder b(ctx);
@@ -843,11 +843,11 @@ FailureOr<bool>
843843
ValueBoundsConstraintSet::areEquivalentSlices(MLIRContext *ctx,
844844
HyperrectangularSlice slice1,
845845
HyperrectangularSlice slice2) {
846-
assert(slice1.getMixedOffsets().size() == slice1.getMixedOffsets().size() &&
846+
assert(slice1.getMixedOffsets().size() == slice2.getMixedOffsets().size() &&
847847
"expected slices of same rank");
848-
assert(slice1.getMixedSizes().size() == slice1.getMixedSizes().size() &&
848+
assert(slice1.getMixedSizes().size() == slice2.getMixedSizes().size() &&
849849
"expected slices of same rank");
850-
assert(slice1.getMixedStrides().size() == slice1.getMixedStrides().size() &&
850+
assert(slice1.getMixedStrides().size() == slice2.getMixedStrides().size() &&
851851
"expected slices of same rank");
852852

853853
// The two slices are equivalent if all of their offsets, sizes and strides

0 commit comments

Comments
 (0)