diff --git a/mlir/examples/toy/Ch1/parser/AST.cpp b/mlir/examples/toy/Ch1/parser/AST.cpp index 7b98b017d82d..875b2e268ccd 100644 --- a/mlir/examples/toy/Ch1/parser/AST.cpp +++ b/mlir/examples/toy/Ch1/parser/AST.cpp @@ -60,7 +60,8 @@ private: } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch2/parser/AST.cpp b/mlir/examples/toy/Ch2/parser/AST.cpp index 7b98b017d82d..875b2e268ccd 100644 --- a/mlir/examples/toy/Ch2/parser/AST.cpp +++ b/mlir/examples/toy/Ch2/parser/AST.cpp @@ -60,7 +60,8 @@ private: } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch3/parser/AST.cpp b/mlir/examples/toy/Ch3/parser/AST.cpp index 7b98b017d82d..875b2e268ccd 100644 --- a/mlir/examples/toy/Ch3/parser/AST.cpp +++ b/mlir/examples/toy/Ch3/parser/AST.cpp @@ -60,7 +60,8 @@ private: } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch4/parser/AST.cpp b/mlir/examples/toy/Ch4/parser/AST.cpp index 7b98b017d82d..875b2e268ccd 100644 --- a/mlir/examples/toy/Ch4/parser/AST.cpp +++ b/mlir/examples/toy/Ch4/parser/AST.cpp @@ -60,7 +60,8 @@ private: } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp index b518a287b6e1..5c8b1bcd2101 100644 --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -104,25 +104,26 @@ struct BinaryOpLowering : public ConversionPattern { matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); - lowerOpToLoops( - op, operands, rewriter, - [loc](OpBuilder &builder, ValueRange memRefOperands, - ValueRange loopIvs) { - // Generate an adaptor for the remapped operands of the BinaryOp. This - // allows for using the nice named accessors that are generated by the - // ODS. - typename BinaryOp::Adaptor binaryAdaptor(memRefOperands); + lowerOpToLoops(op, operands, rewriter, + [loc](OpBuilder &builder, ValueRange memRefOperands, + ValueRange loopIvs) { + // Generate an adaptor for the remapped operands of the + // BinaryOp. This allows for using the nice named accessors + // that are generated by the ODS. + typename BinaryOp::Adaptor binaryAdaptor(memRefOperands); - // Generate loads for the element of 'lhs' and 'rhs' at the inner - // loop. - auto loadedLhs = builder.create( - loc, binaryAdaptor.getLhs(), loopIvs); - auto loadedRhs = builder.create( - loc, binaryAdaptor.getRhs(), loopIvs); + // Generate loads for the element of 'lhs' and 'rhs' at the + // inner loop. + auto loadedLhs = builder.create( + loc, binaryAdaptor.getLhs(), loopIvs); + auto loadedRhs = builder.create( + loc, binaryAdaptor.getRhs(), loopIvs); - // Create the binary operation performed on the loaded values. - return builder.create(loc, loadedLhs, loadedRhs); - }); + // Create the binary operation performed on the loaded + // values. + return builder.create(loc, loadedLhs, + loadedRhs); + }); return success(); } }; diff --git a/mlir/examples/toy/Ch5/parser/AST.cpp b/mlir/examples/toy/Ch5/parser/AST.cpp index 7b98b017d82d..875b2e268ccd 100644 --- a/mlir/examples/toy/Ch5/parser/AST.cpp +++ b/mlir/examples/toy/Ch5/parser/AST.cpp @@ -60,7 +60,8 @@ private: } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp index b518a287b6e1..5c8b1bcd2101 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -104,25 +104,26 @@ struct BinaryOpLowering : public ConversionPattern { matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); - lowerOpToLoops( - op, operands, rewriter, - [loc](OpBuilder &builder, ValueRange memRefOperands, - ValueRange loopIvs) { - // Generate an adaptor for the remapped operands of the BinaryOp. This - // allows for using the nice named accessors that are generated by the - // ODS. - typename BinaryOp::Adaptor binaryAdaptor(memRefOperands); + lowerOpToLoops(op, operands, rewriter, + [loc](OpBuilder &builder, ValueRange memRefOperands, + ValueRange loopIvs) { + // Generate an adaptor for the remapped operands of the + // BinaryOp. This allows for using the nice named accessors + // that are generated by the ODS. + typename BinaryOp::Adaptor binaryAdaptor(memRefOperands); - // Generate loads for the element of 'lhs' and 'rhs' at the inner - // loop. - auto loadedLhs = builder.create( - loc, binaryAdaptor.getLhs(), loopIvs); - auto loadedRhs = builder.create( - loc, binaryAdaptor.getRhs(), loopIvs); + // Generate loads for the element of 'lhs' and 'rhs' at the + // inner loop. + auto loadedLhs = builder.create( + loc, binaryAdaptor.getLhs(), loopIvs); + auto loadedRhs = builder.create( + loc, binaryAdaptor.getRhs(), loopIvs); - // Create the binary operation performed on the loaded values. - return builder.create(loc, loadedLhs, loadedRhs); - }); + // Create the binary operation performed on the loaded + // values. + return builder.create(loc, loadedLhs, + loadedRhs); + }); return success(); } }; diff --git a/mlir/examples/toy/Ch6/parser/AST.cpp b/mlir/examples/toy/Ch6/parser/AST.cpp index 7b98b017d82d..875b2e268ccd 100644 --- a/mlir/examples/toy/Ch6/parser/AST.cpp +++ b/mlir/examples/toy/Ch6/parser/AST.cpp @@ -60,7 +60,8 @@ private: } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp index b518a287b6e1..5c8b1bcd2101 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -104,25 +104,26 @@ struct BinaryOpLowering : public ConversionPattern { matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); - lowerOpToLoops( - op, operands, rewriter, - [loc](OpBuilder &builder, ValueRange memRefOperands, - ValueRange loopIvs) { - // Generate an adaptor for the remapped operands of the BinaryOp. This - // allows for using the nice named accessors that are generated by the - // ODS. - typename BinaryOp::Adaptor binaryAdaptor(memRefOperands); + lowerOpToLoops(op, operands, rewriter, + [loc](OpBuilder &builder, ValueRange memRefOperands, + ValueRange loopIvs) { + // Generate an adaptor for the remapped operands of the + // BinaryOp. This allows for using the nice named accessors + // that are generated by the ODS. + typename BinaryOp::Adaptor binaryAdaptor(memRefOperands); - // Generate loads for the element of 'lhs' and 'rhs' at the inner - // loop. - auto loadedLhs = builder.create( - loc, binaryAdaptor.getLhs(), loopIvs); - auto loadedRhs = builder.create( - loc, binaryAdaptor.getRhs(), loopIvs); + // Generate loads for the element of 'lhs' and 'rhs' at the + // inner loop. + auto loadedLhs = builder.create( + loc, binaryAdaptor.getLhs(), loopIvs); + auto loadedRhs = builder.create( + loc, binaryAdaptor.getRhs(), loopIvs); - // Create the binary operation performed on the loaded values. - return builder.create(loc, loadedLhs, loadedRhs); - }); + // Create the binary operation performed on the loaded + // values. + return builder.create(loc, loadedLhs, + loadedRhs); + }); return success(); } }; diff --git a/mlir/examples/toy/Ch7/parser/AST.cpp b/mlir/examples/toy/Ch7/parser/AST.cpp index 80c87dc21b48..5ee5c4e02716 100644 --- a/mlir/examples/toy/Ch7/parser/AST.cpp +++ b/mlir/examples/toy/Ch7/parser/AST.cpp @@ -62,7 +62,8 @@ private: } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/include/mlir/Analysis/AliasAnalysis.h b/mlir/include/mlir/Analysis/AliasAnalysis.h index 4fc31f3dbf9e..fd36b2db3e50 100644 --- a/mlir/include/mlir/Analysis/AliasAnalysis.h +++ b/mlir/include/mlir/Analysis/AliasAnalysis.h @@ -193,7 +193,8 @@ struct AliasAnalysisTraits { /// `ImplT`. A model is instantiated for each alias analysis implementation /// to implement the `Concept` without the need for the derived /// implementation to inherit from the `Concept` class. - template class Model final : public Concept { + template + class Model final : public Concept { public: explicit Model(ImplT &&impl) : impl(std::forward(impl)) {} ~Model() override = default; diff --git a/mlir/include/mlir/Analysis/CallGraph.h b/mlir/include/mlir/Analysis/CallGraph.h index 9238b95ccc0c..fe7a6faffb4c 100644 --- a/mlir/include/mlir/Analysis/CallGraph.h +++ b/mlir/include/mlir/Analysis/CallGraph.h @@ -221,7 +221,8 @@ private: namespace llvm { // Provide graph traits for traversing call graphs using standard graph // traversals. -template <> struct GraphTraits { +template <> +struct GraphTraits { using NodeRef = mlir::CallGraphNode *; static NodeRef getEntryNode(NodeRef node) { return node; } diff --git a/mlir/include/mlir/Bindings/Python/PybindAdaptors.h b/mlir/include/mlir/Bindings/Python/PybindAdaptors.h index 582855a33afb..588721c3f77c 100644 --- a/mlir/include/mlir/Bindings/Python/PybindAdaptors.h +++ b/mlir/include/mlir/Bindings/Python/PybindAdaptors.h @@ -252,7 +252,7 @@ public: } template - pure_subclass &def(const char *name, Func &&f, const Extra &... extra) { + pure_subclass &def(const char *name, Func &&f, const Extra &...extra) { py::cpp_function cf( std::forward(f), py::name(name), py::is_method(thisClass), py::sibling(py::getattr(thisClass, name, py::none())), extra...); @@ -262,7 +262,7 @@ public: template pure_subclass &def_property_readonly(const char *name, Func &&f, - const Extra &... extra) { + const Extra &...extra) { py::cpp_function cf( std::forward(f), py::name(name), py::is_method(thisClass), py::sibling(py::getattr(thisClass, name, py::none())), extra...); @@ -274,7 +274,7 @@ public: template pure_subclass &def_staticmethod(const char *name, Func &&f, - const Extra &... extra) { + const Extra &...extra) { static_assert(!std::is_member_function_pointer::value, "def_staticmethod(...) called with a non-static member " "function pointer"); @@ -287,7 +287,7 @@ public: template pure_subclass &def_classmethod(const char *name, Func &&f, - const Extra &... extra) { + const Extra &...extra) { static_assert(!std::is_member_function_pointer::value, "def_classmethod(...) called with a non-static member " "function pointer"); diff --git a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h b/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h index 92e3f80b2be3..fe543886152c 100644 --- a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h +++ b/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h @@ -21,7 +21,8 @@ namespace mlir { class ModuleOp; -template class OperationPass; +template +class OperationPass; std::unique_ptr> createConvertVulkanLaunchFuncToVulkanCallsPass(); diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h index c5f6c129feea..64a37cffa280 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h @@ -49,7 +49,8 @@ public: /// Allow the given dialects. /// /// This function adds one or multiple ALLOW entries. - template void allowDialect() { + template + void allowDialect() { // The following expands a call to allowDialectImpl for each dialect // in 'DialectTs'. This magic is necessary due to a limitation in the places // that a parameter pack can be expanded in c++11. @@ -60,7 +61,8 @@ public: /// Deny the given dialects. /// /// This function adds one or multiple DENY entries. - template void denyDialect() { + template + void denyDialect() { // FIXME: In c++17 this can be simplified by using 'fold expressions'. (void)std::initializer_list{0, (denyDialectImpl(), 0)...}; } @@ -78,7 +80,8 @@ public: /// Allow the given ops. /// /// This function adds one or multiple ALLOW entries. - template void allowOperation() { + template + void allowOperation() { // FIXME: In c++17 this can be simplified by using 'fold expressions'. (void)std::initializer_list{0, (allowOperationImpl(), 0)...}; } @@ -86,7 +89,8 @@ public: /// Deny the given ops. /// /// This function adds one or multiple DENY entries. - template void denyOperation() { + template + void denyOperation() { // FIXME: In c++17 this can be simplified by using 'fold expressions'. (void)std::initializer_list{0, (denyOperationImpl(), 0)...}; } @@ -135,22 +139,26 @@ private: } /// Allow a dialect. - template void allowDialectImpl() { + template + void allowDialectImpl() { allowDialect(DialectT::getDialectNamespace()); } /// Deny a dialect. - template void denyDialectImpl() { + template + void denyDialectImpl() { denyDialect(DialectT::getDialectNamespace()); } /// Allow an op. - template void allowOperationImpl() { + template + void allowOperationImpl() { allowOperation(OpTy::getOperationName()); } /// Deny an op. - template void denyOperationImpl() { + template + void denyOperationImpl() { denyOperation(OpTy::getOperationName()); } diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 2b5cd2a8e965..190b6649a95f 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -24,7 +24,8 @@ #include namespace llvm { -template class Expected; +template +class Expected; class Module; class ExecutionEngine; class JITEventListener; diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensorUtils.h b/mlir/include/mlir/ExecutionEngine/SparseTensorUtils.h index fba501286072..2ed000224654 100644 --- a/mlir/include/mlir/ExecutionEngine/SparseTensorUtils.h +++ b/mlir/include/mlir/ExecutionEngine/SparseTensorUtils.h @@ -182,8 +182,8 @@ FOREVERY_O(DECL_SPARSEINDICES) /// Coordinate-scheme method for adding a new element. #define DECL_ADDELT(VNAME, V) \ MLIR_CRUNNERUTILS_EXPORT void *_mlir_ciface_addElt##VNAME( \ - void *coo, \ - StridedMemRefType *vref, StridedMemRefType *iref, \ + void *coo, StridedMemRefType *vref, \ + StridedMemRefType *iref, \ StridedMemRefType *pref); FOREVERY_V(DECL_ADDELT) #undef DECL_ADDELT diff --git a/mlir/include/mlir/IR/AffineExprVisitor.h b/mlir/include/mlir/IR/AffineExprVisitor.h index 74d75c218e0b..30ee1b6e0819 100644 --- a/mlir/include/mlir/IR/AffineExprVisitor.h +++ b/mlir/include/mlir/IR/AffineExprVisitor.h @@ -65,7 +65,8 @@ namespace mlir { /// just as efficient as having your own switch instruction over the instruction /// opcode. -template class AffineExprVisitor { +template +class AffineExprVisitor { //===--------------------------------------------------------------------===// // Interface code - This is the public interface of the AffineExprVisitor // that you use to visit affine expressions... diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index 6c420f13ee1d..1c38db9933d4 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -46,14 +46,18 @@ public: bool operator!() const { return impl == nullptr; } - template bool isa() const; + template + bool isa() const; template bool isa() const; template bool isa_and_nonnull() const; - template U dyn_cast() const; - template U dyn_cast_or_null() const; - template U cast() const; + template + U dyn_cast() const; + template + U dyn_cast_or_null() const; + template + U cast() const; // Support dyn_cast'ing Attribute to itself. static bool classof(Attribute) { return true; } @@ -106,7 +110,8 @@ inline raw_ostream &operator<<(raw_ostream &os, Attribute attr) { return os; } -template bool Attribute::isa() const { +template +bool Attribute::isa() const { assert(impl && "isa<> used on a null attribute."); return U::classof(*this); } @@ -121,13 +126,16 @@ bool Attribute::isa_and_nonnull() const { return impl && isa(); } -template U Attribute::dyn_cast() const { +template +U Attribute::dyn_cast() const { return isa() ? U(impl) : U(nullptr); } -template U Attribute::dyn_cast_or_null() const { +template +U Attribute::dyn_cast_or_null() const { return (impl && isa()) ? U(impl) : U(nullptr); } -template U Attribute::cast() const { +template +U Attribute::cast() const { assert(isa()); return U(impl); } @@ -248,7 +256,8 @@ using IsMutable = detail::StorageUserTrait::IsMutable; namespace llvm { // Attribute hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::Attribute getEmptyKey() { auto *pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::Attribute(static_cast(pointer)); @@ -280,7 +289,8 @@ struct DenseMapInfo< }; /// Allow LLVM to steal the low bits of Attributes. -template <> struct PointerLikeTypeTraits { +template <> +struct PointerLikeTypeTraits { static inline void *getAsVoidPointer(mlir::Attribute attr) { return const_cast(attr.getAsOpaquePointer()); } @@ -291,7 +301,8 @@ template <> struct PointerLikeTypeTraits { mlir::AttributeStorage *>::NumLowBitsAvailable; }; -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::NamedAttribute getEmptyKey() { auto emptyAttr = llvm::DenseMapInfo::getEmptyKey(); return mlir::NamedAttribute(emptyAttr, emptyAttr); diff --git a/mlir/include/mlir/IR/BlockAndValueMapping.h b/mlir/include/mlir/IR/BlockAndValueMapping.h index e6aea7968314..8134902bfd64 100644 --- a/mlir/include/mlir/IR/BlockAndValueMapping.h +++ b/mlir/include/mlir/IR/BlockAndValueMapping.h @@ -63,7 +63,8 @@ public: /// Lookup a mapped value within the map. This asserts the provided value /// exists within the map. - template T lookup(T from) const { + template + T lookup(T from) const { auto result = lookupOrNull(from); assert(result && "expected 'from' to be contained within the map"); return result; diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h index 78c4e2026ab5..dafe75ed2acd 100644 --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -52,7 +52,6 @@ class PredecessorIterator final static Block *unwrap(BlockOperand &value); public: - /// Initializes the operand type iterator to the specified operand iterator. PredecessorIterator(ValueUseIterator it) : llvm::mapped_iterator, @@ -162,7 +161,6 @@ class op_iterator static OpT unwrap(Operation &op) { return cast(op); } public: - /// Initializes the iterator to the specified filter iterator. op_iterator(op_filter_iterator it) : llvm::mapped_iterator, @@ -225,7 +223,8 @@ protected: }; } // namespace ilist_detail -template <> struct ilist_traits<::mlir::Operation> { +template <> +struct ilist_traits<::mlir::Operation> { using Operation = ::mlir::Operation; using op_iterator = simple_ilist::iterator; diff --git a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h index 80ff95eca3ca..e4da88f300b4 100644 --- a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h +++ b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h @@ -76,7 +76,8 @@ public: } /// Access the element at the given index. - template T at(uint64_t index) const { + template + T at(uint64_t index) const { if (isSplat) index = 0; return isContiguous ? conState.at(index) : nonConState.at(index); @@ -93,7 +94,8 @@ private: ContiguousState(const void *firstEltPtr) : firstEltPtr(firstEltPtr) {} /// Access the element at the given index. - template const T &at(uint64_t index) const { + template + const T &at(uint64_t index) const { return *(reinterpret_cast(firstEltPtr) + index); } @@ -171,7 +173,8 @@ private: NonContiguousState(NonContiguousState &&other) = default; /// Access the element at the given index. - template T at(uint64_t index) const { + template + T at(uint64_t index) const { auto *valueIt = static_cast *>(iterator.get()); return valueIt->at(index); } diff --git a/mlir/include/mlir/IR/BuiltinAttributes.h b/mlir/include/mlir/IR/BuiltinAttributes.h index f22f66fd6ac2..a88dc7af9985 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.h +++ b/mlir/include/mlir/IR/BuiltinAttributes.h @@ -61,7 +61,8 @@ protected: }; /// Type trait detector that checks if a given type T is a complex type. -template struct is_complex_t : public std::false_type {}; +template +struct is_complex_t : public std::false_type {}; template struct is_complex_t> : public std::true_type {}; } // namespace detail @@ -81,7 +82,8 @@ public: /// floating point type that can be used to access the underlying element /// types of a DenseElementsAttr. // TODO: Use std::disjunction when C++17 is supported. - template struct is_valid_cpp_fp_type { + template + struct is_valid_cpp_fp_type { /// The type is a valid floating point type if it is a builtin floating /// point type, or is a potentially user defined floating point type. The /// latter allows for supporting users that have custom types defined for diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h index f17ce961023d..0494cdaca034 100644 --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -201,9 +201,7 @@ public: /// Stream in an Operation. Diagnostic &operator<<(Operation &val); - Diagnostic &operator<<(Operation *val) { - return *this << *val; - } + Diagnostic &operator<<(Operation *val) { return *this << *val; } /// Append an operation with the given printing flags. Diagnostic &appendOp(Operation &val, const OpPrintingFlags &flags); @@ -229,12 +227,13 @@ public: /// Append arguments to the diagnostic. template - Diagnostic &append(Arg1 &&arg1, Arg2 &&arg2, Args &&... args) { + Diagnostic &append(Arg1 &&arg1, Arg2 &&arg2, Args &&...args) { append(std::forward(arg1)); return append(std::forward(arg2), std::forward(args)...); } /// Append one argument to the diagnostic. - template Diagnostic &append(Arg &&arg) { + template + Diagnostic &append(Arg &&arg) { *this << std::forward(arg); return *this; } @@ -323,21 +322,25 @@ public: } /// Stream operator for new diagnostic arguments. - template InFlightDiagnostic &operator<<(Arg &&arg) & { + template + InFlightDiagnostic &operator<<(Arg &&arg) & { return append(std::forward(arg)); } - template InFlightDiagnostic &&operator<<(Arg &&arg) && { + template + InFlightDiagnostic &&operator<<(Arg &&arg) && { return std::move(append(std::forward(arg))); } /// Append arguments to the diagnostic. - template InFlightDiagnostic &append(Args &&... args) & { + template + InFlightDiagnostic &append(Args &&...args) & { assert(isActive() && "diagnostic not active"); if (isInFlight()) impl->append(std::forward(args)...); return *this; } - template InFlightDiagnostic &&append(Args &&... args) && { + template + InFlightDiagnostic &&append(Args &&...args) && { return std::move(append(std::forward(args)...)); } @@ -483,19 +486,19 @@ InFlightDiagnostic emitRemark(Location loc, const Twine &message); /// the diagnostic arguments directly instead of relying on the returned /// InFlightDiagnostic. template -LogicalResult emitOptionalError(Optional loc, Args &&... args) { +LogicalResult emitOptionalError(Optional loc, Args &&...args) { if (loc) return emitError(*loc).append(std::forward(args)...); return failure(); } template -LogicalResult emitOptionalWarning(Optional loc, Args &&... args) { +LogicalResult emitOptionalWarning(Optional loc, Args &&...args) { if (loc) return emitWarning(*loc).append(std::forward(args)...); return failure(); } template -LogicalResult emitOptionalRemark(Optional loc, Args &&... args) { +LogicalResult emitOptionalRemark(Optional loc, Args &&...args) { if (loc) return emitRemark(*loc).append(std::forward(args)...); return failure(); @@ -520,7 +523,8 @@ public: protected: /// Set the handler to manage via RAII. - template void setHandler(FuncTy &&handler) { + template + void setHandler(FuncTy &&handler) { auto &diagEngine = ctx->getDiagEngine(); if (handlerID) diagEngine.eraseHandler(handlerID); diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h index ee14ec088af4..d09d96d21d15 100644 --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -161,7 +161,8 @@ public: auto it = registeredInterfaces.find(interfaceID); return it != registeredInterfaces.end() ? it->getSecond().get() : nullptr; } - template const InterfaceT *getRegisteredInterface() { + template + const InterfaceT *getRegisteredInterface() { return static_cast( getRegisteredInterface(InterfaceT::getInterfaceID())); } @@ -201,13 +202,15 @@ protected: /// This method is used by derived classes to add their operations to the set. /// - template void addOperations() { + template + void addOperations() { (void)std::initializer_list{ 0, (RegisteredOperationName::insert(*this), 0)...}; } /// Register a set of type classes with this dialect. - template void addTypes() { + template + void addTypes() { (void)std::initializer_list{0, (addType(), 0)...}; } @@ -217,7 +220,8 @@ protected: void addType(TypeID typeID, AbstractType &&typeInfo); /// Register a set of attribute classes with this dialect. - template void addAttributes() { + template + void addAttributes() { (void)std::initializer_list{0, (addAttribute(), 0)...}; } @@ -237,14 +241,16 @@ private: void operator=(Dialect &) = delete; /// Register an attribute instance with this dialect. - template void addAttribute() { + template + void addAttribute() { // Add this attribute to the dialect and register it with the uniquer. addAttribute(T::getTypeID(), AbstractAttribute::get(*this)); detail::AttributeUniquer::registerAttribute(context); } /// Register a type instance with this dialect. - template void addType() { + template + void addType() { // Add this type to the dialect and register it with the uniquer. addType(T::getTypeID(), AbstractType::get(*this)); detail::TypeUniquer::registerType(context); diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h index 8649e48dedfc..2b3aa1211455 100644 --- a/mlir/include/mlir/IR/DialectInterface.h +++ b/mlir/include/mlir/IR/DialectInterface.h @@ -126,10 +126,12 @@ protected: }; /// Iterator access to the held interfaces. - template iterator interface_begin() const { + template + iterator interface_begin() const { return iterator(orderedInterfaces.begin()); } - template iterator interface_end() const { + template + iterator interface_end() const { return iterator(orderedInterfaces.end()); } diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h index 5d6aaea2388d..082e8bff7816 100644 --- a/mlir/include/mlir/IR/IntegerSet.h +++ b/mlir/include/mlir/IR/IntegerSet.h @@ -128,7 +128,8 @@ inline ::llvm::hash_code hash_value(IntegerSet arg) { namespace llvm { // IntegerSet hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::IntegerSet getEmptyKey() { auto *pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::IntegerSet(static_cast(pointer)); diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h index 16cd3889e576..424d93ddf6c6 100644 --- a/mlir/include/mlir/IR/Location.h +++ b/mlir/include/mlir/IR/Location.h @@ -62,9 +62,18 @@ public: LocationAttr *operator->() const { return const_cast(&impl); } /// Type casting utilities on the underlying location. - template bool isa() const { return impl.isa(); } - template U dyn_cast() const { return impl.dyn_cast(); } - template U cast() const { return impl.cast(); } + template + bool isa() const { + return impl.isa(); + } + template + U dyn_cast() const { + return impl.dyn_cast(); + } + template + U cast() const { + return impl.cast(); + } /// Comparison operators. bool operator==(Location rhs) const { return impl == rhs.impl; } @@ -128,7 +137,8 @@ inline OpaqueLoc OpaqueLoc::get(T underlyingLocation, MLIRContext *context) { namespace llvm { // Type hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::Location getEmptyKey() { auto *pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::Location::getFromOpaquePointer(pointer); @@ -146,7 +156,8 @@ template <> struct DenseMapInfo { }; /// We align LocationStorage by 8, so allow LLVM to steal the low bits. -template <> struct PointerLikeTypeTraits { +template <> +struct PointerLikeTypeTraits { public: static inline void *getAsVoidPointer(mlir::Location I) { return const_cast(I.getAsOpaquePointer()); diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 427c606fd90e..1e8f93a89573 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -1732,14 +1732,16 @@ private: struct InterfaceTargetOrOpT { using type = typename T::ConcreteEntity; }; - template struct InterfaceTargetOrOpT { + template + struct InterfaceTargetOrOpT { using type = ConcreteType; }; /// A hook for static assertion that the external interface model T is /// targeting the concrete type of this op. The model can also be a fallback /// model that works for every op. - template static void checkInterfaceTarget() { + template + static void checkInterfaceTarget() { static_assert(std::is_same::type, ConcreteType>::value, "attaching an interface to the wrong op kind"); diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index cb240a40e0c7..c4bbac91bd93 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -151,10 +151,9 @@ public: std::enable_if_t::value> *sfinae = nullptr> void printStrippedAttrOrType(ArrayRef attrOrTypes) { - llvm::interleaveComma(attrOrTypes, getStream(), - [this](AttrOrType attrOrType) { - printStrippedAttrOrType(attrOrType); - }); + llvm::interleaveComma( + attrOrTypes, getStream(), + [this](AttrOrType attrOrType) { printStrippedAttrOrType(attrOrType); }); } /// SFINAE for printing the provided attribute in the context of an operation diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index 83dd9eab4964..825ba95bf080 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -141,7 +141,8 @@ public: /// Returns true if the operation was registered with a particular trait, e.g. /// hasTrait(). Returns false if the operation /// is unregistered. - template