Parsing clang++ output

I would like to write support for text editors that I use, for clang++. This would include auto-suggesting fix-it replacements, as well as the more traditional jump to warning/error.

Just out of interest, is there either computer-readable clang++ output, any guarantee that clang++'s output won't change substantially (do I have to worry about other languages?), or any text editors / projects that have already started doing this that anyone knows about?

Thank you very much,

Chris Jefferson

Hello,

Just out of interest, is there either computer-readable clang++ output, any guarantee that clang++'s output won't change substantially (do I have to worry about other languages?), or any text editors / projects that have already started doing this that anyone knows about?

XCode 3.2 and higher (for Mac OS) parse clang's output to provide the user with a list of errors. As far as I can see,
it simply parses clang's output (I'm using XCode 3.2.6 with clang trunk).

It seems that Code::Blocks (which is OpenSource) has or is in the process of getting clang support:
<Integration with LLVM/clang; There also a VIM and EMacs support for clang, using it for
code completion: <LLVM C++ IDE for Windows - Stack Overflow;

I do not know whether clang's output is mostly fixed, though.

Hope that helps,
Jonathan

The clang vim autocompletion [1] uses the python bindings of libclang. Maybe this is an approach that might also work for you.

Cheers
Tobi

[1] https://github.com/Rip-Rip/clang_complete

Isn't the whole point of Clang to have APIs for this so parsing output isn't necessary?

XCode 3.2 and higher (for Mac OS) parse clang’s output to provide the user with a list of errors. As far as I can see,
it simply parses clang’s output (I’m using XCode 3.2.6 with clang trunk).

I’d guess/bet that XCode doesn’t parse clang’s output. Judging by Ted’s post on this ( http://llvm.org/bugs/show_bug.cgi?id=10696 ) bug I was just reading tihs morning, where he implies that the XCode is doing something correctly where the console output is incorrect - if XCode was parsing clang’s text output it wouldn’t have any hope of getting this right. Though I wouldn’t know which builds that would be applicable to.

  • David

Hello,

I'd guess/bet that XCode doesn't parse clang's output. Judging by Ted's post on this ( http://llvm.org/bugs/show_bug.cgi?id=10696 ) bug I was just reading tihs morning, where he implies that the XCode is doing something correctly where the console output is incorrect - if XCode was parsing clang's text output it wouldn't have any hope of getting this right. Though I wouldn't know which builds that would be applicable to.

Oh. I guess things changed with XCode 4, when clang was integrated into the IDE as a plugin. XCode 3.2.6
parses clang's output (at least that's my guess from looking into XCode's "Clang LLVM 1.0.xcspec" file).

Jonathan

That’s not quite correct.

Xcode 4 uses a clang dylib for syntax highlighting, code completion, and indexing. As part of this, it also obtains “live issues” from clang through an API.

For compilation, Xcode 4 still uses the standalone compiler. It passes a “special” flag, -fdiagnostics-parseable-fixits, which causes the text output of the compiler to include a “serialized” version of the FIXIT hints that is easy for an external tool to process. That information includes essentially ranges of characters to insert and delete. This is different from the display of FIXITs from Clang on the command line, which runs into the problems mentioned in 10696.

FWIW, -fdiagnostics-parseable-fixits is documented along with a few other “editor-parsing-friendly” diagnostics output flags at

http://clang.llvm.org/docs/UsersManual.html#cl_diag_formatting

  • Doug