Skip to content

Commit 205cfcb

Browse files
committed
llvm-wrapper: fix warning C4244
llvm-wrapper/RustWrapper.cpp(1234): warning C4244: '=': conversion from 'uint64_t' to 'unsigned int', possible loss of data nice consistency: uint64_t https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/llvm/include/llvm/IR/DiagnosticInfo.h#L172 but unsigned https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/llvm/include/llvm/IR/DiagnosticInfo.h#L1091
1 parent bea5beb commit 205cfcb

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rustc_span::InnerSpan;
3636
use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel};
3737

3838
use crate::llvm::diagnostic::OptimizationDiagnosticKind;
39-
use libc::{c_char, c_int, c_uint, c_void, size_t};
39+
use libc::{c_char, c_int, c_void, size_t};
4040
use std::ffi::CString;
4141
use std::fs;
4242
use std::io::{self, Write};
@@ -406,7 +406,7 @@ fn report_inline_asm(
406406
cgcx: &CodegenContext<LlvmCodegenBackend>,
407407
msg: String,
408408
level: llvm::DiagnosticLevel,
409-
mut cookie: c_uint,
409+
mut cookie: u64,
410410
source: Option<(String, Vec<InnerSpan>)>,
411411
) {
412412
// In LTO build we may get srcloc values from other crates which are invalid
@@ -420,7 +420,7 @@ fn report_inline_asm(
420420
llvm::DiagnosticLevel::Warning => Level::Warning,
421421
llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note,
422422
};
423-
cgcx.diag_emitter.inline_asm_error(cookie as u32, msg, level, source);
423+
cgcx.diag_emitter.inline_asm_error(cookie.try_into().unwrap(), msg, level, source);
424424
}
425425

426426
unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) {

compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl SrcMgrDiagnostic {
123123
#[derive(Clone)]
124124
pub struct InlineAsmDiagnostic {
125125
pub level: super::DiagnosticLevel,
126-
pub cookie: c_uint,
126+
pub cookie: u64,
127127
pub message: String,
128128
pub source: Option<(String, Vec<InnerSpan>)>,
129129
}
@@ -149,7 +149,7 @@ impl InlineAsmDiagnostic {
149149
let smdiag = SrcMgrDiagnostic::unpack(super::LLVMRustGetSMDiagnostic(di, &mut cookie));
150150
InlineAsmDiagnostic {
151151
level: smdiag.level,
152-
cookie,
152+
cookie: cookie.into(),
153153
message: smdiag.message,
154154
source: smdiag.source,
155155
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,7 @@ extern "C" {
22542254
pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
22552255
DI: &'a DiagnosticInfo,
22562256
level_out: &mut DiagnosticLevel,
2257-
cookie_out: &mut c_uint,
2257+
cookie_out: &mut u64,
22582258
message_out: &mut Option<&'a Twine>,
22592259
);
22602260

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ enum class LLVMRustDiagnosticLevel {
12251225
extern "C" void
12261226
LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI,
12271227
LLVMRustDiagnosticLevel *LevelOut,
1228-
unsigned *CookieOut,
1228+
uint64_t *CookieOut,
12291229
LLVMTwineRef *MessageOut) {
12301230
// Undefined to call this not on an inline assembly diagnostic!
12311231
llvm::DiagnosticInfoInlineAsm *IA =

0 commit comments

Comments
 (0)