[C-API][DIBuilder] Added DIFlags in LLVMDIBuilderCreateBasicType

Added DIFlags in LLVMDIBuilderCreateBasicType to add optional DWARF
attributes, such as DW_AT_endianity.

Patch by Chirag Patel.

Differential Revision: https://reviews.llvm.org/D50832

llvm-svn: 340146
This commit is contained in:
whitequark 2018-08-19 23:39:47 +00:00
parent 3762bd1fe5
commit b8bf292fc1
4 changed files with 11 additions and 4 deletions

View File

@ -299,6 +299,7 @@ func (d *DIBuilder) CreateBasicType(t DIBasicType) Metadata {
C.size_t(len(t.Name)),
C.uint64_t(t.SizeInBits),
C.unsigned(t.Encoding),
C.LLVMDIFlags(0),
)
return Metadata{C: result}
}

View File

@ -57,6 +57,8 @@ typedef enum {
LLVMDIFlagFixedEnum = 1 << 24,
LLVMDIFlagThunk = 1 << 25,
LLVMDIFlagTrivial = 1 << 26,
LLVMDIFlagBigEndian = 1 << 27,
LLVMDIFlagLittleEndian = 1 << 28,
LLVMDIFlagIndirectVirtualBase = (1 << 2) | (1 << 5),
LLVMDIFlagAccessibility = LLVMDIFlagPrivate | LLVMDIFlagProtected |
LLVMDIFlagPublic,
@ -531,11 +533,13 @@ LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name,
* \param NameLen Length of type name.
* \param SizeInBits Size of the type.
* \param Encoding DWARF encoding code, e.g. \c LLVMDWARFTypeEncoding_float.
* \param Flags Flags to encode optional attribute like endianity
*/
LLVMMetadataRef
LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder, const char *Name,
size_t NameLen, uint64_t SizeInBits,
LLVMDWARFTypeEncoding Encoding);
LLVMDWARFTypeEncoding Encoding,
LLVMDIFlags Flags);
/**
* Create debugging information entry for a pointer.

View File

@ -948,9 +948,11 @@ LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size,
LLVMMetadataRef
LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder, const char *Name,
size_t NameLen, uint64_t SizeInBits,
LLVMDWARFTypeEncoding Encoding) {
LLVMDWARFTypeEncoding Encoding,
LLVMDIFlags Flags) {
return wrap(unwrap(Builder)->createBasicType({Name, NameLen},
SizeInBits, Encoding));
SizeInBits, Encoding,
map_from_llvmDIFlags(Flags)));
}
LLVMMetadataRef LLVMDIBuilderCreatePointerType(

View File

@ -68,7 +68,7 @@ int llvm_test_dibuilder(void) {
NULL, 0);
LLVMMetadataRef Int64Ty =
LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0);
LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
LLVMMetadataRef Int64TypeDef =
LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File);