[mlir][ods][nfc] fix gcc-5 build
GitOrigin-RevId: ecaad4a87611c0c6e0d6e448906d15b6fec06dc9
diff --git a/include/mlir/TableGen/Class.h b/include/mlir/TableGen/Class.h
index ea56158..11fa261 100644
--- a/include/mlir/TableGen/Class.h
+++ b/include/mlir/TableGen/Class.h
@@ -556,9 +556,15 @@
public:
virtual ~Class() = default;
+ /// Explicitly delete the copy constructor. This is to work around a gcc-5 bug
+ /// with std::is_trivially_move_constructible.
+ Class(const Class &) = delete;
+
/// Create a class with a name, and whether it should be declared as a `class`
- /// or `struct`.
- template <typename NameT>
+ /// or `struct`. Also, prevent this from being mistaken as a move constructor
+ /// candidate.
+ template <typename NameT, typename = typename std::enable_if_t<
+ !std::is_same<NameT, Class>::value>>
Class(NameT &&name, bool isStruct = false)
: className(stringify(std::forward<NameT>(name))), isStruct(isStruct) {}
diff --git a/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index 8402877..372b669 100644
--- a/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -251,7 +251,7 @@
void DefGen::emitParserPrinter() {
auto *mnemonic = defCls.addStaticMethod<Method::Constexpr>(
"::llvm::StringLiteral", "getMnemonic");
- mnemonic->body().indent() << strfmt("return \"{0}\";", *def.getMnemonic());
+ mnemonic->body().indent() << strfmt("return {\"{0}\"};", *def.getMnemonic());
// Declare the parser and printer, if needed.
if (!def.needsParserPrinter() && !def.hasGeneratedParser() &&
!def.hasGeneratedPrinter())