diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -66,23 +66,26 @@ //===--------------------------------------------------------------------===// /// This class represents a specific pass option, with a provided data type. - template - struct Option : public detail::PassOptions::Option { + template > + struct Option : public detail::PassOptions::Option { template Option(Pass &parent, StringRef arg, Args &&... args) - : detail::PassOptions::Option(parent.passOptions, arg, - std::forward(args)...) {} - using detail::PassOptions::Option::operator=; + : detail::PassOptions::Option( + parent.passOptions, arg, std::forward(args)...) {} + using detail::PassOptions::Option::operator=; }; /// This class represents a specific pass option that contains a list of /// values of the provided data type. - template - struct ListOption : public detail::PassOptions::ListOption { + template > + struct ListOption + : public detail::PassOptions::ListOption { template ListOption(Pass &parent, StringRef arg, Args &&... args) - : detail::PassOptions::ListOption( + : detail::PassOptions::ListOption( parent.passOptions, arg, std::forward(args)...) {} - using detail::PassOptions::ListOption::operator=; + using detail::PassOptions::ListOption::operator=; }; /// Attempt to initialize the options of this pass from the given string. diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h --- a/mlir/include/mlir/Pass/PassOptions.h +++ b/mlir/include/mlir/Pass/PassOptions.h @@ -69,18 +69,6 @@ } }; - /// The specific parser to use depending on llvm::cl parser used. This is only - /// necessary because we need to provide additional methods for certain data - /// type parsers. - /// TODO(riverriddle) We should upstream the methods in GenericOptionParser to - /// avoid the need to do this. - template - using OptionParser = - std::conditional_t>::value, - GenericOptionParser, - llvm::cl::parser>; - /// Utility methods for printing option values. template static void printValue(raw_ostream &os, GenericOptionParser &parser, @@ -100,23 +88,34 @@ } public: - /// This class represents a specific pass option, with a provided data type. + /// The specific parser to use depending on llvm::cl parser used. This is only + /// necessary because we need to provide additional methods for certain data + /// type parsers. + /// TODO(riverriddle) We should upstream the methods in GenericOptionParser to + /// avoid the need to do this. template - class Option : public llvm::cl::opt>, - public OptionBase { + using OptionParser = + std::conditional_t>::value, + GenericOptionParser, + llvm::cl::parser>; + + /// This class represents a specific pass option, with a provided data type. + template > + class Option + : public llvm::cl::opt, + public OptionBase { public: template Option(PassOptions &parent, StringRef arg, Args &&... args) - : llvm::cl::opt>(arg, llvm::cl::sub(parent), - std::forward(args)...) { + : llvm::cl::opt( + arg, llvm::cl::sub(parent), std::forward(args)...) { assert(!this->isPositional() && !this->isSink() && "sink and positional options are not supported"); parent.options.push_back(this); } using llvm::cl::opt>::operator=; + OptionParser>::operator=; ~Option() override = default; private: @@ -131,22 +130,22 @@ /// Copy the value from the given option into this one. void copyValueFrom(const OptionBase &other) final { - this->setValue(static_cast &>(other).getValue()); + this->setValue(static_cast &>(other) + .getValue()); } }; /// This class represents a specific pass option that contains a list of /// values of the provided data type. - template - class ListOption : public llvm::cl::list>, - public OptionBase { + template > + class ListOption + : public llvm::cl::list, + public OptionBase { public: template ListOption(PassOptions &parent, StringRef arg, Args &&... args) - : llvm::cl::list>(arg, llvm::cl::sub(parent), - std::forward(args)...) { + : llvm::cl::list( + arg, llvm::cl::sub(parent), std::forward(args)...) { assert(!this->isPositional() && !this->isSink() && "sink and positional options are not supported"); parent.options.push_back(this); @@ -154,7 +153,7 @@ ~ListOption() override = default; /// Allow assigning from an ArrayRef. - ListOption &operator=(ArrayRef values) { + ListOption &operator=(ArrayRef values) { (*this)->assign(values.begin(), values.end()); return *this; } @@ -177,7 +176,8 @@ /// Copy the value from the given option into this one. void copyValueFrom(const OptionBase &other) final { (*this) = ArrayRef( - (ListOption &)(const_cast(other))); + (ListOption &)(const_cast( + other))); } };