@@ -8273,7 +8273,6 @@ ClangImporter::Implementation::importSwiftAttrAttributes(Decl *MappedDecl) {
8273
8273
8274
8274
std::optional<const clang::SwiftAttrAttr *> seenMainActorAttr;
8275
8275
const clang::SwiftAttrAttr *seenMutabilityAttr = nullptr ;
8276
- PatternBindingInitializer *initContext = nullptr ;
8277
8276
8278
8277
auto importAttrsFromDecl = [&](const clang::NamedDecl *ClangDecl) {
8279
8278
//
@@ -8401,36 +8400,11 @@ ClangImporter::Implementation::importSwiftAttrAttributes(Decl *MappedDecl) {
8401
8400
auto &sourceFile = getClangSwiftAttrSourceFile (
8402
8401
*MappedDecl->getDeclContext ()->getParentModule (), bufferID);
8403
8402
8404
- // Spin up a parser.
8405
- swift::Parser parser (
8406
- bufferID, sourceFile, &SwiftContext.Diags , nullptr , nullptr );
8407
- // Prime the lexer.
8408
- parser.consumeTokenWithoutFeedingReceiver ();
8409
-
8410
- bool hadError = false ;
8411
- if (parser.Tok .is (tok::at_sign)) {
8412
- SourceLoc atEndLoc = parser.Tok .getRange ().getEnd ();
8413
- SourceLoc atLoc = parser.consumeToken (tok::at_sign);
8414
- hadError = parser
8415
- .parseDeclAttribute (MappedDecl->getAttrs (), atLoc,
8416
- atEndLoc, initContext,
8417
- /* isFromClangAttribute=*/ true )
8418
- .isError ();
8419
- } else {
8420
- SourceLoc staticLoc;
8421
- StaticSpellingKind staticSpelling;
8422
- hadError = parser
8423
- .parseDeclModifierList (MappedDecl->getAttrs (), staticLoc,
8424
- staticSpelling,
8425
- /* isFromClangAttribute=*/ true )
8426
- .isError ();
8427
- }
8428
-
8429
- if (hadError) {
8430
- // Complain about the unhandled attribute or modifier.
8431
- HeaderLoc attrLoc (swiftAttr->getLocation ());
8432
- diagnose (attrLoc, diag::clang_swift_attr_unhandled,
8433
- swiftAttr->getAttribute ());
8403
+ // Collect the attributes from the synthesized top-level declaration in
8404
+ // the source file.
8405
+ auto topLevelDecls = sourceFile.getTopLevelDecls ();
8406
+ for (auto decl : topLevelDecls) {
8407
+ MappedDecl->getAttrs ().add (decl->getAttrs ());
8434
8408
}
8435
8409
}
8436
8410
0 commit comments