Please see this discussion as well
I'm looking to implement some features in an IDE project using libclang.
In particular I'm investigating a feature allowing the IDE to suggest a
missing #include or forward declaration when stumbling upon a
"undeclared identifier" error.
Unfortunately, libclang does not expose any way of determining the
specific failure that triggers a problem, and clang itself does not
suggest any diagnostic. The only solution I've been able to find with
the current state of libclang is to parse the diagnostic message and try
to determine if it is because of an unknown declaration. This is of
course not a good solution - it is brittle and subject to breakage on
Are there any chance of getting a diagnostic enumeration to libclang? I
think the use case is obvious - in many tools it would be desirable to
suggest solutions to problems clang cannot figure out.