-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Frontend] Avoid creating a temporary instance of std::string (NFC) #140326
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
[Frontend] Avoid creating a temporary instance of std::string (NFC) #140326
Conversation
Since getLastArgValue returns StringRef, and the constructor of SmallString accepts StringRef, we do not need to go through a temporary instance of std::string.
@llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) ChangesSince getLastArgValue returns StringRef, and the constructor of Full diff: https://github.com/llvm/llvm-project/pull/140326.diff 1 Files Affected:
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index fd48e425a5c21..3c23073fc6a8c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2055,8 +2055,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
// The memory profile runtime appends the pid to make this name more unique.
const char *MemProfileBasename = "memprof.profraw";
if (Args.hasArg(OPT_fmemory_profile_EQ)) {
- SmallString<128> Path(
- std::string(Args.getLastArgValue(OPT_fmemory_profile_EQ)));
+ SmallString<128> Path(Args.getLastArgValue(OPT_fmemory_profile_EQ));
llvm::sys::path::append(Path, MemProfileBasename);
Opts.MemoryProfileOutput = std::string(Path);
} else if (Args.hasArg(OPT_fmemory_profile))
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/20134 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/15331 Here is the relevant piece of the build log for the reference
|
Since getLastArgValue returns StringRef, and the constructor of
SmallString accepts StringRef, we do not need to go through a
temporary instance of std::string.