This is an archive of the discontinued LLVM Phabricator instance.

[libTooling] Add `getFileRange` as an alternative to `getRangeForEdit`
ClosedPublic

Authored by li.zhe.hua on Jan 12 2023, 2:16 PM.

Details

Summary

Add a getFileRange function alongside the existing getRangeForEdit
as a way to get a contiguous range within a single file (similar to
getRangeForEdit) but without the restriction that it cannot be in a
system header.

This can be used where a tool may want to use the range to extract the
source text. In such cases, we don't want to restrict this from
pulling from system headers.

Diff Detail

Event Timeline

li.zhe.hua created this revision.Jan 12 2023, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 2:16 PM
li.zhe.hua requested review of this revision.Jan 12 2023, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 2:16 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ymandel accepted this revision.Jan 12 2023, 2:28 PM

Can you add a test? probably valuable even if its nearly identical to the test for getRangeForEdit.

clang/include/clang/Tooling/Transformer/SourceCode.h
120–126

This description seems a bit out of place for this function, since it's explicitly *not* focused on the case of edits. Can this be rephrased?

This revision is now accepted and ready to land.Jan 12 2023, 2:28 PM

Fix description.
Remove default argument.
Fix copy/paste error.

Upload correct commit this time...

Try this again...

This revision was landed with ongoing or failed builds.Jan 12 2023, 2:44 PM
This revision was automatically updated to reflect the committed changes.