================ @@ -9860,6 +9860,33 @@ void ASTReader::finishPendingActions() { } PendingDeducedVarTypes.clear(); + ASTContext &Context = getContext(); + for (unsigned I = 0; I != PendingPreferredNameAttributes.size(); ++I) { + auto *D = PendingPreferredNameAttributes[I].D; + QualType InfoTy = GetType(PendingPreferredNameAttributes[I].TypeID); + TypeSourceInfo *TInfo = nullptr; + if (!InfoTy.isNull()) { + TInfo = getContext().CreateTypeSourceInfo(InfoTy); + if (auto Loc = TInfo->getTypeLoc().getAs<ElaboratedTypeLoc>()) { + Loc.setElaboratedKeywordLoc( + PendingPreferredNameAttributes[I].ElaboratedTypedefSL); + Loc.setQualifierLoc(PendingPreferredNameAttributes[I].NestedNameSL); + if (auto TypedefLoc = Loc.getNextTypeLoc().getAs<TypedefTypeLoc>()) + TypedefLoc.setNameLoc(PendingPreferredNameAttributes[I].TypedefSL); + } + } + + AttrVec &Attrs = getContext().getDeclAttrs(D); + PreferredNameAttr *New = new (Context) PreferredNameAttr( + Context, PendingPreferredNameAttributes[I].Info, TInfo); + cast<InheritableAttr>(New)->setInherited( + PendingPreferredNameAttributes[I].isInherited); + New->setImplicit(PendingPreferredNameAttributes[I].isImplicit); ---------------- ilya-biryukov wrote:
Duplicating the code here may lead to errors later. Could we ensure that's the only code path that's being used to read preferred_name attributes? That would entail asserting that the common `readAttr` asserts the attribute is **not** PreferredName and I'd also suggest adding a documentation comment in `Attr.td` that PreferredName has a custom deserialization logic pointing to that function. https://github.com/llvm/llvm-project/pull/122250 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits