[llvm] [gold] Don't pass StringRef to message() (PR #95083)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 01:34:18 PDT 2024
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/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.
>From adf744400ddabf9a0780f9ae8e24d3802f73775f Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Tue, 11 Jun 2024 10:32:49 +0200
Subject: [PATCH] [gold] Don't pass StringRef to message()
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.
---
llvm/tools/gold/gold-plugin.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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