From e49c3c8f2ef97bdf256ca76f3d001eeb79361d56 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 10 Jan 2020 14:58:07 +0100 Subject: [PATCH] Sprinkle some constexpr on default ctors so the compiler can diagnose unused instances. NFCI. --- mlir/include/mlir/IR/Attributes.h | 2 +- mlir/include/mlir/IR/Types.h | 2 +- mlir/include/mlir/IR/Value.h | 2 +- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 1 - mlir/lib/Dialect/VectorOps/VectorOps.cpp | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index 64b8063bdcb5..49f42affb566 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -69,7 +69,7 @@ public: using ImplType = AttributeStorage; using ValueType = void; - Attribute() : impl(nullptr) {} + constexpr Attribute() : impl(nullptr) {} /* implicit */ Attribute(const ImplType *impl) : impl(const_cast(impl)) {} diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h index 6246e9bedd0d..21d6493a4176 100644 --- a/mlir/include/mlir/IR/Types.h +++ b/mlir/include/mlir/IR/Types.h @@ -108,7 +108,7 @@ public: using ImplType = TypeStorage; - Type() : impl(nullptr) {} + constexpr Type() : impl(nullptr) {} /* implicit */ Type(const ImplType *impl) : impl(const_cast(impl)) {} diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index d4869f242c0f..3fb5a91c73ae 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -70,7 +70,7 @@ public: using ImplType = llvm::PointerIntPair; public: - Value(std::nullptr_t) : ownerAndKind() {} + constexpr Value(std::nullptr_t) : ownerAndKind() {} Value(ImplType ownerAndKind = {}) : ownerAndKind(ownerAndKind) {} Value(const Value &) = default; Value &operator=(const Value &) = default; diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index 1de7bceaf232..ff20e091f91b 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -1470,7 +1470,6 @@ spirv::ConstantOp spirv::ConstantOp::getZero(Type type, Location loc, OpBuilder *builder) { if (auto intType = type.dyn_cast()) { unsigned width = intType.getWidth(); - Attribute val; if (width == 1) return builder->create(loc, type, builder->getBoolAttr(false)); diff --git a/mlir/lib/Dialect/VectorOps/VectorOps.cpp b/mlir/lib/Dialect/VectorOps/VectorOps.cpp index 4afd05758ed3..92a230eb5d1b 100644 --- a/mlir/lib/Dialect/VectorOps/VectorOps.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorOps.cpp @@ -1650,7 +1650,6 @@ static ParseResult parseTupleGetOp(OpAsmParser &parser, StringRef indexAttrName = TupleGetOp::getIndexAttrName(); Type indexType = parser.getBuilder().getIndexType(); TupleType tupleType; - VectorType resultVectorType; if (parser.parseOperand(operandInfo) || parser.parseComma() || parser.parseAttribute(indexAttr, indexType, indexAttrName, result.attributes) ||