parent
225353d8bb
commit
ad9a1daa81
6 changed files with 297 additions and 13 deletions
|
@ -31,13 +31,14 @@ use std::c_str::ToCStr;
|
|||
use std::cell::RefCell;
|
||||
use std::{raw, mem};
|
||||
use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
|
||||
use libc::{c_longlong, c_ulonglong};
|
||||
use libc::{c_longlong, c_ulonglong, c_void};
|
||||
use debuginfo::{DIBuilderRef, DIDescriptor,
|
||||
DIFile, DILexicalBlock, DISubprogram, DIType,
|
||||
DIBasicType, DIDerivedType, DICompositeType,
|
||||
DIVariable, DIGlobalVariable, DIArray, DISubrange};
|
||||
|
||||
pub mod archive_ro;
|
||||
pub mod diagnostic;
|
||||
|
||||
pub type Opcode = u32;
|
||||
pub type Bool = c_uint;
|
||||
|
@ -81,6 +82,15 @@ pub enum Linkage {
|
|||
CommonLinkage = 14,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[deriving(Show)]
|
||||
pub enum DiagnosticSeverity {
|
||||
Error,
|
||||
Warning,
|
||||
Remark,
|
||||
Note,
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub enum Attribute {
|
||||
ZExtAttribute = 1 << 0,
|
||||
|
@ -360,6 +370,18 @@ pub enum CodeGenModel {
|
|||
CodeModelLarge = 5,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum DiagnosticKind {
|
||||
DK_InlineAsm = 0,
|
||||
DK_StackSize,
|
||||
DK_DebugMetadataVersion,
|
||||
DK_SampleProfile,
|
||||
DK_OptimizationRemark,
|
||||
DK_OptimizationRemarkMissed,
|
||||
DK_OptimizationRemarkAnalysis,
|
||||
DK_OptimizationFailure,
|
||||
}
|
||||
|
||||
// Opaque pointer types
|
||||
pub enum Module_opaque {}
|
||||
pub type ModuleRef = *mut Module_opaque;
|
||||
|
@ -395,6 +417,14 @@ pub enum TargetMachine_opaque {}
|
|||
pub type TargetMachineRef = *mut TargetMachine_opaque;
|
||||
pub enum Archive_opaque {}
|
||||
pub type ArchiveRef = *mut Archive_opaque;
|
||||
pub enum Twine_opaque {}
|
||||
pub type TwineRef = *mut Twine_opaque;
|
||||
pub enum DiagnosticInfo_opaque {}
|
||||
pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
|
||||
pub enum DebugLoc_opaque {}
|
||||
pub type DebugLocRef = *mut DebugLoc_opaque;
|
||||
|
||||
pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
|
||||
|
||||
pub mod debuginfo {
|
||||
use super::{ValueRef};
|
||||
|
@ -1918,6 +1948,24 @@ extern {
|
|||
|
||||
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
|
||||
data: *mut *const c_char) -> c_int;
|
||||
|
||||
pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
|
||||
|
||||
pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
|
||||
Handler: DiagnosticHandler,
|
||||
DiagnosticContext: *mut c_void);
|
||||
|
||||
pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
|
||||
pass_name_out: *mut *const c_char,
|
||||
function_out: *mut ValueRef,
|
||||
debugloc_out: *mut DebugLocRef,
|
||||
message_out: *mut TwineRef);
|
||||
|
||||
pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
|
||||
pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
|
||||
pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
|
||||
|
||||
pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
|
||||
}
|
||||
|
||||
pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
|
||||
|
@ -2072,6 +2120,16 @@ pub fn build_string(f: |RustStringRef|) -> Option<String> {
|
|||
String::from_utf8(buf.unwrap()).ok()
|
||||
}
|
||||
|
||||
pub unsafe fn twine_to_string(tr: TwineRef) -> String {
|
||||
build_string(|s| LLVMWriteTwineToString(tr, s))
|
||||
.expect("got a non-UTF8 Twine from LLVM")
|
||||
}
|
||||
|
||||
pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
|
||||
build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
|
||||
.expect("got a non-UTF8 DebugLoc from LLVM")
|
||||
}
|
||||
|
||||
// FIXME #15460 - create a public function that actually calls our
|
||||
// static LLVM symbols. Otherwise the linker will just throw llvm
|
||||
// away. We're just calling lots of stuff until we transitively get
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue