Smart error reporting mechanism


can anybody hint how can I get clang diagnostic errors associated with the given AST Decls.

E.g. get error for clang::CXXRecordDecl which contains syntax error.

Thanks in advance.

The AST doesn't directly store this information. Diagnostics are emitted by parsing or semantic analysis, but aren't specifically associated with any AST node.

You could try to recover this information by looking at the source locations of the diagnostics, and then searching through the AST to find the AST node whose source range encloses a particular diagnostic. I think that would work reasonably well, and this could be prototyped very quickly with libclang's clang_parseTranslationUnit() and clang_getCursor() operations.

  - Doug