use libc::{c_longlong, c_ulonglong, c_void};
use debuginfo::{DIBuilderRef, DIDescriptor,
DIFile, DILexicalBlock, DISubprogram, DIType,
- DIBasicType, DIDerivedType, DICompositeType,
- DIVariable, DIGlobalVariable, DIArray, DISubrange};
+ DIBasicType, DIDerivedType, DICompositeType, DIScope,
+ DIVariable, DIGlobalVariable, DIArray, DISubrange,
+ DITemplateTypeParameter, DIEnumerator, DINameSpace};
pub mod archive_ro;
pub mod diagnostic;
pub enum Value_opaque {}
pub type ValueRef = *mut Value_opaque;
#[allow(missing_copy_implementations)]
+pub enum Metadata_opaque {}
+pub type MetadataRef = *mut Metadata_opaque;
+#[allow(missing_copy_implementations)]
pub enum BasicBlock_opaque {}
pub type BasicBlockRef = *mut BasicBlock_opaque;
#[allow(missing_copy_implementations)]
pub mod debuginfo {
pub use self::DIDescriptorFlags::*;
- use super::{ValueRef};
+ use super::{MetadataRef};
#[allow(missing_copy_implementations)]
pub enum DIBuilder_opaque {}
pub type DIBuilderRef = *mut DIBuilder_opaque;
- pub type DIDescriptor = ValueRef;
+ pub type DIDescriptor = MetadataRef;
pub type DIScope = DIDescriptor;
pub type DILocation = DIDescriptor;
pub type DIFile = DIScope;
pub type DILexicalBlock = DIScope;
pub type DISubprogram = DIScope;
+ pub type DINameSpace = DIScope;
pub type DIType = DIDescriptor;
pub type DIBasicType = DIType;
pub type DIDerivedType = DIType;
pub type DIGlobalVariable = DIDescriptor;
pub type DIArray = DIDescriptor;
pub type DISubrange = DIDescriptor;
+ pub type DIEnumerator = DIDescriptor;
+ pub type DITemplateTypeParameter = DIDescriptor;
#[derive(Copy)]
pub enum DIDescriptorFlags {
Flags: c_uint,
isOptimized: bool,
Fn: ValueRef,
- TParam: ValueRef,
- Decl: ValueRef)
+ TParam: DIArray,
+ Decl: DIDescriptor)
-> DISubprogram;
pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
DerivedFrom: DIType,
Elements: DIArray,
RunTimeLang: c_uint,
- VTableHolder: ValueRef,
+ VTableHolder: DIType,
UniqueId: *const c_char)
-> DICompositeType;
-> DIDerivedType;
pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
- Scope: DIDescriptor,
+ Scope: DIScope,
File: DIFile,
Line: c_uint,
Col: c_uint)
-> DILexicalBlock;
pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
- Context: DIDescriptor,
+ Context: DIScope,
Name: *const c_char,
LinkageName: *const c_char,
File: DIFile,
Ty: DIType,
isLocalToUnit: bool,
Val: ValueRef,
- Decl: ValueRef)
+ Decl: DIDescriptor)
-> DIGlobalVariable;
- pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
+ pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
Tag: c_uint,
Scope: DIDescriptor,
Name: *const c_char,
Ty: DIType,
AlwaysPreserve: bool,
Flags: c_uint,
+ AddrOps: *const i64,
+ AddrOpsCount: c_uint,
ArgNo: c_uint)
-> DIVariable;
pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
Val: ValueRef,
VarInfo: DIVariable,
+ AddrOps: *const i64,
+ AddrOpsCount: c_uint,
InsertAtEnd: BasicBlockRef)
-> ValueRef;
pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
Val: ValueRef,
VarInfo: DIVariable,
+ AddrOps: *const i64,
+ AddrOpsCount: c_uint,
InsertBefore: ValueRef)
-> ValueRef;
pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
Name: *const c_char,
Val: c_ulonglong)
- -> ValueRef;
+ -> DIEnumerator;
pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
- Scope: ValueRef,
+ Scope: DIScope,
Name: *const c_char,
- File: ValueRef,
+ File: DIFile,
LineNumber: c_uint,
SizeInBits: c_ulonglong,
AlignInBits: c_ulonglong,
- Elements: ValueRef,
- ClassType: ValueRef)
- -> ValueRef;
+ Elements: DIArray,
+ ClassType: DIType)
+ -> DIType;
pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
- Scope: ValueRef,
+ Scope: DIScope,
Name: *const c_char,
- File: ValueRef,
+ File: DIFile,
LineNumber: c_uint,
SizeInBits: c_ulonglong,
AlignInBits: c_ulonglong,
Flags: c_uint,
- Elements: ValueRef,
+ Elements: DIArray,
RunTimeLang: c_uint,
UniqueId: *const c_char)
- -> ValueRef;
+ -> DIType;
pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
- Scope: ValueRef,
+ Scope: DIScope,
Name: *const c_char,
- Ty: ValueRef,
- File: ValueRef,
+ Ty: DIType,
+ File: DIFile,
LineNo: c_uint,
ColumnNo: c_uint)
- -> ValueRef;
-
- pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
+ -> DITemplateTypeParameter;
- pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
+ pub fn LLVMDIBuilderCreateOpDeref() -> i64;
- pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
- Tag: c_uint,
- Scope: ValueRef,
- Name: *const c_char,
- File: ValueRef,
- LineNo: c_uint,
- Ty: ValueRef,
- AddrOps: *const ValueRef,
- AddrOpsCount: c_uint,
- ArgNo: c_uint)
- -> ValueRef;
+ pub fn LLVMDIBuilderCreateOpPlus() -> i64;
pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
- Scope: ValueRef,
+ Scope: DIScope,
Name: *const c_char,
- File: ValueRef,
+ File: DIFile,
LineNo: c_uint)
- -> ValueRef;
+ -> DINameSpace;
+
+ pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
+ Line: c_uint,
+ Column: c_uint,
+ Scope: DIScope,
+ InlinedAt: MetadataRef)
+ -> ValueRef;
- pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
+ pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
+ CompositeType: DIType,
+ TypeArray: DIArray);
pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
use middle::subst::{self, Substs};
use trans::{self, adt, machine, type_of};
use trans::common::{self, NodeIdAndSpan, CrateContext, FunctionContext, Block,
- C_bytes, C_i32, C_i64, NormalizingClosureTyper};
+ C_bytes, NormalizingClosureTyper};
use trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef};
use trans::monomorphize;
use trans::type_::Type;
DirectVariable { alloca: ValueRef },
// The llptr given is an alloca containing the start of some pointer chain
// leading to the variable's content.
- IndirectVariable { alloca: ValueRef, address_operations: &'a [ValueRef] }
+ IndirectVariable { alloca: ValueRef, address_operations: &'a [i64] }
}
enum VariableKind {
env_index);
let address_operations = unsafe {
- [llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref()),
- llvm::LLVMDIBuilderCreateOpPlus(Type::i64(cx).to_ref()),
- C_i64(cx, byte_offset_of_var_in_env as i64),
- llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref())]
+ [llvm::LLVMDIBuilderCreateOpDeref(),
+ llvm::LLVMDIBuilderCreateOpPlus(),
+ byte_offset_of_var_in_env as i64,
+ llvm::LLVMDIBuilderCreateOpDeref()]
};
let address_op_count = if captured_by_ref {
let scope_metadata = scope_metadata(bcx.fcx, binding.id, binding.span);
let aops = unsafe {
- [llvm::LLVMDIBuilderCreateOpDeref(bcx.ccx().int_type().to_ref())]
+ [llvm::LLVMDIBuilderCreateOpDeref()]
};
// Regardless of the actual type (`T`) we're always passed the stack slot (alloca)
// for the binding. For ByRef bindings that's a `T*` but for ByMove bindings we
};
let name = CString::from_slice(name.get().as_bytes());
- let (var_alloca, var_metadata) = match variable_access {
- DirectVariable { alloca } => (
- alloca,
- unsafe {
- llvm::LLVMDIBuilderCreateLocalVariable(
+ match (variable_access, [].as_slice()) {
+ (DirectVariable { alloca }, address_operations) |
+ (IndirectVariable {alloca, address_operations}, _) => {
+ let metadata = unsafe {
+ llvm::LLVMDIBuilderCreateVariable(
DIB(cx),
dwarf_tag,
scope_metadata,
type_metadata,
cx.sess().opts.optimize != config::No,
0,
- argument_index)
- }
- ),
- IndirectVariable { alloca, address_operations } => (
- alloca,
- unsafe {
- llvm::LLVMDIBuilderCreateComplexVariable(
- DIB(cx),
- dwarf_tag,
- scope_metadata,
- name.as_ptr(),
- file_metadata,
- loc.line as c_uint,
- type_metadata,
address_operations.as_ptr(),
address_operations.len() as c_uint,
argument_index)
- }
- )
- };
-
- set_debug_location(cx, InternalDebugLocation::new(scope_metadata,
+ };
+ set_debug_location(cx, InternalDebugLocation::new(scope_metadata,
loc.line,
loc.col.to_usize()));
- unsafe {
- let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
- DIB(cx),
- var_alloca,
- var_metadata,
- bcx.llbb);
+ unsafe {
+ let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
+ DIB(cx),
+ alloca,
+ metadata,
+ address_operations.as_ptr(),
+ address_operations.len() as c_uint,
+ bcx.llbb);
- llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
+ llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
+ }
+ }
}
match variable_kind {
unsafe {
let type_array = create_DIArray(DIB(cx), &member_metadata[]);
- llvm::LLVMDICompositeTypeSetTypeArray(composite_type_metadata, type_array);
+ llvm::LLVMDICompositeTypeSetTypeArray(DIB(cx), composite_type_metadata, type_array);
}
}
// Always set the column to zero like Clang and GCC
let col = UNKNOWN_COLUMN_NUMBER;
debug!("setting debug location to {} {}", line, col);
- let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32),
- scope, ptr::null_mut()];
+
unsafe {
- metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext,
- elements.as_ptr(),
- elements.len() as c_uint);
+ metadata_node = llvm::LLVMDIBuilderCreateDebugLocation(
+ debug_context(cx).llcontext,
+ line as c_uint,
+ col as c_uint,
+ scope,
+ ptr::null_mut());
}
}
UnknownLocation => {
typedef DIBuilder* DIBuilderRef;
+#if LLVM_VERSION_MINOR >= 6
+typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
+
+namespace llvm {
+DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef)
+
+inline Metadata **unwrap(LLVMMetadataRef *Vals) {
+ return reinterpret_cast<Metadata**>(Vals);
+}
+}
+#else
+typedef LLVMValueRef LLVMMetadataRef;
+#endif
+
template<typename DIT>
-DIT unwrapDI(LLVMValueRef ref) {
+DIT unwrapDI(LLVMMetadataRef ref) {
return DIT(ref ? unwrap<MDNode>(ref) : NULL);
}
Builder->finalize();
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateCompileUnit(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(
DIBuilderRef Builder,
unsigned Lang,
const char* File,
SplitName));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateFile(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateFile(
DIBuilderRef Builder,
const char* Filename,
const char* Directory) {
return wrap(Builder->createFile(Filename, Directory));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateSubroutineType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(
DIBuilderRef Builder,
- LLVMValueRef File,
- LLVMValueRef ParameterTypes) {
+ LLVMMetadataRef File,
+ LLVMMetadataRef ParameterTypes) {
return wrap(Builder->createSubroutineType(
unwrapDI<DIFile>(File),
#if LLVM_VERSION_MINOR >= 6
#endif
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateFunction(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateFunction(
DIBuilderRef Builder,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
const char* LinkageName,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNo,
- LLVMValueRef Ty,
+ LLVMMetadataRef Ty,
bool isLocalToUnit,
bool isDefinition,
unsigned ScopeLine,
unsigned Flags,
bool isOptimized,
LLVMValueRef Fn,
- LLVMValueRef TParam,
- LLVMValueRef Decl) {
+ LLVMMetadataRef TParam,
+ LLVMMetadataRef Decl) {
return wrap(Builder->createFunction(
unwrapDI<DIScope>(Scope), Name, LinkageName,
unwrapDI<DIFile>(File), LineNo,
unwrapDI<MDNode*>(Decl)));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateBasicType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateBasicType(
DIBuilderRef Builder,
const char* Name,
uint64_t SizeInBits,
AlignInBits, Encoding));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreatePointerType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreatePointerType(
DIBuilderRef Builder,
- LLVMValueRef PointeeTy,
+ LLVMMetadataRef PointeeTy,
uint64_t SizeInBits,
uint64_t AlignInBits,
const char* Name) {
unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits, Name));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateStructType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType(
DIBuilderRef Builder,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
unsigned Flags,
- LLVMValueRef DerivedFrom,
- LLVMValueRef Elements,
+ LLVMMetadataRef DerivedFrom,
+ LLVMMetadataRef Elements,
unsigned RunTimeLang,
- LLVMValueRef VTableHolder,
+ LLVMMetadataRef VTableHolder,
const char *UniqueId) {
return wrap(Builder->createStructType(
unwrapDI<DIDescriptor>(Scope),
));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateMemberType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateMemberType(
DIBuilderRef Builder,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNo,
uint64_t SizeInBits,
uint64_t AlignInBits,
uint64_t OffsetInBits,
unsigned Flags,
- LLVMValueRef Ty) {
+ LLVMMetadataRef Ty) {
return wrap(Builder->createMemberType(
unwrapDI<DIDescriptor>(Scope), Name,
unwrapDI<DIFile>(File), LineNo,
unwrapDI<DIType>(Ty)));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(
DIBuilderRef Builder,
- LLVMValueRef Scope,
- LLVMValueRef File,
+ LLVMMetadataRef Scope,
+ LLVMMetadataRef File,
unsigned Line,
unsigned Col) {
return wrap(Builder->createLexicalBlock(
));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateStaticVariable(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable(
DIBuilderRef Builder,
- LLVMValueRef Context,
+ LLVMMetadataRef Context,
const char* Name,
const char* LinkageName,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNo,
- LLVMValueRef Ty,
+ LLVMMetadataRef Ty,
bool isLocalToUnit,
LLVMValueRef Val,
- LLVMValueRef Decl = NULL) {
+ LLVMMetadataRef Decl = NULL) {
#if LLVM_VERSION_MINOR == 6
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
#else
LineNo,
unwrapDI<DIType>(Ty),
isLocalToUnit,
- unwrap(Val),
+ cast<Constant>(unwrap(Val)),
unwrapDI<MDNode*>(Decl)));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateLocalVariable(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable(
DIBuilderRef Builder,
unsigned Tag,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNo,
- LLVMValueRef Ty,
+ LLVMMetadataRef Ty,
bool AlwaysPreserve,
unsigned Flags,
+ int64_t* AddrOps,
+ unsigned AddrOpsCount,
unsigned ArgNo) {
+#if LLVM_VERSION_MINOR < 6
+ if (AddrOpsCount > 0) {
+ SmallVector<llvm::Value *, 16> addr_ops;
+ llvm::Type *Int64Ty = Type::getInt64Ty(VMContext);
+ for (int i = 0; i < AddrOpsCount; ++i)
+ addr_ops.push_back(ConstantInt::get(Int64Ty, AddrOps[i]));
+
+ return wrap(Builder->createComplexVariable(
+ Tag,
+ unwrapDI<DIDescriptor>(Scope),
+ Name,
+ unwrapDI<DIFile>(File),
+ LineNo,
+ unwrapDI<DIType>(Ty),
+ addr_ops,
+ ArgNo
+ ));
+ }
+#endif
return wrap(Builder->createLocalVariable(Tag,
unwrapDI<DIDescriptor>(Scope), Name,
unwrapDI<DIFile>(File),
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateArrayType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateArrayType(
DIBuilderRef Builder,
uint64_t Size,
uint64_t AlignInBits,
- LLVMValueRef Ty,
- LLVMValueRef Subscripts) {
+ LLVMMetadataRef Ty,
+ LLVMMetadataRef Subscripts) {
return wrap(Builder->createArrayType(Size, AlignInBits,
unwrapDI<DIType>(Ty),
unwrapDI<DIArray>(Subscripts)));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateVectorType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateVectorType(
DIBuilderRef Builder,
uint64_t Size,
uint64_t AlignInBits,
- LLVMValueRef Ty,
- LLVMValueRef Subscripts) {
+ LLVMMetadataRef Ty,
+ LLVMMetadataRef Subscripts) {
return wrap(Builder->createVectorType(Size, AlignInBits,
unwrapDI<DIType>(Ty),
unwrapDI<DIArray>(Subscripts)));
}
-extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateSubrange(
+extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(
DIBuilderRef Builder,
int64_t Lo,
int64_t Count) {
return wrap(Builder->getOrCreateSubrange(Lo, Count));
}
-extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateArray(
+extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(
DIBuilderRef Builder,
- LLVMValueRef* Ptr,
+ LLVMMetadataRef* Ptr,
unsigned Count) {
return wrap(Builder->getOrCreateArray(
- ArrayRef<Value*>(reinterpret_cast<Value**>(Ptr), Count)));
+ ArrayRef<Metadata*>(unwrap(Ptr), Count)));
}
extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
DIBuilderRef Builder,
LLVMValueRef Val,
- LLVMValueRef VarInfo,
+ LLVMMetadataRef VarInfo,
+ int64_t* AddrOps,
+ unsigned AddrOpsCount,
LLVMBasicBlockRef InsertAtEnd) {
+#if LLVM_VERSION_MINOR >= 6
+ DIExpression Expr;
+ if (AddrOpsCount == 0) {
+ Expr = Builder->createExpression();
+ } else {
+ llvm::ArrayRef<int64_t> addr_ops(AddrOps, AddrOpsCount);
+ Expr = Builder->createExpression(addr_ops);
+ }
+#endif
return wrap(Builder->insertDeclare(
unwrap(Val),
unwrapDI<DIVariable>(VarInfo),
+#if LLVM_VERSION_MINOR >= 6
+ Expr,
+#endif
unwrap(InsertAtEnd)));
}
extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
DIBuilderRef Builder,
LLVMValueRef Val,
- LLVMValueRef VarInfo,
+ LLVMMetadataRef VarInfo,
+ int64_t* AddrOps,
+ unsigned AddrOpsCount,
LLVMValueRef InsertBefore) {
+#if LLVM_VERSION_MINOR >= 6
+ DIExpression Expr;
+ if (AddrOpsCount == 0) {
+ Expr = Builder->createExpression();
+ } else {
+ llvm::ArrayRef<int64_t> addr_ops(AddrOps, AddrOpsCount);
+ Expr = Builder->createExpression(addr_ops);
+ }
+#endif
return wrap(Builder->insertDeclare(
unwrap(Val),
unwrapDI<DIVariable>(VarInfo),
+#if LLVM_VERSION_MINOR >= 6
+ Expr,
+#endif
unwrap<Instruction>(InsertBefore)));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerator(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerator(
DIBuilderRef Builder,
const char* Name,
uint64_t Val)
return wrap(Builder->createEnumerator(Name, Val));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerationType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(
DIBuilderRef Builder,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
- LLVMValueRef Elements,
- LLVMValueRef ClassType)
+ LLVMMetadataRef Elements,
+ LLVMMetadataRef ClassType)
{
return wrap(Builder->createEnumerationType(
unwrapDI<DIDescriptor>(Scope),
unwrapDI<DIType>(ClassType)));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateUnionType(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType(
DIBuilderRef Builder,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
unsigned Flags,
- LLVMValueRef Elements,
+ LLVMMetadataRef Elements,
unsigned RunTimeLang,
const char* UniqueId)
{
}
#endif
-extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter(
DIBuilderRef Builder,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
- LLVMValueRef Ty,
- LLVMValueRef File,
+ LLVMMetadataRef Ty,
+ LLVMMetadataRef File,
unsigned LineNo,
unsigned ColumnNo)
{
ColumnNo));
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateOpDeref(LLVMTypeRef IntTy)
+extern "C" int64_t LLVMDIBuilderCreateOpDeref()
{
- return LLVMConstInt(IntTy, DIBuilder::OpDeref, true);
+ return dwarf::DW_OP_deref;
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateOpPlus(LLVMTypeRef IntTy)
+extern "C" int64_t LLVMDIBuilderCreateOpPlus()
{
- return LLVMConstInt(IntTy, DIBuilder::OpPlus, true);
+ return dwarf::DW_OP_plus;
}
-extern "C" LLVMValueRef LLVMDIBuilderCreateComplexVariable(
+extern "C" LLVMMetadataRef LLVMDIBuilderCreateNameSpace(
DIBuilderRef Builder,
- unsigned Tag,
- LLVMValueRef Scope,
- const char *Name,
- LLVMValueRef File,
- unsigned LineNo,
- LLVMValueRef Ty,
- LLVMValueRef* AddrOps,
- unsigned AddrOpsCount,
- unsigned ArgNo)
-{
- llvm::ArrayRef<llvm::Value*> addr_ops((llvm::Value**)AddrOps, AddrOpsCount);
-
- return wrap(Builder->createComplexVariable(
- Tag,
- unwrapDI<DIDescriptor>(Scope),
- Name,
- unwrapDI<DIFile>(File),
- LineNo,
- unwrapDI<DIType>(Ty),
- addr_ops,
- ArgNo
- ));
-}
-
-extern "C" LLVMValueRef LLVMDIBuilderCreateNameSpace(
- DIBuilderRef Builder,
- LLVMValueRef Scope,
+ LLVMMetadataRef Scope,
const char* Name,
- LLVMValueRef File,
+ LLVMMetadataRef File,
unsigned LineNo)
{
return wrap(Builder->createNameSpace(
}
extern "C" void LLVMDICompositeTypeSetTypeArray(
- LLVMValueRef CompositeType,
- LLVMValueRef TypeArray)
+ DIBuilderRef Builder,
+ LLVMMetadataRef CompositeType,
+ LLVMMetadataRef TypeArray)
{
#if LLVM_VERSION_MINOR >= 6
- unwrapDI<DICompositeType>(CompositeType).setArrays(unwrapDI<DIArray>(TypeArray));
+ DICompositeType tmp = unwrapDI<DICompositeType>(CompositeType);
+ Builder->replaceArrays(tmp, unwrapDI<DIArray>(TypeArray));
#else
unwrapDI<DICompositeType>(CompositeType).setTypeArray(unwrapDI<DIArray>(TypeArray));
#endif
}
+extern "C" LLVMValueRef LLVMDIBuilderCreateDebugLocation(
+ LLVMContextRef Context,
+ unsigned Line,
+ unsigned Column,
+ LLVMMetadataRef Scope,
+ LLVMMetadataRef InlinedAt) {
+
+ LLVMContext& context = *unwrap(Context);
+
+ DebugLoc debug_loc = DebugLoc::get(Line,
+ Column,
+ unwrapDI<MDNode*>(Scope),
+ unwrapDI<MDNode*>(InlinedAt));
+
+#if LLVM_VERSION_MINOR >= 6
+ return wrap(MetadataAsValue::get(context, debug_loc.getAsMDNode(context)));
+#else
+ return wrap(debug_loc.getAsMDNode(context));
+#endif
+}
+
extern "C" void LLVMWriteTypeToString(LLVMTypeRef Type, RustStringRef str) {
raw_rust_string_ostream os(str);
unwrap<llvm::Type>(Type)->print(os);
}
std::string Err;
+
+#if LLVM_VERSION_MINOR >= 6
+ raw_string_ostream Stream(Err);
+ DiagnosticPrinterRawOStream DP(Stream);
+ if (Linker::LinkModules(Dst, *Src, [&](const DiagnosticInfo &DI) { DI.print(DP); })) {
+#else
if (Linker::LinkModules(Dst, *Src, Linker::DestroySource, &Err)) {
+#endif
LLVMRustSetLastError(Err.c_str());
return false;
}
#if LLVM_VERSION_MINOR >= 6
LLVMRustArchiveReadSection(OwningBinary<Archive> *ob, char *name, size_t *size) {
- std::unique_ptr<Archive> &ar = ob->getBinary();
+ Archive *ar = ob->getBinary();
#else
LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) {
#endif