This is an archive of the discontinued LLVM Phabricator instance.

SourceRange.__contains__ may return wrong result in python bindings
Changes PlannedPublic

Authored by tbao2011 on Jan 29 2015, 4:35 PM.

Details

Reviewers
eliben
akyrtzi
Summary

The function tests if a given location is inside the represented range, but it may give wrong result when the given location is on the same line with the current one-line range.

For example,

tu = ...
extent = tu.get_extent('test.c', ((1, 1), (1, 14)))
location = tu.get_location('test.c', (1, 20))
print location
print extent
print location in extent

It gives:
<SourceLocation file 'test.c', line 1, column 20>
<SourceRange start <SourceLocation file 'test.c', line 1, column 1>, end <SourceLocation file 'test.c', line 1, column 14>>
True # should be a False #

Diff Detail

Event Timeline

tbao2011 updated this revision to Diff 19005.Jan 29 2015, 4:35 PM
tbao2011 retitled this revision from to SourceRange.__contains__ may return wrong result in python bindings.
tbao2011 updated this object.
tbao2011 edited the test plan for this revision. (Show Details)
tbao2011 added reviewers: eliben, akyrtzi.
tbao2011 added a subscriber: Unknown Object (MLST).
eliben edited edge metadata.Feb 2 2015, 11:09 AM

Thanks!

Could you add tests?

tbao2011 edited edge metadata.Feb 12 2015, 6:01 PM
tbao2011 updated this revision to Diff 19865.Feb 12 2015, 6:08 PM

Adding tests for the change.

tbao2011 planned changes to this revision.Feb 12 2015, 6:09 PM
eliben accepted this revision.Feb 13 2015, 9:14 AM
eliben edited edge metadata.

LGTM