@@ -6565,6 +6565,7 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
65656565 auto namedMember = dyn_cast<ValueDecl>(member);
65666566 if (!namedMember || !namedMember->hasName () ||
65676567 namedMember->getName ().getBaseName () != name ||
6568+ clangModuleLoader->isMemberSynthesizedPerType (namedMember) ||
65686569 clangModuleLoader->getOriginalForClonedMember (namedMember))
65696570 continue ;
65706571
@@ -8033,6 +8034,16 @@ ValueDecl *ClangImporter::Implementation::getOriginalForClonedMember(
80338034 return nullptr ;
80348035}
80358036
8037+ bool ClangImporter::Implementation::isMemberSynthesizedPerType (
8038+ const ValueDecl *decl) {
8039+ return membersSynthesizedPerType.contains (decl);
8040+ }
8041+
8042+ void ClangImporter::Implementation::markMemberSynthesizedPerType (
8043+ const ValueDecl *decl) {
8044+ membersSynthesizedPerType.insert (decl);
8045+ }
8046+
80368047size_t ClangImporter::Implementation::getImportedBaseMemberDeclArity (
80378048 const ValueDecl *valueDecl) {
80388049 if (auto *func = dyn_cast<FuncDecl>(valueDecl)) {
@@ -8053,6 +8064,10 @@ ValueDecl *ClangImporter::getOriginalForClonedMember(const ValueDecl *decl) {
80538064 return Impl.getOriginalForClonedMember (decl);
80548065}
80558066
8067+ bool ClangImporter::isMemberSynthesizedPerType (const ValueDecl *decl) {
8068+ return Impl.isMemberSynthesizedPerType (decl);
8069+ }
8070+
80568071void ClangImporter::diagnoseTopLevelValue (const DeclName &name) {
80578072 Impl.diagnoseTopLevelValue (name);
80588073}
@@ -8206,12 +8221,15 @@ importer::getValueDeclsForName(NominalTypeDecl *decl, StringRef name) {
82068221 auto clangDecl = decl->getClangDecl ();
82078222 llvm::SmallVector<ValueDecl *, 1 > results;
82088223
8209- if (name.starts_with (" ." )) {
8224+ if (name.consume_front (" ." )) {
82108225 // Look for a member of decl instead of a global.
8211- StringRef memberName = name.drop_front (1 );
8212- if (memberName.empty ())
8226+ if (name.empty ())
82138227 return {};
8214- auto declName = DeclName (ctx.getIdentifier (memberName));
8228+ auto declName = DeclName (ctx.getIdentifier (name));
8229+ auto swiftLookupResults = decl->lookupDirect (declName);
8230+ if (!swiftLookupResults.empty ())
8231+ return SmallVector<ValueDecl *, 1 >(swiftLookupResults.begin (),
8232+ swiftLookupResults.end ());
82158233 auto allResults = evaluateOrDefault (
82168234 ctx.evaluator , ClangRecordMemberLookup ({decl, declName}), {});
82178235 return SmallVector<ValueDecl *, 1 >(allResults.begin (), allResults.end ());
@@ -8242,9 +8260,9 @@ importer::getValueDeclsForName(NominalTypeDecl *decl, StringRef name) {
82428260 return results;
82438261}
82448262
8245- static const clang::RecordDecl *
8246- getRefParentOrDiag (const clang::RecordDecl *decl, ASTContext &ctx,
8247- ClangImporter::Implementation *importerImpl) {
8263+ const clang::RecordDecl *
8264+ importer:: getRefParentOrDiag (const clang::RecordDecl *decl, ASTContext &ctx,
8265+ ClangImporter::Implementation *importerImpl) {
82488266 auto refParentDecls = getRefParentDecls (decl, ctx, importerImpl);
82498267 if (refParentDecls.empty ())
82508268 return nullptr ;
@@ -8257,11 +8275,11 @@ getRefParentOrDiag(const clang::RecordDecl *decl, ASTContext &ctx,
82578275 assert (refParentDecl && " refParentDecl is null inside getRefParentOrDiag" );
82588276 for (const auto *attr : refParentDecl->getAttrs ()) {
82598277 if (const auto swiftAttr = llvm::dyn_cast<clang::SwiftAttrAttr>(attr)) {
8260- const auto & attribute = swiftAttr->getAttribute ();
8261- if (attribute.starts_with (retainPrefix))
8262- uniqueRetainDecls.insert (attribute. drop_front (retainPrefix. size ()) );
8263- else if (attribute.starts_with (releasePrefix))
8264- uniqueReleaseDecls.insert (attribute. drop_front (releasePrefix. size ()) );
8278+ auto attribute = swiftAttr->getAttribute ();
8279+ if (attribute.consume_front (retainPrefix))
8280+ uniqueRetainDecls.insert (attribute);
8281+ else if (attribute.consume_front (releasePrefix))
8282+ uniqueReleaseDecls.insert (attribute);
82658283 }
82668284 }
82678285 }
@@ -8811,19 +8829,12 @@ CustomRefCountingOperationResult CustomRefCountingOperation::evaluate(
88118829 Evaluator &evaluator, CustomRefCountingOperationDescriptor desc) const {
88128830 auto swiftDecl = desc.decl ;
88138831 auto operation = desc.kind ;
8814- auto &ctx = swiftDecl->getASTContext ();
88158832
8816- std::string operationStr = operation == CustomRefCountingOperationKind::retain
8817- ? " retain:"
8818- : " release:" ;
8833+ StringRef operationStr = operation == CustomRefCountingOperationKind::retain
8834+ ? " retain:"
8835+ : " release:" ;
88198836
88208837 auto decl = cast<clang::RecordDecl>(swiftDecl->getClangDecl ());
8821-
8822- if (!hasImportAsRefAttr (decl)) {
8823- if (auto parentRefDecl = getRefParentOrDiag (decl, ctx, nullptr ))
8824- decl = parentRefDecl;
8825- }
8826-
88278838 if (!decl->hasAttrs ())
88288839 return {CustomRefCountingOperationResult::noAttribute, nullptr , " " };
88298840
@@ -8842,10 +8853,8 @@ CustomRefCountingOperationResult CustomRefCountingOperation::evaluate(
88428853 if (retainReleaseAttrs.size () > 1 )
88438854 return {CustomRefCountingOperationResult::tooManyAttributes, nullptr , " " };
88448855
8845- auto name = retainReleaseAttrs.front ()
8846- ->getAttribute ()
8847- .drop_front (StringRef (operationStr).size ())
8848- .str ();
8856+ auto name = retainReleaseAttrs.front ()->getAttribute ().drop_front (
8857+ operationStr.size ());
88498858
88508859 if (name == " immortal" )
88518860 return {CustomRefCountingOperationResult::immortal, nullptr , name};
0 commit comments