This is an archive of the discontinued LLVM Phabricator instance.

Add dump() method for SourceRange
ClosedPublic

Authored by steveire on Aug 13 2018, 1:27 PM.

Diff Detail

Event Timeline

steveire created this revision.Aug 13 2018, 1:27 PM

This seems like a reasonable addition. Maybe it could also provide print and printToString to more closely match the SourceLocation API?

steveire updated this revision to Diff 161570.Aug 20 2018, 2:51 PM

Add dump() and supporting methods to SourceRange

Thanks, I've done that now.

a_sidorin requested changes to this revision.Aug 20 2018, 3:02 PM

Hello Stephen,
These methods will be really useful.

lib/Basic/SourceLocation.cpp
90

I think we should print both locations on the same line, without adding a newline after the start SLoc.

92

print() shouldn't add a newline, it is up to dump() methods.

This revision now requires changes to proceed.Aug 20 2018, 3:02 PM
rsmith added inline comments.Aug 20 2018, 3:04 PM
lib/Basic/SourceLocation.cpp
89–93

It would seem somewhat more natural to dump SourceRanges the same way we dump them in -ast-dump. (That is: use angle brackets, no newline, and omit the file name / line number / column number on the end location if it's the same as on the start location.)

steveire updated this revision to Diff 162280.Aug 23 2018, 3:33 PM

Add dump() and supporting methods to SourceRange

steveire updated this revision to Diff 162282.Aug 23 2018, 3:35 PM
steveire marked 3 inline comments as done.

Add dump() and supporting methods to SourceRange

steveire added inline comments.Aug 23 2018, 3:36 PM
unittests/Basic/SourceManagerTest.cpp
189

I don't know how to resolve this TODO, and somehow test a range between two files.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 30 2018, 4:12 PM
This revision was automatically updated to reflect the committed changes.