diff --git a/llvm/include/llvm/MC/MCInstPrinter.h b/llvm/include/llvm/MC/MCInstPrinter.h index 8c628256eecf4..d51379c9305cc 100644 --- a/llvm/include/llvm/MC/MCInstPrinter.h +++ b/llvm/include/llvm/MC/MCInstPrinter.h @@ -9,6 +9,7 @@ #ifndef LLVM_MC_MCINSTPRINTER_H #define LLVM_MC_MCINSTPRINTER_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/Format.h" #include @@ -97,8 +98,8 @@ class MCInstPrinter { class WithMarkup { public: - WithMarkup(raw_ostream &OS, Markup M, bool EnableMarkup, - bool EnableColor); + LLVM_CTOR_NODISCARD WithMarkup(raw_ostream &OS, Markup M, bool EnableMarkup, + bool EnableColor); ~WithMarkup(); template WithMarkup &operator<<(T &O) { diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index 10d5cec231a52..12afe90f8facd 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -307,6 +307,12 @@ #define LLVM_GSL_POINTER #endif +#if LLVM_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L +#define LLVM_CTOR_NODISCARD [[nodiscard]] +#else +#define LLVM_CTOR_NODISCARD +#endif + /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress /// pedantic diagnostics. #ifdef __GNUC__