forked from OSchip/llvm-project
parent
64567a80d2
commit
8e9f2813cf
|
@ -858,68 +858,6 @@ in ``lib/IR/DIBuilder.cpp``.
|
||||||
C/C++ source file information
|
C/C++ source file information
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
Given the source files ``MySource.cpp`` and ``MyHeader.h`` located in the
|
|
||||||
directory ``/Users/mine/sources``, the following code:
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
#include "MyHeader.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
a C/C++ front-end would generate the following descriptors:
|
|
||||||
|
|
||||||
.. code-block:: llvm
|
|
||||||
|
|
||||||
...
|
|
||||||
;;
|
|
||||||
;; Define the compile unit for the main source file "/Users/mine/sources/MySource.cpp".
|
|
||||||
;;
|
|
||||||
!0 = metadata !{
|
|
||||||
i32 786449, ;; Tag
|
|
||||||
metadata !1, ;; File/directory name
|
|
||||||
i32 4, ;; Language Id
|
|
||||||
metadata !"clang version 3.4 ",
|
|
||||||
i1 false, ;; Optimized compile unit
|
|
||||||
metadata !"", ;; Compiler flags
|
|
||||||
i32 0, ;; Runtime version
|
|
||||||
metadata !2, ;; Enumeration types
|
|
||||||
metadata !2, ;; Retained types
|
|
||||||
metadata !3, ;; Subprograms
|
|
||||||
metadata !2, ;; Global variables
|
|
||||||
metadata !2, ;; Imported entities (declarations and namespaces)
|
|
||||||
metadata !"" ;; Split debug filename
|
|
||||||
1, ;; Full debug info
|
|
||||||
}
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Define the file for the file "/Users/mine/sources/MySource.cpp".
|
|
||||||
;;
|
|
||||||
!1 = metadata !{
|
|
||||||
metadata !"MySource.cpp",
|
|
||||||
metadata !"/Users/mine/sources"
|
|
||||||
}
|
|
||||||
!5 = metadata !{
|
|
||||||
i32 786473, ;; Tag
|
|
||||||
metadata !1
|
|
||||||
}
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Define the file for the file "/Users/mine/sources/Myheader.h"
|
|
||||||
;;
|
|
||||||
!14 = metadata !{
|
|
||||||
i32 786473, ;; Tag
|
|
||||||
metadata !15
|
|
||||||
}
|
|
||||||
!15 = metadata !{
|
|
||||||
metadata !"./MyHeader.h",
|
|
||||||
metadata !"/Users/mine/sources",
|
|
||||||
}
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
``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::getMetadata()`` and ``DILocation::getLineNumber()``.
|
||||||
|
|
Loading…
Reference in New Issue