aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2022-12-20 11:46:09 +0100
committerTimm Bäder <tbaeder@redhat.com>2022-12-20 11:46:09 +0100
commit1a24bbeefd2ad29e579f871144cfb17a4afb4320 (patch)
treeee080d52e74e69ae11ed8c429574a615cd7bfef3 /clang/lib/Frontend/CompilerInstance.cpp
parent1953c7e03b086e0680545980ef1c9461a7513e29 (diff)
downloadllvm-1a24bbeefd2ad29e579f871144cfb17a4afb4320.zip
llvm-1a24bbeefd2ad29e579f871144cfb17a4afb4320.tar.gz
llvm-1a24bbeefd2ad29e579f871144cfb17a4afb4320.tar.bz2
Revert "[clang][NFC] Clean up createDefaultOutputFile()"
This reverts commit d20101db48945e9d7a19ce3edcfd91d7e1aeadab. Lifetime of the string is not what I thought it was it seems.
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp7
1 files changed, 4 insertions, 3 deletions
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<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;
}
}