vabridgers created this revision. vabridgers added a reviewer: martong. Herald added subscribers: cfe-commits, teemperor, rnkovacs. Herald added a reviewer: a.sidorin. Herald added a project: clang.
We found a case where Typedef Name Declarations were not being added correctly when importing builtin types. This exposed the need for a TypedefNameDecl visitor so these types can be added by RecordDecl and fields. This code is covered by the ASTImporterTest cases that use the implicit struct __NSConstantString_tag definitions. Thanks to @martong for the debugging assist! Depends on D83970 <https://reviews.llvm.org/D83970>. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83992 Files: clang/lib/AST/ASTImporterLookupTable.cpp Index: clang/lib/AST/ASTImporterLookupTable.cpp =================================================================== --- clang/lib/AST/ASTImporterLookupTable.cpp +++ clang/lib/AST/ASTImporterLookupTable.cpp @@ -22,6 +22,20 @@ struct Builder : RecursiveASTVisitor<Builder> { ASTImporterLookupTable < Builder(ASTImporterLookupTable <) : LT(LT) {} + + bool VisitTypedefNameDecl(TypedefNameDecl *D) { + QualType Ty = D->getUnderlyingType(); + Ty = Ty.getCanonicalType(); + if (const auto *RTy = dyn_cast<RecordType>(Ty)) { + LT.add(RTy->getAsRecordDecl()); + // iterate over the field decls, adding them + for (auto it : RTy->getAsRecordDecl()->fields()) { + LT.add(it); + } + } + return true; + } + bool VisitNamedDecl(NamedDecl *D) { LT.add(D); return true;
Index: clang/lib/AST/ASTImporterLookupTable.cpp =================================================================== --- clang/lib/AST/ASTImporterLookupTable.cpp +++ clang/lib/AST/ASTImporterLookupTable.cpp @@ -22,6 +22,20 @@ struct Builder : RecursiveASTVisitor<Builder> { ASTImporterLookupTable < Builder(ASTImporterLookupTable <) : LT(LT) {} + + bool VisitTypedefNameDecl(TypedefNameDecl *D) { + QualType Ty = D->getUnderlyingType(); + Ty = Ty.getCanonicalType(); + if (const auto *RTy = dyn_cast<RecordType>(Ty)) { + LT.add(RTy->getAsRecordDecl()); + // iterate over the field decls, adding them + for (auto it : RTy->getAsRecordDecl()->fields()) { + LT.add(it); + } + } + return true; + } + bool VisitNamedDecl(NamedDecl *D) { LT.add(D); return true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits