https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/141990
We can only print and use a default arg, if it is instantiated. I was unable to reduce the test case for this to something of reasonable size, but this is easily hit by running clang-doc to generate clang's documentation. For now, we can fix the assertion quickly to unbreak users, and add the proper test once it is small enough. >From ac37e01318046d3af42c5aa86b0480a3e82922fe Mon Sep 17 00:00:00 2001 From: Paul Kirth <paulki...@google.com> Date: Thu, 29 May 2025 10:03:30 -0700 Subject: [PATCH] [clang-doc] Fix assertions error in Serialize.cpp We can only print and use a default arg, if it is instantiated. I was unable to reduce the test case for this to something of reasonable size, but this is easily hit by running clang-doc to generate clang's documentation. For now, we can fix the assertion quickly to unbreak users, and add the proper test once it is small enough. --- clang-tools-extra/clang-doc/Serialize.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp index 97ea1f02a6178..e9212e4de7644 100644 --- a/clang-tools-extra/clang-doc/Serialize.cpp +++ b/clang-tools-extra/clang-doc/Serialize.cpp @@ -113,9 +113,8 @@ getFunctionPrototype(const FunctionDecl *FuncDecl) { Stream << " " << ParamDecl->getNameAsString(); // Print default argument if it exists - if (ParamDecl->hasDefaultArg()) { - const Expr *DefaultArg = ParamDecl->getDefaultArg(); - if (DefaultArg) { + if (ParamDecl->hasDefaultArg() && !ParamDecl->hasUninstantiatedDefaultArg()) { + if(const Expr *DefaultArg = ParamDecl->getDefaultArg()) { Stream << " = "; DefaultArg->printPretty(Stream, nullptr, Ctx.getPrintingPolicy()); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits