forked from OSchip/llvm-project
Update docs for accessing !dbg attachments
llvm-svn: 244238
This commit is contained in:
parent
14c3c4bb85
commit
f032c956de
llvm/docs
|
@ -368,15 +368,14 @@ C/C++ source file information
|
||||||
|
|
||||||
``llvm::Instruction`` provides easy access to metadata attached with an
|
``llvm::Instruction`` provides easy access to metadata attached with an
|
||||||
instruction. One can extract line number information encoded in LLVM IR using
|
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++
|
.. code-block:: c++
|
||||||
|
|
||||||
if (MDNode *N = I->getMetadata("dbg")) { // Here I is an LLVM instruction
|
if (DILocation *Loc = I->getDebugLoc()) { // Here I is an LLVM instruction
|
||||||
DILocation Loc(N); // DILocation is in DebugInfo.h
|
unsigned Line = Loc->getLine();
|
||||||
unsigned Line = Loc.getLineNumber();
|
StringRef File = Loc->getFilename();
|
||||||
StringRef File = Loc.getFilename();
|
StringRef Dir = Loc->getDirectory();
|
||||||
StringRef Dir = Loc.getDirectory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
C/C++ global variable information
|
C/C++ global variable information
|
||||||
|
|
Loading…
Reference in New Issue