diff --git a/kernel/register.cc b/kernel/register.cc index f0ce6e94e..a6d07cd8f 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -945,12 +945,12 @@ struct HelpPass : public Pass { auto name = it.first; auto pass = it.second; auto title = pass->short_help; - vector usages; + vector usages; auto experimental_flag = pass->experimental_flag; if (pass->HasUsages()) { for (auto usage : pass->pass_usages) - usages.push_back(&usage); + usages.push_back(usage); } else { enum PassUsageState { PUState_signature, @@ -971,7 +971,6 @@ struct HelpPass : public Pass { int blank_count = 0; size_t def_strip_count = 0; auto current_state = PUState_postscript; - PassUsageBlock *current_usage; auto catch_verific = false; for (string line; std::getline(ss, line, '\n');) { // find position of first non space character @@ -1000,8 +999,7 @@ struct HelpPass : public Pass { if (NewUsage) { current_state = PUState_signature; - current_usage = new PassUsageBlock(); - usages.push_back(current_usage); + usages.push_back({}); def_strip_count = first_pos; catch_verific = false; } else if (IsDedent) { @@ -1014,19 +1012,19 @@ struct HelpPass : public Pass { if (IsDefinition && IsIndent && !catch_verific) { current_state = PUState_options; - current_usage->options.push_back(PassOption({stripped_line, ""})); + usages.back().options.push_back(PassOption({stripped_line, ""})); def_strip_count = first_pos; } else { string *desc_str; if (current_state == PUState_signature) { - desc_str = &(current_usage->signature); + desc_str = &(usages.back().signature); blank_count += 1; } else if (current_state == PUState_description) { - desc_str = &(current_usage->description); + desc_str = &(usages.back().description); } else if (current_state == PUState_options) { - desc_str = &(current_usage->options.back().description); + desc_str = &(usages.back().options.back().description); } else if (current_state == PUState_postscript) { - desc_str = &(current_usage->postscript); + desc_str = &(usages.back().postscript); } else { log_abort(); } @@ -1050,17 +1048,17 @@ struct HelpPass : public Pass { json.name("usages"); json.begin_array(); for (auto usage : usages) { json.begin_object(); - json.entry("signature", usage->signature); - json.entry("description", usage->description); + json.entry("signature", usage.signature); + json.entry("description", usage.description); json.name("options"); json.begin_array(); - for (auto option : usage->options) { + for (auto option : usage.options) { json.begin_array(); json.value(option.keyword); json.value(option.description); json.end_array(); } json.end_array(); - json.entry("postscript", usage->postscript); + json.entry("postscript", usage.postscript); json.end_object(); } json.end_array();