[clang] [clang][AST] Assert that DependentNameType::Name is not null (PR #122418)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 9 20:57:35 PST 2025


https://github.com/HighCommander4 created https://github.com/llvm/llvm-project/pull/122418

Also clarify the comment above DependentNameType::getIdentifier()

>From a1e3dcc6063cafa2f79aed88090dcc6f14be0ed7 Mon Sep 17 00:00:00 2001
From: Nathan Ridge <zeratul976 at hotmail.com>
Date: Thu, 9 Jan 2025 23:55:35 -0500
Subject: [PATCH] [clang][AST] Assert that DependentNameType::Name is not null

Also clarify the comment above DependentNameType::getIdentifier()
---
 clang/include/clang/AST/Type.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 09c98f642852fc..2ec59c2cb9a8f6 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -7035,17 +7035,16 @@ class DependentNameType : public TypeWithKeyword, public llvm::FoldingSetNode {
       : TypeWithKeyword(Keyword, DependentName, CanonType,
                         TypeDependence::DependentInstantiation |
                             toTypeDependence(NNS->getDependence())),
-        NNS(NNS), Name(Name) {}
+        NNS(NNS), Name(Name) {
+    assert(Name);
+  }
 
 public:
   /// Retrieve the qualification on this type.
   NestedNameSpecifier *getQualifier() const { return NNS; }
 
-  /// Retrieve the type named by the typename specifier as an identifier.
-  ///
-  /// This routine will return a non-NULL identifier pointer when the
-  /// form of the original typename was terminated by an identifier,
-  /// e.g., "typename T::type".
+  /// Retrieve the identifier that terminates this type name.
+  /// For example, "type" in "typename T::type".
   const IdentifierInfo *getIdentifier() const {
     return Name;
   }



More information about the cfe-commits mailing list