This is an archive of the discontinued LLVM Phabricator instance.

Fix the help for "type X delete" to make the -a & -w behaviors clear
ClosedPublic

Authored by jingham on Apr 13 2023, 5:52 PM.

Details

Summary

If you run:

(lldb) type summary delete Foo

that will only search for the type summary for Foo in the "default" category. That's by design, since this is "delete" you wouldn't want to accidentally delete a format it might be hard to get back, so making you specify the category or say "all" explicitly is a good safeguard. But the help is not at all clear that that's how it works and it has confused several people now.

This patch fixes the help strings. Since all the type X delete commands go through a common base, I centralized the help output in the base class so the help would be consistent. I also removed an unused macro, and changed where we were calling these formatter_kind_mask to be formatter_kind since we only use them as a single enum element, we never use them as masks in this context.

Diff Detail

Event Timeline

jingham created this revision.Apr 13 2023, 5:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 5:52 PM
jingham requested review of this revision.Apr 13 2023, 5:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 5:52 PM
bulbazord added inline comments.
lldb/source/Commands/CommandObjectType.cpp
112–113

maybe add an llvm_unreachable after the switch statement?

886–892

You could define these in the class and not out-of-line if you use constexpr. So for example, above in the class you can do:

static constexpr const char *g_short_help_template = "Delete an existing %s for a type.";
jingham updated this revision to Diff 516590.Apr 24 2023, 5:44 PM

Adopt suggestions from Alex.

jingham marked 2 inline comments as done.Apr 24 2023, 5:45 PM
jingham added inline comments.
lldb/source/Commands/CommandObjectType.cpp
886–892

That's neat though I'm not 100% sure why it has to be so ugly...

This revision was not accepted when it landed; it landed in state Needs Review.May 1 2023, 2:22 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
jingham marked an inline comment as done.