llvm.org GIT mirror llvm / 07e5114
[LLVM-C] Consolidate llgo's DIBuilder Bindings Summary: Move and correct LLVMDIBuilderCreateTypedef. This is the last API in DIBuilderBindings.h, so it is being removed and the C API will now be re-exported from IRBindings.h. Reviewers: whitequark, harlanhaskins, deadalnix Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46725 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332041 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 1 year, 4 months ago
8 changed file(s) with 64 addition(s) and 102 deletion(s). Raw diff Collapse all Expand all
+0
-30
bindings/go/llvm/DIBuilderBindings.cpp less more
None //===- DIBuilderBindings.cpp - Bindings for DIBuilder ---------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines C bindings for the DIBuilder class.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "DIBuilderBindings.h"
14 #include "IRBindings.h"
15 #include "llvm/IR/DIBuilder.h"
16 #include "llvm/IR/IRBuilder.h"
17 #include "llvm/IR/Module.h"
18
19 using namespace llvm;
20
21 LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref,
22 LLVMMetadataRef Ty, const char *Name,
23 LLVMMetadataRef File, unsigned Line,
24 LLVMMetadataRef Context) {
25 DIBuilder *D = unwrap(Dref);
26 return wrap(D->createTypedef(unwrap(Ty), Name,
27 File ? unwrap(File) : nullptr, Line,
28 Context ? unwrap(Context) : nullptr));
29 }
+0
-40
bindings/go/llvm/DIBuilderBindings.h less more
None //===- DIBuilderBindings.h - Bindings for DIBuilder -------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines C bindings for the DIBuilder class.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_BINDINGS_GO_LLVM_DIBUILDERBINDINGS_H
14 #define LLVM_BINDINGS_GO_LLVM_DIBUILDERBINDINGS_H
15
16 #include "IRBindings.h"
17 #include "llvm-c/Core.h"
18 #include "llvm-c/DebugInfo.h"
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 // FIXME: These bindings shouldn't be Go-specific and should eventually move to
25 // a (somewhat) less stable collection of C APIs for use in creating bindings of
26 // LLVM in other languages.
27
28 typedef struct LLVMOpaqueDIBuilder *LLVMDIBuilderRef;
29
30 LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef D,
31 LLVMMetadataRef Ty, const char *Name,
32 LLVMMetadataRef File, unsigned Line,
33 LLVMMetadataRef Context);
34
35 #ifdef __cplusplus
36 } // extern "C"
37 #endif
38
39 #endif
1414 #define LLVM_BINDINGS_GO_LLVM_IRBINDINGS_H
1515
1616 #include "llvm-c/Core.h"
17 #include "llvm-c/DebugInfo.h"
1718 #ifdef __cplusplus
1819 #include "llvm/IR/Metadata.h"
1920 #include "llvm/Support/CBindingWrapping.h"
1313 package llvm
1414
1515 /*
16 #include "DIBuilderBindings.h"
16 #include "IRBindings.h"
1717 #include
1818 */
1919 import "C"
513513 d.ref,
514514 t.Type.C,
515515 name,
516 C.size_t(len(t.Name)),
516517 t.File.C,
517518 C.unsigned(t.Line),
518519 t.Context.C,
673673 LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder);
674674
675675 /**
676 * Create debugging information entry for a typedef.
677 * \param Builder The DIBuilder.
678 * \param Type Original type.
679 * \param Name Typedef name.
680 * \param File File where this type is defined.
681 * \param LineNo Line number.
682 * \param Scope The surrounding context for the typedef.
683 */
684 LLVMMetadataRef
685 LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
686 const char *Name, size_t NameLen,
687 LLVMMetadataRef File, unsigned LineNo,
688 LLVMMetadataRef Scope);
689
690 /**
676691 * Create a permanent forward-declared type.
677692 * \param Builder The DIBuilder.
678693 * \param Tag A unique tag for this type.
10181018 }
10191019
10201020 LLVMMetadataRef
1021 LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
1022 const char *Name, size_t NameLen,
1023 LLVMMetadataRef File, unsigned LineNo,
1024 LLVMMetadataRef Scope) {
1025 return wrap(unwrap(Builder)->createTypedef(
1026 unwrapDI(Type), {Name, NameLen},
1027 unwrapDI(File), LineNo,
1028 unwrapDI(Scope)));
1029 }
1030
1031 LLVMMetadataRef
10211032 LLVMDIBuilderCreateForwardDecl(
10221033 LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
10231034 size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
22 ; CHECK: ; ModuleID = 'debuginfo.c'
33 ; CHECK-NEXT: source_filename = "debuginfo.c"
44
5 ; CHECK: define i64 @foo(i64, i64, <10 x i64>) !dbg !16 {
5 ; CHECK: define i64 @foo(i64, i64, <10 x i64>) !dbg !17 {
66 ; CHECK-NEXT: entry:
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
7 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !24, metadata !DIExpression()), !dbg !29
8 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !25, metadata !DIExpression()), !dbg !29
9 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !26, metadata !DIExpression()), !dbg !29
1010 ; CHECK: vars:
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
11 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 0, metadata !27, metadata !DIExpression(DW_OP_constu, 0, DW_OP_stack_value)), !dbg !30
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 = !{!12}
18 ; CHECK: !FooType = !{!13}
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, imports: !8, 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: !9, splitDebugInlining: false)
2121 ; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".")
2222 ; CHECK-NEXT: !2 = !{}
2323 ; CHECK-NEXT: !3 = !{!4}
2424 ; CHECK-NEXT: !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
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")
27 ; CHECK-NEXT: !7 = !DIBasicType(name: "Int64", size: 64)
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, retainedNodes: !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)
27 ; CHECK-NEXT: !7 = !DIDerivedType(tag: DW_TAG_typedef, name: "int64_t", scope: !1, file: !1, line: 42, baseType: !8)
28 ; CHECK-NEXT: !8 = !DIBasicType(name: "Int64", size: 64)
29 ; CHECK-NEXT: !9 = !{!10, !12}
30 ; CHECK-NEXT: !10 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !6, entity: !11, file: !1, line: 42)
31 ; CHECK-NEXT: !11 = !DIModule(scope: null, name: "llvm-c-test-import", includePath: "/test/include/llvm-c-test-import.h")
32 ; CHECK-NEXT: !12 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !6, entity: !10, file: !1, line: 42)
33 ; CHECK-NEXT: !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 192, dwarfAddressSpace: 0)
34 ; CHECK-NEXT: !14 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", scope: !15, file: !1, size: 192, elements: !16, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
35 ; CHECK-NEXT: !15 = !DINamespace(name: "NameSpace", scope: !6)
36 ; CHECK-NEXT: !16 = !{!8, !8, !8}
37 ; CHECK-NEXT: !17 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !18, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, retainedNodes: !23)
38 ; CHECK-NEXT: !18 = !DISubroutineType(types: !19)
39 ; CHECK-NEXT: !19 = !{!8, !8, !20}
40 ; CHECK-NEXT: !20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 640, flags: DIFlagVector, elements: !21)
41 ; CHECK-NEXT: !21 = !{!22}
42 ; CHECK-NEXT: !22 = !DISubrange(count: 10)
43 ; CHECK-NEXT: !23 = !{!24, !25, !26, !27}
44 ; CHECK-NEXT: !24 = !DILocalVariable(name: "a", arg: 1, scope: !17, file: !1, line: 42, type: !8)
45 ; CHECK-NEXT: !25 = !DILocalVariable(name: "b", arg: 2, scope: !17, file: !1, line: 42, type: !8)
46 ; CHECK-NEXT: !26 = !DILocalVariable(name: "c", arg: 3, scope: !17, file: !1, line: 42, type: !20)
47 ; CHECK-NEXT: !27 = !DILocalVariable(name: "d", scope: !28, file: !1, line: 43, type: !8)
48 ; CHECK-NEXT: !28 = distinct !DILexicalBlock(scope: !17, file: !1, line: 42)
49 ; CHECK-NEXT: !29 = !DILocation(line: 42, scope: !17)
50 ; CHECK-NEXT: !30 = !DILocation(line: 43, scope: !17)
4949
5050 LLVMMetadataRef Int64Ty =
5151 LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0);
52 LLVMMetadataRef Int64TypeDef =
53 LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File);
54
5255 LLVMMetadataRef GlobalVarValueExpr =
5356 LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
5457 LLVMDIBuilderCreateGlobalVariableExpression(DIB, Module, "global", 6,
55 "", 0, File, 1, Int64Ty,
58 "", 0, File, 1, Int64TypeDef,
5659 true, GlobalVarValueExpr,
5760 NULL, 0);
5861