diff options
Diffstat (limited to 'clang/lib/Driver/ToolChains/Clang.cpp')
| -rw-r--r-- | clang/lib/Driver/ToolChains/Clang.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 926db3d4f9d..a8ddd8adc32 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3250,15 +3250,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, bool IsCuda = JA.isOffloading(Action::OFK_Cuda); bool IsHIP = JA.isOffloading(Action::OFK_HIP); bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP); + bool IsModulePrecompile = + isa<PrecompileJobAction>(JA) && JA.getType() == types::TY_ModuleFile; bool IsHeaderModulePrecompile = isa<HeaderModulePrecompileJobAction>(JA); // A header module compilation doesn't have a main input file, so invent a // fake one as a placeholder. + // FIXME: Pick the language based on the header file language. const char *ModuleName = [&]{ auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ); return ModuleNameArg ? ModuleNameArg->getValue() : ""; }(); - InputInfo HeaderModuleInput(Inputs[0].getType(), ModuleName, ModuleName); + InputInfo HeaderModuleInput(types::TY_CXXModule, ModuleName, ModuleName); const InputInfo &Input = IsHeaderModulePrecompile ? HeaderModuleInput : Inputs[0]; @@ -3269,9 +3272,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, for (const InputInfo &I : Inputs) { if (&I == &Input) { // This is the primary input. - } else if (IsHeaderModulePrecompile && + } else if (IsModulePrecompile && types::getPrecompiledType(I.getType()) == types::TY_PCH) { - types::ID Expected = HeaderModuleInput.getType(); + types::ID Expected = + types::lookupHeaderTypeForSourceType(Inputs[0].getType()); if (I.getType() != Expected) { D.Diag(diag::err_drv_module_header_wrong_kind) << I.getFilename() << types::getTypeName(I.getType()) |

