From 9b34b968af67c0089d902e7fed63a30d7fbe000d Mon Sep 17 00:00:00 2001 From: walkingeyerobot Date: Wed, 17 May 2023 13:11:20 -0400 Subject: avoid incomplete type in a vector (#5730) Swap the order of struct declarations to avoid using an incomplete type in a vector. In C++20, using std::vector with an incomplete type often becomes a build failure due to increased usage of constexpr for vector members. --- src/analysis/cfg.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/analysis/cfg.h b/src/analysis/cfg.h index 3b980f410..ba4d7a774 100644 --- a/src/analysis/cfg.h +++ b/src/analysis/cfg.h @@ -30,23 +30,7 @@ namespace wasm::analysis { -struct BasicBlock; - -struct CFG { - // Iterate through basic blocks. - using iterator = std::vector::const_iterator; - iterator begin() const { return blocks.cbegin(); } - iterator end() const { return blocks.cend(); } - size_t size() const { return blocks.size(); } - - static CFG fromFunction(Function* func); - - void print(std::ostream& os, Module* wasm = nullptr) const; - -private: - std::vector blocks; - friend BasicBlock; -}; +struct CFG; struct BasicBlock { using iterator = std::vector::const_iterator; @@ -72,6 +56,22 @@ private: friend CFG; }; +struct CFG { + // Iterate through basic blocks. + using iterator = std::vector::const_iterator; + iterator begin() const { return blocks.cbegin(); } + iterator end() const { return blocks.cend(); } + size_t size() const { return blocks.size(); } + + static CFG fromFunction(Function* func); + + void print(std::ostream& os, Module* wasm = nullptr) const; + +private: + std::vector blocks; + friend BasicBlock; +}; + } // namespace wasm::analysis #include "cfg-impl.h" -- cgit v1.2.3