Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6204,10 +6204,28 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
}

llvm::PrettyStackTraceString CrashInfo("Computing output path");

// Output to a user requested destination?
if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
bool IsCLNonPCH =
IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
(isa<PreprocessJobAction>(JA) || isa<PrecompileJobAction>(JA));
bool HasAnyOutputArg =
C.getArgs().hasArg(options::OPT_o, options::OPT__SLASH_Fo);

Arg *FinalOutput = nullptr;
if (IsCLNonPCH && HasAnyOutputArg) {
FinalOutput =
C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo);
} else if (IsCLNonPCH) {
FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo);
} else {
FinalOutput = C.getArgs().getLastArg(options::OPT_o);
}

if (FinalOutput) {
return C.addResultFile(FinalOutput->getValue(), &JA);
}
}

// For /P, preprocess to file named after BaseInput.
Expand Down
8 changes: 8 additions & 0 deletions clang/test/Driver/cl-cxx20-modules.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@

//--- test.pcm
// CPP20WARNING-NOT: clang-cl: warning: argument unused during compilation: '/std:c++20' [-Wunused-command-line-argument]

// test whether the following outputs %Hello.bmi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// test whether the following outputs %Hello.bmi
// test whether the following outputs %t/Hello.bmi

// RUN: %clang_cl /std:c++20 --precompile -x c++-module -Fo:"%t/Hello.bmi" -c -- %t/Hello.cppm -### 2>&1 | FileCheck %s
// CHECK: "-emit-module-interface"
// CHECK: "-o" "{{.*}}Hello.bmi"

//--- Hello.cppm
export module Hello;
Loading