[cfe-dev] libclang: traversing initializers in for-range statements

jeaye contact at jeaye.com
Wed Mar 4 20:08:49 PST 2015


On Thu, Mar 05, 2015 at 02:15:24AM +0300, Дмитрий Ермолов wrote:
> Hi,
> 
> I'm trying to use libclang to parse some C++. When I parse source that includes for-range statement like:
> 
>   int main() {
>       char a[1000];
>       for (auto x: a) { // <--- expect to traverse reference to `a` here
>       ++x;
>       }
>   }
> 
> I expect to traverse reference to `a` at some point, but it looks like such traversal never happens.
> 
> Below is the example my traversal code in Python (actually I write in C++ but situation is similar there) and its output on the sample C++ source.
> 
> Am I doing something wrong or such case is not supported by libclang?
> 
> Thanks,
> Dmitry

Dmitry,

I don't know about your specific case, but I've found multiple
incomplete cursor traversal issues in libclang and I've reported them
here (along with fixes and test code):

http://llvm.org/bugs/buglist.cgi?quicksearch=incomplete%20traversal&list_id=68006

So far, every single one has been ignored (tried IRC, the mailing list several
months ago, and now these issues since January).

In my experimentation, I did find there were issues with range-based for
loops, as I've documented here:

https://github.com/jeaye/color_coded/issues/2

However, I found that specific issue was fixed some time in January.
Still, I'm hoping that this thread can build momentum for the existing
issues in libclang which have not been resolved for months.

Cheers,
Jeaye




More information about the cfe-dev mailing list