From 5bc1c4bd4e4fba7ea12ea9446447d889040e67c1 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 26 Mar 2010 19:08:36 +0000 Subject: Add a paragram describing how to extract line number information. llvm-svn: 99636 --- llvm/docs/SourceLevelDebugging.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm/docs/SourceLevelDebugging.html') diff --git a/llvm/docs/SourceLevelDebugging.html b/llvm/docs/SourceLevelDebugging.html index 66a9a2e34ef..f92a1656a90 100644 --- a/llvm/docs/SourceLevelDebugging.html +++ b/llvm/docs/SourceLevelDebugging.html @@ -1069,6 +1069,18 @@ int main(int argc, char *argv[]) { +

llvm::Instruction provides easy access to metadata attached with an +instruction. One can extract line number information encoded in LLVM IR +using Instruction::getMetadata() and +DILocation::getLineNumber(). +

+ 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();
+ }
+
-- cgit v1.2.3