This is an archive of the discontinued LLVM Phabricator instance.

[clang][Tooling] Add a way to tokenize a FileRange
ClosedPublic

Authored by kadircet on Feb 21 2020, 6:42 AM.

Diff Detail

Event Timeline

kadircet created this revision.Feb 21 2020, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2020, 6:42 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
sammccall added inline comments.Feb 21 2020, 8:00 AM
clang/lib/Tooling/Syntax/Tokens.cpp
335

Discussed offline, this loop includes an extra token if the truncation is at whitespace between tokens. (Please test this case)

Also the eof comment is confusing.

I think the loop should be rewritten.

346

nit: FileRange(FID, 0, SM.getFileIDSize(FID)) is a lot more direct :-)

kadircet updated this revision to Diff 246646.Feb 26 2020, 1:15 AM
  • Address comments
kadircet marked 2 inline comments as done.Feb 26 2020, 1:16 AM
kadircet added inline comments.
clang/lib/Tooling/Syntax/Tokens.cpp
335

instead of re-writing the loop I just changed the after-the-loop check to verify latest lexed token to be in range.

sammccall accepted this revision.Feb 26 2020, 2:12 AM
This revision is now accepted and ready to land.Feb 26 2020, 2:12 AM
This revision was automatically updated to reflect the committed changes.