From: Timm Bäder Date: Tue, 20 Dec 2022 10:46:09 +0000 (+0100) Subject: Revert "[clang][NFC] Clean up createDefaultOutputFile()" X-Git-Tag: upstream/17.0.6~23141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a24bbeefd2ad29e579f871144cfb17a4afb4320;p=platform%2Fupstream%2Fllvm.git Revert "[clang][NFC] Clean up createDefaultOutputFile()" This reverts commit d20101db48945e9d7a19ce3edcfd91d7e1aeadab. Lifetime of the string is not what I thought it was it seems. --- diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 858c580..a124566 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -805,13 +805,14 @@ std::unique_ptr CompilerInstance::createDefaultOutputFile( bool Binary, StringRef InFile, StringRef Extension, bool RemoveFileOnSignal, bool CreateMissingDirectories, bool ForceUseTemporary) { StringRef OutputPath = getFrontendOpts().OutputFile; + std::optional> PathStorage; if (OutputPath.empty()) { if (InFile == "-" || Extension.empty()) { OutputPath = "-"; } else { - SmallString<128> PathStorage = InFile; - llvm::sys::path::replace_extension(PathStorage, Extension); - OutputPath = PathStorage; + PathStorage.emplace(InFile); + llvm::sys::path::replace_extension(*PathStorage, Extension); + OutputPath = *PathStorage; } }