Skip to content

Commit 4670813

Browse files
authored
misc: fix clang warnings: deprecated,bitwise-logic (#4776)
Fixing some clang warnings about mixing logical and bitwise and the use of one deprecated CPP type (Removed in cpp17, same change as seen in #4761). Some are using those bitwise operation to avoid operator laziness. It was fixed upstream by an int cast, applying the same fixes. Signed-off-by: Nathan Gauër <[email protected]>
1 parent 6dd31be commit 4670813

10 files changed

Lines changed: 24 additions & 22 deletions

File tree

include/llvm/CodeGen/MachineInstr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,15 @@ class MachineInstr : public ilist_node<MachineInstr> {
439439
/// block. The TargetInstrInfo::AnalyzeBranch method can be used to get more
440440
/// information about this branch.
441441
bool isConditionalBranch(QueryType Type = AnyInBundle) const {
442-
return isBranch(Type) & !isBarrier(Type) & !isIndirectBranch(Type);
442+
return isBranch(Type) && !isBarrier(Type) && !isIndirectBranch(Type);
443443
}
444444

445445
/// Return true if this is a branch which always
446446
/// transfers control flow to some other block. The
447447
/// TargetInstrInfo::AnalyzeBranch method can be used to get more information
448448
/// about this branch.
449449
bool isUnconditionalBranch(QueryType Type = AnyInBundle) const {
450-
return isBranch(Type) & isBarrier(Type) & !isIndirectBranch(Type);
450+
return isBranch(Type) && isBarrier(Type) && !isIndirectBranch(Type);
451451
}
452452

453453
/// Return true if this instruction has a predicate operand that

include/llvm/MC/MCInstrDesc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ class MCInstrDesc {
242242
/// block. The TargetInstrInfo::AnalyzeBranch method can be used to get more
243243
/// information about this branch.
244244
bool isConditionalBranch() const {
245-
return isBranch() & !isBarrier() & !isIndirectBranch();
245+
return isBranch() && !isBarrier() && !isIndirectBranch();
246246
}
247247

248248
/// \brief Return true if this is a branch which always
249249
/// transfers control flow to some other block. The
250250
/// TargetInstrInfo::AnalyzeBranch method can be used to get more information
251251
/// about this branch.
252252
bool isUnconditionalBranch() const {
253-
return isBranch() & isBarrier() & !isIndirectBranch();
253+
return isBranch() && isBarrier() && !isIndirectBranch();
254254
}
255255

256256
/// \brief Return true if this is a branch or an instruction which directly

lib/IR/Instructions.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,21 +1890,21 @@ void BinaryOperator::copyIRFlags(const Value *V) {
18901890
// Copy the exact flag.
18911891
if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
18921892
setIsExact(PE->isExact());
1893-
1893+
18941894
// Copy the fast-math flags.
18951895
if (auto *FP = dyn_cast<FPMathOperator>(V))
18961896
copyFastMathFlags(FP->getFastMathFlags());
18971897
}
18981898

18991899
void BinaryOperator::andIRFlags(const Value *V) {
19001900
if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
1901-
setHasNoSignedWrap(hasNoSignedWrap() & OB->hasNoSignedWrap());
1902-
setHasNoUnsignedWrap(hasNoUnsignedWrap() & OB->hasNoUnsignedWrap());
1901+
setHasNoSignedWrap(hasNoSignedWrap() && OB->hasNoSignedWrap());
1902+
setHasNoUnsignedWrap(hasNoUnsignedWrap() && OB->hasNoUnsignedWrap());
19031903
}
1904-
1904+
19051905
if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
1906-
setIsExact(isExact() & PE->isExact());
1907-
1906+
setIsExact(isExact() && PE->isExact());
1907+
19081908
if (auto *FP = dyn_cast<FPMathOperator>(V)) {
19091909
FastMathFlags FM = getFastMathFlags();
19101910
FM &= FP->getFastMathFlags();

tools/clang/include/clang/Basic/IdentifierTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ class IdentifierInfo {
326326
/// change to it should be reflected here.
327327
void RecomputeNeedsHandleIdentifier() {
328328
NeedsHandleIdentifier =
329-
(isPoisoned() | hasMacroDefinition() | isCPlusPlusOperatorKeyword() |
330-
isExtensionToken() | isFutureCompatKeyword() || isOutOfDate() ||
329+
(isPoisoned() || hasMacroDefinition() || isCPlusPlusOperatorKeyword() ||
330+
isExtensionToken() || isFutureCompatKeyword() || isOutOfDate() ||
331331
isModulesImport());
332332
}
333333
};

tools/clang/lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3161,7 +3161,7 @@ class CachedProperties {
31613161
friend CachedProperties merge(CachedProperties L, CachedProperties R) {
31623162
Linkage MergedLinkage = minLinkage(L.L, R.L);
31633163
return CachedProperties(MergedLinkage,
3164-
L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3164+
L.hasLocalOrUnnamedType() || R.hasLocalOrUnnamedType());
31653165
}
31663166
};
31673167
}

tools/clang/lib/CodeGen/CGExpr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ static llvm::Value *emitHash16Bytes(CGBuilderTy &Builder, llvm::Value *Low,
484484
}
485485

486486
bool CodeGenFunction::sanitizePerformTypeCheck() const {
487-
return SanOpts.has(SanitizerKind::Null) |
488-
SanOpts.has(SanitizerKind::Alignment) |
489-
SanOpts.has(SanitizerKind::ObjectSize) |
487+
return SanOpts.has(SanitizerKind::Null) ||
488+
SanOpts.has(SanitizerKind::Alignment) ||
489+
SanOpts.has(SanitizerKind::ObjectSize) ||
490490
SanOpts.has(SanitizerKind::Vptr);
491491
}
492492

tools/clang/lib/Lex/PPExpressions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
544544
case tok::ampamp: // Logical && does not do UACs.
545545
break; // No UAC
546546
default:
547-
Res.setIsUnsigned(LHS.isUnsigned()|RHS.isUnsigned());
547+
Res.setIsUnsigned(LHS.isUnsigned() || RHS.isUnsigned());
548548
// If this just promoted something from signed to unsigned, and if the
549549
// value was negative, warn about it.
550550
if (ValueLive && Res.isUnsigned()) {
@@ -701,7 +701,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
701701

702702
// Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
703703
// either operand is unsigned.
704-
Res.setIsUnsigned(RHS.isUnsigned() | AfterColonVal.isUnsigned());
704+
Res.setIsUnsigned(RHS.isUnsigned() || AfterColonVal.isUnsigned());
705705

706706
// Figure out the precedence of the token after the : part.
707707
PeekPrec = getPrecedence(PeekTok.getKind());

tools/clang/lib/SPIRV/DeclResultIdMapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ bool DeclResultIdMapper::decorateStageIOLocations() {
933933
return true;
934934
}
935935
// Try both input and output even if input location assignment failed
936-
return finalizeStageIOLocations(true) & finalizeStageIOLocations(false);
936+
return (int) finalizeStageIOLocations(true) & (int) finalizeStageIOLocations(false);
937937
}
938938

939939
bool DeclResultIdMapper::isInputStorageClass(const StageVar &v) {

utils/TableGen/CodeGenDAGPatterns.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,10 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
974974
unsigned OResNo = 0;
975975
TreePatternNode *OtherNode =
976976
getOperandNum(x.SDTCisSameAs_Info.OtherOperandNum, N, NodeInfo, OResNo);
977-
return NodeToApply->UpdateNodeType(ResNo, OtherNode->getExtType(OResNo),TP)|
978-
OtherNode->UpdateNodeType(OResNo,NodeToApply->getExtType(ResNo),TP);
977+
return (int) NodeToApply->UpdateNodeType(ResNo,
978+
OtherNode->getExtType(OResNo),TP) |
979+
(int) OtherNode->UpdateNodeType(OResNo,
980+
NodeToApply->getExtType(ResNo),TP);
979981
}
980982
case SDTCisVTSmallerThanOp: {
981983
// The NodeToApply must be a leaf node that is a VT. OtherOperandNum must

utils/TableGen/SequenceToOffsetTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SequenceToOffsetTable {
3838

3939
// Define a comparator for SeqT that sorts a suffix immediately before a
4040
// sequence with that suffix.
41-
struct SeqLess : public std::binary_function<SeqT, SeqT, bool> {
41+
struct SeqLess {
4242
Less L;
4343
bool operator()(const SeqT &A, const SeqT &B) const {
4444
return std::lexicographical_compare(A.rbegin(), A.rend(),

0 commit comments

Comments
 (0)