Browse Source

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]>
Nathan Gauër 2 years ago
parent
commit
4670813096

+ 2 - 2
include/llvm/CodeGen/MachineInstr.h

@@ -439,7 +439,7 @@ public:
   /// block.  The TargetInstrInfo::AnalyzeBranch method can be used to get more
   /// information about this branch.
   bool isConditionalBranch(QueryType Type = AnyInBundle) const {
-    return isBranch(Type) & !isBarrier(Type) & !isIndirectBranch(Type);
+    return isBranch(Type) && !isBarrier(Type) && !isIndirectBranch(Type);
   }
 
   /// Return true if this is a branch which always
@@ -447,7 +447,7 @@ public:
   /// TargetInstrInfo::AnalyzeBranch method can be used to get more information
   /// about this branch.
   bool isUnconditionalBranch(QueryType Type = AnyInBundle) const {
-    return isBranch(Type) & isBarrier(Type) & !isIndirectBranch(Type);
+    return isBranch(Type) && isBarrier(Type) && !isIndirectBranch(Type);
   }
 
   /// Return true if this instruction has a predicate operand that

+ 2 - 2
include/llvm/MC/MCInstrDesc.h

@@ -242,7 +242,7 @@ public:
   /// block.  The TargetInstrInfo::AnalyzeBranch method can be used to get more
   /// information about this branch.
   bool isConditionalBranch() const {
-    return isBranch() & !isBarrier() & !isIndirectBranch();
+    return isBranch() && !isBarrier() && !isIndirectBranch();
   }
 
   /// \brief Return true if this is a branch which always
@@ -250,7 +250,7 @@ public:
   /// TargetInstrInfo::AnalyzeBranch method can be used to get more information
   /// about this branch.
   bool isUnconditionalBranch() const {
-    return isBranch() & isBarrier() & !isIndirectBranch();
+    return isBranch() && isBarrier() && !isIndirectBranch();
   }
 
   /// \brief Return true if this is a branch or an instruction which directly

+ 6 - 6
lib/IR/Instructions.cpp

