Skip to content

Commit 3567c0e

Browse files
Try reformatting
1 parent f5d9926 commit 3567c0e

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/passes/GlobalEffects.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,17 @@ CallGraph buildCallGraph(const Module& module,
190190
// We are essentially walking up each supertype chain and adding edges from
191191
// super -> subtype, but doing it via DFS to avoid repeated work.
192192
Graph superTypeGraph(allFunctionTypes.begin(),
193-
allFunctionTypes.end(),
194-
[&callGraph](auto&& push, HeapType t) {
195-
// Not needed except that during lookup we expect the key to exist.
196-
callGraph[t];
197-
198-
if (auto super = t.getDeclaredSuperType()) {
199-
callGraph[*super].insert(t);
200-
push(*super);
201-
}
202-
});
193+
allFunctionTypes.end(),
194+
[&callGraph](auto&& push, HeapType t) {
195+
// Not needed except that during lookup we expect the
196+
// key to exist.
197+
callGraph[t];
198+
199+
if (auto super = t.getDeclaredSuperType()) {
200+
callGraph[*super].insert(t);
201+
push(*super);
202+
}
203+
});
203204
(void)superTypeGraph.traverseDepthFirst();
204205

205206
return callGraph;

src/support/graph_traversal.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919
namespace wasm {
2020

2121
template<typename T, typename SuccessorFunction>
22-
requires std::invocable<SuccessorFunction, std::function<void(const T&)>&, const T&>
23-
class Graph {
22+
requires std::
23+
invocable<SuccessorFunction, std::function<void(const T&)>&, const T&>
24+
class Graph {
2425
public:
2526
template<std::input_iterator It, std::sentinel_for<It> Sen>
2627
requires std::convertible_to<std::iter_reference_t<It>, T>
2728
Graph(It rootsBegin, Sen rootsEnd, auto&& successors)
2829
: roots(rootsBegin, rootsEnd),
2930
successors(std::forward<decltype(successors)>(successors)) {}
3031

32+
// Traverse the graph depth-first, calling `successors` exactly once for each
33+
// node (unless the node appears multiple times in `roots`). Return the set of
34+
// nodes visited.
3135
std::unordered_set<T> traverseDepthFirst() const {
3236
std::vector<T> stack(roots.begin(), roots.end());
3337
std::unordered_set<T> visited(roots.begin(), roots.end());
@@ -62,4 +66,4 @@ template<std::input_iterator It,
6266
Graph(It, Sen, SuccessorFunction)
6367
-> Graph<std::iter_value_t<It>, std::decay_t<SuccessorFunction>>;
6468

65-
} // namespace wasm
69+
} // namespace wasm

0 commit comments

Comments
 (0)