|
64 | 64 | #include "clang/Basic/SourceManager.h" |
65 | 65 | #include "clang/Basic/SourceManagerInternals.h" |
66 | 66 | #include "clang/Basic/Specifiers.h" |
| 67 | +#include "clang/Basic/Stack.h" |
67 | 68 | #include "clang/Basic/TargetInfo.h" |
68 | 69 | #include "clang/Basic/TargetOptions.h" |
69 | 70 | #include "clang/Basic/TokenKinds.h" |
@@ -9648,18 +9649,15 @@ DiagnosticBuilder ASTReader::Diag(SourceLocation Loc, unsigned DiagID) const { |
9648 | 9649 | return Diags.Report(Loc, DiagID); |
9649 | 9650 | } |
9650 | 9651 |
|
9651 | | -void ASTReader::warnStackExhausted(SourceLocation Loc) { |
| 9652 | +void ASTReader::runWithSufficientStackSpace(SourceLocation Loc, |
| 9653 | + llvm::function_ref<void()> Fn) { |
9652 | 9654 | // When Sema is available, avoid duplicate errors. |
9653 | 9655 | if (SemaObj) { |
9654 | | - SemaObj->warnStackExhausted(Loc); |
| 9656 | + SemaObj->runWithSufficientStackSpace(Loc, Fn); |
9655 | 9657 | return; |
9656 | 9658 | } |
9657 | 9659 |
|
9658 | | - if (WarnedStackExhausted) |
9659 | | - return; |
9660 | | - WarnedStackExhausted = true; |
9661 | | - |
9662 | | - Diag(Loc, diag::warn_stack_exhausted); |
| 9660 | + StackHandler.runWithSufficientStackSpace(Loc, Fn); |
9663 | 9661 | } |
9664 | 9662 |
|
9665 | 9663 | /// Retrieve the identifier table associated with the |
@@ -10509,13 +10507,14 @@ ASTReader::ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache, |
10509 | 10507 | bool AllowConfigurationMismatch, bool ValidateSystemInputs, |
10510 | 10508 | bool ValidateASTInputFilesContent, bool UseGlobalIndex, |
10511 | 10509 | std::unique_ptr<llvm::Timer> ReadTimer) |
10512 | | - : Listener(bool(DisableValidationKind &DisableValidationForModuleKind::PCH) |
| 10510 | + : Listener(bool(DisableValidationKind & DisableValidationForModuleKind::PCH) |
10513 | 10511 | ? cast<ASTReaderListener>(new SimpleASTReaderListener(PP)) |
10514 | 10512 | : cast<ASTReaderListener>(new PCHValidator(PP, *this))), |
10515 | 10513 | SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()), |
10516 | | - PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP), |
10517 | | - ContextObj(Context), ModuleMgr(PP.getFileManager(), ModuleCache, |
10518 | | - PCHContainerRdr, PP.getHeaderSearchInfo()), |
| 10514 | + PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), |
| 10515 | + StackHandler(Diags), PP(PP), ContextObj(Context), |
| 10516 | + ModuleMgr(PP.getFileManager(), ModuleCache, PCHContainerRdr, |
| 10517 | + PP.getHeaderSearchInfo()), |
10519 | 10518 | DummyIdResolver(PP), ReadTimer(std::move(ReadTimer)), isysroot(isysroot), |
10520 | 10519 | DisableValidationKind(DisableValidationKind), |
10521 | 10520 | AllowASTWithCompilerErrors(AllowASTWithCompilerErrors), |
|
0 commit comments