-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[gold] Don't pass StringRef to message() #95083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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/pr-subscribers-lto Author: Nikita Popov (nikic) ChangesThis 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. Full diff: https://github.com/llvm/llvm-project/pull/95083.diff 1 Files Affected:
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 {
|
@@ -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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we directly use the variable opt_?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that would also include the opt-remarks-hotness-threshold=
prefix.
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.