Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/compiler-support.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@
#define WASM_BUILTIN_UNREACHABLE __assume(false)
#endif

#if defined(__GNUC__) || defined(__clang__)
#define BYN_WARN_UNUSED [[gnu::warn_unused]]
#else
#define BYN_WARN_UNUSED
#endif

#endif // wasm_compiler_support_h
1 change: 0 additions & 1 deletion src/ir/possible-contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,6 @@ struct InfoCollector
}

void visitCall(Call* curr) {
Name targetName;
if (!Intrinsics(*getModule()).isCallWithoutEffects(curr)) {
// This is just a normal call.
handleDirectCall(curr, curr->target);
Expand Down
2 changes: 1 addition & 1 deletion src/support/istring.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace wasm {

struct IString {
struct BYN_WARN_UNUSED IString {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels odd to me, to scatter these throughout the codebase. Is there no global flag we can set?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean its kind of like llvm/llvm-project#203084.

If there was a flag I guess it would be something like "-falways-assume-ctors-have-no-side-effects" but I'm pretty sure that is never always true so you wouldn't want it to be global.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, so this is for the ctors? Can we annotate the ctors directly, then, not the entire class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the way to do this is to annotate the class itself.

Annotating a C++ class with [[gnu::warn_unused]] tells the compiler to issue a -Wunused-variable warning if a variable of that type is instantiated but never explicitly used.

private:
static const char* interned(std::string_view s);

Expand Down
2 changes: 1 addition & 1 deletion src/support/name.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace wasm {
// TODO: as an optimization, IString values < some threshold could be considered
// numerical indices directly.

struct Name : public IString {
struct BYN_WARN_UNUSED Name : public IString {
Name() : IString() {}
Name(std::string_view str) : IString(str) {}
Name(const char* str) : IString(str) {}
Expand Down
2 changes: 0 additions & 2 deletions src/tools/wasm-ctor-eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,8 +1540,6 @@ static bool canEval(Module& wasm) {
//

int main(int argc, const char* argv[]) {
Name entry;
std::vector<std::string> passes;
bool emitBinary = true;
bool debugInfo = false;
String::Split ctors;
Expand Down
2 changes: 0 additions & 2 deletions src/tools/wasm-metadce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,6 @@ struct MetaDCEGraph {
//

int main(int argc, const char* argv[]) {
Name entry;
std::vector<std::string> passes;
bool emitBinary = true;
bool debugInfo = false;
std::string graphFile;
Expand Down
1 change: 0 additions & 1 deletion src/tools/wasm-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ willRemoveDebugInfo(const std::vector<OptimizationOptions::PassInfo>& passes) {
//

int main(int argc, const char* argv[]) {
Name entry;
bool emitBinary = true;
bool converge = false;
bool fuzzExecBefore = false;
Expand Down
3 changes: 0 additions & 3 deletions src/tools/wasm-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,6 @@ struct Shell {
};

int main(int argc, const char* argv[]) {
Name entry;
std::set<size_t> skipped;

// Read stdin by default.
std::string infile = "-";
Options options("wasm-shell", "Execute .wast files");
Expand Down
Loading