diff options
author | Alon Zakai <azakai@google.com> | 2019-04-26 16:59:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-26 16:59:41 -0700 |
commit | db9124f1de0478dcac525009b6f1589b44a7edd8 (patch) | |
tree | fa26395a0f6cca53cf5cb6e10189f989c5bfa847 /src/passes/RemoveUnusedNames.cpp | |
parent | 87636dccd404a340d75acb1d96301581343f29ca (diff) | |
download | binaryen-db9124f1de0478dcac525009b6f1589b44a7edd8.tar.gz binaryen-db9124f1de0478dcac525009b6f1589b44a7edd8.tar.bz2 binaryen-db9124f1de0478dcac525009b6f1589b44a7edd8.zip |
Apply format changes from #2048 (#2059)
Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
Diffstat (limited to 'src/passes/RemoveUnusedNames.cpp')
-rw-r--r-- | src/passes/RemoveUnusedNames.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/passes/RemoveUnusedNames.cpp b/src/passes/RemoveUnusedNames.cpp index e5aaf5509..86db53b0c 100644 --- a/src/passes/RemoveUnusedNames.cpp +++ b/src/passes/RemoveUnusedNames.cpp @@ -19,8 +19,8 @@ // merge names when possible (by merging their blocks) // -#include <wasm.h> #include <pass.h> +#include <wasm.h> namespace wasm { @@ -33,11 +33,9 @@ struct RemoveUnusedNames : public WalkerPass<PostWalker<RemoveUnusedNames>> { // a parent block, we know if it was branched to std::map<Name, std::set<Expression*>> branchesSeen; - void visitBreak(Break *curr) { - branchesSeen[curr->name].insert(curr); - } + void visitBreak(Break* curr) { branchesSeen[curr->name].insert(curr); } - void visitSwitch(Switch *curr) { + void visitSwitch(Switch* curr) { for (auto name : curr->targets) { branchesSeen[name].insert(curr); } @@ -54,20 +52,24 @@ struct RemoveUnusedNames : public WalkerPass<PostWalker<RemoveUnusedNames>> { } } - void visitBlock(Block *curr) { + void visitBlock(Block* curr) { if (curr->name.is() && curr->list.size() == 1) { auto* child = curr->list[0]->dynCast<Block>(); if (child && child->name.is() && child->type == curr->type) { - // we have just one child, this block, so breaking out of it goes to the same place as breaking out of us, we just need one name (and block) + // we have just one child, this block, so breaking out of it goes to the + // same place as breaking out of us, we just need one name (and block) auto& branches = branchesSeen[curr->name]; for (auto* branch : branches) { if (Break* br = branch->dynCast<Break>()) { - if (br->name == curr->name) br->name = child->name; + if (br->name == curr->name) + br->name = child->name; } else if (Switch* sw = branch->dynCast<Switch>()) { for (auto& target : sw->targets) { - if (target == curr->name) target = child->name; + if (target == curr->name) + target = child->name; } - if (sw->default_ == curr->name) sw->default_ = child->name; + if (sw->default_ == curr->name) + sw->default_ = child->name; } else { WASM_UNREACHABLE(); } @@ -79,20 +81,16 @@ struct RemoveUnusedNames : public WalkerPass<PostWalker<RemoveUnusedNames>> { handleBreakTarget(curr->name); } - void visitLoop(Loop *curr) { + void visitLoop(Loop* curr) { handleBreakTarget(curr->name); if (!curr->name.is()) { replaceCurrent(curr->body); } } - void visitFunction(Function *curr) { - assert(branchesSeen.empty()); - } + void visitFunction(Function* curr) { assert(branchesSeen.empty()); } }; -Pass *createRemoveUnusedNamesPass() { - return new RemoveUnusedNames(); -} +Pass* createRemoveUnusedNamesPass() { return new RemoveUnusedNames(); } } // namespace wasm |