[clang] Guard against nullptr (PR #94084)

via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 17:50:28 PDT 2024


https://github.com/Sterling-Augustine created https://github.com/llvm/llvm-project/pull/94084

None

>From 169e09f2aa403676873a440d8496356cefe69b9e Mon Sep 17 00:00:00 2001
From: Sterling Augustine <saugustine at google.com>
Date: Fri, 31 May 2024 23:18:32 +0000
Subject: [PATCH] Guard against nullptr

---
 clang/lib/AST/QualTypeNames.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 066377423df76..18ac4b1eb57e7 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -65,8 +65,9 @@ static bool getFullyQualifiedTemplateName(const ASTContext &Ctx,
   assert(ArgTDecl != nullptr);
   QualifiedTemplateName *QTName = TName.getAsQualifiedTemplateName();
 
-  if (QTName && !QTName->hasTemplateKeyword()) {
-    NNS = QTName->getQualifier();
+  if (QTName &&
+      !QTName->hasTemplateKeyword() &&
+      (NNS = QTName->getQualifier())) {
     NestedNameSpecifier *QNNS = getFullyQualifiedNestedNameSpecifier(
         Ctx, NNS, WithGlobalNsPrefix);
     if (QNNS != NNS) {



More information about the cfe-commits mailing list