mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-23 12:08:25 +00:00
Add a paragram describing how to extract line number information.
llvm-svn: 99636
This commit is contained in:
parent
f823bd13ae
commit
341502ebd8
@ -1069,6 +1069,18 @@ int main(int argc, char *argv[]) {
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>llvm::Instruction provides easy access to metadata attached with an
|
||||
instruction. One can extract line number information encoded in LLVM IR
|
||||
using <tt>Instruction::getMetadata()</tt> and
|
||||
<tt>DILocation::getLineNumber()</tt>.
|
||||
<pre>
|
||||
if (MDNode *N = I->getMetadata("dbg")) { // Here I is an LLVM instruction
|
||||
DILocation Loc(N); // DILocation is in DebugInfo.h
|
||||
unsigned Line = Loc.getLineNumber();
|
||||
StringRef File = Loc.getFilename();
|
||||
StringRef Dir = Loc.getDirectory();
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<!-- ======================================================================= -->
|
||||
|
Loading…
Reference in New Issue
Block a user