[llvm] 511b4dd - [llvm] Add LLVM_CTOR_NODISCARD to WithColor
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 16:52:06 PDT 2023
Author: Jonas Devlieghere
Date: 2023-09-05T16:47:41-07:00
New Revision: 511b4dd928e3e625bc6c59ab50c3ac5fa6a8bac3
URL: https://github.com/llvm/llvm-project/commit/511b4dd928e3e625bc6c59ab50c3ac5fa6a8bac3
DIFF: https://github.com/llvm/llvm-project/commit/511b4dd928e3e625bc6c59ab50c3ac5fa6a8bac3.diff
LOG: [llvm] Add LLVM_CTOR_NODISCARD to WithColor
Similarly to WithMarkup, add LLVM_CTOR_NODISCARD to the WithColor
constructor.
Added:
Modified:
llvm/include/llvm/Support/WithColor.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/WithColor.h b/llvm/include/llvm/Support/WithColor.h
index 20540059284766..e80e5d469363db 100644
--- a/llvm/include/llvm/Support/WithColor.h
+++ b/llvm/include/llvm/Support/WithColor.h
@@ -9,6 +9,7 @@
#ifndef LLVM_SUPPORT_WITHCOLOR_H
#define LLVM_SUPPORT_WITHCOLOR_H
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
@@ -58,8 +59,8 @@ class WithColor {
/// @param OS The output stream
/// @param S Symbolic name for syntax element to color
/// @param Mode Enable, disable or compute whether to use colors.
- WithColor(raw_ostream &OS, HighlightColor S,
- ColorMode Mode = ColorMode::Auto);
+ LLVM_CTOR_NODISCARD WithColor(raw_ostream &OS, HighlightColor S,
+ ColorMode Mode = ColorMode::Auto);
/// To be used like this: WithColor(OS, raw_ostream::BLACK) << "text";
/// @param OS The output stream
/// @param Color ANSI color to use, the special SAVEDCOLOR can be used to
@@ -67,10 +68,9 @@ class WithColor {
/// @param Bold Bold/brighter text, default false
/// @param BG If true, change the background, default: change foreground
/// @param Mode Enable, disable or compute whether to use colors.
- WithColor(raw_ostream &OS,
- raw_ostream::Colors Color = raw_ostream::SAVEDCOLOR,
- bool Bold = false, bool BG = false,
- ColorMode Mode = ColorMode::Auto)
+ LLVM_CTOR_NODISCARD WithColor(
+ raw_ostream &OS, raw_ostream::Colors Color = raw_ostream::SAVEDCOLOR,
+ bool Bold = false, bool BG = false, ColorMode Mode = ColorMode::Auto)
: OS(OS), Mode(Mode) {
changeColor(Color, Bold, BG);
}
More information about the llvm-commits
mailing list