[cfe-dev] Running clang programmatically

Douglas Gregor dgregor at apple.com
Thu Mar 18 07:24:35 PDT 2010


On Mar 18, 2010, at 7:00 AM, Stefan Seefeld wrote:

> I still have trouble running clang programmatically, and I'm not quite sure what goes wrong. I have attached a minimal test case demonstrating the problem:
> 
> I compiled it as "g++ -o clang clang.cc -lCIndex", then invoke that on a little test C++ input, via "./clang test.cc".
> 
> I then attempt to print the location of the first traversed cursor, but get nonsense. (The reported cursor type also seems incorrect, as I get a CXCursor_StructDecl, with an input file not containing any struct.)

That's probably __va_list_tag, which is defined in the predefines buffer for every source file (hence, a location that looks invalid). Get the cursor's spelling to see the name.

> Can anybody please help me figure out what I'm doing wrong ?

Looks like to me.

	- Doug



More information about the cfe-dev mailing list