aboutsummaryrefslogtreecommitdiff
path: root/docs/SourceLevelDebugging.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/SourceLevelDebugging.html')
-rw-r--r--docs/SourceLevelDebugging.html12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/SourceLevelDebugging.html b/docs/SourceLevelDebugging.html
index 66a9a2e34e..f92a1656a9 100644
--- a/docs/SourceLevelDebugging.html
+++ b/docs/SourceLevelDebugging.html
@@ -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>
<!-- ======================================================================= -->