@@ -51,6 +51,14 @@ pub struct Config {
51
51
pub uint_type : UintTy ,
52
52
}
53
53
54
+ #[ derive( Clone ) ]
55
+ pub enum Sanitizer {
56
+ Address ,
57
+ Leak ,
58
+ Memory ,
59
+ Thread ,
60
+ }
61
+
54
62
#[ derive( Clone , Copy , PartialEq , Hash ) ]
55
63
pub enum OptLevel {
56
64
No , // -O0
@@ -626,11 +634,13 @@ macro_rules! options {
626
634
Some ( "a number" ) ;
627
635
pub const parse_panic_strategy: Option <& ' static str > =
628
636
Some ( "either `panic` or `abort`" ) ;
637
+ pub const parse_sanitizer: Option <& ' static str > =
638
+ Some ( "one of: `address`, `leak`, `memory` or `thread`" ) ;
629
639
}
630
640
631
641
#[ allow( dead_code) ]
632
642
mod $mod_set {
633
- use super :: { $struct_name, Passes , SomePasses , AllPasses } ;
643
+ use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer } ;
634
644
use rustc_back:: PanicStrategy ;
635
645
636
646
$(
@@ -751,6 +761,17 @@ macro_rules! options {
751
761
}
752
762
true
753
763
}
764
+
765
+ fn parse_sanitizer( slote: & mut Option <Sanitizer >, v: Option <& str >) -> bool {
766
+ match v {
767
+ Some ( "address" ) => * slote = Some ( Sanitizer :: Address ) ,
768
+ Some ( "leak" ) => * slote = Some ( Sanitizer :: Leak ) ,
769
+ Some ( "memory" ) => * slote = Some ( Sanitizer :: Memory ) ,
770
+ Some ( "thread" ) => * slote = Some ( Sanitizer :: Thread ) ,
771
+ _ => return false ,
772
+ }
773
+ true
774
+ }
754
775
}
755
776
) }
756
777
@@ -949,6 +970,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
949
970
"encode MIR of all functions into the crate metadata" ) ,
950
971
osx_rpath_install_name: bool = ( false , parse_bool, [ TRACKED ] ,
951
972
"pass `-install_name @rpath/...` to the OSX linker" ) ,
973
+ sanitizer: Option <Sanitizer > = ( None , parse_sanitizer, [ UNTRACKED ] ,
974
+ "Use a sanitizer" ) ,
952
975
}
953
976
954
977
pub fn default_lib_output ( ) -> CrateType {
0 commit comments