[llvm] 2b15fb1 - [gold] Don't pass StringRef to message() (#95083)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 06:26:57 PDT 2024
Author: Nikita Popov
Date: 2024-06-11T15:26:53+02:00
New Revision: 2b15fb16cee05e6fe56edc6bc24d4d31df48a115
URL: https://github.com/llvm/llvm-project/commit/2b15fb16cee05e6fe56edc6bc24d4d31df48a115
DIFF: https://github.com/llvm/llvm-project/commit/2b15fb16cee05e6fe56edc6bc24d4d31df48a115.diff
LOG: [gold] Don't pass StringRef to message() (#95083)
This is a printf style variadic function. If using a "%s" format, we
should pass "const char *" rather than "StringRef".
The use of data() here is safe because we know that the StringRef was
originally derived from a null-terminated string.
Added:
Modified:
llvm/tools/gold/gold-plugin.cpp
Removed:
################################################################################
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index 265ebcbff5877..0b175a3852e42 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -307,7 +307,8 @@ namespace options {
} else if (opt.consume_front("opt-remarks-hotness-threshold=")) {
auto ResultOrErr = remarks::parseHotnessThresholdOption(opt);
if (!ResultOrErr)
- message(LDPL_FATAL, "Invalid remarks hotness threshold: %s", opt);
+ message(LDPL_FATAL, "Invalid remarks hotness threshold: %s",
+ opt.data());
else
RemarksHotnessThreshold = *ResultOrErr;
} else if (opt.consume_front("opt-remarks-format=")) {
@@ -319,7 +320,7 @@ namespace options {
} else if (opt.consume_front("time-trace-granularity=")) {
unsigned Granularity;
if (opt.getAsInteger(10, Granularity))
- message(LDPL_FATAL, "Invalid time trace granularity: %s", opt);
+ message(LDPL_FATAL, "Invalid time trace granularity: %s", opt.data());
else
time_trace_granularity = Granularity;
} else {
More information about the llvm-commits
mailing list