Unverified Commit 4ff87c01 authored by Matt Arsenault's avatar Matt Arsenault Committed by GitHub
Browse files

clang: Stop using replace_extension when there's no extension (#195335)

The offload case is building a fresh filepath and there's no file
extension to replace. Just directly append the file extension to avoid
clobbering part of the path name if the triple contains a period.

Avoids confusing test updates in future triple patch.
parent 67bd7bc4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -6029,6 +6029,7 @@ static void handleTimeTrace(Compilation &C, const ArgList &Args,
      Path = DumpDir->getValue();
      Path += llvm::sys::path::stem(BaseInput);
      Path += OffloadingPrefix;
      Path += ".json";
    } else if (!OffloadingPrefix.empty()) {
      // For offloading, derive path from -o output directory combined with
      // the input filename and offload prefix.
@@ -6037,11 +6038,12 @@ static void handleTimeTrace(Compilation &C, const ArgList &Args,
      if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
        Path = llvm::sys::path::parent_path(FinalOutput->getValue());
      llvm::sys::path::append(Path, TraceName);
      Path += ".json";
    } else {
      Path = Result.getFilename();
    }
      llvm::sys::path::replace_extension(Path, "json");
    }
  }
  const char *ResultFile = C.getArgs().MakeArgString(Path);
  C.addTimeTraceFile(ResultFile, JA);
  C.addResultFile(ResultFile, JA);