How to access the CGDebug class for lineNumbers and columnNumber

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(). 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.

Thanks,
Phil

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

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.

Thanks. I think I see the flow to get the line number from the AST;
using:
clang::CompilerInstance->getASTContext()->getSourceManager()->getInstantiationLineNumber(SourceLocation
Loc)
This takes a SourceLocation. Can you point in the right direction to
get a SourceLocation for a LLVM bytecode?

Thanks.
Phillip

To do that, you'll need to read the debug metadata back. The CGDebug class won't help you there - it does the opposite of what you want to do. I don't think there's any example code for doing this - you'll have to look at the debug metadata and parse it yourself.

David