[clang][NFC] Clean up createDefaultOutputFile()
authorTimm Bäder <tbaeder@redhat.com>
Tue, 20 Dec 2022 10:19:20 +0000 (11:19 +0100)
committerTimm Bäder <tbaeder@redhat.com>
Tue, 20 Dec 2022 10:29:44 +0000 (11:29 +0100)
PathStorage is only used in one of the if branches, so doesn't need to
be a std::optional anyway.

clang/lib/Frontend/CompilerInstance.cpp

index a124566..858c580 100644 (file)
@@ -805,14 +805,13 @@ 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 {
-      PathStorage.emplace(InFile);
-      llvm::sys::path::replace_extension(*PathStorage, Extension);
-      OutputPath = *PathStorage;
+      SmallString<128> PathStorage = InFile;
+      llvm::sys::path::replace_extension(PathStorage, Extension);
+      OutputPath = PathStorage;
     }
   }