Skip to content

Commit 2b15fb1

Browse files
authored
[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.
1 parent 400d4fd commit 2b15fb1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/tools/gold/gold-plugin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ namespace options {
307307
} else if (opt.consume_front("opt-remarks-hotness-threshold=")) {
308308
auto ResultOrErr = remarks::parseHotnessThresholdOption(opt);
309309
if (!ResultOrErr)
310-
message(LDPL_FATAL, "Invalid remarks hotness threshold: %s", opt);
310+
message(LDPL_FATAL, "Invalid remarks hotness threshold: %s",
311+
opt.data());
311312
else
312313
RemarksHotnessThreshold = *ResultOrErr;
313314
} else if (opt.consume_front("opt-remarks-format=")) {
@@ -319,7 +320,7 @@ namespace options {
319320
} else if (opt.consume_front("time-trace-granularity=")) {
320321
unsigned Granularity;
321322
if (opt.getAsInteger(10, Granularity))
322-
message(LDPL_FATAL, "Invalid time trace granularity: %s", opt);
323+
message(LDPL_FATAL, "Invalid time trace granularity: %s", opt.data());
323324
else
324325
time_trace_granularity = Granularity;
325326
} else {

0 commit comments

Comments
 (0)