[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 23:03:35 PDT 2024


https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/93926

>From db56ac3130164f570942d54686ffb39cf7d2ae33 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Fri, 31 May 2024 02:53:18 -0300
Subject: [PATCH] [clang] AST Visitor: skip empty qualifiers in
 QualifiedTemplateName

This change was missed in #93433.
---
 clang/include/clang/AST/RecursiveASTVisitor.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 4bbb4380cdd7f..d16074443b2dc 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -855,10 +855,14 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclarationNameInfo(
 
 template <typename Derived>
 bool RecursiveASTVisitor<Derived>::TraverseTemplateName(TemplateName Template) {
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
     TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-    TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN =
+                 Template.getAsQualifiedTemplateName()) {
+    if (T->getQualifier()) {
+      TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+    }
+  }
 
   return true;
 }



More information about the cfe-commits mailing list