1
Fork 0

Rollup merge of #121389 - klensy:llvm-warn-fix, r=nikic

llvm-wrapper: fix few warnings

Two fixes: first one is simple unsigned -> uint64_t, but how second one is more subtile, see commit description.
This commit is contained in:
Matthias Krüger 2024-02-26 16:06:02 +01:00 committed by GitHub
commit 6700714394
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 8 additions and 8 deletions

View file

@ -36,7 +36,7 @@ use rustc_span::InnerSpan;
use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel};
use crate::llvm::diagnostic::OptimizationDiagnosticKind; use crate::llvm::diagnostic::OptimizationDiagnosticKind;
use libc::{c_char, c_int, c_uint, c_void, size_t}; use libc::{c_char, c_int, c_void, size_t};
use std::ffi::CString; use std::ffi::CString;
use std::fs; use std::fs;
use std::io::{self, Write}; use std::io::{self, Write};
@ -406,7 +406,7 @@ fn report_inline_asm(
cgcx: &CodegenContext<LlvmCodegenBackend>, cgcx: &CodegenContext<LlvmCodegenBackend>,
msg: String, msg: String,
level: llvm::DiagnosticLevel, level: llvm::DiagnosticLevel,
mut cookie: c_uint, mut cookie: u64,
source: Option<(String, Vec<InnerSpan>)>, source: Option<(String, Vec<InnerSpan>)>,
) { ) {
// In LTO build we may get srcloc values from other crates which are invalid // In LTO build we may get srcloc values from other crates which are invalid
@ -420,7 +420,7 @@ fn report_inline_asm(
llvm::DiagnosticLevel::Warning => Level::Warning, llvm::DiagnosticLevel::Warning => Level::Warning,
llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note, llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note,
}; };
cgcx.diag_emitter.inline_asm_error(cookie as u32, msg, level, source); cgcx.diag_emitter.inline_asm_error(cookie.try_into().unwrap(), msg, level, source);
} }
unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) { unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) {

View file

@ -123,7 +123,7 @@ impl SrcMgrDiagnostic {
#[derive(Clone)] #[derive(Clone)]
pub struct InlineAsmDiagnostic { pub struct InlineAsmDiagnostic {
pub level: super::DiagnosticLevel, pub level: super::DiagnosticLevel,
pub cookie: c_uint, pub cookie: u64,
pub message: String, pub message: String,
pub source: Option<(String, Vec<InnerSpan>)>, pub source: Option<(String, Vec<InnerSpan>)>,
} }
@ -149,7 +149,7 @@ impl InlineAsmDiagnostic {
let smdiag = SrcMgrDiagnostic::unpack(super::LLVMRustGetSMDiagnostic(di, &mut cookie)); let smdiag = SrcMgrDiagnostic::unpack(super::LLVMRustGetSMDiagnostic(di, &mut cookie));
InlineAsmDiagnostic { InlineAsmDiagnostic {
level: smdiag.level, level: smdiag.level,
cookie, cookie: cookie.into(),
message: smdiag.message, message: smdiag.message,
source: smdiag.source, source: smdiag.source,
} }

View file

@ -2256,7 +2256,7 @@ extern "C" {
pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>( pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
DI: &'a DiagnosticInfo, DI: &'a DiagnosticInfo,
level_out: &mut DiagnosticLevel, level_out: &mut DiagnosticLevel,
cookie_out: &mut c_uint, cookie_out: &mut u64,
message_out: &mut Option<&'a Twine>, message_out: &mut Option<&'a Twine>,
); );

View file

@ -67,7 +67,7 @@ typedef RustArchiveIterator *LLVMRustArchiveIteratorRef;
extern "C" LLVMRustArchiveRef LLVMRustOpenArchive(char *Path) { extern "C" LLVMRustArchiveRef LLVMRustOpenArchive(char *Path) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOr = ErrorOr<std::unique_ptr<MemoryBuffer>> BufOr =
MemoryBuffer::getFile(Path, -1, false); MemoryBuffer::getFile(Path, /*IsText*/false, /*RequiresNullTerminator=*/false);
if (!BufOr) { if (!BufOr) {
LLVMRustSetLastError(BufOr.getError().message().c_str()); LLVMRustSetLastError(BufOr.getError().message().c_str());
return nullptr; return nullptr;

View file

@ -1262,7 +1262,7 @@ enum class LLVMRustDiagnosticLevel {
extern "C" void extern "C" void
LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI, LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI,
LLVMRustDiagnosticLevel *LevelOut, LLVMRustDiagnosticLevel *LevelOut,
unsigned *CookieOut, uint64_t *CookieOut,
LLVMTwineRef *MessageOut) { LLVMTwineRef *MessageOut) {
// Undefined to call this not on an inline assembly diagnostic! // Undefined to call this not on an inline assembly diagnostic!
llvm::DiagnosticInfoInlineAsm *IA = llvm::DiagnosticInfoInlineAsm *IA =