aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profdata/llvm-profdata.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-05-20 17:15:52 -0700
committerFangrui Song <i@maskray.me>2024-05-20 17:15:52 -0700
commit3fa6b3bbdb0f9de18def8596d1f7fcec2ef77b5e (patch)
tree4b99ebf6f4d0b8049428e23833dc3db743354099 /llvm/tools/llvm-profdata/llvm-profdata.cpp
parent7064e4b1633811da984261fdc585ba4438efe827 (diff)
downloadllvm-3fa6b3bbdb0f9de18def8596d1f7fcec2ef77b5e.zip
llvm-3fa6b3bbdb0f9de18def8596d1f7fcec2ef77b5e.tar.gz
llvm-3fa6b3bbdb0f9de18def8596d1f7fcec2ef77b5e.tar.bz2
[llvm-profdata] Fix some style and clang-tidy issues
Fix #92761 Fix #92762
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 4126b55..693af06 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -75,7 +75,6 @@ cl::SubCommand MergeSubcommand(
namespace {
enum ProfileKinds { instr, sample, memory };
enum FailureMode { warnOnly, failIfAnyAreInvalid, failIfAllAreInvalid };
-} // namespace
enum ProfileFormat {
PF_None = 0,
@@ -87,6 +86,7 @@ enum ProfileFormat {
};
enum class ShowFormat { Text, Json, Yaml };
+} // namespace
// Common options.
cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
@@ -443,8 +443,7 @@ cl::opt<bool> ShowProfileVersion("profile-version", cl::init(false),
// multiple static functions map to the same name.
const std::string DuplicateNameStr = "----";
-static void warn(Twine Message, std::string Whence = "",
- std::string Hint = "") {
+static void warn(Twine Message, StringRef Whence = "", StringRef Hint = "") {
WithColor::warning();
if (!Whence.empty())
errs() << Whence << ": ";
@@ -456,13 +455,13 @@ static void warn(Twine Message, std::string Whence = "",
static void warn(Error E, StringRef Whence = "") {
if (E.isA<InstrProfError>()) {
handleAllErrors(std::move(E), [&](const InstrProfError &IPE) {
- warn(IPE.message(), std::string(Whence), std::string(""));
+ warn(IPE.message(), Whence);
});
}
}
-static void exitWithError(Twine Message, std::string Whence = "",
- std::string Hint = "") {
+static void exitWithError(Twine Message, StringRef Whence = "",
+ StringRef Hint = "") {
WithColor::error();
if (!Whence.empty())
errs() << Whence << ": ";
@@ -481,16 +480,16 @@ static void exitWithError(Error E, StringRef Whence = "") {
// Hint in case user missed specifying the profile type.
Hint = "Perhaps you forgot to use the --sample or --memory option?";
}
- exitWithError(IPE.message(), std::string(Whence), std::string(Hint));
+ exitWithError(IPE.message(), Whence, Hint);
});
return;
}
- exitWithError(toString(std::move(E)), std::string(Whence));
+ exitWithError(toString(std::move(E)), Whence);
}
static void exitWithErrorCode(std::error_code EC, StringRef Whence = "") {
- exitWithError(EC.message(), std::string(Whence));
+ exitWithError(EC.message(), Whence);
}
static void warnOrExitGivenError(FailureMode FailMode, std::error_code EC,
@@ -498,7 +497,7 @@ static void warnOrExitGivenError(FailureMode FailMode, std::error_code EC,
if (FailMode == failIfAnyAreInvalid)
exitWithErrorCode(EC, Whence);
else
- warn(EC.message(), std::string(Whence));
+ warn(EC.message(), Whence);
}
static void handleMergeWriterError(Error E, StringRef WhenceFile = "",
@@ -1585,7 +1584,7 @@ static void mergeSampleProfile(const WeightedFileVector &Inputs,
// If OutputSizeLimit is 0 (default), it is the same as write().
if (std::error_code EC =
Writer->writeWithSizeLimit(ProfileMap, OutputSizeLimit))
- exitWithErrorCode(std::move(EC));
+ exitWithErrorCode(EC);
}
static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) {