[cfe-commits] [PATCH 1/2] [clang.py] Add TranslationUnit.get_{file, source_location, source_range}

Gregory Szorc gregory.szorc at gmail.com
Fri Jun 29 19:15:09 PDT 2012


Updated patch.

On Fri, Jun 29, 2012 at 8:47 AM, Gregory Szorc <gregory.szorc at gmail.com> wrote:
> Having thought about this in my sleep, I may want to rescind this
> review request and refactor things a little.
>
> 1) I may change "range" and "source_range" names to "extent" since
> that is what is used elsewhere.
> 2) I may combine the bounds to obtain ranges/extents from two
> arguments to 2-tuples.
> 3) I may remove the "_source" from get_source_location and
> get_source_extent. I don't think that's any less clear.
>
> This will of course invalidate the token API patch that followed,
> albeit trivially.
>
> On Fri, Jun 29, 2012 at 12:13 AM, Gregory Szorc <gregory.szorc at gmail.com> wrote:
>> These are just convenience APIs to make obtaining File,
>> SourceLocation, and SourceRange instances easier.
>>
>> Old way:
>>
>> f = File.from_name(tu, 'foo.c')
>> location = SourceLocation.from_offset(tu, f, 10)
>>
>> New way:
>>
>> location = tu.get_source_location('foo.c', offset=10)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-clang.py-Add-TranslationUnit.get_-file-source_locati.patch
Type: application/octet-stream
Size: 5853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120629/8a7d83b7/attachment.obj>


More information about the cfe-commits mailing list