@@ -75,7 +75,6 @@ cl::SubCommand MergeSubcommand(
75
75
namespace {
76
76
enum ProfileKinds { instr, sample, memory };
77
77
enum FailureMode { warnOnly, failIfAnyAreInvalid, failIfAllAreInvalid };
78
- } // namespace
79
78
80
79
enum ProfileFormat {
81
80
PF_None = 0 ,
@@ -87,6 +86,7 @@ enum ProfileFormat {
87
86
};
88
87
89
88
enum class ShowFormat { Text, Json, Yaml };
89
+ } // namespace
90
90
91
91
// Common options.
92
92
cl::opt<std::string> OutputFilename (" output" , cl::value_desc(" output" ),
@@ -443,8 +443,7 @@ cl::opt<bool> ShowProfileVersion("profile-version", cl::init(false),
443
443
// multiple static functions map to the same name.
444
444
const std::string DuplicateNameStr = " ----" ;
445
445
446
- static void warn (Twine Message, std::string Whence = " " ,
447
- std::string Hint = " " ) {
446
+ static void warn (Twine Message, StringRef Whence = " " , StringRef Hint = " " ) {
448
447
WithColor::warning ();
449
448
if (!Whence.empty ())
450
449
errs () << Whence << " : " ;
@@ -456,13 +455,13 @@ static void warn(Twine Message, std::string Whence = "",
456
455
static void warn (Error E, StringRef Whence = " " ) {
457
456
if (E.isA <InstrProfError>()) {
458
457
handleAllErrors (std::move (E), [&](const InstrProfError &IPE) {
459
- warn (IPE.message (), std::string ( Whence), std::string ( " " ) );
458
+ warn (IPE.message (), Whence);
460
459
});
461
460
}
462
461
}
463
462
464
- static void exitWithError (Twine Message, std::string Whence = " " ,
465
- std::string Hint = " " ) {
463
+ static void exitWithError (Twine Message, StringRef Whence = " " ,
464
+ StringRef Hint = " " ) {
466
465
WithColor::error ();
467
466
if (!Whence.empty ())
468
467
errs () << Whence << " : " ;
@@ -481,24 +480,24 @@ static void exitWithError(Error E, StringRef Whence = "") {
481
480
// Hint in case user missed specifying the profile type.
482
481
Hint = " Perhaps you forgot to use the --sample or --memory option?" ;
483
482
}
484
- exitWithError (IPE.message (), std::string ( Whence), std::string ( Hint) );
483
+ exitWithError (IPE.message (), Whence, Hint);
485
484
});
486
485
return ;
487
486
}
488
487
489
- exitWithError (toString (std::move (E)), std::string ( Whence) );
488
+ exitWithError (toString (std::move (E)), Whence);
490
489
}
491
490
492
491
static void exitWithErrorCode (std::error_code EC, StringRef Whence = " " ) {
493
- exitWithError (EC.message (), std::string ( Whence) );
492
+ exitWithError (EC.message (), Whence);
494
493
}
495
494
496
495
static void warnOrExitGivenError (FailureMode FailMode, std::error_code EC,
497
496
StringRef Whence = " " ) {
498
497
if (FailMode == failIfAnyAreInvalid)
499
498
exitWithErrorCode (EC, Whence);
500
499
else
501
- warn (EC.message (), std::string ( Whence) );
500
+ warn (EC.message (), Whence);
502
501
}
503
502
504
503
static void handleMergeWriterError (Error E, StringRef WhenceFile = " " ,
@@ -1585,7 +1584,7 @@ static void mergeSampleProfile(const WeightedFileVector &Inputs,
1585
1584
// If OutputSizeLimit is 0 (default), it is the same as write().
1586
1585
if (std::error_code EC =
1587
1586
Writer->writeWithSizeLimit (ProfileMap, OutputSizeLimit))
1588
- exitWithErrorCode (std::move (EC) );
1587
+ exitWithErrorCode (EC );
1589
1588
}
1590
1589
1591
1590
static WeightedFile parseWeightedFile (const StringRef &WeightedFilename) {
0 commit comments