https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140326
Since getLastArgValue returns StringRef, and the constructor of SmallString accepts StringRef, we do not need to go through a temporary instance of std::string. >From 0f87807ef3159de0350dd85b4f5f8dd289c797f4 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Fri, 16 May 2025 17:58:06 -0700 Subject: [PATCH] [Frontend] Avoid creating a temporary instance of std::string (NFC) Since getLastArgValue returns StringRef, and the constructor of SmallString accepts StringRef, we do not need to go through a temporary instance of std::string. --- clang/lib/Frontend/CompilerInvocation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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)) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits