clang-cc -ast-print-xml errors


I’m using ‘clang-cc’ and specifying the argument: -ast-print-xml to the the XML output for Foundation.h

./clang-cc -ast-print-xml -x=objective-c /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h -o /tmp/output.xml

This produces some error diagnostics when processing the headers:

In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:29:
/Developer/usr/lib/clang/1.0/include/xmmintrin.h:28:2: error: #error “SSE instruction set not enabled”
#error “SSE instruction set not enabled”
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32:

/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:216:3: error: unknown type name ‘__m128’
__m128 s;

The second one appears to be a propagated error from the first.

It looks like ‘Streaming SIMD Extensions’ needs to be enabled?

#ifndef SSE

#error “SSE instruction set not enabled”

The same thing goes for MMX and SSE2

If I happen to define these, of course other errors appear relating to incompatible types ‘int’ and ‘__mm128’, etc.

I actually get a crash at the end of processing at:

Assertion failed: (NodeStack.size() > 1 && “to much backtracking”), function toParent, file DocumentXML.cpp, line 51.

Thanks for the help.


You have to run clang -v <rest of command line>
and then read down to the clang-cc line, and then use _that_ line, modified appropriately.

Hi Mike,

OK, I got further using:

./clang-cc -ast-print -triple i386-apple-darwin10 -emit-pch -disable-free -main-file-name Foundation.h --relocation-model pic -pic-level=1 --disable-fp-elim --unwind-tables=0 --mcpu=yonah --fmath-errno=0 -v -mmacosx-version-min=10.6.0 -fdiagnostics-show-option -o /tmp/output.xml -x=objective-c /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h

I get passed the __SSE__, etc. issues.

I still get this error though:

In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:29:
/Developer/usr/lib/clang/1.0/include/xmmintrin.h:41:10: error: incompatible type returning 'int', expected '__m128'
   return __builtin_ia32_addss(a, b);


That indicates that clang is using the headers from an older version
of clang; I don't know how you ended up in that situation, though.


That's just a bug... :frowning: I've seen it before recently, but don't know who broke it or why. If you want, you can do a binary search on clang to find the checkin that caused the problem. I believe it used to work (but I'm not certain).

Oh, not sure if it makes a difference, but you might want -fsyntax-only. You may also be interested in not running the semantic checks (depending upon what exactly you want). It seems like we should have a way to do a bit less work, but I don't think we yet have a way to request this.

Yep. That was my problem. I didn't update the headers in /Developer/user/lib/clang/1.0/include/

Now that it completes successfully, the xml output file can't be read because the encoding is unknown. I don't see where to specify the encoding.


Is the file written an xml file? I think -emit-pch might be hosing you.

Hi Mike,
If I specify the -ast-print-xml, I'm assuming the output will be xml. I think you're right about the pch-thing. At the beginning of the output file, I see 'CPCH'

Removing the -emit-pch will cause an assertion during the creation of the output xml file:
Assertion failed: (NodeStack.size() > 1 && "to much backtracking"), function toParent, file DocumentXML.cpp, line 51.

...the incomplete output file is in fact xml and I can read the contents. The file is simply incomplete because of the assertion.

This is the command I'm using (with the -emit-pch)

./clang-cc -ast-print-xml -emit-pch --mcpu=yonah -v -o /tmp/output.xml -x=objective-c /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h

I would attach the output file here, but it's a few Mbs...


Ok, that's a bug. Someone would have to fix it for the xml writing to work.

Hi Craig,

The driver doesn't have a built in way to deal with extra clang-cc
options we don't care to expose from the compiler.

The best way to deal with this is use a driver option which only runs
clang-cc, and use -Xclang to pass the extra option you want:


Craig Mortensen schrieb:

Removing the -emit-pch will cause an assertion during the creation of the output xml file:
Assertion failed: (NodeStack.size() > 1 && "to much backtracking"), function toParent, file DocumentXML.cpp, line 51.

Strange. Somewhere a sub-node is not added which should be added. Can you just send me a little program showing this behavior.
BTW I don't think that compile flags influence that bug. Maybe something goes wrong when emtting compiler intrinsics.

Best regards


Here's the command I'm using:

/Developer/usr/libexec/clang-cc -ast-print-xml --mcpu=yonah -v -o /tmp/output.xml -x=objective-c /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h


Hi Daniel,

I tried:

clang -S -Xclang -ast-print-xml -x objective-c /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h -o /tmp/output.xml

...and it gives me the same assertion in DocumentXML.cpp line 51.

I tried your suggestions with empty.c and I was able to get that working on a empty.c file. I think using '-x objective-c' is the culprit.


The assertion is an unrelated problem, I was just indicating the way
to get the driver to run -ast-print-xml for you, instead of having to
manufacture clang-cc arguments yourself.

- Daniel