File tree Expand file tree Collapse file tree 2 files changed +18
-13
lines changed
Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Original file line number Diff line number Diff 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;
Original file line number Diff line number Diff line change 1919namespace wasm {
2020
2121template <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 {
2425public:
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,
6266Graph (It, Sen, SuccessorFunction)
6367 -> Graph<std::iter_value_t<It>, std::decay_t<SuccessorFunction>>;
6468
65- } // namespace wasm
69+ } // namespace wasm
You can’t perform that action at this time.
0 commit comments