spirv-opt: Rename ControlDependenceAnalysis::DoesBlockExist to HasBlock (#4412)
Suggested by Jakub as 'DoesBlockExist' was confusing.
diff --git a/source/opt/control_dependence.h b/source/opt/control_dependence.h
index 920e4dc..993f379 100644
--- a/source/opt/control_dependence.h
+++ b/source/opt/control_dependence.h
@@ -156,13 +156,11 @@
// Returns true if the block |id| exists in the control dependence graph.
// This can be false even if the block exists in the function when it is part
// of an infinite loop, since it is not part of the post-dominator tree.
- bool DoesBlockExist(uint32_t id) const {
- return forward_nodes_.count(id) > 0;
- }
+ bool HasBlock(uint32_t id) const { return forward_nodes_.count(id) > 0; }
// Returns true if block |a| is dependent on block |b|.
bool IsDependent(uint32_t a, uint32_t b) const {
- if (!DoesBlockExist(a)) return false;
+ if (!HasBlock(a)) return false;
// BBs tend to have more dependents (targets) than they are dependent on
// (sources), so search sources.
const ControlDependenceList& a_sources = GetDependenceSources(a);
diff --git a/test/opt/control_dependence.cpp b/test/opt/control_dependence.cpp
index 94618d7..4665547 100644
--- a/test/opt/control_dependence.cpp
+++ b/test/opt/control_dependence.cpp
@@ -122,16 +122,15 @@
ControlDependenceAnalysis cdg;
cdg.ComputeControlDependenceGraph(cfg, pdom);
- // Test DoesBlockExist.
+ // Test HasBlock.
for (uint32_t id = 10; id <= 19; id++) {
- EXPECT_TRUE(cdg.DoesBlockExist(id));
+ EXPECT_TRUE(cdg.HasBlock(id));
}
- EXPECT_TRUE(
- cdg.DoesBlockExist(ControlDependenceAnalysis::kPseudoEntryBlock));
+ EXPECT_TRUE(cdg.HasBlock(ControlDependenceAnalysis::kPseudoEntryBlock));
// Check blocks before/after valid range.
- EXPECT_FALSE(cdg.DoesBlockExist(5));
- EXPECT_FALSE(cdg.DoesBlockExist(25));
- EXPECT_FALSE(cdg.DoesBlockExist(UINT32_MAX));
+ EXPECT_FALSE(cdg.HasBlock(5));
+ EXPECT_FALSE(cdg.HasBlock(25));
+ EXPECT_FALSE(cdg.HasBlock(UINT32_MAX));
// Test ForEachBlockLabel.
std::set<uint32_t> block_labels;