Add RemoveParameter method (#3437)

This commit is contained in:
Vasyl Teliman 2020-06-17 17:15:50 +03:00 committed by GitHub
parent 57d9e360c6
commit 99651228b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,6 +72,10 @@ class Function {
// Delete all basic blocks that contain no instructions.
inline void RemoveEmptyBlocks();
// Removes a parameter from the function with result id equal to |id|.
// Does nothing if the function doesn't have such a parameter.
inline void RemoveParameter(uint32_t id);
// Saves the given function end instruction.
inline void SetFunctionEnd(std::unique_ptr<Instruction> end_inst);
@ -219,6 +223,14 @@ inline void Function::RemoveEmptyBlocks() {
blocks_.erase(first_empty, std::end(blocks_));
}
inline void Function::RemoveParameter(uint32_t id) {
params_.erase(std::remove_if(params_.begin(), params_.end(),
[id](const std::unique_ptr<Instruction>& param) {
return param->result_id() == id;
}),
params_.end());
}
inline void Function::SetFunctionEnd(std::unique_ptr<Instruction> end_inst) {
end_inst_ = std::move(end_inst);
}