[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 08:47:38 PDT 2012


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)



More information about the cfe-commits mailing list