summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler-support.h8
-rw-r--r--src/support/utilities.cpp5
-rw-r--r--src/support/utilities.h15
-rw-r--r--src/tools/tool-options.h4
-rw-r--r--src/wasm-features.h6
5 files changed, 16 insertions, 22 deletions
diff --git a/src/compiler-support.h b/src/compiler-support.h
index 5f3edacea..eddb2d7f0 100644
--- a/src/compiler-support.h
+++ b/src/compiler-support.h
@@ -31,14 +31,6 @@
#define WASM_BUILTIN_UNREACHABLE __assume(false)
#endif
-#ifdef __GNUC__
-#define WASM_NORETURN __attribute__((noreturn))
-#elif defined(_MSC_VER)
-#define WASM_NORETURN __declspec(noreturn)
-#else
-#define WASM_NORETURN
-#endif
-
// The code might contain TODOs or stubs that read some values but do nothing
// with them. The compiler might fail with [-Werror,-Wunused-variable].
// The WASM_UNUSED(varible) is a wrapper that helps to suppress the error.
diff --git a/src/support/utilities.cpp b/src/support/utilities.cpp
index ea426df9c..f051a1871 100644
--- a/src/support/utilities.cpp
+++ b/src/support/utilities.cpp
@@ -24,9 +24,8 @@
#include "sanitizer/common_interface_defs.h"
#endif
-void wasm::handle_unreachable(const char* msg,
- const char* file,
- unsigned line) {
+[[noreturn]] void
+wasm::handle_unreachable(const char* msg, const char* file, unsigned line) {
#ifndef NDEBUG
if (msg) {
std::cerr << msg << "\n";
diff --git a/src/support/utilities.h b/src/support/utilities.h
index 38fe6fd73..57d170269 100644
--- a/src/support/utilities.h
+++ b/src/support/utilities.h
@@ -36,8 +36,11 @@ template<class Destination, class Source>
inline Destination bit_cast(const Source& source) {
static_assert(sizeof(Destination) == sizeof(Source),
"bit_cast needs to be between types of the same size");
- static_assert(std::is_pod<Destination>::value, "non-POD bit_cast undefined");
- static_assert(std::is_pod<Source>::value, "non-POD bit_cast undefined");
+ static_assert(std::is_trivial_v<Destination> &&
+ std::is_standard_layout_v<Destination>,
+ "non-POD bit_cast undefined");
+ static_assert(std::is_trivial_v<Source> && std::is_standard_layout_v<Source>,
+ "non-POD bit_cast undefined");
Destination destination;
std::memcpy(&destination, &source, sizeof(destination));
return destination;
@@ -65,7 +68,7 @@ public:
std::cerr << arg;
return *this;
}
- WASM_NORETURN ~Fatal() {
+ [[noreturn]] ~Fatal() {
std::cerr << "\n";
// Use _Exit here to avoid calling static destructors. This avoids deadlocks
// in (for example) the thread worker pool, where workers hold a lock while
@@ -74,9 +77,9 @@ public:
}
};
-WASM_NORETURN void handle_unreachable(const char* msg = nullptr,
- const char* file = nullptr,
- unsigned line = 0);
+[[noreturn]] void handle_unreachable(const char* msg = nullptr,
+ const char* file = nullptr,
+ unsigned line = 0);
// If control flow reaches the point of the WASM_UNREACHABLE(), the program is
// undefined.
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h
index 0ed0f27fb..f8278e950 100644
--- a/src/tools/tool-options.h
+++ b/src/tools/tool-options.h
@@ -155,7 +155,7 @@ struct ToolOptions : public Options {
std::string("Enable ") + description,
ToolOptionsCategory,
Arguments::Zero,
- [=](Options*, const std::string&) {
+ [this, feature](Options*, const std::string&) {
enabledFeatures.set(feature, true);
disabledFeatures.set(feature, false);
})
@@ -165,7 +165,7 @@ struct ToolOptions : public Options {
std::string("Disable ") + description,
ToolOptionsCategory,
Arguments::Zero,
- [=](Options*, const std::string&) {
+ [this, feature](Options*, const std::string&) {
enabledFeatures.set(feature, false);
disabledFeatures.set(feature, true);
});
diff --git a/src/wasm-features.h b/src/wasm-features.h
index 7311aadd3..02e1660bb 100644
--- a/src/wasm-features.h
+++ b/src/wasm-features.h
@@ -82,7 +82,7 @@ struct FeatureSet {
}
}
- std::string toString() {
+ std::string toString() const {
std::string ret;
uint32_t x = 1;
while (x & Feature::All) {
@@ -102,7 +102,7 @@ struct FeatureSet {
operator uint32_t() const { return features; }
bool isMVP() const { return features == MVP; }
- bool has(FeatureSet f) { return (features & f) == f; }
+ bool has(FeatureSet f) const { return (features & f) == f.features; }
bool hasAtomics() const { return (features & Atomics) != 0; }
bool hasMutableGlobals() const { return (features & MutableGlobals) != 0; }
bool hasTruncSat() const { return (features & TruncSat) != 0; }
@@ -165,7 +165,7 @@ struct FeatureSet {
features = features & ~other.features & All;
}
- template<typename F> void iterFeatures(F f) {
+ template<typename F> void iterFeatures(F f) const {
for (uint32_t feature = MVP + 1; feature < All; feature <<= 1) {
if (has(feature)) {
f(static_cast<Feature>(feature));