Author: Corentin Jabot
Date: 2026-08-20T10:09:56+02:00
New Revision: 8ee17c20c0e368e73eb1b9c3c5c6db9f8d74840b

URL: 
https://github.com/llvm/llvm-project/commit/8ee17c20c0e368e73eb1b9c3c5c6db9f8d74840b
DIFF: 
https://github.com/llvm/llvm-project/commit/8ee17c20c0e368e73eb1b9c3c5c6db9f8d74840b.diff

LOG: [Clang][NFC] DeducedTemplateSpecializationType can't actually be null. 
(#217462)

There are two issues here
- DeducedTemplateSpecializationType's template name is never actualy
null so trying to handling a null case is unecessary.

- The serialization of a null template name would not actually work as
getKind() expect a non-null storage.

We could arguably specialize DataStreamBasicWriter::writeOptional for
TemplateName however no one would use that code, so it still would leave
us with some dead code.

Added: 
    

Modified: 
    clang/include/clang/AST/PropertiesBase.td
    clang/include/clang/AST/TypeBase.h
    clang/include/clang/AST/TypeProperties.td

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 25ef4c26a9aa1..d36cbbf7074b5 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -142,7 +142,7 @@ def StmtRef : RefPropertyType<"Stmt"> { let 
ConstWhenWriting = 1; }
   def ExprRef : SubclassPropertyType<"Expr", StmtRef>;
 def TemplateArgument : PropertyType;
 def TemplateArgumentKind : EnumPropertyType<"TemplateArgument::ArgKind">;
-def TemplateName : DefaultValuePropertyType;
+def TemplateName : PropertyType;
 def TemplateNameKind : EnumPropertyType<"TemplateName::NameKind">;
 def TypeOfKind : EnumPropertyType<"TypeOfKind">;
 def UInt32 : CountPropertyType<"uint32_t">;

diff  --git a/clang/include/clang/AST/TypeBase.h 
b/clang/include/clang/AST/TypeBase.h
index eb05a068934ea..3150124c596f4 100644
--- a/clang/include/clang/AST/TypeBase.h
+++ b/clang/include/clang/AST/TypeBase.h
@@ -7438,6 +7438,9 @@ class DeducedTemplateSpecializationType : public 
KeywordWrapper<DeducedType>,
       : KeywordWrapper(Keyword, DeducedTemplateSpecialization, DK,
                        DeducedAsTypeOrCanon),
         Template(Template) {
+
+    assert(!Template.isNull());
+
     auto Dep = toTypeDependence(Template.getDependence());
     // A deduced AutoType only syntactically depends on its template name.
     if (DK == DeducedKind::Deduced)

diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 1723fed7bfd91..2393543e85b96 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -550,8 +550,8 @@ let Class = DeducedTemplateSpecializationType in {
   def : Property<"keyword", ElaboratedTypeKeyword> {
     let Read = [{ node->getKeyword() }];
   }
-  def : Property<"templateName", Optional<TemplateName>> {
-    let Read = [{ makeOptionalFromNullable(node->getTemplateName()) }];
+  def : Property<"templateName", TemplateName> {
+    let Read = [{ node->getTemplateName() }];
   }
   def : Property<"deducedKind", DeducedKind> {
     let Read = [{ node->getDeducedKind() }];
@@ -561,8 +561,7 @@ let Class = DeducedTemplateSpecializationType in {
   }
 
   def : Creator<[{
-    return ctx.getDeducedTemplateSpecializationType(deducedKind, deducedType, 
keyword,
-                                     makeNullableFromOptional(templateName));
+    return ctx.getDeducedTemplateSpecializationType(deducedKind, deducedType, 
keyword, templateName);
   }]>;
 }
 


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to