[clang] [Clang] Don't form a type constraint if the concept is invalid (PR #122065)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 14:30:11 PST 2025


================
@@ -1969,7 +1970,7 @@ void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
   if (OwnsDefaultArg)
     Record.AddTemplateArgumentLoc(D->getDefaultArgument());
 
-  if (!TC && !OwnsDefaultArg &&
+  if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
----------------
shafik wrote:

The logic here is a little tricky. The new condition is really "it has a constraint and it does not matter if it is initialized".

I feel like this deserves a comment.

It also makes me wonder if "initialized" is the right word here, isn't it really that it was invalid?

I am just thinking of folks coming to maintain this code in the future and understanding the intent and I don't think the intent is 💯 clear as written.

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


More information about the cfe-commits mailing list