I'm toying with the idea of detecting and parsing user diagnostics to
help IWYU guess which is the public header for a given private header.
For example, glib has the following convention:
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
#error "Only <glib.h> can be included directly."
Essentially I would like to trap all #error directives within a #if,
#ifdef or #ifndef, scan the raw message for a pattern and extract the
quoted include name. This would be an optional heuristic, but I think
it could be made to work reasonably well in the general case.
Is there a way to use PPCallbacks for this? I noticed there's no
PPCallback for #error, but even given that I'm not sure if I can
reason about structure in the preprocessor (like I would in the AST),
e.g. find the nearest #if block.