Skip to content

[llvm] Add LLVM_CTOR_NODISCARD #65418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions llvm/include/llvm/MC/MCInstPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstdint>

Expand Down Expand Up @@ -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 <typename T> WithMarkup &operator<<(T &O) {
Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/Support/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down