@@ -99,7 +99,7 @@ pub struct Options {
99
99
pub parse_only : bool ,
100
100
pub no_trans : bool ,
101
101
pub no_analysis : bool ,
102
- pub debugging_opts : u64 ,
102
+ pub debugging_opts : DebuggingOptions ,
103
103
/// Whether to write dependency files. It's (enabled, optional filename).
104
104
pub write_dependency_info : ( bool , Option < Path > ) ,
105
105
pub prints : Vec < PrintRequest > ,
@@ -224,7 +224,7 @@ pub fn basic_options() -> Options {
224
224
parse_only : false ,
225
225
no_trans : false ,
226
226
no_analysis : false ,
227
- debugging_opts : 0 ,
227
+ debugging_opts : basic_debugging_options ( ) ,
228
228
write_dependency_info : ( false , None ) ,
229
229
prints : Vec :: new ( ) ,
230
230
cg : basic_codegen_options ( ) ,
@@ -257,103 +257,6 @@ pub enum CrateType {
257
257
CrateTypeStaticlib ,
258
258
}
259
259
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
- }
357
260
358
261
#[ derive( Clone ) ]
359
262
pub enum Passes {
@@ -387,6 +290,7 @@ macro_rules! options {
387
290
$( $opt: ident : $t: ty = ( $init: expr, $parse: ident, $desc: expr) ) ,* , ) =>
388
291
(
389
292
#[ derive( Clone ) ]
293
+ #[ allow( missing_copy_implementations) ]
390
294
pub struct $struct_name { $( pub $opt: $t) ,* }
391
295
392
296
pub fn $defaultfn( ) -> $struct_name {
@@ -439,7 +343,7 @@ macro_rules! options {
439
343
Option <& ' static str >, & ' static str ) ] =
440
344
& [ $( ( stringify!( $opt) , $mod_set:: $opt, $mod_desc:: $parse, $desc) ) ,* ] ;
441
345
442
- #[ allow( non_upper_case_globals) ]
346
+ #[ allow( non_upper_case_globals, dead_code ) ]
443
347
mod $mod_desc {
444
348
pub const parse_bool: Option <& ' static str > = None ;
445
349
pub const parse_opt_bool: Option <& ' static str > = None ;
@@ -454,6 +358,7 @@ macro_rules! options {
454
358
Some ( "a number" ) ;
455
359
}
456
360
361
+ #[ allow( dead_code) ]
457
362
mod $mod_set {
458
363
use super :: { $struct_name, Passes , SomePasses , AllPasses } ;
459
364
@@ -608,6 +513,73 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
608
513
"Optimize with possible levels 0-3" ) ,
609
514
}
610
515
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
+
611
583
pub fn default_lib_output ( ) -> CrateType {
612
584
CrateTypeRlib
613
585
}
@@ -883,52 +855,36 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
883
855
}
884
856
}
885
857
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) ;
903
859
904
860
let parse_only = if matches. opt_present ( "parse-only" ) {
905
861
// FIXME(acrichto) remove this eventually
906
862
early_warn ( "--parse-only is deprecated in favor of -Z parse-only" ) ;
907
863
true
908
864
} else {
909
- debugging_opts & PARSE_ONLY != 0
865
+ debugging_opts. parse_only
910
866
} ;
911
867
let no_trans = if matches. opt_present ( "no-trans" ) {
912
868
// FIXME(acrichto) remove this eventually
913
869
early_warn ( "--no-trans is deprecated in favor of -Z no-trans" ) ;
914
870
true
915
871
} else {
916
- debugging_opts & NO_TRANS != 0
872
+ debugging_opts. no_trans
917
873
} ;
918
874
let no_analysis = if matches. opt_present ( "no-analysis" ) {
919
875
// FIXME(acrichto) remove this eventually
920
876
early_warn ( "--no-analysis is deprecated in favor of -Z no-analysis" ) ;
921
877
true
922
878
} else {
923
- debugging_opts & NO_ANALYSIS != 0
879
+ debugging_opts. no_analysis
924
880
} ;
925
881
926
- if debugging_opts & DEBUG_LLVM != 0 {
882
+ if debugging_opts. debug_llvm {
927
883
unsafe { llvm:: LLVMSetDebug ( 1 ) ; }
928
884
}
929
885
930
886
let mut output_types = Vec :: new ( ) ;
931
- if !parse_only && !no_trans {
887
+ if !debugging_opts . parse_only && !no_trans {
932
888
let unparsed_output_types = matches. opt_strs ( "emit" ) ;
933
889
for unparsed_output_type in unparsed_output_types. iter ( ) {
934
890
for part in unparsed_output_type. split ( ',' ) {
@@ -998,7 +954,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
998
954
}
999
955
}
1000
956
} ;
1001
- let gc = debugging_opts & GC != 0 ;
957
+ let gc = debugging_opts. gc ;
1002
958
let debuginfo = if matches. opt_present ( "g" ) {
1003
959
if matches. opt_present ( "debuginfo" ) {
1004
960
early_error ( "-g and --debuginfo both provided" ) ;
0 commit comments