Skip to content

lint ImproperCTypes: overhaul (take 2 of "better handling of indirections") #134697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
307a134
Changes to the ImproperCTypes lint, start of take 1 [does not pass te…
niacdoial Dec 11, 2024
999972b
lint ImproperCTypes: make checking indirection more DRY
niacdoial Dec 23, 2024
ca5fb8f
lint ImproperCTypes: fix TypeSizedness code
niacdoial Dec 23, 2024
f3dbc00
lint ImproperCTypes: add test to cover all ty_kinds
niacdoial Dec 23, 2024
6027630
lint ImproperCtypes: move code to new place, prior to full rewrite
niacdoial Dec 29, 2024
e4ec443
lint ImproperCTypes: properly separate the lint generation from the type
niacdoial Jan 5, 2025
366f8f2
lint ImproperCTypes: more cleanups and reworks [...]
niacdoial Jan 9, 2025
b27bb61
lint ImproperCTypes: add considerations for which values can be sourc…
niacdoial Jan 18, 2025
4aa6a20
lint ImproperCTypes: smoothing out some nits and un-tidy-ness
niacdoial Jan 18, 2025
f794b6d
lint ImproperCTypes: add recursion limit
niacdoial May 23, 2025
e842f07
lint ImproperCTypes: split the two lints into four total [...]
niacdoial May 4, 2025
b73c51f
lint ImproperCTypes: deal with uninhabited types
niacdoial May 6, 2025
9dfb1d0
lint ImproperCTypes: redo handling of pattern types [...]
niacdoial May 6, 2025
83cee26
lint ImproperCTypes: change what elements are being checked [...]
niacdoial May 6, 2025
13030e3
lint ImproperCTypes: rm improper_ctype_definitions [...]
niacdoial May 6, 2025
43bfc72
lint ImproperCTypes: clean up exported static variables
niacdoial May 20, 2025
b70eb45
lint ImproperCTypes: changes to pass CI [...]
niacdoial May 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4011,6 +4011,7 @@ dependencies = [
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"rustc_type_ir",
"smallvec",
"tracing",
"unicode-security",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/example/std_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn rust_call_abi() {
struct I64X2([i64; 2]);

#[cfg_attr(target_arch = "s390x", allow(dead_code))]
#[allow(improper_ctypes_definitions)]
#[allow(improper_c_fn_definitions)]
extern "C" fn foo(_a: I64X2) {}

#[cfg(target_arch = "x86_64")]
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,11 @@ fn report_inline_asm(
cgcx.diag_emitter.inline_asm_error(span, msg, level, source);
}

unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) {
unsafe extern "C" fn diagnostic_handler(info: Option<&DiagnosticInfo>, user: *mut c_void) {
if user.is_null() {
return;
}
let info = info.unwrap();
let (cgcx, dcx) =
unsafe { *(user as *const (&CodegenContext<LlvmCodegenBackend>, DiagCtxtHandle<'_>)) };

Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use libc::{c_char, c_uint};
use super::MetadataKindId;
use super::ffi::{AttributeKind, BasicBlock, Metadata, Module, Type, Value};
use crate::llvm::Bool;
use crate::wrap_returns_in_options;

wrap_returns_in_options! {
#[link(name = "llvm-wrapper", kind = "static")]
unsafe extern "C" {
// Enzyme
Expand All @@ -15,7 +17,7 @@ unsafe extern "C" {
pub(crate) fn LLVMRustGetLastInstruction<'a>(BB: &BasicBlock) -> Option<&'a Value>;
pub(crate) fn LLVMRustDIGetInstMetadata(I: &Value) -> Option<&Metadata>;
pub(crate) fn LLVMRustEraseInstFromParent(V: &Value);
pub(crate) fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value;
|wrap pub(crate) fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value;
pub(crate) fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool;
pub(crate) fn LLVMRustHasAttributeAtIndex(V: &Value, i: c_uint, Kind: AttributeKind) -> bool;
pub(crate) fn LLVMRustGetArrayNumElements(Ty: &Type) -> u64;
Expand All @@ -39,10 +41,11 @@ unsafe extern "C" {
pub(crate) fn LLVMDumpModule(M: &Module);
pub(crate) fn LLVMDumpValue(V: &Value);
pub(crate) fn LLVMGetFunctionCallConv(F: &Value) -> c_uint;
pub(crate) fn LLVMGetReturnType(T: &Type) -> &Type;
|wrap pub(crate) fn LLVMGetReturnType(T: &Type) -> &Type;
pub(crate) fn LLVMGetParams(Fnc: &Value, parms: *mut &Value);
pub(crate) fn LLVMGetNamedFunction(M: &Module, Name: *const c_char) -> Option<&Value>;
}
}

#[repr(C)]
#[derive(Copy, Clone, PartialEq)]
Expand Down
Loading
Loading