Move the diagnostic client init before potential source of diagnostics.

Handling modulemap files may issue parsing errors or not found errors and our
diagnostics client should be prepared for it.

This patch fixes an assertion in clang when we see duplicate modulemap files.
This commit is contained in:
Vassil Vassilev 2020-03-19 09:05:49 +02:00 committed by jenkins
parent 37ee0fa612
commit 4d0c4f41bc
2 changed files with 6 additions and 4 deletions

View File

@ -1594,6 +1594,12 @@ static void stringifyPreprocSetting(PreprocessorOptions& PPOpts,
PP.getTargetInfo().getTriple());
}
// Tell the diagnostic client that we are entering file parsing mode as the
// handling of modulemap files may issue diagnostics.
// FIXME: Consider moving in SetupDiagnostics.
DiagnosticConsumer& DClient = CI->getDiagnosticClient();
DClient.BeginSourceFile(CI->getLangOpts(), &PP);
for (const auto& Filename : FrontendOpts.ModuleMapFiles) {
if (auto* File = FM.getFile(Filename))
PP.getHeaderSearchInfo().loadModuleMapFile(File, /*IsSystem*/ false);

View File

@ -265,10 +265,6 @@ namespace cling {
return;
}
// Tell the diagnostic client that we are entering file parsing mode.
DiagnosticConsumer& DClient = getCI()->getDiagnosticClient();
DClient.BeginSourceFile(getCI()->getLangOpts(), &PP);
bool usingCxxModules = getSema().getLangOpts().Modules;
if (usingCxxModules) {
// Explicitly create the modulemanager now. If we would create it later