[clang] [Syntax] Append EOF token to truncated expanded token stream when the parser halts prematurely (PR #196861)

Harlen Batagelo via cfe-commits cfe-commits at lists.llvm.org
Mon May 11 06:26:34 PDT 2026


================
@@ -1148,4 +1151,37 @@ TEST_F(TokenCollectorTest, Pragmas) {
     }
   )cpp");
 }
+
+TEST_F(TokenBufferTest, EofTokenOnFunctionScopeDepthLimit) {
+  static_assert(ParmVarDecl::getMaxFunctionScopeDepth() == 127,
+                "Test input relies on a max depth of 127");
+
+  // Force parser to bail out due to exceeding the function scope depth limit.
----------------
hbatagelo wrote:

`EofTokenOnFunctionScopeDepthLimit` seems to be about 3x the cost of `EofTokenOnBracketDepthLimit`. Indeed, the latter is enough to exercise the new code. I'll drop the first.

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


More information about the cfe-commits mailing list