Skip to content

Commit e807fd7

Browse files
authoredMay 12, 2023
Remove unnecessary dependency (rust-lang#2438)
We don't need name demangling since we store the mangled and pretty name of harnesses in the metadata file. I also updated the comment in the `symbol_name` function.
1 parent 2e06509 commit e807fd7

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed
 

‎Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ dependencies = [
571571
"num",
572572
"object",
573573
"regex",
574-
"rustc-demangle",
575574
"serde",
576575
"serde_json",
577576
"shell-words",

‎kani-compiler/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ libc = { version = "0.2", optional = true }
2222
num = { version = "0.4.0", optional = true }
2323
object = { version = "0.30.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"], optional = true }
2424
regex = "1.7.0"
25-
rustc-demangle = { version = "0.1.21", optional = true }
2625
serde = { version = "1", optional = true }
2726
serde_json = { version = "1", optional = true }
2827
strum = {version = "0.24.0", optional = true}
@@ -35,7 +34,7 @@ tracing-tree = "0.2.2"
3534
# Future proofing: enable backend dependencies using feature.
3635
[features]
3736
default = ['cprover']
38-
cprover = ['ar', 'cbmc', 'libc', 'num', 'object', 'rustc-demangle', 'serde',
37+
cprover = ['ar', 'cbmc', 'libc', 'num', 'object', 'serde',
3938
'serde_json', "strum", "strum_macros"]
4039
write_json_symtab = []
4140

‎kani-compiler/src/codegen_cprover_gotoc/utils/names.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,18 @@ impl<'tcx> GotocCtx<'tcx> {
5959
pub fn symbol_name(&self, instance: Instance<'tcx>) -> String {
6060
let llvm_mangled = self.tcx.symbol_name(instance).name.to_string();
6161
debug!(
62-
"finding function name for instance: {}, debug: {:?}, name: {}, symbol: {}, demangle: {}",
62+
"finding function name for instance: {}, debug: {:?}, name: {}, symbol: {}",
6363
instance,
6464
instance,
6565
self.readable_instance_name(instance),
6666
llvm_mangled,
67-
rustc_demangle::demangle(&llvm_mangled).to_string()
6867
);
6968

7069
let pretty = self.readable_instance_name(instance);
7170

72-
// Make main function a special case for easy CBMC entry
73-
// TODO: probably need to edit for https://github.com/model-checking/kani/issues/169
74-
if pretty == "main" {
75-
"main".to_string()
76-
} else {
77-
// TODO: llvm mangled string is not very readable. one way to tackle this is to
78-
// demangle it. but the demangled string has no generic info.
79-
// the best scenario is to use v0 mangler, but this is not default at this moment.
80-
// this is the kind of tiny but annoying issue.
81-
// c.f. https://github.com/rust-lang/rust/issues/60705
82-
//
83-
// the following solution won't work pretty:
84-
// match self.tcx.sess.opts.debugging_opts.symbol_mangling_version {
85-
// SymbolManglingVersion::Legacy => llvm_mangled,
86-
// SymbolManglingVersion::V0 => rustc_demangle::demangle(llvm_mangled.as_str()).to_string(),
87-
// }
88-
llvm_mangled
89-
}
71+
// Make main function a special case in order to support `--function main`
72+
// TODO: Get rid of this: https://github.com/model-checking/kani/issues/2129
73+
if pretty == "main" { pretty } else { llvm_mangled }
9074
}
9175

9276
/// The name for a tuple field

0 commit comments

Comments
 (0)
Please sign in to comment.