Skip to content

Commit

Permalink
di: Aggreggate one WARN log for skipped types
Browse files Browse the repository at this point in the history
On WARN level, instead of logging each skipped type separately,
aggreggate the skipped types and issue a WARN log once.
  • Loading branch information
vadorovsky committed Feb 8, 2024
1 parent 7f37732 commit b9ff8b5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/llvm/di.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct DISanitizer {
visited_nodes: HashSet<u64>,
item_stack: Vec<Item>,
replace_operands: HashMap<u64, LLVMMetadataRef>,
skipped_types: Vec<String>,
}

// Sanitize Rust type names to be valid C type names.
Expand Down Expand Up @@ -67,6 +68,7 @@ impl DISanitizer {
visited_nodes: HashSet::new(),
item_stack: Vec::new(),
replace_operands: HashMap::new(),
skipped_types: Vec::new(),
}
}

Expand Down Expand Up @@ -124,9 +126,10 @@ impl DISanitizer {
None => "<unknown>".to_owned(),
};

warn!(
trace!(
"found data carrying enum {name} ({filename}:{line}), not emitting the debug info for it"
);
self.skipped_types.push(name);

is_data_carrying_enum = true;
break;
Expand Down Expand Up @@ -302,6 +305,13 @@ impl DISanitizer {
self.visit_item(Item::Function(function));
}

if !self.skipped_types.is_empty() {
warn!(
"debug info was not emitted for the following types: {}",
self.skipped_types.join(", ")
);
}

unsafe { LLVMDisposeDIBuilder(self.builder) };
}

Expand Down

0 comments on commit b9ff8b5

Please sign in to comment.