From 1568175235766d9dcf6bad89b9b4571f6c2b598b Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 8 Apr 2015 20:18:57 +0000 Subject: [PATCH] Go bindings: make various DIBuilder arguments optional. r234262 changed some code in DIBuilderBindings.cpp to use the unwrap function to unwrap debug metadata. The problem with this is that unwrap asserts that its argument is non-null, which is not what we want in a number of places in DIBuilder where the argument is optional. This change makes certain arguments optional by adding null checks in places where it is required, fixing the llgo build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234428 91177308-0d34-0410-b5e6-96231b3b80d8 --- bindings/go/llvm/DIBuilderBindings.cpp | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/bindings/go/llvm/DIBuilderBindings.cpp b/bindings/go/llvm/DIBuilderBindings.cpp index ed583a8f76a..ee2e70a579b 100644 --- a/bindings/go/llvm/DIBuilderBindings.cpp +++ b/bindings/go/llvm/DIBuilderBindings.cpp @@ -83,9 +83,9 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction( DIBuilder *D = unwrap(Dref); DISubprogram SP = D->createFunction( DIDescriptor(unwrap(Scope)), Name, LinkageName, - unwrap(File), Line, unwrap(CompositeType), - IsLocalToUnit, IsDefinition, ScopeLine, Flags, IsOptimized, - unwrap(Func)); + File ? unwrap(File) : nullptr, Line, + unwrap(CompositeType), IsLocalToUnit, IsDefinition, + ScopeLine, Flags, IsOptimized, unwrap(Func)); return wrap(SP); } @@ -125,8 +125,9 @@ LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Dref, LLVMMetadataRef File, LLVMMetadataRef ParameterTypes) { DIBuilder *D = unwrap(Dref); - DICompositeType CT = D->createSubroutineType( - unwrap(File), DITypeArray(unwrap(ParameterTypes))); + DICompositeType CT = + D->createSubroutineType(File ? unwrap(File) : nullptr, + DITypeArray(unwrap(ParameterTypes))); return wrap(CT); } @@ -137,9 +138,10 @@ LLVMMetadataRef LLVMDIBuilderCreateStructType( LLVMMetadataRef ElementTypes) { DIBuilder *D = unwrap(Dref); DICompositeType CT = D->createStructType( - DIDescriptor(unwrap(Scope)), Name, unwrap(File), Line, - SizeInBits, AlignInBits, Flags, unwrap(DerivedFrom), - DIArray(unwrap(ElementTypes))); + DIDescriptor(unwrap(Scope)), Name, + File ? unwrap(File) : nullptr, Line, SizeInBits, AlignInBits, + Flags, DerivedFrom ? unwrap(DerivedFrom) : nullptr, + ElementTypes ? DIArray(unwrap(ElementTypes)) : nullptr); return wrap(CT); } @@ -150,8 +152,9 @@ LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType( unsigned Flags) { DIBuilder *D = unwrap(Dref); DICompositeType CT = D->createReplaceableCompositeType( - Tag, Name, DIDescriptor(unwrap(Scope)), unwrap(File), - Line, RuntimeLang, SizeInBits, AlignInBits, Flags); + Tag, Name, DIDescriptor(unwrap(Scope)), + File ? unwrap(File) : nullptr, Line, RuntimeLang, SizeInBits, + AlignInBits, Flags); return wrap(CT); } @@ -163,8 +166,9 @@ LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, unsigned Flags, LLVMMetadataRef Ty) { DIBuilder *D = unwrap(Dref); DIDerivedType DT = D->createMemberType( - DIDescriptor(unwrap(Scope)), Name, unwrap(File), Line, - SizeInBits, AlignInBits, OffsetInBits, Flags, unwrap(Ty)); + DIDescriptor(unwrap(Scope)), Name, + File ? unwrap(File) : nullptr, Line, SizeInBits, AlignInBits, + OffsetInBits, Flags, unwrap(Ty)); return wrap(DT); } @@ -185,9 +189,9 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Context) { DIBuilder *D = unwrap(Dref); - DIDerivedType DT = - D->createTypedef(unwrap(Ty), Name, unwrap(File), Line, - DIDescriptor(unwrap(Context))); + DIDerivedType DT = D->createTypedef( + unwrap(Ty), Name, File ? unwrap(File) : nullptr, Line, + Context ? DIDescriptor(unwrap(Context)) : DIDescriptor()); return wrap(DT); } -- 2.34.1