@@ -1890,7 +1890,7 @@ void BinaryOperator::copyIRFlags(const Value *V) {
   // Copy the exact flag.
   if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
     setIsExact(PE->isExact());
-  
+
   // Copy the fast-math flags.
   if (auto *FP = dyn_cast<FPMathOperator>(V))
     copyFastMathFlags(FP->getFastMathFlags());
@@ -1898,13 +1898,13 @@ void BinaryOperator::copyIRFlags(const Value *V) {
 
 void BinaryOperator::andIRFlags(const Value *V) {
   if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
-    setHasNoSignedWrap(hasNoSignedWrap() & OB->hasNoSignedWrap());
-    setHasNoUnsignedWrap(hasNoUnsignedWrap() & OB->hasNoUnsignedWrap());
+    setHasNoSignedWrap(hasNoSignedWrap() && OB->hasNoSignedWrap());
+    setHasNoUnsignedWrap(hasNoUnsignedWrap() && OB->hasNoUnsignedWrap());
   }
-  
+
   if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
-    setIsExact(isExact() & PE->isExact());
-  
+    setIsExact(isExact() && PE->isExact());
+
   if (auto *FP = dyn_cast<FPMathOperator>(V)) {
     FastMathFlags FM = getFastMathFlags();
     FM &= FP->getFastMathFlags();

+ 2 - 2
tools/clang/include/clang/Basic/IdentifierTable.h

@@ -326,8 +326,8 @@ private:
   /// change to it should be reflected here.
   void RecomputeNeedsHandleIdentifier() {
     NeedsHandleIdentifier =
-      (isPoisoned() | hasMacroDefinition() | isCPlusPlusOperatorKeyword() |
-       isExtensionToken() | isFutureCompatKeyword() || isOutOfDate() ||
+      (isPoisoned() || hasMacroDefinition() || isCPlusPlusOperatorKeyword() ||
+       isExtensionToken() || isFutureCompatKeyword() || isOutOfDate() ||
        isModulesImport());
   }
 };

+ 1 - 1
tools/clang/lib/AST/Type.cpp

@@ -3161,7 +3161,7 @@ public:
   friend CachedProperties merge(CachedProperties L, CachedProperties R) {
     Linkage MergedLinkage = minLinkage(L.L, R.L);
     return CachedProperties(MergedLinkage,
-                         L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
+                         L.hasLocalOrUnnamedType() || R.hasLocalOrUnnamedType());
   }
 };
 }

+ 3 - 3
tools/clang/lib/CodeGen/CGExpr.cpp

@@ -484,9 +484,9 @@ static llvm::Value *emitHash16Bytes(CGBuilderTy &Builder, llvm::Value *Low,
 }
 
 bool CodeGenFunction::sanitizePerformTypeCheck() const {
-  return SanOpts.has(SanitizerKind::Null) |
-         SanOpts.has(SanitizerKind::Alignment) |
-         SanOpts.has(SanitizerKind::ObjectSize) |
+  return SanOpts.has(SanitizerKind::Null) ||
+         SanOpts.has(SanitizerKind::Alignment) ||
+         SanOpts.has(SanitizerKind::ObjectSize) ||
          SanOpts.has(SanitizerKind::Vptr);
 }
 

+ 2 - 2
tools/clang/lib/Lex/PPExpressions.cpp

@@ -544,7 +544,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
     case tok::ampamp:         // Logical && does not do UACs.
       break;                  // No UAC
     default:
-      Res.setIsUnsigned(LHS.isUnsigned()|RHS.isUnsigned());
+      Res.setIsUnsigned(LHS.isUnsigned() || RHS.isUnsigned());
       // If this just promoted something from signed to unsigned, and if the
       // value was negative, warn about it.
       if (ValueLive && Res.isUnsigned()) {
@@ -701,7 +701,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
 
       // Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
       // either operand is unsigned.
-      Res.setIsUnsigned(RHS.isUnsigned() | AfterColonVal.isUnsigned());
+      Res.setIsUnsigned(RHS.isUnsigned() || AfterColonVal.isUnsigned());
 
       // Figure out the precedence of the token after the : part.
       PeekPrec = getPrecedence(PeekTok.getKind());

+ 1 - 1
tools/clang/lib/SPIRV/DeclResultIdMapper.h

@@ -933,7 +933,7 @@ bool DeclResultIdMapper::decorateStageIOLocations() {
     return true;
   }
   // Try both input and output even if input location assignment failed
-  return finalizeStageIOLocations(true) & finalizeStageIOLocations(false);
+  return (int) finalizeStageIOLocations(true) & (int) finalizeStageIOLocations(false);
 }
 
 bool DeclResultIdMapper::isInputStorageClass(const StageVar &v) {

+ 4 - 2
utils/TableGen/CodeGenDAGPatterns.cpp

@@ -974,8 +974,10 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
     unsigned OResNo = 0;
     TreePatternNode *OtherNode =
       getOperandNum(x.SDTCisSameAs_Info.OtherOperandNum, N, NodeInfo, OResNo);
-    return NodeToApply->UpdateNodeType(ResNo, OtherNode->getExtType(OResNo),TP)|
-           OtherNode->UpdateNodeType(OResNo,NodeToApply->getExtType(ResNo),TP);
+    return (int) NodeToApply->UpdateNodeType(ResNo,
+                                             OtherNode->getExtType(OResNo),TP) |
+           (int) OtherNode->UpdateNodeType(OResNo,
+                                           NodeToApply->getExtType(ResNo),TP);
   }
   case SDTCisVTSmallerThanOp: {
     // The NodeToApply must be a leaf node that is a VT.  OtherOperandNum must

+ 1 - 1
utils/TableGen/SequenceToOffsetTable.h

@@ -38,7 +38,7 @@ class SequenceToOffsetTable {
 
   // Define a comparator for SeqT that sorts a suffix immediately before a
   // sequence with that suffix.
-  struct SeqLess : public std::binary_function<SeqT, SeqT, bool> {
+  struct SeqLess {
     Less L;
     bool operator()(const SeqT &A, const SeqT &B) const {
       return std::lexicographical_compare(A.rbegin(), A.rend(),