This is an archive of the discontinued LLVM Phabricator instance.

[LLDB][NFC] Simplify IOHandler's getLine to avoid strange casts and redundant checks
AbandonedPublic

Authored by gAlfonso-bit on Aug 7 2021, 4:53 PM.

Details

Reviewers
teemperor

Diff Detail

Event Timeline

gAlfonso-bit requested review of this revision.Aug 7 2021, 4:53 PM
gAlfonso-bit created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 7 2021, 4:53 PM
gAlfonso-bit added reviewers: Restricted Project, Restricted Project.Aug 7 2021, 4:54 PM
gAlfonso-bit added a project: Restricted Project.
teemperor removed a reviewer: Restricted Project.Aug 8 2021, 7:59 AM
teemperor removed a project: Restricted Project.
teemperor requested changes to this revision.Aug 9 2021, 9:11 AM
teemperor added a subscriber: teemperor.

Thanks for the patch! I think we can actually simplify that code even more by just removing the !got_line checks in both ifs? There is really no reason to have them from what I can see.

lldb/source/Core/IOHandler.cpp
388–390

Just a small FYI: I removed the m_editing variable here in 324000054652d47467d23b73ada5c8a599087167

431

This version is fine too, but we could potentially do an LLVMy early return:

if (!got_line)
  return false;
[...]
return true;
This revision now requires changes to proceed.Aug 9 2021, 9:11 AM
This comment was removed by gAlfonso-bit.
gAlfonso-bit marked 2 inline comments as done.
This comment was removed by gAlfonso-bit.
gAlfonso-bit removed a reviewer: Restricted Project.Aug 9 2021, 12:41 PM
shafik added a subscriber: shafik.Aug 9 2021, 3:06 PM
shafik added inline comments.
lldb/source/Core/IOHandler.cpp
374

A goto is not warranted here, using if (!got_line && !in is perfectly fine and less lines.

This comment was removed by gAlfonso-bit.
gAlfonso-bit marked an inline comment as done.Aug 10 2021, 1:19 PM
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.

Only clang-tidy is upset and it is falsely flagging "missing" files

This is because llvm precommit doesn't actually build lldb (due to some test failures they were/are having) so those headers are unknown to clang-tidy when it runs. You can ignore it.

gAlfonso-bit edited the summary of this revision. (Show Details)Sep 27 2023, 11:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2023, 11:09 AM
gAlfonso-bit abandoned this revision.Sep 27 2023, 11:09 AM