From 19dd17c5c438c650d8c9c152db53dec67f3e583f Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 6 Aug 2015 18:15:25 +0000 Subject: [PATCH] Update docs for accessing !dbg attachments llvm-svn: 244238 --- docs/SourceLevelDebugging.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/SourceLevelDebugging.rst b/docs/SourceLevelDebugging.rst index 67b81c61d8a..b98fd33002a 100644 --- a/docs/SourceLevelDebugging.rst +++ b/docs/SourceLevelDebugging.rst @@ -368,15 +368,14 @@ C/C++ source file information ``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()``. +``Instruction::getDebugLoc()`` and ``DILocation::getLine()``. .. code-block:: c++ - 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(); + if (DILocation *Loc = I->getDebugLoc()) { // Here I is an LLVM instruction + unsigned Line = Loc->getLine(); + StringRef File = Loc->getFilename(); + StringRef Dir = Loc->getDirectory(); } C/C++ global variable information