[cfe-dev] How to access the CGDebug class for lineNumbers and columnNumber

David Chisnall csdavec at swan.ac.uk
Tue Mar 29 09:42:05 PDT 2011


On 29 Mar 2011, at 16:28, Phillip Power wrote:

> I am experimenting with CLANG with the idea of building an analyzer.  I
> have started with the clang/examples/clang-interpreter and started
> adding some calls to my code in the Execute().  

Clang already includes a static analyser, so I'm assuming that you mean a dynamic (run time) analyser.  

> All looks good, however
> it is important that I can output the fileName:lineNumber:ColumnNumber
> with the analysis output, but I cannot see how to do this.  I have
> checked over as many forums as I can find.
> 
> As far as I can tell the CGDebugInfo class should be used to store the
> raw information as metatags.  However, I cannot find how to access this
> class.  Can anyone point me in the right direction.

You are looking too far down the compilation chain.  CGDebugInfo is for writing debug metadata out to LLVM IR.  You want to get the information from the AST.  Every node on the AST has a SourceLocation associated with it, which stores its location in the source file.  

David



More information about the cfe-dev mailing list