llvm.org GIT mirror llvm / 2fbfc40
[LLVM-C] Finish Up Scope Bindings Summary: Adds bindings for Module and NameSpace scopes and LLVMDIBuilderCreateForwardDecl, a counterpart to LLVMDIBuilderCreateReplaceableCompositeType. Reviewers: harlanhaskins, whitequark, deadalnix Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45934 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330591 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 1 year, 4 months ago
4 changed file(s) with 137 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
217217 size_t DirectoryLen);
218218
219219 /**
220 * Creates a new descriptor for a module with the specified parent scope.
221 * \param Builder The \c DIBuilder.
222 * \param ParentScope The parent scope containing this module declaration.
223 * \param Name Module name.
224 * \param NameLen The length of the C string passed to \c Name.
225 * \param ConfigMacros A space-separated shell-quoted list of -D macro
226 definitions as they would appear on a command line.
227 * \param ConfigMacrosLen The length of the C string passed to \c ConfigMacros.
228 * \param IncludePath The path to the module map file.
229 * \param IncludePathLen The length of the C string passed to \c IncludePath.
230 * \param ISysRoot The Clang system root (value of -isysroot).
231 * \param ISysRootLen The length of the C string passed to \c ISysRoot.
232 */
233 LLVMMetadataRef
234 LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope,
235 const char *Name, size_t NameLen,
236 const char *ConfigMacros, size_t ConfigMacrosLen,
237 const char *IncludePath, size_t IncludePathLen,
238 const char *ISysRoot, size_t ISysRootLen);
239
240 /**
241 * Creates a new descriptor for a namespace with the specified parent scope.
242 * \param Builder The \c DIBuilder.
243 * \param ParentScope The parent scope containing this module declaration.
244 * \param Name NameSpace name.
245 * \param NameLen The length of the C string passed to \c Name.
246 * \param ExportSymbols Whether or not the namespace exports symbols, e.g.
247 * this is true of C++ inline namespaces.
248 */
249 LLVMMetadataRef
250 LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
251 LLVMMetadataRef ParentScope,
252 const char *Name, size_t NameLen,
253 LLVMBool ExportSymbols);
254
255 /**
220256 * Create a new descriptor for the specified subprogram.
221257 * \param Builder The \c DIBuilder.
222258 * \param Scope Function scope.
537573 LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder);
538574
539575 /**
576 * Create a permanent forward-declared type.
577 * \param Builder The DIBuilder.
578 * \param Tag A unique tag for this type.
579 * \param Name Type name.
580 * \param NameLen Length of type name.
581 * \param Scope Type scope.
582 * \param File File where this type is defined.
583 * \param Line Line number where this type is defined.
584 * \param RuntimeLang Indicates runtime version for languages like
585 * Objective-C.
586 * \param SizeInBits Member size.
587 * \param AlignInBits Member alignment.
588 * \param Flags Flags.
589 * \param UniqueIdentifier A unique identifier for the type.
590 * \param UniqueIdentifierLen Length of the unique identifier.
591 */
592 LLVMMetadataRef LLVMDIBuilderCreateForwardDecl(
593 LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
594 size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
595 unsigned RuntimeLang, unsigned SizeInBits, unsigned AlignInBits,
596 const char *UniqueIdentifier, size_t UniqueIdentifierLen);
597
598 /**
540599 * Create a temporary forward-declared type.
541 * \param Builder The DIBuilder.
542 * \param Tag A unique tag for this type.
543 * \param Name Type name.
544 * \param NameLen Length of type name.
545 * \param Scope Type scope.
546 * \param File File where this type is defined.
547 * \param Line Line number where this type is defined.
600 * \param Builder The DIBuilder.
601 * \param Tag A unique tag for this type.
602 * \param Name Type name.
603 * \param NameLen Length of type name.
604 * \param Scope Type scope.
605 * \param File File where this type is defined.
606 * \param Line Line number where this type is defined.
607 * \param RuntimeLang Indicates runtime version for languages like
608 * Objective-C.
609 * \param SizeInBits Member size.
610 * \param AlignInBits Member alignment.
611 * \param Flags Flags.
612 * \param UniqueIdentifier A unique identifier for the type.
613 * \param UniqueIdentifierLen Length of the unique identifier.
548614 */
549615 LLVMMetadataRef
550616 LLVMDIBuilderCreateReplaceableCompositeType(
774774 StringRef(Directory, DirectoryLen)));
775775 }
776776
777 LLVMMetadataRef
778 LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope,
779 const char *Name, size_t NameLen,
780 const char *ConfigMacros, size_t ConfigMacrosLen,
781 const char *IncludePath, size_t IncludePathLen,
782 const char *ISysRoot, size_t ISysRootLen) {
783 return wrap(unwrap(Builder)->createModule(
784 unwrapDI(ParentScope), StringRef(Name, NameLen),
785 StringRef(ConfigMacros, ConfigMacrosLen),
786 StringRef(IncludePath, IncludePathLen),
787 StringRef(ISysRoot, ISysRootLen)));
788 }
789
790 LLVMMetadataRef LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
791 LLVMMetadataRef ParentScope,
792 const char *Name, size_t NameLen,
793 LLVMBool ExportSymbols) {
794 return wrap(unwrap(Builder)->createNameSpace(
795 unwrapDI(ParentScope), StringRef(Name, NameLen), ExportSymbols));
796 }
797
777798 LLVMMetadataRef LLVMDIBuilderCreateFunction(
778799 LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
779800 size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
932953 }
933954
934955 LLVMMetadataRef
956 LLVMDIBuilderCreateForwardDecl(
957 LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
958 size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
959 unsigned RuntimeLang, unsigned SizeInBits, unsigned AlignInBits,
960 const char *UniqueIdentifier, size_t UniqueIdentifierLen) {
961 return wrap(unwrap(Builder)->createForwardDecl(
962 Tag, {Name, NameLen}, unwrapDI(Scope),
963 unwrapDI(File), Line, RuntimeLang, SizeInBits,
964 AlignInBits, {UniqueIdentifier, UniqueIdentifierLen}));
965 }
966
967 LLVMMetadataRef
935968 LLVMDIBuilderCreateReplaceableCompositeType(
936969 LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
937970 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) !dbg !7 {
5 ; CHECK: define i64 @foo(i64, i64) !dbg !9 {
66 ; CHECK-NEXT: entry:
7 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !11, metadata !DIExpression()), !dbg !13
8 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !12, metadata !DIExpression()), !dbg !13
7 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !13, metadata !DIExpression()), !dbg !15
8 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !14, metadata !DIExpression()), !dbg !15
99 ; CHECK-NEXT: }
1010
1111 ; CHECK: declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
1212
13 ; CHECK: declare !dbg !14 i64 @foo_inner_scope(i64, i64)
13 ; CHECK: declare !dbg !16 i64 @foo_inner_scope(i64, i64)
1414
1515 ; CHECK: !llvm.dbg.cu = !{!0}
1616 ; CHECK-NEXT: !FooType = !{!3}
1919 ; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".")
2020 ; CHECK-NEXT: !2 = !{}
2121 ; CHECK-NEXT: !3 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 192, dwarfAddressSpace: 0)
22 ; CHECK-NEXT: !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", file: !1, size: 192, elements: !5, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
23 ; CHECK-NEXT: !5 = !{!6, !6, !6}
24 ; CHECK-NEXT: !6 = !DIBasicType(name: "Int64", size: 64)
25 ; CHECK-NEXT: !7 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !8, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !10)
26 ; CHECK-NEXT: !8 = !DISubroutineType(types: !9)
27 ; CHECK-NEXT: !9 = !{!6, !6}
28 ; CHECK-NEXT: !10 = !{!11, !12}
29 ; CHECK-NEXT: !11 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 42, type: !6)
30 ; CHECK-NEXT: !12 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 42, type: !6)
31 ; CHECK-NEXT: !13 = !DILocation(line: 42, scope: !7)
32 ; CHECK-NEXT: !14 = distinct !DISubprogram(name: "foo_inner_scope", linkageName: "foo_inner_scope", scope: !15, file: !1, line: 42, type: !8, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !2)
33 ; CHECK-NEXT: !15 = distinct !DILexicalBlock(scope: !7, file: !1, line: 42)
34
22 ; CHECK-NEXT: !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", scope: !5, file: !1, size: 192, elements: !7, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
23 ; CHECK-NEXT: !5 = !DINamespace(name: "NameSpace", scope: !6)
24 ; CHECK-NEXT: !6 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h")
25 ; CHECK-NEXT: !7 = !{!8, !8, !8}
26 ; CHECK-NEXT: !8 = !DIBasicType(name: "Int64", size: 64)
27 ; CHECK-NEXT: !9 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !10, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !12)
28 ; CHECK-NEXT: !10 = !DISubroutineType(types: !11)
29 ; CHECK-NEXT: !11 = !{!8, !8}
30 ; CHECK-NEXT: !12 = !{!13, !14}
31 ; CHECK-NEXT: !13 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 42, type: !8)
32 ; CHECK-NEXT: !14 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 42, type: !8)
33 ; CHECK-NEXT: !15 = !DILocation(line: 42, scope: !9)
34 ; CHECK-NEXT: !16 = distinct !DISubprogram(name: "foo_inner_scope", linkageName: "foo_inner_scope", scope: !17, file: !1, line: 42, type: !10, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !2)
35 ; CHECK-NEXT: !17 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42)
2525 strlen(Filename), ".", 1);
2626
2727 LLVMMetadataRef CompileUnit = LLVMDIBuilderCreateCompileUnit(DIB,
28 LLVMDWARFSourceLanguageC, File,"llvm-c-test", 11, 0, NULL, 0, 0,
29 NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0);
28 LLVMDWARFSourceLanguageC, File, "llvm-c-test", 11, 0, NULL, 0, 0,
29 NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0);
30
31 LLVMMetadataRef Module =
32 LLVMDIBuilderCreateModule(DIB, CompileUnit,
33 "llvm-c-test", 11,
34 "", 0,
35 "/test/include/llvm-c-test.h", 27,
36 "", 0);
37
38 LLVMMetadataRef NameSpace =
39 LLVMDIBuilderCreateNameSpace(DIB, Module, "NameSpace", 9, false);
3040
3141 LLVMMetadataRef Int64Ty =
3242 LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0);
3343
3444 LLVMMetadataRef StructDbgElts[] = {Int64Ty, Int64Ty, Int64Ty};
3545 LLVMMetadataRef StructDbgTy =
36 LLVMDIBuilderCreateStructType(DIB, CompileUnit, "MyStruct",
46 LLVMDIBuilderCreateStructType(DIB, NameSpace, "MyStruct",
3747 8, File, 0, 192, 0, 0, NULL, StructDbgElts, 3,
3848 LLVMDWARFSourceLanguageC, NULL, "MyStruct", 8);
3949