[cfe-dev] Smart error reporting mechanism

Douglas Gregor dgregor at apple.com
Tue May 17 07:47:54 PDT 2011


On May 17, 2011, at 1:33 AM, Anna Lu wrote:

> Hi,
> 
> 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.


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



More information about the cfe-dev mailing list