Replace macros with C++17 features (see issue #3362)

- Convert ALLOW_UNUSED_LOCAL to [[maybe_unused]]
- Convert WARN_UNUSED_RESULT to [[nodiscard]]
This commit is contained in:
Marshall Greenblatt
2022-07-27 12:52:42 -04:00
parent 02d7a758fe
commit a9043f2e80
8 changed files with 16 additions and 47 deletions

View File

@ -386,26 +386,4 @@ inline constexpr bool AnalyzerAssumeTrue(bool arg) {
#endif
#endif // !USING_CHROMIUM_INCLUDES
// Annotate a function indicating the caller must examine the return value.
// Use like:
// int foo() WARN_UNUSED_RESULT;
// To explicitly ignore a result, use std::ignore from <tuple>.
// Alternately use `[[nodiscard]]` with code that supports C++17.
#undef WARN_UNUSED_RESULT
#if defined(COMPILER_GCC) || defined(__clang__)
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
#define WARN_UNUSED_RESULT
#endif
// Annotate a variable indicating it's ok if the variable is not used.
// (Typically used to silence a compiler warning when the assignment
// is important for some other reason.)
// Use like:
// int x = ...;
// ALLOW_UNUSED_LOCAL(x);
// Alternately use `[[maybe_unused]]` with code that supports C++17.
#define ALLOW_UNUSED_LOCAL(x) (void)x
#endif // CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_