[clang] 1a24bbe - Revert "[clang][NFC] Clean up createDefaultOutputFile()"
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 20 02:46:37 PST 2022
Author: Timm Bäder
Date: 2022-12-20T11:46:09+01:00
New Revision: 1a24bbeefd2ad29e579f871144cfb17a4afb4320
URL: https://github.com/llvm/llvm-project/commit/1a24bbeefd2ad29e579f871144cfb17a4afb4320
DIFF: https://github.com/llvm/llvm-project/commit/1a24bbeefd2ad29e579f871144cfb17a4afb4320.diff
LOG: Revert "[clang][NFC] Clean up createDefaultOutputFile()"
This reverts commit d20101db48945e9d7a19ce3edcfd91d7e1aeadab.
Lifetime of the string is not what I thought it was it seems.
Added:
Modified:
clang/lib/Frontend/CompilerInstance.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 858c5805b3abb..a12456640c7ac 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -805,13 +805,14 @@ std::unique_ptr<raw_pwrite_stream> CompilerInstance::createDefaultOutputFile(
bool Binary, StringRef InFile, StringRef Extension, bool RemoveFileOnSignal,
bool CreateMissingDirectories, bool ForceUseTemporary) {
StringRef OutputPath = getFrontendOpts().OutputFile;
+ std::optional<SmallString<128>> 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;
}
}
More information about the cfe-commits
mailing list