Skip to content

Conversation

mizvekov
Copy link
Contributor

The code being removed became non-functional when injected class names were removed from the redecl chain in 470c454, but that commit didn't clean the code base out of all the workarounds for that state of affairs.

The code being removed became non-functional when injected class names
were removed from the redecl chain in 470c454,
but that commit didn't clean the code base out of all the workarounds
for that state of affairs.
@mizvekov mizvekov self-assigned this Aug 29, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 29, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 29, 2025

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

Changes

The code being removed became non-functional when injected class names were removed from the redecl chain in 470c454, but that commit didn't clean the code base out of all the workarounds for that state of affairs.


Full diff: https://github.com/llvm/llvm-project/pull/155959.diff

1 Files Affected:

  • (modified) clang/include/clang/AST/ASTNodeTraverser.h (+2-15)
diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h
index d9dc8290b0e49..fe08d637a1e1d 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -649,21 +649,8 @@ class ASTNodeTraverser
 
   template <typename SpecializationDecl>
   void dumpTemplateDeclSpecialization(const SpecializationDecl *D) {
-    for (const auto *RedeclWithBadType : D->redecls()) {
-      // FIXME: The redecls() range sometimes has elements of a less-specific
-      // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
-      // us TagDecls, and should give CXXRecordDecls).
-      auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
-      if (!Redecl) {
-        // Found the injected-class-name for a class template. This will be
-        // dumped as part of its surrounding class so we don't need to dump it
-        // here.
-        assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
-               "expected an injected-class-name");
-        continue;
-      }
-      Visit(Redecl);
-    }
+    for (const auto *Redecl : D->redecls())
+      Visit(cast<SpecializationDecl>(Redecl));
   }
 
   template <typename TemplateDecl>

@mizvekov mizvekov enabled auto-merge (squash) August 29, 2025 01:59
@mizvekov mizvekov merged commit 5135dcd into main Aug 29, 2025
12 checks passed
@mizvekov mizvekov deleted the users/mizvekov/injected-class-name-redecl-cleanup branch August 29, 2025 02:38
@zwuis zwuis added the skip-precommit-approval PR for CI feedback, not intended for review label Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category skip-precommit-approval PR for CI feedback, not intended for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants