@@ -99,7 +99,7 @@ pub struct Options {
9999 pub parse_only : bool ,
100100 pub no_trans : bool ,
101101 pub no_analysis : bool ,
102- pub debugging_opts : u64 ,
102+ pub debugging_opts : DebuggingOptions ,
103103 /// Whether to write dependency files. It's (enabled, optional filename).
104104 pub write_dependency_info : ( bool , Option < Path > ) ,
105105 pub prints : Vec < PrintRequest > ,
@@ -224,7 +224,7 @@ pub fn basic_options() -> Options {
224224 parse_only : false ,
225225 no_trans : false ,
226226 no_analysis : false ,
227- debugging_opts : 0 ,
227+ debugging_opts : basic_debugging_options ( ) ,
228228 write_dependency_info : ( false , None ) ,
229229 prints : Vec :: new ( ) ,
230230 cg : basic_codegen_options ( ) ,
@@ -257,103 +257,6 @@ pub enum CrateType {
257257 CrateTypeStaticlib ,
258258}
259259
260- macro_rules! debugging_opts {
261- ( [ $opt: ident ] $cnt: expr ) => (
262- pub const $opt: u64 = 1 << $cnt;
263- ) ;
264- ( [ $opt: ident, $( $rest: ident) ,* ] $cnt: expr ) => (
265- pub const $opt: u64 = 1 << $cnt;
266- debugging_opts! { [ $( $rest) ,* ] $cnt + 1 }
267- )
268- }
269-
270- debugging_opts ! {
271- [
272- VERBOSE ,
273- TIME_PASSES ,
274- COUNT_LLVM_INSNS ,
275- TIME_LLVM_PASSES ,
276- TRANS_STATS ,
277- ASM_COMMENTS ,
278- NO_VERIFY ,
279- BORROWCK_STATS ,
280- NO_LANDING_PADS ,
281- DEBUG_LLVM ,
282- COUNT_TYPE_SIZES ,
283- META_STATS ,
284- GC ,
285- PRINT_LINK_ARGS ,
286- PRINT_LLVM_PASSES ,
287- AST_JSON ,
288- AST_JSON_NOEXPAND ,
289- LS ,
290- SAVE_ANALYSIS ,
291- PRINT_MOVE_FRAGMENTS ,
292- FLOWGRAPH_PRINT_LOANS ,
293- FLOWGRAPH_PRINT_MOVES ,
294- FLOWGRAPH_PRINT_ASSIGNS ,
295- FLOWGRAPH_PRINT_ALL ,
296- PRINT_REGION_GRAPH ,
297- PARSE_ONLY ,
298- NO_TRANS ,
299- NO_ANALYSIS ,
300- UNSTABLE_OPTIONS ,
301- PRINT_ENUM_SIZES
302- ]
303- 0
304- }
305-
306- pub fn debugging_opts_map ( ) -> Vec < ( & ' static str , & ' static str , u64 ) > {
307- vec ! [ ( "verbose" , "in general, enable more debug printouts" , VERBOSE ) ,
308- ( "time-passes" , "measure time of each rustc pass" , TIME_PASSES ) ,
309- ( "count-llvm-insns" , "count where LLVM \
310- instrs originate", COUNT_LLVM_INSNS ) ,
311- ( "time-llvm-passes" , "measure time of each LLVM pass" ,
312- TIME_LLVM_PASSES ) ,
313- ( "trans-stats" , "gather trans statistics" , TRANS_STATS ) ,
314- ( "asm-comments" , "generate comments into the assembly (may change behavior)" ,
315- ASM_COMMENTS ) ,
316- ( "no-verify" , "skip LLVM verification" , NO_VERIFY ) ,
317- ( "borrowck-stats" , "gather borrowck statistics" , BORROWCK_STATS ) ,
318- ( "no-landing-pads" , "omit landing pads for unwinding" ,
319- NO_LANDING_PADS ) ,
320- ( "debug-llvm" , "enable debug output from LLVM" , DEBUG_LLVM ) ,
321- ( "count-type-sizes" , "count the sizes of aggregate types" ,
322- COUNT_TYPE_SIZES ) ,
323- ( "meta-stats" , "gather metadata statistics" , META_STATS ) ,
324- ( "print-link-args" , "Print the arguments passed to the linker" ,
325- PRINT_LINK_ARGS ) ,
326- ( "gc" , "Garbage collect shared data (experimental)" , GC ) ,
327- ( "print-llvm-passes" ,
328- "Prints the llvm optimization passes being run" ,
329- PRINT_LLVM_PASSES ) ,
330- ( "ast-json" , "Print the AST as JSON and halt" , AST_JSON ) ,
331- ( "ast-json-noexpand" , "Print the pre-expansion AST as JSON and halt" , AST_JSON_NOEXPAND ) ,
332- ( "ls" , "List the symbols defined by a library crate" , LS ) ,
333- ( "save-analysis" , "Write syntax and type analysis information \
334- in addition to normal output", SAVE_ANALYSIS ) ,
335- ( "print-move-fragments" , "Print out move-fragment data for every fn" ,
336- PRINT_MOVE_FRAGMENTS ) ,
337- ( "flowgraph-print-loans" , "Include loan analysis data in \
338- --pretty flowgraph output", FLOWGRAPH_PRINT_LOANS ) ,
339- ( "flowgraph-print-moves" , "Include move analysis data in \
340- --pretty flowgraph output", FLOWGRAPH_PRINT_MOVES ) ,
341- ( "flowgraph-print-assigns" , "Include assignment analysis data in \
342- --pretty flowgraph output", FLOWGRAPH_PRINT_ASSIGNS ) ,
343- ( "flowgraph-print-all" , "Include all dataflow analysis data in \
344- --pretty flowgraph output", FLOWGRAPH_PRINT_ALL ) ,
345- ( "print-region-graph" , "Prints region inference graph. \
346- Use with RUST_REGION_GRAPH=help for more info",
347- PRINT_REGION_GRAPH ) ,
348- ( "parse-only" , "Parse only; do not compile, assemble, or link" , PARSE_ONLY ) ,
349- ( "no-trans" , "Run all passes except translation; no output" , NO_TRANS ) ,
350- ( "no-analysis" , "Parse and expand the source, but run no analysis and" ,
351- NO_ANALYSIS ) ,
352- ( "unstable-options" , "Adds unstable command line options to rustc interface" ,
353- UNSTABLE_OPTIONS ) ,
354- ( "print-enum-sizes" , "Print the size of enums and their variants" , PRINT_ENUM_SIZES ) ,
355- ]
356- }
357260
358261#[ derive( Clone ) ]
359262pub enum Passes {
@@ -387,6 +290,7 @@ macro_rules! options {
387290 $( $opt: ident : $t: ty = ( $init: expr, $parse: ident, $desc: expr) ) ,* , ) =>
388291(
389292 #[ derive( Clone ) ]
293+ #[ allow( missing_copy_implementations) ]
390294 pub struct $struct_name { $( pub $opt: $t) ,* }
391295
392296 pub fn $defaultfn( ) -> $struct_name {
@@ -439,7 +343,7 @@ macro_rules! options {
439343 Option <& ' static str >, & ' static str ) ] =
440344 & [ $( ( stringify!( $opt) , $mod_set:: $opt, $mod_desc:: $parse, $desc) ) ,* ] ;
441345
442- #[ allow( non_upper_case_globals) ]
346+ #[ allow( non_upper_case_globals, dead_code ) ]
443347 mod $mod_desc {
444348 pub const parse_bool: Option <& ' static str > = None ;
445349 pub const parse_opt_bool: Option <& ' static str > = None ;
@@ -454,6 +358,7 @@ macro_rules! options {
454358 Some ( "a number" ) ;
455359 }
456360
361+ #[ allow( dead_code) ]
457362 mod $mod_set {
458363 use super :: { $struct_name, Passes , SomePasses , AllPasses } ;
459364
@@ -608,6 +513,73 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
608513 "Optimize with possible levels 0-3" ) ,
609514}
610515
516+
517+ options ! { DebuggingOptions , DebuggingSetter , basic_debugging_options,
518+ build_debugging_options, "Z" , "debugging" ,
519+ DB_OPTIONS , db_type_desc, dbsetters,
520+ verbose: bool = ( false , parse_bool,
521+ "in general, enable more debug printouts" ) ,
522+ time_passes: bool = ( false , parse_bool,
523+ "measure time of each rustc pass" ) ,
524+ count_llvm_insns: bool = ( false , parse_bool,
525+ "count where LLVM instrs originate" ) ,
526+ time_llvm_passes: bool = ( false , parse_bool,
527+ "measure time of each LLVM pass" ) ,
528+ trans_stats: bool = ( false , parse_bool,
529+ "gather trans statistics" ) ,
530+ asm_comments: bool = ( false , parse_bool,
531+ "generate comments into the assembly (may change behavior)" ) ,
532+ no_verify: bool = ( false , parse_bool,
533+ "skip LLVM verification" ) ,
534+ borrowck_stats: bool = ( false , parse_bool,
535+ "gather borrowck statistics" ) ,
536+ no_landing_pads: bool = ( false , parse_bool,
537+ "omit landing pads for unwinding" ) ,
538+ debug_llvm: bool = ( false , parse_bool,
539+ "enable debug output from LLVM" ) ,
540+ count_type_sizes: bool = ( false , parse_bool,
541+ "count the sizes of aggregate types" ) ,
542+ meta_stats: bool = ( false , parse_bool,
543+ "gather metadata statistics" ) ,
544+ print_link_args: bool = ( false , parse_bool,
545+ "Print the arguments passed to the linker" ) ,
546+ gc: bool = ( false , parse_bool,
547+ "Garbage collect shared data (experimental)" ) ,
548+ print_llvm_passes: bool = ( false , parse_bool,
549+ "Prints the llvm optimization passes being run" ) ,
550+ ast_json: bool = ( false , parse_bool,
551+ "Print the AST as JSON and halt" ) ,
552+ ast_json_noexpand: bool = ( false , parse_bool,
553+ "Print the pre-expansion AST as JSON and halt" ) ,
554+ ls: bool = ( false , parse_bool,
555+ "List the symbols defined by a library crate" ) ,
556+ save_analysis: bool = ( false , parse_bool,
557+ "Write syntax and type analysis information in addition to normal output" ) ,
558+ print_move_fragments: bool = ( false , parse_bool,
559+ "Print out move-fragment data for every fn" ) ,
560+ flowgraph_print_loans: bool = ( false , parse_bool,
561+ "Include loan analysis data in --pretty flowgraph output" ) ,
562+ flowgraph_print_moves: bool = ( false , parse_bool,
563+ "Include move analysis data in --pretty flowgraph output" ) ,
564+ flowgraph_print_assigns: bool = ( false , parse_bool,
565+ "Include assignment analysis data in --pretty flowgraph output" ) ,
566+ flowgraph_print_all: bool = ( false , parse_bool,
567+ "Include all dataflow analysis data in --pretty flowgraph output" ) ,
568+ print_region_graph: bool = ( false , parse_bool,
569+ "Prints region inference graph. \
570+ Use with RUST_REGION_GRAPH=help for more info") ,
571+ parse_only: bool = ( false , parse_bool,
572+ "Parse only; do not compile, assemble, or link" ) ,
573+ no_trans: bool = ( false , parse_bool,
574+ "Run all passes except translation; no output" ) ,
575+ no_analysis: bool = ( false , parse_bool,
576+ "Parse and expand the source, but run no analysis" ) ,
577+ unstable_options: bool = ( false , parse_bool,
578+ "Adds unstable command line options to rustc interface" ) ,
579+ print_enum_sizes: bool = ( false , parse_bool,
580+ "Print the size of enums and their variants" ) ,
581+ }
582+
611583pub fn default_lib_output ( ) -> CrateType {
612584 CrateTypeRlib
613585}
@@ -883,52 +855,36 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
883855 }
884856 }
885857
886- let mut debugging_opts = 0 ;
887- let debug_flags = matches. opt_strs ( "Z" ) ;
888- let debug_map = debugging_opts_map ( ) ;
889- for debug_flag in debug_flags. iter ( ) {
890- let mut this_bit = 0 ;
891- for & ( name, _, bit) in debug_map. iter ( ) {
892- if name == * debug_flag {
893- this_bit = bit;
894- break ;
895- }
896- }
897- if this_bit == 0 {
898- early_error ( & format ! ( "unknown debug flag: {}" ,
899- * debug_flag) [ ] )
900- }
901- debugging_opts |= this_bit;
902- }
858+ let debugging_opts = build_debugging_options ( matches) ;
903859
904860 let parse_only = if matches. opt_present ( "parse-only" ) {
905861 // FIXME(acrichto) remove this eventually
906862 early_warn ( "--parse-only is deprecated in favor of -Z parse-only" ) ;
907863 true
908864 } else {
909- debugging_opts & PARSE_ONLY != 0
865+ debugging_opts. parse_only
910866 } ;
911867 let no_trans = if matches. opt_present ( "no-trans" ) {
912868 // FIXME(acrichto) remove this eventually
913869 early_warn ( "--no-trans is deprecated in favor of -Z no-trans" ) ;
914870 true
915871 } else {
916- debugging_opts & NO_TRANS != 0
872+ debugging_opts. no_trans
917873 } ;
918874 let no_analysis = if matches. opt_present ( "no-analysis" ) {
919875 // FIXME(acrichto) remove this eventually
920876 early_warn ( "--no-analysis is deprecated in favor of -Z no-analysis" ) ;
921877 true
922878 } else {
923- debugging_opts & NO_ANALYSIS != 0
879+ debugging_opts. no_analysis
924880 } ;
925881
926- if debugging_opts & DEBUG_LLVM != 0 {
882+ if debugging_opts. debug_llvm {
927883 unsafe { llvm:: LLVMSetDebug ( 1 ) ; }
928884 }
929885
930886 let mut output_types = Vec :: new ( ) ;
931- if !parse_only && !no_trans {
887+ if !debugging_opts . parse_only && !no_trans {
932888 let unparsed_output_types = matches. opt_strs ( "emit" ) ;
933889 for unparsed_output_type in unparsed_output_types. iter ( ) {
934890 for part in unparsed_output_type. split ( ',' ) {
@@ -998,7 +954,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
998954 }
999955 }
1000956 } ;
1001- let gc = debugging_opts & GC != 0 ;
957+ let gc = debugging_opts. gc ;
1002958 let debuginfo = if matches. opt_present ( "g" ) {
1003959 if matches. opt_present ( "debuginfo" ) {
1004960 early_error ( "-g and --debuginfo both provided" ) ;
0 commit comments