[clang] [Serialization] Check for stack exhaustion when reading declarations (PR #79875)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed May 29 08:12:20 PDT 2024
================
@@ -4099,7 +4099,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
// calls to Decl::getASTContext() by Decl's methods will find the
// TranslationUnitDecl without crashing.
D->setDeclContext(Context.getTranslationUnitDecl());
- Reader.Visit(D);
+
+ // Reading some declarations can result in deep recursion.
+ SemaObj->runWithSufficientStackSpace(DeclLoc, [&] { Reader.Visit(D); });
----------------
ilya-biryukov wrote:
I did not realize Sema can be null, I have updated the code as you suggested, but it now duplicates the logic we have in Sema to avoid showing the error multiple times.
Please take a look and see if the new version makes sense.
https://github.com/llvm/llvm-project/pull/79875
More information about the cfe-commits
mailing list