Skip to content

Commit 1a24bbe

Browse files
committed
Revert "[clang][NFC] Clean up createDefaultOutputFile()"
This reverts commit d20101d. Lifetime of the string is not what I thought it was it seems.
1 parent 1953c7e commit 1a24bbe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,14 @@ std::unique_ptr<raw_pwrite_stream> CompilerInstance::createDefaultOutputFile(
805805
bool Binary, StringRef InFile, StringRef Extension, bool RemoveFileOnSignal,
806806
bool CreateMissingDirectories, bool ForceUseTemporary) {
807807
StringRef OutputPath = getFrontendOpts().OutputFile;
808+
std::optional<SmallString<128>> PathStorage;
808809
if (OutputPath.empty()) {
809810
if (InFile == "-" || Extension.empty()) {
810811
OutputPath = "-";
811812
} else {
812-
SmallString<128> PathStorage = InFile;
813-
llvm::sys::path::replace_extension(PathStorage, Extension);
814-
OutputPath = PathStorage;
813+
PathStorage.emplace(InFile);
814+
llvm::sys::path::replace_extension(*PathStorage, Extension);
815+
OutputPath = *PathStorage;
815816
}
816817
}
817818

0 commit comments

Comments
 (0)