From ecaad4a87611c0c6e0d6e448906d15b6fec06dc9 Mon Sep 17 00:00:00 2001 From: Mogball Date: Wed, 1 Dec 2021 18:12:37 +0000 Subject: [PATCH] [mlir][ods][nfc] fix gcc-5 build --- mlir/include/mlir/TableGen/Class.h | 10 ++++++++-- mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mlir/include/mlir/TableGen/Class.h b/mlir/include/mlir/TableGen/Class.h index ea56158fe331..11fa261faccf 100644 --- a/mlir/include/mlir/TableGen/Class.h +++ b/mlir/include/mlir/TableGen/Class.h @@ -556,9 +556,15 @@ class Class { 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 + /// or `struct`. Also, prevent this from being mistaken as a move constructor + /// candidate. + template ::value>> Class(NameT &&name, bool isStruct = false) : className(stringify(std::forward(name))), isStruct(isStruct) {} diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp index 8402877d9cb2..372b6690eeae 100644 --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -251,7 +251,7 @@ void DefGen::emitVerifier() { void DefGen::emitParserPrinter() { auto *mnemonic = defCls.addStaticMethod( "::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())