Add llvm_unreachable in unreachable path to silence GCC warning (NFC)
authorMehdi Amini <aminim@google.com>
Fri, 10 May 2019 21:06:10 +0000 (14:06 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sat, 11 May 2019 02:30:06 +0000 (19:30 -0700)
    The switch is supposed to be fully covered, but GCC warns that:
     "control reaches end of non-void function"

--

PiperOrigin-RevId: 247672430

mlir/include/mlir/IR/AffineExprVisitor.h
mlir/lib/IR/AffineExpr.cpp
mlir/lib/IR/AffineMap.cpp
mlir/lib/IR/Diagnostics.cpp
mlir/lib/IR/SDBMExpr.cpp
mlir/lib/IR/Value.cpp
mlir/lib/Parser/Parser.cpp

index 0bf49ef..7b14381 100644 (file)
@@ -155,6 +155,7 @@ public:
       return static_cast<SubClass *>(this)->visitSymbolExpr(
           expr.cast<AffineSymbolExpr>());
     }
+    llvm_unreachable("Unknown AffineExpr");
   }
 
   //===--------------------------------------------------------------------===//
index e380c8d..739be15 100644 (file)
@@ -84,6 +84,7 @@ AffineExpr::replaceDimsAndSymbols(ArrayRef<AffineExpr> dimReplacements,
       return *this;
     return getAffineBinaryOpExpr(getKind(), newLHS, newRHS);
   }
+  llvm_unreachable("Unknown AffineExpr");
 }
 
 /// Returns true if this expression is made out of only symbols and
@@ -107,6 +108,7 @@ bool AffineExpr::isSymbolicOrConstant() const {
            expr.getRHS().isSymbolicOrConstant();
   }
   }
+  llvm_unreachable("Unknown AffineExpr");
 }
 
 /// Returns true if this is a pure affine expression, i.e., multiplication,
@@ -138,9 +140,10 @@ bool AffineExpr::isPureAffine() const {
            op.getRHS().template isa<AffineConstantExpr>();
   }
   }
+  llvm_unreachable("Unknown AffineExpr");
 }
 
-/// Returns the greatest known integral divisor of this affine expression.
+// Returns the greatest known integral divisor of this affine expression.
 uint64_t AffineExpr::getLargestKnownDivisor() const {
   AffineBinaryOpExpr binExpr(nullptr);
   switch (getKind()) {
@@ -166,6 +169,7 @@ uint64_t AffineExpr::getLargestKnownDivisor() const {
         binExpr.getRHS().getLargestKnownDivisor());
   }
   }
+  llvm_unreachable("Unknown AffineExpr");
 }
 
 bool AffineExpr::isMultipleOf(int64_t factor) const {
@@ -199,6 +203,7 @@ bool AffineExpr::isMultipleOf(int64_t factor) const {
            0;
   }
   }
+  llvm_unreachable("Unknown AffineExpr");
 }
 
 bool AffineExpr::isFunctionOfDim(unsigned position) const {
index f62a1c9..8039a38 100644 (file)
@@ -78,6 +78,7 @@ private:
         return attr.getInt();
       return llvm::None;
     }
+    llvm_unreachable("Unknown AffineExpr");
   }
 
   // TODO: Change these to operate on APInts too.
index 2076d17..c06539d 100644 (file)
@@ -280,6 +280,7 @@ static llvm::SourceMgr::DiagKind getDiagKind(DiagnosticSeverity kind) {
   case DiagnosticSeverity::Remark:
     return llvm::SourceMgr::DK_Remark;
   }
+  llvm_unreachable("Unknown DiagnosticSeverity");
 }
 
 SourceMgrDiagnosticHandler::SourceMgrDiagnosticHandler(llvm::SourceMgr &mgr,
@@ -426,6 +427,7 @@ static StringRef getDiagKindStr(DiagnosticSeverity kind) {
   case DiagnosticSeverity::Remark:
     return "remark";
   }
+  llvm_unreachable("Unknown DiagnosticSeverity");
 }
 
 /// Returns the expected diagnostics for the given source file.
index bb7c199..305fc31 100644 (file)
@@ -54,6 +54,7 @@ public:
     case SDBMExprKind::Constant:
       return derived->visitConstant(expr.cast<SDBMConstantExpr>());
     }
+    llvm_unreachable("Unknown SDBMExpr Kind");
   }
 
 protected:
index 5dbc72d..073c3b3 100644 (file)
@@ -37,6 +37,7 @@ Function *Value::getFunction() {
   case Value::Kind::OpResult:
     return getDefiningOp()->getFunction();
   }
+  llvm_unreachable("Unknown Value Kind");
 }
 
 Location Value::getLoc() {
@@ -54,6 +55,7 @@ Region *Value::getContainingRegion() {
   case Value::Kind::OpResult:
     return getDefiningOp()->getContainingRegion();
   }
+  llvm_unreachable("Unknown Value Kind");
 }
 
 //===----------------------------------------------------------------------===//
index 59ff337..5ff6c9c 100644 (file)
@@ -1744,6 +1744,7 @@ AffineExpr AffineParser::getAffineBinaryOpExpr(AffineHighPrecOp op,
     llvm_unreachable("can't create affine expression for null high prec op");
     return nullptr;
   }
+  llvm_unreachable("Unknown AffineHighPrecOp");
 }
 
 /// Create an affine binary low precedence op expression (add, sub).
@@ -1758,6 +1759,7 @@ AffineExpr AffineParser::getAffineBinaryOpExpr(AffineLowPrecOp op,
     llvm_unreachable("can't create affine expression for null low prec op");
     return nullptr;
   }
+  llvm_unreachable("Unknown AffineLowPrecOp");
 }
 
 /// Consume this token if it is a lower precedence affine op (there are only