[llvm] r330591 - [LLVM-C] Finish Up Scope Bindings
Robert Widmann via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 23 06:51:43 PDT 2018
Author: codafi
Date: Mon Apr 23 06:51:43 2018
New Revision: 330591
URL: http://llvm.org/viewvc/llvm-project?rev=330591&view=rev
Log:
[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
Modified:
llvm/trunk/include/llvm-c/DebugInfo.h
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/test/Bindings/llvm-c/debug_info.ll
llvm/trunk/tools/llvm-c-test/debuginfo.c
Modified: llvm/trunk/include/llvm-c/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/DebugInfo.h?rev=330591&r1=330590&r2=330591&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/DebugInfo.h (original)
+++ llvm/trunk/include/llvm-c/DebugInfo.h Mon Apr 23 06:51:43 2018
@@ -218,6 +218,42 @@ LLVMDIBuilderCreateFile(LLVMDIBuilderRef
size_t DirectoryLen);
/**
+ * Creates a new descriptor for a module with the specified parent scope.
+ * \param Builder The \c DIBuilder.
+ * \param ParentScope The parent scope containing this module declaration.
+ * \param Name Module name.
+ * \param NameLen The length of the C string passed to \c Name.
+ * \param ConfigMacros A space-separated shell-quoted list of -D macro
+ definitions as they would appear on a command line.
+ * \param ConfigMacrosLen The length of the C string passed to \c ConfigMacros.
+ * \param IncludePath The path to the module map file.
+ * \param IncludePathLen The length of the C string passed to \c IncludePath.
+ * \param ISysRoot The Clang system root (value of -isysroot).
+ * \param ISysRootLen The length of the C string passed to \c ISysRoot.
+ */
+LLVMMetadataRef
+LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope,
+ const char *Name, size_t NameLen,
+ const char *ConfigMacros, size_t ConfigMacrosLen,
+ const char *IncludePath, size_t IncludePathLen,
+ const char *ISysRoot, size_t ISysRootLen);
+
+/**
+ * Creates a new descriptor for a namespace with the specified parent scope.
+ * \param Builder The \c DIBuilder.
+ * \param ParentScope The parent scope containing this module declaration.
+ * \param Name NameSpace name.
+ * \param NameLen The length of the C string passed to \c Name.
+ * \param ExportSymbols Whether or not the namespace exports symbols, e.g.
+ * this is true of C++ inline namespaces.
+ */
+LLVMMetadataRef
+LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
+ LLVMMetadataRef ParentScope,
+ const char *Name, size_t NameLen,
+ LLVMBool ExportSymbols);
+
+/**
* Create a new descriptor for the specified subprogram.
* \param Builder The \c DIBuilder.
* \param Scope Function scope.
@@ -538,14 +574,44 @@ LLVMMetadataRef
LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder);
/**
+ * Create a permanent forward-declared type.
+ * \param Builder The DIBuilder.
+ * \param Tag A unique tag for this type.
+ * \param Name Type name.
+ * \param NameLen Length of type name.
+ * \param Scope Type scope.
+ * \param File File where this type is defined.
+ * \param Line Line number where this type is defined.
+ * \param RuntimeLang Indicates runtime version for languages like
+ * Objective-C.
+ * \param SizeInBits Member size.
+ * \param AlignInBits Member alignment.
+ * \param Flags Flags.
+ * \param UniqueIdentifier A unique identifier for the type.
+ * \param UniqueIdentifierLen Length of the unique identifier.
+ */
+LLVMMetadataRef LLVMDIBuilderCreateForwardDecl(
+ LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
+ size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
+ unsigned RuntimeLang, unsigned SizeInBits, unsigned AlignInBits,
+ const char *UniqueIdentifier, size_t UniqueIdentifierLen);
+
+/**
* Create a temporary forward-declared type.
- * \param Builder The DIBuilder.
- * \param Tag A unique tag for this type.
- * \param Name Type name.
- * \param NameLen Length of type name.
- * \param Scope Type scope.
- * \param File File where this type is defined.
- * \param Line Line number where this type is defined.
+ * \param Builder The DIBuilder.
+ * \param Tag A unique tag for this type.
+ * \param Name Type name.
+ * \param NameLen Length of type name.
+ * \param Scope Type scope.
+ * \param File File where this type is defined.
+ * \param Line Line number where this type is defined.
+ * \param RuntimeLang Indicates runtime version for languages like
+ * Objective-C.
+ * \param SizeInBits Member size.
+ * \param AlignInBits Member alignment.
+ * \param Flags Flags.
+ * \param UniqueIdentifier A unique identifier for the type.
+ * \param UniqueIdentifierLen Length of the unique identifier.
*/
LLVMMetadataRef
LLVMDIBuilderCreateReplaceableCompositeType(
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=330591&r1=330590&r2=330591&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr 23 06:51:43 2018
@@ -775,6 +775,27 @@ LLVMDIBuilderCreateFile(LLVMDIBuilderRef
StringRef(Directory, DirectoryLen)));
}
+LLVMMetadataRef
+LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope,
+ const char *Name, size_t NameLen,
+ const char *ConfigMacros, size_t ConfigMacrosLen,
+ const char *IncludePath, size_t IncludePathLen,
+ const char *ISysRoot, size_t ISysRootLen) {
+ return wrap(unwrap(Builder)->createModule(
+ unwrapDI<DIScope>(ParentScope), StringRef(Name, NameLen),
+ StringRef(ConfigMacros, ConfigMacrosLen),
+ StringRef(IncludePath, IncludePathLen),
+ StringRef(ISysRoot, ISysRootLen)));
+}
+
+LLVMMetadataRef LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
+ LLVMMetadataRef ParentScope,
+ const char *Name, size_t NameLen,
+ LLVMBool ExportSymbols) {
+ return wrap(unwrap(Builder)->createNameSpace(
+ unwrapDI<DIScope>(ParentScope), StringRef(Name, NameLen), ExportSymbols));
+}
+
LLVMMetadataRef LLVMDIBuilderCreateFunction(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
@@ -933,6 +954,18 @@ LLVMDIBuilderCreateObjectPointerType(LLV
}
LLVMMetadataRef
+LLVMDIBuilderCreateForwardDecl(
+ LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
+ size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
+ unsigned RuntimeLang, unsigned SizeInBits, unsigned AlignInBits,
+ const char *UniqueIdentifier, size_t UniqueIdentifierLen) {
+ return wrap(unwrap(Builder)->createForwardDecl(
+ Tag, {Name, NameLen}, unwrapDI<DIScope>(Scope),
+ unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
+ AlignInBits, {UniqueIdentifier, UniqueIdentifierLen}));
+}
+
+LLVMMetadataRef
LLVMDIBuilderCreateReplaceableCompositeType(
LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
Modified: llvm/trunk/test/Bindings/llvm-c/debug_info.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/llvm-c/debug_info.ll?rev=330591&r1=330590&r2=330591&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/llvm-c/debug_info.ll (original)
+++ llvm/trunk/test/Bindings/llvm-c/debug_info.ll Mon Apr 23 06:51:43 2018
@@ -3,15 +3,15 @@
; CHECK: ; ModuleID = 'debuginfo.c'
; CHECK-NEXT: source_filename = "debuginfo.c"
-; CHECK: define i64 @foo(i64, i64) !dbg !7 {
+; CHECK: define i64 @foo(i64, i64) !dbg !9 {
; CHECK-NEXT: entry:
-; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !11, metadata !DIExpression()), !dbg !13
-; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !12, metadata !DIExpression()), !dbg !13
+; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !13, metadata !DIExpression()), !dbg !15
+; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !14, metadata !DIExpression()), !dbg !15
; CHECK-NEXT: }
; CHECK: declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
-; CHECK: declare !dbg !14 i64 @foo_inner_scope(i64, i64)
+; CHECK: declare !dbg !16 i64 @foo_inner_scope(i64, i64)
; CHECK: !llvm.dbg.cu = !{!0}
; CHECK-NEXT: !FooType = !{!3}
@@ -20,16 +20,17 @@
; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".")
; CHECK-NEXT: !2 = !{}
; CHECK-NEXT: !3 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 192, dwarfAddressSpace: 0)
-; CHECK-NEXT: !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", file: !1, size: 192, elements: !5, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
-; CHECK-NEXT: !5 = !{!6, !6, !6}
-; CHECK-NEXT: !6 = !DIBasicType(name: "Int64", size: 64)
-; 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)
-; CHECK-NEXT: !8 = !DISubroutineType(types: !9)
-; CHECK-NEXT: !9 = !{!6, !6}
-; CHECK-NEXT: !10 = !{!11, !12}
-; CHECK-NEXT: !11 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 42, type: !6)
-; CHECK-NEXT: !12 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 42, type: !6)
-; CHECK-NEXT: !13 = !DILocation(line: 42, scope: !7)
-; 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)
-; CHECK-NEXT: !15 = distinct !DILexicalBlock(scope: !7, file: !1, line: 42)
-
+; 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")
+; CHECK-NEXT: !5 = !DINamespace(name: "NameSpace", scope: !6)
+; CHECK-NEXT: !6 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h")
+; CHECK-NEXT: !7 = !{!8, !8, !8}
+; CHECK-NEXT: !8 = !DIBasicType(name: "Int64", size: 64)
+; 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)
+; CHECK-NEXT: !10 = !DISubroutineType(types: !11)
+; CHECK-NEXT: !11 = !{!8, !8}
+; CHECK-NEXT: !12 = !{!13, !14}
+; CHECK-NEXT: !13 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 42, type: !8)
+; CHECK-NEXT: !14 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 42, type: !8)
+; CHECK-NEXT: !15 = !DILocation(line: 42, scope: !9)
+; 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)
+; CHECK-NEXT: !17 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42)
Modified: llvm/trunk/tools/llvm-c-test/debuginfo.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-c-test/debuginfo.c?rev=330591&r1=330590&r2=330591&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-c-test/debuginfo.c (original)
+++ llvm/trunk/tools/llvm-c-test/debuginfo.c Mon Apr 23 06:51:43 2018
@@ -26,15 +26,25 @@ int llvm_test_dibuilder(void) {
strlen(Filename), ".", 1);
LLVMMetadataRef CompileUnit = LLVMDIBuilderCreateCompileUnit(DIB,
- LLVMDWARFSourceLanguageC, File,"llvm-c-test", 11, 0, NULL, 0, 0,
- NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0);
+ LLVMDWARFSourceLanguageC, File, "llvm-c-test", 11, 0, NULL, 0, 0,
+ NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0);
+
+ LLVMMetadataRef Module =
+ LLVMDIBuilderCreateModule(DIB, CompileUnit,
+ "llvm-c-test", 11,
+ "", 0,
+ "/test/include/llvm-c-test.h", 27,
+ "", 0);
+
+ LLVMMetadataRef NameSpace =
+ LLVMDIBuilderCreateNameSpace(DIB, Module, "NameSpace", 9, false);
LLVMMetadataRef Int64Ty =
LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0);
LLVMMetadataRef StructDbgElts[] = {Int64Ty, Int64Ty, Int64Ty};
LLVMMetadataRef StructDbgTy =
- LLVMDIBuilderCreateStructType(DIB, CompileUnit, "MyStruct",
+ LLVMDIBuilderCreateStructType(DIB, NameSpace, "MyStruct",
8, File, 0, 192, 0, 0, NULL, StructDbgElts, 3,
LLVMDWARFSourceLanguageC, NULL, "MyStruct", 8);
More information about the llvm-commits
mailing list