@@ -8583,28 +8583,12 @@ void ClangImporter::Implementation::importBoundsAttributes(
8583
8583
auto &sourceFile = getClangSwiftAttrSourceFile (
8584
8584
*MappedDecl->getDeclContext ()->getParentModule (), MacroString);
8585
8585
8586
- // Spin up a parser.
8587
- swift::Parser parser (sourceFile.getBufferID (), sourceFile,
8588
- &SwiftContext.Diags , nullptr , nullptr );
8589
- // Prime the lexer.
8590
- parser.consumeTokenWithoutFeedingReceiver ();
8591
-
8592
- bool hadError = false ;
8593
- assert (parser.Tok .is (tok::at_sign));
8594
- SourceLoc atEndLoc = parser.Tok .getRange ().getEnd ();
8595
- SourceLoc atLoc = parser.consumeToken (tok::at_sign);
8596
- DeclContext *DC = MappedDecl->getParent ();
8597
- auto initContext = PatternBindingInitializer::create (DC);
8598
- hadError = parser
8599
- .parseDeclAttribute (MappedDecl->getAttrs (), atLoc, atEndLoc,
8600
- initContext,
8601
- /* isFromClangAttribute=*/ true )
8602
- .isError ();
8603
- if (hadError) {
8604
- HeaderLoc attrLoc (ClangDecl->getLocation ());
8605
- diagnose (attrLoc, diag::clang_pointer_bounds_unhandled,
8606
- MappedDecl->getName (), MacroString);
8607
- return ;
8586
+ // Collect the attributes from the synthesized top-level declaration in
8587
+ // the source file.
8588
+ auto topLevelDecls = sourceFile.getTopLevelDecls ();
8589
+ for (auto decl : topLevelDecls) {
8590
+ for (auto attr : decl->getAttrs ())
8591
+ MappedDecl->getAttrs ().add (attr->clone (SwiftContext));
8608
8592
}
8609
8593
}
8610
8594
0 commit comments