1- use std:: path:: { Path , PathBuf } ;
2- use std:: process:: { Command , Output } ;
3- use std:: io:: { BufReader , Read , Write } ;
41use std:: fs:: File ;
2+ use std:: io:: { BufReader , Read , Write } ;
3+ use std:: path:: { Path , PathBuf } ;
54
6- use crate :: { env_var, handle_failed_output } ;
5+ use crate :: { env_var, Command } ;
76
87/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
98/// at `$LLVM_BIN_DIR/llvm-readobj`.
@@ -42,11 +41,12 @@ pub struct LlvmFilecheck {
4241}
4342
4443crate :: impl_common_helpers!( LlvmReadobj ) ;
44+ crate :: impl_common_helpers!( LlvmProfdata ) ;
45+ crate :: impl_common_helpers!( LlvmFilecheck ) ;
4546
4647/// Generate the path to the bin directory of LLVM.
4748pub fn llvm_bin_dir ( ) -> PathBuf {
48- let llvm_bin_dir = env_var ( "LLVM_BIN_DIR" )
49- . expect ( "`LLVM_BIN_DIR` not specified, but this is required to find `llvm-readobj`" ) ;
49+ let llvm_bin_dir = env_var ( "LLVM_BIN_DIR" ) ;
5050 PathBuf :: from ( llvm_bin_dir)
5151}
5252
@@ -70,12 +70,6 @@ impl LlvmReadobj {
7070 self . cmd . arg ( "--file-header" ) ;
7171 self
7272 }
73-
74- /// Get the [`Output`][::std::process::Output] of the finished process.
75- #[ track_caller]
76- pub fn command_output ( & mut self ) -> Output {
77- self . cmd . output ( ) . expect ( "failed to get output of finished process" )
78- }
7973}
8074
8175impl LlvmProfdata {
@@ -89,13 +83,13 @@ impl LlvmProfdata {
8983
9084 /// Provide an input file.
9185 pub fn input < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
92- self . cmd . arg ( "-o" ) ;
9386 self . cmd . arg ( path. as_ref ( ) ) ;
9487 self
9588 }
9689
9790 /// Specify the output file path.
9891 pub fn output < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
92+ self . cmd . arg ( "-o" ) ;
9993 self . cmd . arg ( path. as_ref ( ) ) ;
10094 self
10195 }
@@ -106,12 +100,6 @@ impl LlvmProfdata {
106100 self . cmd . arg ( "merge" ) ;
107101 self
108102 }
109-
110- /// Get the [`Output`][::std::process::Output] of the finished process.
111- #[ track_caller]
112- pub fn command_output ( & mut self ) -> Output {
113- self . cmd . output ( ) . expect ( "failed to get output of finished process" )
114- }
115103}
116104
117105impl LlvmFilecheck {
0 commit comments