@@ -25,7 +25,6 @@ use libc::{c_uint, c_int, size_t, c_char};
2525use libc:: { c_ulonglong, c_void} ;
2626
2727use std:: marker:: PhantomData ;
28- use std:: ptr:: NonNull ;
2928
3029use super :: RustString ;
3130
@@ -383,6 +382,7 @@ pub enum ThreadLocalMode {
383382}
384383
385384extern { type Opaque ; }
385+ #[ repr( C ) ]
386386struct InvariantOpaque < ' a > {
387387 _marker : PhantomData < & ' a mut & ' a ( ) > ,
388388 _opaque : Opaque ,
@@ -397,22 +397,27 @@ extern { pub type Metadata; }
397397extern { pub type BasicBlock ; }
398398extern { pub type Builder ; }
399399extern { pub type MemoryBuffer ; }
400+ #[ repr( C ) ]
400401pub struct PassManager < ' a > ( InvariantOpaque < ' a > ) ;
401402extern { pub type PassManagerBuilder ; }
402403extern { pub type ObjectFile ; }
404+ #[ repr( C ) ]
403405pub struct SectionIterator < ' a > ( InvariantOpaque < ' a > ) ;
404406extern { pub type Pass ; }
405407extern { pub type TargetMachine ; }
406408extern { pub type Archive ; }
409+ #[ repr( C ) ]
407410pub struct ArchiveIterator < ' a > ( InvariantOpaque < ' a > ) ;
408- extern { pub type ArchiveChild ; }
409- pub type ArchiveChildRef = * mut ArchiveChild ;
411+ # [ repr ( C ) ]
412+ pub struct ArchiveChild < ' a > ( InvariantOpaque < ' a > ) ;
410413extern { pub type Twine ; }
411414extern { pub type DiagnosticInfo ; }
412415extern { pub type SMDiagnostic ; }
413416extern { pub type RustArchiveMember ; }
414417pub type RustArchiveMemberRef = * mut RustArchiveMember ;
418+ #[ repr( C ) ]
415419pub struct OperandBundleDef < ' a > ( InvariantOpaque < ' a > ) ;
420+ #[ repr( C ) ]
416421pub struct Linker < ' a > ( InvariantOpaque < ' a > ) ;
417422
418423pub type DiagnosticHandler = unsafe extern "C" fn ( & DiagnosticInfo , * mut c_void ) ;
@@ -474,7 +479,6 @@ pub mod debuginfo {
474479
475480extern { pub type ModuleBuffer ; }
476481
477- #[ allow( improper_ctypes) ] // TODO remove this (use for NonNull)
478482extern "C" {
479483 // Create and destroy contexts.
480484 pub fn LLVMRustContextCreate ( shouldDiscardNames : bool ) -> & ' static mut Context ;
@@ -1403,10 +1407,15 @@ extern "C" {
14031407 -> & ' a Value ;
14041408 pub fn LLVMRustDIBuilderCreateOpDeref ( ) -> i64 ;
14051409 pub fn LLVMRustDIBuilderCreateOpPlusUconst ( ) -> i64 ;
1410+ }
14061411
1412+ #[ allow( improper_ctypes) ] // FIXME(#52456) needed for RustString.
1413+ extern "C" {
14071414 pub fn LLVMRustWriteTypeToString ( Type : & Type , s : & RustString ) ;
14081415 pub fn LLVMRustWriteValueToString ( value_ref : & Value , s : & RustString ) ;
1416+ }
14091417
1418+ extern "C" {
14101419 pub fn LLVMIsAConstantInt ( value_ref : & Value ) -> Option < & Value > ;
14111420 pub fn LLVMIsAConstantFP ( value_ref : & Value ) -> Option < & Value > ;
14121421
@@ -1471,42 +1480,64 @@ extern "C" {
14711480
14721481 pub fn LLVMRustOpenArchive ( path : * const c_char ) -> Option < & ' static mut Archive > ;
14731482 pub fn LLVMRustArchiveIteratorNew ( AR : & ' a Archive ) -> & ' a mut ArchiveIterator < ' a > ;
1474- pub fn LLVMRustArchiveIteratorNext ( AIR : & ArchiveIterator ) -> ArchiveChildRef ;
1475- pub fn LLVMRustArchiveChildName ( ACR : ArchiveChildRef , size : & mut size_t ) -> * const c_char ;
1476- pub fn LLVMRustArchiveChildData ( ACR : ArchiveChildRef , size : & mut size_t ) -> * const c_char ;
1477- pub fn LLVMRustArchiveChildFree ( ACR : ArchiveChildRef ) ;
1483+ pub fn LLVMRustArchiveIteratorNext ( AIR : & ArchiveIterator < ' a > ) -> Option < & ' a mut ArchiveChild < ' a > > ;
1484+ pub fn LLVMRustArchiveChildName ( ACR : & ArchiveChild , size : & mut size_t ) -> * const c_char ;
1485+ pub fn LLVMRustArchiveChildData ( ACR : & ArchiveChild , size : & mut size_t ) -> * const c_char ;
1486+ pub fn LLVMRustArchiveChildFree ( ACR : & ' a mut ArchiveChild < ' a > ) ;
14781487 pub fn LLVMRustArchiveIteratorFree ( AIR : & ' a mut ArchiveIterator < ' a > ) ;
14791488 pub fn LLVMRustDestroyArchive ( AR : & ' static mut Archive ) ;
14801489
14811490 pub fn LLVMRustGetSectionName ( SI : & SectionIterator , data : & mut * const c_char ) -> size_t ;
1491+ }
14821492
1493+ #[ allow( improper_ctypes) ] // FIXME(#52456) needed for RustString.
1494+ extern "C" {
14831495 pub fn LLVMRustWriteTwineToString ( T : & Twine , s : & RustString ) ;
1496+ }
14841497
1498+ extern "C" {
14851499 pub fn LLVMContextSetDiagnosticHandler ( C : & Context ,
14861500 Handler : DiagnosticHandler ,
14871501 DiagnosticContext : * mut c_void ) ;
1502+ }
14881503
1504+ #[ allow( improper_ctypes) ] // FIXME(#52456) needed for RustString.
1505+ extern "C" {
14891506 pub fn LLVMRustUnpackOptimizationDiagnostic ( DI : & ' a DiagnosticInfo ,
14901507 pass_name_out : & RustString ,
14911508 function_out : & mut Option < & ' a Value > ,
14921509 loc_line_out : & mut c_uint ,
14931510 loc_column_out : & mut c_uint ,
14941511 loc_filename_out : & RustString ,
14951512 message_out : & RustString ) ;
1513+ }
1514+
1515+ extern "C" {
14961516 pub fn LLVMRustUnpackInlineAsmDiagnostic ( DI : & ' a DiagnosticInfo ,
14971517 cookie_out : & mut c_uint ,
14981518 message_out : & mut Option < & ' a Twine > ,
14991519 instruction_out : & mut Option < & ' a Value > ) ;
1520+ }
15001521
1522+ #[ allow( improper_ctypes) ] // FIXME(#52456) needed for RustString.
1523+ extern "C" {
15011524 pub fn LLVMRustWriteDiagnosticInfoToString ( DI : & DiagnosticInfo , s : & RustString ) ;
1525+ }
1526+
1527+ extern "C" {
15021528 pub fn LLVMRustGetDiagInfoKind ( DI : & DiagnosticInfo ) -> DiagnosticKind ;
15031529
15041530 pub fn LLVMRustSetInlineAsmDiagnosticHandler ( C : & Context ,
15051531 H : InlineAsmDiagHandler ,
15061532 CX : * mut c_void ) ;
1533+ }
15071534
1535+ #[ allow( improper_ctypes) ] // FIXME(#52456) needed for RustString.
1536+ extern "C" {
15081537 pub fn LLVMRustWriteSMDiagnosticToString ( d : & SMDiagnostic , s : & RustString ) ;
1538+ }
15091539
1540+ extern "C" {
15101541 pub fn LLVMRustWriteArchive ( Dst : * const c_char ,
15111542 NumMembers : size_t ,
15121543 Members : * const RustArchiveMemberRef ,
@@ -1515,7 +1546,7 @@ extern "C" {
15151546 -> LLVMRustResult ;
15161547 pub fn LLVMRustArchiveMemberNew ( Filename : * const c_char ,
15171548 Name : * const c_char ,
1518- Child : Option < NonNull < ArchiveChild > > )
1549+ Child : Option < & ArchiveChild > )
15191550 -> RustArchiveMemberRef ;
15201551 pub fn LLVMRustArchiveMemberFree ( Member : RustArchiveMemberRef ) ;
15211552
0 commit comments