[llvm-dev] Getting SMLoc from debug metadata

Carl Peto via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 2 07:28:14 PDT 2021


Hi,

I’m trying to create something like an LLVM pass fairly low in my compiler (a variant of swift).

I have an llvm::Function and llvm::Instruction where I want to emit diagnostics, using swift’s built in diagnostics system. That means I think I need an SMLoc.

I’ve used getDebugLoc().get(); to get the DILocation and can getLine(), getColumn() etc. from there to get the source location as a filename, line and column, which seems accurate enough.


I’m trying to figure out how to then create an SMLoc from that. The SMLoc class only seems to take a pointer in the constructor, which I don’t understand.

Sorry I couldn’t figure this out by googling!

Carl


More information about the llvm-dev mailing list