[all-commits] [llvm/llvm-project] 651d01: [clang][AST] Fix infinite recursion when printing ...

AZero13 via All-commits all-commits at lists.llvm.org
Tue Sep 8 05:47:35 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 651d01e873c6fce3c8d300362585b1a5f98bb883
      https://github.com/llvm/llvm-project/commit/651d01e873c6fce3c8d300362585b1a5f98bb883
  Author: AZero13 <gfunni234 at gmail.com>
  Date:   2026-09-08 (Tue, 08 Sep 2026)

  Changed paths:
    M clang/lib/AST/StmtPrinter.cpp
    M clang/unittests/AST/TypePrinterTest.cpp

  Log Message:
  -----------
  [clang][AST] Fix infinite recursion when printing fully qualified template parameters (#219044)

This fixes an infinite recursion crash that was introduced in #206041.

When printing a `DeclRefExpr` using
`PrintingPolicy::FullyQualifiedName`, we were previously trying to print
the fully qualified name of all decls. However, when the decl is a
template parameter, its `DeclContext` is the template specialization
itself. If a template specialization's arguments depend on that same
template parameter (e.g., `template<int Count> struct
View<int[Count]>`), attempting to print the qualified name forces Clang
to recursively evaluate the enclosing context. This led to unbounded
recursion (`View<int[Count]>::Count` ->
`View<int[View<int[Count]>::Count]>::Count` and so on). Since template
parameters are inherently scoped to their template declarations and do
not require a fully qualified name, this patch resolves the issue by
skipping `printQualifiedName` if the decl is a template parameter
(`!VD->isTemplateParameter()`).

Fixes #218076.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list