diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Driver/ToolChains/Clang.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 2 |
3 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 83830b51ed5..c35f7a94053 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3250,18 +3250,15 @@ 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(types::TY_CXXModule, ModuleName, ModuleName); + InputInfo HeaderModuleInput(Inputs[0].getType(), ModuleName, ModuleName); const InputInfo &Input = IsHeaderModulePrecompile ? HeaderModuleInput : Inputs[0]; @@ -3272,10 +3269,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, for (const InputInfo &I : Inputs) { if (&I == &Input) { // This is the primary input. - } else if (IsModulePrecompile && + } else if (IsHeaderModulePrecompile && types::getPrecompiledType(I.getType()) == types::TY_PCH) { - types::ID Expected = - types::lookupHeaderTypeForSourceType(Inputs[0].getType()); + types::ID Expected = HeaderModuleInput.getType(); if (I.getType() != Expected) { D.Diag(diag::err_drv_module_header_wrong_kind) << I.getFilename() << types::getTypeName(I.getType()) diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index a9c51d49f65..719474dc765 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -372,6 +372,9 @@ static void InitializeFileRemapping(DiagnosticsEngine &Diags, void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { const PreprocessorOptions &PPOpts = getPreprocessorOpts(); + // The module manager holds a reference to the old preprocessor (if any). + ModuleManager.reset(); + // Create a PTH manager if we are using some form of a token cache. PTHManager *PTHMgr = nullptr; if (!PPOpts.TokenCache.empty()) diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index d44bf124ffc..13d2b728f58 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -523,7 +523,7 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule, // At this point, only non-modular includes remain. - if (LangOpts.ModulesStrictDeclUse) { + if (RequestingModule && LangOpts.ModulesStrictDeclUse) { Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module) << RequestingModule->getTopLevelModule()->Name << Filename; } else if (RequestingModule && RequestingModuleIsModuleInterface && |