From 2c3e0051c31c3f5b2328b447eadf1cf9c4427442 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Wed, 6 May 2015 11:46:36 -0700 Subject: Update aosp/master LLVM for rebase to r235153 Change-Id: I9bf53792f9fc30570e81a8d80d296c681d005ea7 (cherry picked from commit 0c7f116bb6950ef819323d855415b2f2b0aad987) --- bindings/go/llvm/DIBuilderBindings.cpp | 77 ++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'bindings') diff --git a/bindings/go/llvm/DIBuilderBindings.cpp b/bindings/go/llvm/DIBuilderBindings.cpp index f39198d..cfae605 100644 --- a/bindings/go/llvm/DIBuilderBindings.cpp +++ b/bindings/go/llvm/DIBuilderBindings.cpp @@ -21,12 +21,6 @@ using namespace llvm; DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef) -namespace { -template T unwrapDI(LLVMMetadataRef v) { - return v ? T(unwrap(v)) : T(); -} -} - LLVMDIBuilderRef LLVMNewDIBuilder(LLVMModuleRef mref) { Module *m = unwrap(mref); return wrap(new DIBuilder(*m)); @@ -64,8 +58,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Dref, unsigned Line, unsigned Column) { DIBuilder *D = unwrap(Dref); - DILexicalBlock LB = D->createLexicalBlock( - unwrapDI(Scope), unwrapDI(File), Line, Column); + auto *LB = D->createLexicalBlock(unwrap(Scope), + unwrap(File), Line, Column); return wrap(LB); } @@ -75,7 +69,7 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Dref, unsigned Discriminator) { DIBuilder *D = unwrap(Dref); DILexicalBlockFile LBF = D->createLexicalBlockFile( - unwrapDI(Scope), unwrapDI(File), Discriminator); + unwrap(Scope), unwrap(File), Discriminator); return wrap(LBF); } @@ -86,9 +80,10 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction( unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) { DIBuilder *D = unwrap(Dref); DISubprogram SP = D->createFunction( - unwrapDI(Scope), Name, LinkageName, unwrapDI(File), - Line, unwrapDI(CompositeType), IsLocalToUnit, - IsDefinition, ScopeLine, Flags, IsOptimized, unwrap(Func)); + unwrap(Scope), Name, LinkageName, + File ? unwrap(File) : nullptr, Line, + unwrap(CompositeType), IsLocalToUnit, IsDefinition, + ScopeLine, Flags, IsOptimized, unwrap(Func)); return wrap(SP); } @@ -98,8 +93,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLocalVariable( int AlwaysPreserve, unsigned Flags, unsigned ArgNo) { DIBuilder *D = unwrap(Dref); DIVariable V = D->createLocalVariable( - Tag, unwrapDI(Scope), Name, unwrapDI(File), Line, - unwrapDI(Ty), AlwaysPreserve, Flags, ArgNo); + Tag, unwrap(Scope), Name, unwrap(File), Line, + unwrap(Ty), AlwaysPreserve, Flags, ArgNo); return wrap(V); } @@ -119,7 +114,7 @@ LLVMMetadataRef LLVMDIBuilderCreatePointerType(LLVMDIBuilderRef Dref, uint64_t AlignInBits, const char *Name) { DIBuilder *D = unwrap(Dref); - DIDerivedType T = D->createPointerType(unwrapDI(PointeeType), + DIDerivedType T = D->createPointerType(unwrap(PointeeType), SizeInBits, AlignInBits, Name); return wrap(T); } @@ -128,8 +123,9 @@ LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Dref, LLVMMetadataRef File, LLVMMetadataRef ParameterTypes) { DIBuilder *D = unwrap(Dref); - DICompositeType CT = D->createSubroutineType( - unwrapDI(File), unwrapDI(ParameterTypes)); + DICompositeType CT = + D->createSubroutineType(File ? unwrap(File) : nullptr, + DITypeArray(unwrap(ParameterTypes))); return wrap(CT); } @@ -140,9 +136,10 @@ LLVMMetadataRef LLVMDIBuilderCreateStructType( LLVMMetadataRef ElementTypes) { DIBuilder *D = unwrap(Dref); DICompositeType CT = D->createStructType( - unwrapDI(Scope), Name, unwrapDI(File), Line, - SizeInBits, AlignInBits, Flags, unwrapDI(DerivedFrom), - unwrapDI(ElementTypes)); + unwrap(Scope), Name, File ? unwrap(File) : nullptr, Line, + SizeInBits, AlignInBits, Flags, + DerivedFrom ? unwrap(DerivedFrom) : nullptr, + ElementTypes ? DIArray(unwrap(ElementTypes)) : nullptr); return wrap(CT); } @@ -153,8 +150,8 @@ LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType( unsigned Flags) { DIBuilder *D = unwrap(Dref); DICompositeType CT = D->createReplaceableCompositeType( - Tag, Name, unwrapDI(Scope), unwrapDI(File), Line, - RuntimeLang, SizeInBits, AlignInBits, Flags); + Tag, Name, unwrap(Scope), File ? unwrap(File) : nullptr, + Line, RuntimeLang, SizeInBits, AlignInBits, Flags); return wrap(CT); } @@ -166,8 +163,8 @@ LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, unsigned Flags, LLVMMetadataRef Ty) { DIBuilder *D = unwrap(Dref); DIDerivedType DT = D->createMemberType( - unwrapDI(Scope), Name, unwrapDI(File), Line, - SizeInBits, AlignInBits, OffsetInBits, Flags, unwrapDI(Ty)); + unwrap(Scope), Name, File ? unwrap(File) : nullptr, Line, + SizeInBits, AlignInBits, OffsetInBits, Flags, unwrap(Ty)); return wrap(DT); } @@ -178,8 +175,8 @@ LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Dref, LLVMMetadataRef Subscripts) { DIBuilder *D = unwrap(Dref); DICompositeType CT = - D->createArrayType(SizeInBits, AlignInBits, unwrapDI(ElementType), - unwrapDI(Subscripts)); + D->createArrayType(SizeInBits, AlignInBits, unwrap(ElementType), + DIArray(unwrap(Subscripts))); return wrap(CT); } @@ -188,9 +185,9 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Context) { DIBuilder *D = unwrap(Dref); - DIDerivedType DT = - D->createTypedef(unwrapDI(Ty), Name, unwrapDI(File), Line, - unwrapDI(Context)); + DIDerivedType DT = D->createTypedef( + unwrap(Ty), Name, File ? unwrap(File) : nullptr, Line, + Context ? unwrap(Context) : nullptr); return wrap(DT); } @@ -208,7 +205,7 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Dref, Metadata **DataValue = unwrap(Data); ArrayRef Elements(DataValue, Length); DIArray A = D->getOrCreateArray(Elements); - return wrap(A); + return wrap(A.get()); } LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Dref, @@ -218,7 +215,7 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Dref, Metadata **DataValue = unwrap(Data); ArrayRef Elements(DataValue, Length); DITypeArray A = D->getOrCreateTypeArray(Elements); - return wrap(A); + return wrap(A.get()); } LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Dref, @@ -233,10 +230,14 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMBasicBlockRef Block) { + // Fail immediately here until the llgo folks update their bindings. The + // called function is going to assert out anyway. + llvm_unreachable("DIBuilder API change requires a DebugLoc"); + DIBuilder *D = unwrap(Dref); - Instruction *Instr = - D->insertDeclare(unwrap(Storage), unwrapDI(VarInfo), - unwrapDI(Expr), unwrap(Block)); + Instruction *Instr = D->insertDeclare( + unwrap(Storage), unwrap(VarInfo), + unwrap(Expr), /* DebugLoc */ nullptr, unwrap(Block)); return wrap(Instr); } @@ -245,9 +246,13 @@ LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef Dref, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMBasicBlockRef Block) { + // Fail immediately here until the llgo folks update their bindings. The + // called function is going to assert out anyway. + llvm_unreachable("DIBuilder API change requires a DebugLoc"); + DIBuilder *D = unwrap(Dref); Instruction *Instr = D->insertDbgValueIntrinsic( - unwrap(Val), Offset, unwrapDI(VarInfo), - unwrapDI(Expr), unwrap(Block)); + unwrap(Val), Offset, unwrap(VarInfo), + unwrap(Expr), /* DebugLoc */ nullptr, unwrap(Block)); return wrap(Instr); } -- cgit v1.1