return undefined_blocks_;
}
- /// Returns true if called after a label instruction but before a branch
- /// instruction
- bool in_block() const;
-
/// Returns the block that is currently being parsed in the binary
- BasicBlock& get_current_block();
+ BasicBlock* get_current_block();
/// Returns the block that is currently being parsed in the binary
- const BasicBlock& get_current_block() const;
+ const BasicBlock* get_current_block() const;
/// Prints a GraphViz digraph of the CFG of the current funciton
void printDotGraph() const;
bool ValidationState_t::in_function_body() const { return in_function_; }
bool ValidationState_t::in_block() const {
- return module_functions_.back().in_block();
+ return module_functions_.back().get_current_block() != nullptr;
}
void ValidationState_t::RegisterCapability(SpvCapability cap) {
variable_ids_(),
parameter_ids_() {}
-bool Function::in_block() const { return static_cast<bool>(current_block_); }
-
bool Function::IsFirstBlock(uint32_t id) const {
return !ordered_blocks_.empty() && *get_first_block() == id;
}
assert(module_.in_function_body() == true &&
"RegisterFunctionParameter can only be called when parsing the binary "
"outside of another function");
- assert(in_block() == false &&
+ assert(get_current_block() == nullptr &&
"RegisterFunctionParameter can only be called when parsing the binary "
"ouside of a block");
// TODO(umar): Validate function parameter type order and count
uint32_t continue_id) {
RegisterBlock(merge_id, false);
RegisterBlock(continue_id, false);
- cfg_constructs_.emplace_back(&get_current_block(), &blocks_.at(merge_id),
+ cfg_constructs_.emplace_back(get_current_block(), &blocks_.at(merge_id),
&blocks_.at(continue_id));
return SPV_SUCCESS;
spv_result_t Function::RegisterSelectionMerge(uint32_t merge_id) {
RegisterBlock(merge_id, false);
- cfg_constructs_.emplace_back(&get_current_block(), &blocks_.at(merge_id));
+ cfg_constructs_.emplace_back(get_current_block(), &blocks_.at(merge_id));
return SPV_SUCCESS;
}
bool success = false;
tie(inserted_block, success) = blocks_.insert({id, BasicBlock(id)});
if (is_definition) { // new block definition
- assert(in_block() == false &&
+ assert(get_current_block() == nullptr &&
"Register Block can only be called when parsing a binary outside of "
"a BasicBlock");
"RegisterBlockEnd can only be called when parsing a binary in a "
"function");
assert(
- in_block() == true &&
+ get_current_block() &&
"RegisterBlockEnd can only be called when parsing a binary in a block");
vector<BasicBlock*> next_blocks;
}
vector<BasicBlock*>& Function::get_blocks() { return ordered_blocks_; }
-const BasicBlock& Function::get_current_block() const {
- return *current_block_;
-}
-BasicBlock& Function::get_current_block() { return *current_block_; }
+const BasicBlock* Function::get_current_block() const { return current_block_; }
+BasicBlock* Function::get_current_block() { return current_block_; }
const list<CFConstruct>& Function::get_constructs() const {
return cfg_constructs_;