Skip to content
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

Increase robustness to exotic clang versions #163

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ env_logger = "0.10"
# Used for logging
log = "0.4"

# Used to parse versions
regex = "1.10"

# Used for logging in TUI mode
syslog = "6.1"

Expand Down
9 changes: 6 additions & 3 deletions src/clang.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Interactions with clang

use regex::Regex;
use std::{
io,
process::{Command, ExitStatus},
Expand Down Expand Up @@ -31,9 +32,11 @@ pub fn find_clangpp() -> Result<impl AsRef<str> + 'static, ClangError> {
Some(line) => line,
None => return Err(ClangError::EmptyVersion),
};
if let Some(version) = version_line.strip_prefix("clang version ") {
if let Some((major_version, _)) = version.split_once('.') {
if let Ok(major_version) = major_version.parse::<usize>() {
let version_regex =
Regex::new(r"clang version (?<major_version>\d+)\.(?<minor_version>\d+)").unwrap();
if let Some(captures) = version_regex.captures(version_line) {
if let Some(major_version) = captures.name("major_version") {
if let Ok(major_version) = major_version.as_str().parse::<usize>() {
if major_version >= MIN_VERSION {
return Ok(CLANG_PROGRAM);
} else {
Expand Down