[clang] [Serialization] Check for stack exhaustion when reading declarations (PR #79875)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 30 03:13:06 PST 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); });
----------------
ChuanqiXu9 wrote:

As I said, for example, if we're compiling a pcm file to an object file. It makes sense that the Sema is not needed here.

https://github.com/llvm/llvm-project/pull/79875


More information about the cfe-commits mailing list