aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/driver/cc1_main.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2020-11-20 18:04:32 -0800
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-01-26 15:56:19 -0800
commitad7aaa475e5e632242b07380ec47d2f35d077209 (patch)
tree7633c37dced0ea3e786f9fa47ee048e0a04dee63 /clang/tools/driver/cc1_main.cpp
parent4d28f0a6a4036388694bb83aebc0db9334b82f6e (diff)
downloadllvm-ad7aaa475e5e632242b07380ec47d2f35d077209.zip
llvm-ad7aaa475e5e632242b07380ec47d2f35d077209.tar.gz
llvm-ad7aaa475e5e632242b07380ec47d2f35d077209.tar.bz2
Frontend: Fix layering between create{,Default}OutputFile, NFC
Fix layering between `CompilerInstance::createDefaultOutputFile` and the two versions of `createOutputFile`. - Add missing configuration flags to `createDefaultOutputFile` so that GeneratePCHAction and GenerateModuleFromModuleMapAction can use it. They previously promised that temporary files were turned on; now `createDefaultOutputFile` handles that logic. - Lift the logic handling `InFile` and `Extension` to `createDefaultOutputFile`, since it's only the callers of that function that are using it. - Rename the deeper of the two `createOutputFile`s to `createOutputFileImpl` and make it private to `CompilerInstance` (to prove that no one else is using it). - Sink the logic for adding to `CompilerInstance::OutputFiles` down to `createOutputFileImpl`, allowing two "optional" (but always used) `std::string*` out parameters to be removed. - Instead of passing a `std::error_code` out parameter into `createOutputFileImpl`, have it return `Expected<>`. - As a drive-by, inline `CompilerInstance::addOutputFile` into its only caller, `createOutputFileImpl`. Clean layering makes it easier for a future commit to extract `createOutputFileImpl` out of `CompilerInstance`. Differential Revision: https://reviews.llvm.org/D93248
Diffstat (limited to 'clang/tools/driver/cc1_main.cpp')
-rw-r--r--clang/tools/driver/cc1_main.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 0872015..b4ab6f5 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -248,13 +248,9 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
if (llvm::timeTraceProfilerEnabled()) {
SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
llvm::sys::path::replace_extension(Path, "json");
- if (auto profilerOutput =
- Clang->createOutputFile(Path.str(),
- /*Binary=*/false,
- /*RemoveFileOnSignal=*/false, "",
- /*Extension=*/"json",
- /*useTemporary=*/false)) {
-
+ if (auto profilerOutput = Clang->createOutputFile(
+ Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
+ /*useTemporary=*/false)) {
llvm::timeTraceProfilerWrite(*profilerOutput);
// FIXME(ibiryukov): make profilerOutput flush in destructor instead.
profilerOutput->flush();