Author: Fangrui Song Date: 2022-08-09T07:16:34Z New Revision: 5146f84fd616084fb63025a3e8a172179137b1ce
URL: https://github.com/llvm/llvm-project/commit/5146f84fd616084fb63025a3e8a172179137b1ce DIFF: https://github.com/llvm/llvm-project/commit/5146f84fd616084fb63025a3e8a172179137b1ce.diff LOG: LLVM_NODISCARD => [[nodiscard]]. NFC Added: Modified: lldb/include/lldb/Interpreter/CommandInterpreter.h lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp mlir/include/mlir/Analysis/AliasAnalysis.h mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h mlir/include/mlir/IR/OpImplementation.h mlir/include/mlir/Support/LogicalResult.h Removed: ################################################################################ diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 55971136b63b..0f137a7b3c49 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -588,7 +588,7 @@ class CommandInterpreter : public Broadcaster, /// \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 5db8abbdbdf3..3a87570bf804 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 dfa2d4c05126..d71ce0faa7b2 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 fd36b2db3e50..5beae79ad1a0 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 @@ class LLVM_NODISCARD ModRefResult { 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<int>(kind) & static_cast<int>(Kind::Mod); } /// Returns if this result references memory. - LLVM_NODISCARD bool isRef() const { + [[nodiscard]] bool isRef() const { return static_cast<int>(kind) & static_cast<int>(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 5c6177a9e95d..d7dcd84477c9 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 62242301711f..2d3431a8b80a 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -726,7 +726,7 @@ class AsmParser { 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 5a1462aadc6e..4967b921edc4 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 <typename T> -class LLVM_NODISCARD FailureOr : public Optional<T> { +class [[nodiscard]] FailureOr : public Optional<T> { 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 @@ class LLVM_NODISCARD FailureOr : public Optional<T> { /// 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) {} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits