llvm.org GIT mirror llvm / e2e5efb
[LLVM-C] Add DIBuilder bindings to create import declarations Summary: Add bindings to create import declarations for modules, functions, types, and other entities. This wraps the conveniences available in the existing DIBuilder API, but these seem C++-specific. Reviewers: whitequark, harlanhaskins, deadalnix Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46167 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331123 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 1 year, 4 months ago
4 changed file(s) with 157 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
303303 unsigned Discriminator);
304304
305305 /**
306 * Create a descriptor for an imported namespace. Suitable for e.g. C++
307 * using declarations.
308 * \param Builder The \c DIBuilder.
309 * \param Scope The scope this module is imported into
310 * \param File File where the declaration is located.
311 * \param Line Line number of the declaration.
312 */
313 LLVMMetadataRef
314 LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder,
315 LLVMMetadataRef Scope,
316 LLVMMetadataRef NS,
317 LLVMMetadataRef File,
318 unsigned Line);
319
320 /**
321 * Create a descriptor for an imported module that aliases another
322 * imported entity descriptor.
323 * \param Builder The \c DIBuilder.
324 * \param Scope The scope this module is imported into
325 * \param ImportedEntity Previous imported entity to alias.
326 * \param File File where the declaration is located.
327 * \param Line Line number of the declaration.
328 */
329 LLVMMetadataRef
330 LLVMDIBuilderCreateImportedModuleFromAlias(LLVMDIBuilderRef Builder,
331 LLVMMetadataRef Scope,
332 LLVMMetadataRef ImportedEntity,
333 LLVMMetadataRef File,
334 unsigned Line);
335
336 /**
337 * Create a descriptor for an imported module.
338 * \param Builder The \c DIBuilder.
339 * \param Scope The scope this module is imported into
340 * \param M The module being imported here
341 * \param File File where the declaration is located.
342 * \param Line Line number of the declaration.
343 */
344 LLVMMetadataRef
345 LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder,
346 LLVMMetadataRef Scope,
347 LLVMMetadataRef M,
348 LLVMMetadataRef File,
349 unsigned Line);
350
351 /**
352 * Create a descriptor for an imported function, type, or variable. Suitable
353 * for e.g. FORTRAN-style USE declarations.
354 * \param Builder The DIBuilder.
355 * \param Scope The scope this module is imported into.
356 * \param Decl The declaration (or definition) of a function, type,
357 or variable.
358 * \param File File where the declaration is located.
359 * \param Line Line number of the declaration.
360 * \param Name A name that uniquely identifies this imported declaration.
361 * \param NameLen The length of the C string passed to \c Name.
362 */
363 LLVMMetadataRef
364 LLVMDIBuilderCreateImportedDeclaration(LLVMDIBuilderRef Builder,
365 LLVMMetadataRef Scope,
366 LLVMMetadataRef Decl,
367 LLVMMetadataRef File,
368 unsigned Line,
369 const char *Name, size_t NameLen);
370
371 /**
306372 * Creates a new DebugLocation that describes a source location.
307373 * \param Line The line in the source file.
308374 * \param Column The column in the source file.
828828 }
829829
830830 LLVMMetadataRef
831 LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder,
832 LLVMMetadataRef Scope,
833 LLVMMetadataRef NS,
834 LLVMMetadataRef File,
835 unsigned Line) {
836 return wrap(unwrap(Builder)->createImportedModule(unwrapDI(Scope),
837 unwrapDI(NS),
838 unwrapDI(File),
839 Line));
840 }
841
842 LLVMMetadataRef
843 LLVMDIBuilderCreateImportedModuleFromAlias(LLVMDIBuilderRef Builder,
844 LLVMMetadataRef Scope,
845 LLVMMetadataRef ImportedEntity,
846 LLVMMetadataRef File,
847 unsigned Line) {
848 return wrap(unwrap(Builder)->createImportedModule(
849 unwrapDI(Scope),
850 unwrapDI(ImportedEntity),
851 unwrapDI(File), Line));
852 }
853
854 LLVMMetadataRef
855 LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder,
856 LLVMMetadataRef Scope,
857 LLVMMetadataRef M,
858 LLVMMetadataRef File,
859 unsigned Line) {
860 return wrap(unwrap(Builder)->createImportedModule(unwrapDI(Scope),
861 unwrapDI(M),
862 unwrapDI(File),
863 Line));
864 }
865
866 LLVMMetadataRef
867 LLVMDIBuilderCreateImportedDeclaration(LLVMDIBuilderRef Builder,
868 LLVMMetadataRef Scope,
869 LLVMMetadataRef Decl,
870 LLVMMetadataRef File,
871 unsigned Line,
872 const char *Name, size_t NameLen) {
873 return wrap(unwrap(Builder)->createImportedDeclaration(
874 unwrapDI(Scope),
875 unwrapDI(Decl),
876 unwrapDI(File), Line, {Name, NameLen}));
877 }
878
879 LLVMMetadataRef
831880 LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line,
832881 unsigned Column, LLVMMetadataRef Scope,
833882 LLVMMetadataRef InlinedAt) {
22 ; CHECK: ; ModuleID = 'debuginfo.c'
33 ; CHECK-NEXT: source_filename = "debuginfo.c"
44
5 ; CHECK: define i64 @foo(i64, i64, <10 x i64>) !dbg !12 {
5 ; CHECK: define i64 @foo(i64, i64, <10 x i64>) !dbg !16 {
66 ; CHECK-NEXT: entry:
7 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !19, metadata !DIExpression()), !dbg !24
8 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !20, metadata !DIExpression()), !dbg !24
9 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !21, metadata !DIExpression()), !dbg !24
7 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !23, metadata !DIExpression()), !dbg !28
8 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !24, metadata !DIExpression()), !dbg !28
9 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !25, metadata !DIExpression()), !dbg !28
1010 ; CHECK: vars:
11 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 0, metadata !22, metadata !DIExpression(DW_OP_constu, 0, DW_OP_stack_value)), !dbg !25
11 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 0, metadata !26, metadata !DIExpression(DW_OP_constu, 0, DW_OP_stack_value)), !dbg !29
1212 ; CHECK-NEXT: }
1313
1414 ; CHECK: declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
1515 ; CHECK: declare void @llvm.dbg.value(metadata, metadata, metadata) #0
1616
1717 ; CHECK: !llvm.dbg.cu = !{!0}
18 ; CHECK: !FooType = !{!8}
18 ; CHECK: !FooType = !{!12}
1919
20 ; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, splitDebugInlining: false)
20 ; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, imports: !8, splitDebugInlining: false)
2121 ; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".")
2222 ; CHECK-NEXT: !2 = !{}
2323 ; CHECK-NEXT: !3 = !{!4}
2525 ; CHECK-NEXT: !5 = distinct !DIGlobalVariable(name: "global", scope: !6, file: !1, line: 1, type: !7, isLocal: true, isDefinition: true)
2626 ; CHECK-NEXT: !6 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h")
2727 ; CHECK-NEXT: !7 = !DIBasicType(name: "Int64", size: 64)
28 ; CHECK-NEXT: !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 192, dwarfAddressSpace: 0)
29 ; CHECK-NEXT: !9 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", scope: !10, file: !1, size: 192, elements: !11, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
30 ; CHECK-NEXT: !10 = !DINamespace(name: "NameSpace", scope: !6)
31 ; CHECK-NEXT: !11 = !{!7, !7, !7}
32 ; CHECK-NEXT: !12 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !13, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !18)
33 ; CHECK-NEXT: !13 = !DISubroutineType(types: !14)
34 ; CHECK-NEXT: !14 = !{!7, !7, !15}
35 ; CHECK-NEXT: !15 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 640, flags: DIFlagVector, elements: !16)
36 ; CHECK-NEXT: !16 = !{!17}
37 ; CHECK-NEXT: !17 = !DISubrange(count: 10)
38 ; CHECK-NEXT: !18 = !{!19, !20, !21, !22}
39 ; CHECK-NEXT: !19 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !1, line: 42, type: !7)
40 ; CHECK-NEXT: !20 = !DILocalVariable(name: "b", arg: 2, scope: !12, file: !1, line: 42, type: !7)
41 ; CHECK-NEXT: !21 = !DILocalVariable(name: "c", arg: 3, scope: !12, file: !1, line: 42, type: !15)
42 ; CHECK-NEXT: !22 = !DILocalVariable(name: "d", scope: !23, file: !1, line: 43, type: !7)
43 ; CHECK-NEXT: !23 = distinct !DILexicalBlock(scope: !12, file: !1, line: 42)
44 ; CHECK-NEXT: !24 = !DILocation(line: 42, scope: !12)
45 ; CHECK-NEXT: !25 = !DILocation(line: 43, scope: !12)
28 ; CHECK-NEXT: !8 = !{!9, !11}
29 ; CHECK-NEXT: !9 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !6, entity: !10, file: !1, line: 42)
30 ; CHECK-NEXT: !10 = !DIModule(scope: null, name: "llvm-c-test-import", includePath: "/test/include/llvm-c-test-import.h")
31 ; CHECK-NEXT: !11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !6, entity: !9, file: !1, line: 42)
32 ; CHECK-NEXT: !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 192, dwarfAddressSpace: 0)
33 ; CHECK-NEXT: !13 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", scope: !14, file: !1, size: 192, elements: !15, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
34 ; CHECK-NEXT: !14 = !DINamespace(name: "NameSpace", scope: !6)
35 ; CHECK-NEXT: !15 = !{!7, !7, !7}
36 ; CHECK-NEXT: !16 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !17, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !22)
37 ; CHECK-NEXT: !17 = !DISubroutineType(types: !18)
38 ; CHECK-NEXT: !18 = !{!7, !7, !19}
39 ; CHECK-NEXT: !19 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 640, flags: DIFlagVector, elements: !20)
40 ; CHECK-NEXT: !20 = !{!21}
41 ; CHECK-NEXT: !21 = !DISubrange(count: 10)
42 ; CHECK-NEXT: !22 = !{!23, !24, !25, !26}
43 ; CHECK-NEXT: !23 = !DILocalVariable(name: "a", arg: 1, scope: !16, file: !1, line: 42, type: !7)
44 ; CHECK-NEXT: !24 = !DILocalVariable(name: "b", arg: 2, scope: !16, file: !1, line: 42, type: !7)
45 ; CHECK-NEXT: !25 = !DILocalVariable(name: "c", arg: 3, scope: !16, file: !1, line: 42, type: !19)
46 ; CHECK-NEXT: !26 = !DILocalVariable(name: "d", scope: !27, file: !1, line: 43, type: !7)
47 ; CHECK-NEXT: !27 = distinct !DILexicalBlock(scope: !16, file: !1, line: 42)
48 ; CHECK-NEXT: !28 = !DILocation(line: 42, scope: !16)
49 ; CHECK-NEXT: !29 = !DILocation(line: 43, scope: !16)
3434 "", 0,
3535 "/test/include/llvm-c-test.h", 27,
3636 "", 0);
37
38 LLVMMetadataRef OtherModule =
39 LLVMDIBuilderCreateModule(DIB, CompileUnit,
40 "llvm-c-test-import", 18,
41 "", 0,
42 "/test/include/llvm-c-test-import.h", 34,
43 "", 0);
44 LLVMMetadataRef ImportedModule =
45 LLVMDIBuilderCreateImportedModuleFromModule(DIB, Module, OtherModule,
46 File, 42);
47 LLVMMetadataRef AliasImportedModule =
48 LLVMDIBuilderCreateImportedModuleFromAlias(DIB, Module, ImportedModule,
49 File, 42);
3750
3851 LLVMMetadataRef Int64Ty =
3952 LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0);