-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add needs-target-has-atomic
directive
#133736
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::common::{Config, Sanitizer}; | ||
use crate::common::{Config, KNOWN_TARGET_HAS_ATOMIC_WIDTHS, Sanitizer}; | ||
use crate::header::{IgnoreDecision, llvm_has_libzstd}; | ||
|
||
pub(super) fn handle_needs( | ||
|
@@ -171,11 +171,54 @@ pub(super) fn handle_needs( | |
}, | ||
]; | ||
|
||
let (name, comment) = match ln.split_once([':', ' ']) { | ||
Some((name, comment)) => (name, Some(comment)), | ||
let (name, rest) = match ln.split_once([':', ' ']) { | ||
Some((name, rest)) => (name, Some(rest)), | ||
None => (ln, None), | ||
}; | ||
|
||
// FIXME(jieyouxu): tighten up this parsing to reject using both `:` and ` ` as means to | ||
// delineate value. | ||
if name == "needs-target-has-atomic" { | ||
let Some(rest) = rest else { | ||
Comment on lines
-174
to
+181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remark: I didn't want to adjust how directives accept There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I noted this in the original PR I think. It's fine as long as we acknowledge wanting to fix it in the future. |
||
return IgnoreDecision::Error { | ||
message: "expected `needs-target-has-atomic` to have a comma-separated list of atomic widths".to_string(), | ||
}; | ||
}; | ||
|
||
// Expect directive value to be a list of comma-separated atomic widths. | ||
let specified_widths = rest | ||
.split(',') | ||
.map(|width| width.trim()) | ||
.map(ToString::to_string) | ||
.collect::<Vec<String>>(); | ||
|
||
for width in &specified_widths { | ||
if !KNOWN_TARGET_HAS_ATOMIC_WIDTHS.contains(&width.as_str()) { | ||
return IgnoreDecision::Error { | ||
message: format!( | ||
"unknown width specified in `needs-target-has-atomic`: `{width}` is not a \ | ||
known `target_has_atomic_width`, known values are `{:?}`", | ||
KNOWN_TARGET_HAS_ATOMIC_WIDTHS | ||
), | ||
}; | ||
} | ||
} | ||
|
||
let satisfies_all_specified_widths = specified_widths | ||
.iter() | ||
.all(|specified| config.target_cfg().target_has_atomic.contains(specified)); | ||
if satisfies_all_specified_widths { | ||
return IgnoreDecision::Continue; | ||
} else { | ||
return IgnoreDecision::Ignore { | ||
reason: format!( | ||
"skipping test as target does not support all of the required `target_has_atomic` widths `{:?}`", | ||
specified_widths | ||
), | ||
}; | ||
} | ||
} | ||
|
||
if !name.starts_with("needs-") { | ||
return IgnoreDecision::Continue; | ||
} | ||
|
@@ -193,7 +236,7 @@ pub(super) fn handle_needs( | |
break; | ||
} else { | ||
return IgnoreDecision::Ignore { | ||
reason: if let Some(comment) = comment { | ||
reason: if let Some(comment) = rest { | ||
format!("{} ({})", need.ignore_reason, comment.trim()) | ||
} else { | ||
need.ignore_reason.into() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: this is yet another hard-coded list 😅