[PATCH] SourceRange.__contains__ may return wrong result in python bindings
Tao Bao
tbao2011 at gmail.com
Thu Jan 29 16:35:52 PST 2015
Hi eliben, akyrtzi,
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 ###
http://reviews.llvm.org/D7277
Files:
bindings/python/clang/cindex.py
Index: bindings/python/clang/cindex.py
===================================================================
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -279,6 +279,10 @@
# same file, in between lines
if self.start.line < other.line < self.end.line:
return True
+ # same file, same line
+ elif self.start.line == other.line == self.end.line:
+ if self.start.column <= other.column <= self.end.column:
+ return True
elif self.start.line == other.line:
# same file first line
if self.start.column <= other.column:
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7277.19005.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150130/c49e5334/attachment.bin>
More information about the cfe-commits
mailing list