[clang] [Clang][RFC] Resugar attributed type alias (PR #143143)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 6 07:37:07 PDT 2025


================
@@ -6998,6 +7007,31 @@ namespace {
         else
           return C.getRValueReferenceType(New);
       }
+      case Elaborated: {
+        auto *ET = cast<ElaboratedType>(Old);
+        return C.getElaboratedType(ET->getKeyword(), ET->getQualifier(),
+                                   wrap(C, ET->getNamedType(), I));
+      }
+      case TypeAlias: {
+        auto *ET = cast<TypedefType>(Old);
+        QualType Underlying = wrap(C, ET->desugar(), I);
+        TypedefNameDecl *Typedef;
+        if (auto *TD = dyn_cast<TypedefDecl>(ET->getDecl())) {
+          Typedef = TypedefDecl::Create(C, TD->getDeclContext(),
+                                        TD->getBeginLoc(), TD->getLocation(),
+                                        TD->getIdentifier(), nullptr);
+          Typedef->setModedTypeSourceInfo(TD->getTypeSourceInfo(), Underlying);
+        } else {
+          auto *Alias = cast<TypeAliasDecl>(ET->getDecl());
+          Typedef = TypedefDecl::Create(
+              C, Alias->getDeclContext(), Alias->getBeginLoc(),
+              Alias->getLocation(), Alias->getIdentifier(), nullptr);
+          Typedef->setModedTypeSourceInfo(Alias->getTypeSourceInfo(),
+                                          Underlying);
+        }
+        Typedef->setPreviousDecl(ET->getDecl());
+        return C.getTypedefType(Typedef, Underlying);
----------------
mizvekov wrote:

Yeah, but the new function type is still the same as the original one, it's just not identical (different sugar).

If that's the case, that's still under contract with getTypedefType.

If that's not the case, I think it would be possible to remove that assert, you just need to investigate and deal with the consequences elsewhere.

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


More information about the cfe-commits mailing list