[clang] [clang-tools-extra] [clang] Improve nested name specifier AST representation (PR #147835)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 16 12:28:16 PDT 2025


================
@@ -2586,8 +2561,9 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty,
   }
 
   case Type::InjectedClassName:
-    mangleSourceNameWithAbiTags(
-        cast<InjectedClassNameType>(Ty)->getDecl());
+    mangleSourceNameWithAbiTags(cast<InjectedClassNameType>(Ty)
+                                    ->getOriginalDecl()
+                                    ->getDefinitionOrSelf());
----------------
mizvekov wrote:

Not always.

I mean you could certainly attempt to define an `InjectedClassNameType` whose declaration necessarily is the definition.

This would cause many annoyances, most of them surmountable, as you wouldn't be able to form a type to an arbitrary declaration (which we do offhandedly in error recovery and printing diagnostics), and the type would play by different rules than other tag types.

Though I think at the end, you would come to the problem of demoted definitions, which come up for example when merging definitions from the GMF of different modules. You would have to throw away the ability to represent an InjectedClassNameType pointing to a demoted definition.

https://github.com/llvm/llvm-project/pull/147835


More information about the cfe-commits mailing list