This is an archive of the discontinued LLVM Phabricator instance.

[clang-format][NFC] Clean up tryMergeLessLess()
ClosedPublic

Authored by owenpan on Jan 20 2022, 2:08 AM.

Diff Detail

Event Timeline

owenpan requested review of this revision.Jan 20 2022, 2:08 AM
owenpan created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2022, 2:08 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
curdeius accepted this revision.Jan 20 2022, 2:38 AM

LGTM.

clang/lib/Format/FormatTokenLexer.cpp
433–434

To go a bit further, could we move First[1]->isNot(tok::less) || First[0]->isNot(tok::less) into its own if around the top of the function?
Sth like:

if (Tokens.size() < 3)
  return false;

auto First = Tokens.end() - 3;
if (First[0]->isNot(tok::less) || First[1]->isNot(tok::less))
  return false;

?

This revision is now accepted and ready to land.Jan 20 2022, 2:38 AM
owenpan updated this revision to Diff 401579.Jan 20 2022, 3:16 AM

Further cleanup.

owenpan requested review of this revision.Jan 20 2022, 3:17 AM
owenpan marked an inline comment as done.
owenpan added inline comments.
clang/lib/Format/FormatTokenLexer.cpp
433–434

Good idea.

curdeius accepted this revision.Jan 20 2022, 3:30 AM

Great! Thanks.

This revision is now accepted and ready to land.Jan 20 2022, 3:30 AM
MyDeveloperDay accepted this revision.Jan 20 2022, 5:58 AM

LGTM, at first my head was confused with First[-1] but I think its ok.

This revision was automatically updated to reflect the committed changes.
owenpan marked an inline comment as done.