This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add fixits for "frame variable"
Needs ReviewPublic

Authored by kastiglione on Apr 1 2023, 1:52 PM.

Details

Summary

The frame variable command can handle mistaken use of . for ->, and vice versa,
but up until now it has been an error when the user makes such a mistake. This change
adds a flag to frame variable which allows these mistakes to be fixed. The idea is why
make the user manually edit the command if lldb can figure it out.

This is similar to expression which supports fixits supplied by the compiler, which
include correcting . to ->, and vice versa.

Unlike expression, there is no diagnostic message to draw attention to the fix. The
fixed expression _is_ printed though. Compare:

(lldb) frame var -X on thing->field
(int) thing.field = 30

to

(lldb) expr thing->field
(int) $0 = 30
  Fix-it applied, fixed expression was:
    thing.field

I wasn't sure it was worth the noise, so I went with the simple approach.

Diff Detail

Event Timeline

kastiglione created this revision.Apr 1 2023, 1:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2023, 1:52 PM
kastiglione requested review of this revision.Apr 1 2023, 1:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2023, 1:52 PM

Change --apply-fixits take an argument

kastiglione edited the summary of this revision. (Show Details)Apr 1 2023, 5:27 PM
kastiglione edited the summary of this revision. (Show Details)

That looks like a nice quality of life improvement! Personally I would lean towards replicating the expr behavior, though I don't know how much work that would be.