[cfe-dev] How to emit diagnostics?

AlisdairM(public) public at alisdairm.net
Fri Jun 12 16:03:04 PDT 2009


Finally found time to hack a little code, starting with better detection of
source encoding.

My plan is to detect a BOM in ContentCache::getBuffer() and initially flag
an "unsupported encoding" error if a BOM is detected.

A follow-up patch would then transcode from the detected encoding into a
UTF-8 buffer before returning from the function, and flag an appropriate
error if the file then turns out not be the correctly encoded after all.

I can see how the DiagnosticBuilder API works in other code, so I'm happy
with the idea of re-using an existing "not supported" flag or creating a new
one.  My problem is that I can't see how to hook a DiagnosticBuilder in the
first place - there does not seem to be one available from within a member
function of ContentCache and I'm not sure how else to obtain one.

BTW, I have largely turned my UTF-x support plans on their head, and will
start with diagnosing bad encodings, then support extended characters in
identifiers (which also means correcting column numbers in diagnostics) and
UCNs, before adding support for C++0x Unicode types and literals, and then
(finally!) raw string literals.

AlisdairM






More information about the cfe-dev mailing list