From fa4aa997310dc45bd30ac230ad659cfb223f3573 Mon Sep 17 00:00:00 2001 From: karimtera Date: Fri, 15 Jul 2022 18:18:39 +0200 Subject: [PATCH] fixing misc. errors in flow_tree.cc --- verilog/analysis/flow_tree.cc | 12 +++++------- verilog/tools/preprocessor/verilog_preprocessor.cc | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/verilog/analysis/flow_tree.cc b/verilog/analysis/flow_tree.cc index 94920b23c1..d9324306fc 100644 --- a/verilog/analysis/flow_tree.cc +++ b/verilog/analysis/flow_tree.cc @@ -41,10 +41,10 @@ absl::Status FlowTree::GenerateControlFlowTree() { elses_[ifs_.back()].push_back(idx); if (current_enum == PP_endif) { auto& myelses = elses_[ifs_.back()]; - for (int i = 0; i < myelses.size(); i++) { - for (int j = i + 1; j < myelses.size(); j++) { - if (!i && j == myelses.size() - 1) continue; - edges_[myelses[i]].push_back(myelses[j] + 1); + for (auto it = myelses.begin(); it != myelses.end(); it++) { + for (auto it2 = it + 1; it2 != myelses.end(); it2++) { + if (it == myelses.begin() && it2 == myelses.end() - 1) continue; + edges_[*it].push_back(*it2 + (it2 != myelses.end() - 1)); } } ifs_.pop_back(); @@ -53,7 +53,6 @@ absl::Status FlowTree::GenerateControlFlowTree() { idx++; } idx = 0; - int prv_enum = 0; for (auto u : source_sequence_) { current_enum = u.token_enum(); if (current_enum != PP_else && current_enum != PP_elsif) { @@ -61,7 +60,6 @@ absl::Status FlowTree::GenerateControlFlowTree() { } else { if (idx > 0) edges_[idx - 1].push_back(edges_[idx].back()); } - prv_enum = current_enum; idx++; } @@ -78,7 +76,7 @@ absl::Status FlowTree::DepthFirstSearch(int index) { for (auto u : edges_[index]) { auto status = FlowTree::DepthFirstSearch(u); // handle errors } - if (index == source_sequence_.size() - 1) { + if (index == int(source_sequence_.size()) - 1) { variants_.push_back(current_sequence_); } if (curr.token_enum() != PP_Identifier && curr.token_enum() != PP_ifndef && diff --git a/verilog/tools/preprocessor/verilog_preprocessor.cc b/verilog/tools/preprocessor/verilog_preprocessor.cc index e15b596f6a..e96d7d1b78 100644 --- a/verilog/tools/preprocessor/verilog_preprocessor.cc +++ b/verilog/tools/preprocessor/verilog_preprocessor.cc @@ -97,7 +97,7 @@ static absl::Status MultipleCU(const SubcommandArgsRange& args, std::istream&, std::string source_view{post_preproc}; verilog::VerilogAnalyzer analyzer(source_view, "file1", config); auto analyze_status = analyzer.Analyze(); - const auto& mydata = analyzer.Data().Contents(); + /* const auto& mydata = analyzer.Data().Contents(); */ /* outs<