Skip to content

Commit

Permalink
Use C++17's [[maybe_unused]]. NFC (WebAssembly#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Dec 2, 2022
1 parent f6bc569 commit 978193b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/c-writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void CWriter::DefineImportName(const Import* import,
import_syms_.insert(name);
import_module_sym_map_.emplace(name, import->module_name);
global_syms_.insert(mangled);
bool success WABT_UNUSED =
[[maybe_unused]] bool success =
global_sym_map_.emplace(name + MangleField(type), mangled).second;
assert(success);
}
Expand All @@ -610,14 +610,15 @@ std::string CWriter::DefineGlobalScopeName(ModuleFieldType type,
std::string_view name) {
std::string mangled = std::string(name) + MangleField(type);
std::string unique = DefineName(&global_syms_, StripLeadingDollar(name));
bool success WABT_UNUSED = global_sym_map_.emplace(mangled, unique).second;
[[maybe_unused]] bool success =
global_sym_map_.emplace(mangled, unique).second;
assert(success);
return unique;
}

std::string CWriter::DefineLocalScopeName(std::string_view name) {
std::string unique = DefineName(&local_syms_, StripLeadingDollar(name));
bool success WABT_UNUSED = local_sym_map_.emplace(name, unique).second;
[[maybe_unused]] bool success = local_sym_map_.emplace(name, unique).second;
assert(success);
return unique;
}
Expand All @@ -627,7 +628,8 @@ std::string CWriter::DefineStackVarName(Index index,
std::string_view name) {
std::string unique = DefineName(&local_syms_, name);
StackTypePair stp = {index, type};
bool success WABT_UNUSED = stack_var_sym_map_.emplace(stp, unique).second;
[[maybe_unused]] bool success =
stack_var_sym_map_.emplace(stp, unique).second;
assert(success);
return unique;
}
Expand Down
9 changes: 0 additions & 9 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

#if COMPILER_IS_CLANG || COMPILER_IS_GNU

#define WABT_UNUSED __attribute__((unused))
#define WABT_WARN_UNUSED __attribute__((warn_unused_result))
#define WABT_INLINE inline
#define WABT_UNLIKELY(x) __builtin_expect(!!(x), 0)
Expand All @@ -86,15 +85,8 @@
#endif

#ifdef __cplusplus
#if __cplusplus >= 201103L
#define WABT_STATIC_ASSERT(x) static_assert((x), #x)
#else
#define WABT_STATIC_ASSERT__(x, c) \
static int static_assert_##c[(x ? 0 : -1)] WABT_UNUSED
#define WABT_STATIC_ASSERT_(x, c) WABT_STATIC_ASSERT__(x, c)
#define WABT_STATIC_ASSERT(x) WABT_STATIC_ASSERT_(x, __COUNTER__)
#endif
#else
#define WABT_STATIC_ASSERT(x) _Static_assert((x), #x)
#endif

Expand All @@ -103,7 +95,6 @@
#include <intrin.h>
#include <string.h>

#define WABT_UNUSED
#define WABT_WARN_UNUSED
#define WABT_INLINE __inline
#define WABT_STATIC_ASSERT(x) _STATIC_ASSERT(x)
Expand Down

0 comments on commit 978193b

Please sign in to comment.