[modules] If we hit a failure while loading a PCH/module, abort parsi… · llvm/llvm-project@dc9fdaf (original) (raw)

Original file line number Diff line number Diff line change
@@ -216,7 +216,8 @@ const unsigned DefaultPreambleRebuildInterval = 5;
216 216 static llvm::sys::cas_flag ActiveASTUnitObjects;
217 217
218 218 ASTUnit::ASTUnit(bool _MainFileIsAST)
219 - : Reader(0), OnlyLocalDecls(false), CaptureDiagnostics(false),
219 + : Reader(0), HadModuleLoaderFatalFailure(false),
220 + OnlyLocalDecls(false), CaptureDiagnostics(false),
220 221 MainFileIsAST(_MainFileIsAST),
221 222 TUKind(TU_Complete), WantTiming(getenv("LIBCLANG_TIMING")),
222 223 OwnsRemappedFileBuffers(true),
@@ -1705,6 +1706,7 @@ void ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance &CI) {
1705 1706 CI.setFileManager(0);
1706 1707 Target = &CI.getTarget();
1707 1708 Reader = CI.getModuleManager();
1709 + HadModuleLoaderFatalFailure = CI.hadModuleLoaderFatalFailure();
1708 1710 }
1709 1711
1710 1712 StringRef ASTUnit::getMainFileName() const {
@@ -2504,6 +2506,9 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
2504 2506 }
2505 2507
2506 2508 bool ASTUnit::Save(StringRef File) {
2509 +if (HadModuleLoaderFatalFailure)
2510 +return true;
2511 +
2507 2512 // Write to a temporary file and later rename it to the actual file, to avoid
2508 2513 // possible race conditions.
2509 2514 SmallString<128> TempPath;