This revision was automatically updated to reflect the committed changes. Closed by commit rGacd1ab869fca: [clang] NFC: Avoid double allocation when generating command line (authored by jansvoboda11).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157048/new/ https://reviews.llvm.org/D157048 Files: clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -4611,17 +4611,10 @@ } std::vector<std::string> CompilerInvocation::getCC1CommandLine() const { - // Set up string allocator. - llvm::BumpPtrAllocator Alloc; - llvm::StringSaver Strings(Alloc); - auto SA = [&Strings](const Twine &Arg) { return Strings.save(Arg).data(); }; - - // Synthesize full command line from the CompilerInvocation, including "-cc1". - SmallVector<const char *, 32> Args{"-cc1"}; - generateCC1CommandLine(Args, SA); - - // Convert arguments to the return type. - return std::vector<std::string>{Args.begin(), Args.end()}; + std::vector<std::string> Args{"-cc1"}; + generateCC1CommandLine( + [&Args](const Twine &Arg) { Args.push_back(Arg.str()); }); + return Args; } void CompilerInvocation::resetNonModularOptions() {
Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -4611,17 +4611,10 @@ } std::vector<std::string> CompilerInvocation::getCC1CommandLine() const { - // Set up string allocator. - llvm::BumpPtrAllocator Alloc; - llvm::StringSaver Strings(Alloc); - auto SA = [&Strings](const Twine &Arg) { return Strings.save(Arg).data(); }; - - // Synthesize full command line from the CompilerInvocation, including "-cc1". - SmallVector<const char *, 32> Args{"-cc1"}; - generateCC1CommandLine(Args, SA); - - // Convert arguments to the return type. - return std::vector<std::string>{Args.begin(), Args.end()}; + std::vector<std::string> Args{"-cc1"}; + generateCC1CommandLine( + [&Args](const Twine &Arg) { Args.push_back(Arg.str()); }); + return Args; } void CompilerInvocation::resetNonModularOptions() {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits