Add a paragram describing how to extract line number information.
authorDevang Patel <dpatel@apple.com>
Fri, 26 Mar 2010 19:08:36 +0000 (19:08 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 26 Mar 2010 19:08:36 +0000 (19:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99636 91177308-0d34-0410-b5e6-96231b3b80d8

docs/SourceLevelDebugging.html

index 66a9a2e34ef8a36a43d00caac5671eb2e42982b4..f92a1656a901433a48825a62580ee77792e65103 100644 (file)
@@ -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>
 
 <!-- ======================================================================= -->