Skip to content

Commit eb148b1

Browse files
authored
Merge pull request swiftlang#79713 from xymus/index-while-building-allow-errors
Index: Accept more deserialization inconsistencies during index-while-building
2 parents a172489 + 302d6f1 commit eb148b1

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

include/swift/AST/ASTContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ class ASTContext final {
381381
/// files?
382382
bool IgnoreAdjacentModules = false;
383383

384+
/// Override to accept reading errors from swiftmodules and being generally
385+
/// more tolerant to inconsistencies. This is enabled for
386+
/// index-while-building as it runs last and it can afford to read an AST
387+
/// with inconsistencies.
388+
bool ForceAllowModuleWithCompilerErrors = false;
389+
384390
// Define the set of known identifiers.
385391
#define IDENTIFIER_WITH_NAME(Name, IdStr) Identifier Id_##Name;
386392
#include "swift/AST/KnownIdentifiers.def"

lib/Index/Index.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/Module.h"
2121
#include "swift/AST/ParameterList.h"
2222
#include "swift/AST/Pattern.h"
23+
#include "swift/AST/PrettyStackTrace.h"
2324
#include "swift/AST/ProtocolConformance.h"
2425
#include "swift/AST/SourceFile.h"
2526
#include "swift/AST/Stmt.h"
@@ -2156,14 +2157,20 @@ void index::indexSourceFile(SourceFile *SF, IndexDataConsumer &consumer) {
21562157
}
21572158

21582159
void index::indexModule(ModuleDecl *module, IndexDataConsumer &consumer) {
2160+
PrettyStackTraceDecl trace("indexing module", module);
2161+
ASTContext &ctx = module->getASTContext();
21592162
assert(module);
2163+
21602164
auto mName = module->getRealName().str();
2161-
if (module->getASTContext().blockListConfig.hasBlockListAction(mName,
2165+
if (ctx.blockListConfig.hasBlockListAction(mName,
21622166
BlockListKeyKind::ModuleName,
21632167
BlockListAction::SkipIndexingModule)) {
21642168
return;
21652169
}
2166-
IndexSwiftASTWalker walker(consumer, module->getASTContext());
2170+
2171+
llvm::SaveAndRestore<bool> S(ctx.ForceAllowModuleWithCompilerErrors, true);
2172+
2173+
IndexSwiftASTWalker walker(consumer, ctx);
21672174
walker.visitModule(*module);
21682175
consumer.finish();
21692176
}

lib/Serialization/ModuleFile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ ModuleFile::ModuleFile(std::shared_ptr<const ModuleFileSharedCore> core)
135135
}
136136

137137
bool ModuleFile::allowCompilerErrors() const {
138-
return getContext().LangOpts.AllowModuleWithCompilerErrors;
138+
return getContext().LangOpts.AllowModuleWithCompilerErrors ||
139+
getContext().ForceAllowModuleWithCompilerErrors;
139140
}
140141

141142
Status

0 commit comments

Comments
 (0)