From 5146f84fd616084fb63025a3e8a172179137b1ce Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 9 Aug 2022 07:16:34 +0000 Subject: [PATCH] LLVM_NODISCARD => [[nodiscard]]. NFC --- lldb/include/lldb/Interpreter/CommandInterpreter.h | 2 +- .../Plugins/ExpressionParser/Clang/CppModuleConfiguration.h | 2 +- .../ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp | 2 +- mlir/include/mlir/Analysis/AliasAnalysis.h | 12 ++++++------ mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h | 2 +- mlir/include/mlir/IR/OpImplementation.h | 2 +- mlir/include/mlir/Support/LogicalResult.h | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 55971136..0f137a7 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -588,7 +588,7 @@ public: /// \return True if the exit code was successfully set; false if the /// interpreter doesn't allow custom exit codes. /// \see AllowExitCodeOnQuit - LLVM_NODISCARD bool SetQuitExitCode(int exit_code); + [[nodiscard]] bool SetQuitExitCode(int exit_code); /// Returns the exit code that the user has specified when running the /// 'quit' command. diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h index 5db8abb..3a87570 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h @@ -30,7 +30,7 @@ class CppModuleConfiguration { public: /// Try setting the path. Returns true if the path was set and false if /// the path was already set. - LLVM_NODISCARD bool TrySet(llvm::StringRef path); + [[nodiscard]] bool TrySet(llvm::StringRef path); /// Return the path if there is one. llvm::StringRef Get() const { assert(m_valid && "Called Get() on an invalid SetOncePath?"); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index dfa2d4c..d71ce0f 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -503,7 +503,7 @@ ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread( /// \param msg The message to add to the log. /// \return An invalid ThreadSP to be returned from /// GetBacktraceThreadFromException. -LLVM_NODISCARD +[[nodiscard]] static ThreadSP FailExceptionParsing(llvm::StringRef msg) { Log *log = GetLog(LLDBLog::Language); LLDB_LOG(log, "Failed getting backtrace from exception: {0}", msg); diff --git a/mlir/include/mlir/Analysis/AliasAnalysis.h b/mlir/include/mlir/Analysis/AliasAnalysis.h index fd36b2d..5beae79 100644 --- a/mlir/include/mlir/Analysis/AliasAnalysis.h +++ b/mlir/include/mlir/Analysis/AliasAnalysis.h @@ -87,7 +87,7 @@ inline raw_ostream &operator<<(raw_ostream &os, const AliasResult &result) { /// The possible results of whether a memory access modifies or references /// a memory location. The possible results are: no access at all, a /// modification, a reference, or both a modification and a reference. -class LLVM_NODISCARD ModRefResult { +class [[nodiscard]] ModRefResult { /// Note: This is a simplified version of the ModRefResult in /// `llvm/Analysis/AliasAnalysis.h`, and namely removes the `Must` concept. If /// this becomes useful/necessary we should add it here. @@ -123,23 +123,23 @@ public: static ModRefResult getModAndRef() { return Kind::ModRef; } /// Returns if this result does not modify or reference memory. - LLVM_NODISCARD bool isNoModRef() const { return kind == Kind::NoModRef; } + [[nodiscard]] bool isNoModRef() const { return kind == Kind::NoModRef; } /// Returns if this result modifies memory. - LLVM_NODISCARD bool isMod() const { + [[nodiscard]] bool isMod() const { return static_cast(kind) & static_cast(Kind::Mod); } /// Returns if this result references memory. - LLVM_NODISCARD bool isRef() const { + [[nodiscard]] bool isRef() const { return static_cast(kind) & static_cast(Kind::Ref); } /// Returns if this result modifies *or* references memory. - LLVM_NODISCARD bool isModOrRef() const { return kind != Kind::NoModRef; } + [[nodiscard]] bool isModOrRef() const { return kind != Kind::NoModRef; } /// Returns if this result modifies *and* references memory. - LLVM_NODISCARD bool isModAndRef() const { return kind == Kind::ModRef; } + [[nodiscard]] bool isModAndRef() const { return kind == Kind::ModRef; } /// Merge this ModRef result with `other` and return the result. ModRefResult merge(const ModRefResult &other) { diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h index 5c6177a..d7dcd84 100644 --- a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h @@ -31,7 +31,7 @@ namespace mlir { /// Transform IR operations containing other operations are allowed to do either /// with the results of the nested transformations, but must propagate definite /// failures as their diagnostics have been already reported to the user. -class LLVM_NODISCARD DiagnosedSilenceableFailure { +class [[nodiscard]] DiagnosedSilenceableFailure { public: explicit DiagnosedSilenceableFailure(LogicalResult result) : result(result) {} DiagnosedSilenceableFailure(const DiagnosedSilenceableFailure &) = delete; diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index 6224230..2d3431a 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -726,7 +726,7 @@ public: bool hasValue() const { return result.has_value(); } /// Return the result of the switch. - LLVM_NODISCARD operator ResultT() { + [[nodiscard]] operator ResultT() { if (!result) return parser.emitError(loc, "unexpected keyword: ") << keyword; return std::move(*result); diff --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h index 5a1462a..4967b92 100644 --- a/mlir/include/mlir/Support/LogicalResult.h +++ b/mlir/include/mlir/Support/LogicalResult.h @@ -23,7 +23,7 @@ namespace mlir { /// this class, it generally shouldn't be used as the result of functions that /// very frequently have the result ignored. This class is intended to be used /// in conjunction with the utility functions below. -struct LLVM_NODISCARD LogicalResult { +struct [[nodiscard]] LogicalResult { public: /// If isSuccess is true a `success` result is generated, otherwise a /// 'failure' result is generated. @@ -75,7 +75,7 @@ inline bool failed(LogicalResult result) { return result.failed(); } /// value of type `T`. This allows for integrating with LogicalResult, while /// also providing a value on the success path. template -class LLVM_NODISCARD FailureOr : public Optional { +class [[nodiscard]] FailureOr : public Optional { public: /// Allow constructing from a LogicalResult. The result *must* be a failure. /// Success results should use a proper instance of type `T`. @@ -110,7 +110,7 @@ private: /// swallowed up in boilerplate without this, so we provide this for narrow /// cases where it is important. /// -class LLVM_NODISCARD ParseResult : public LogicalResult { +class [[nodiscard]] ParseResult : public LogicalResult { public: ParseResult(LogicalResult result = success()) : LogicalResult(result) {} -- 2.7.4