@@ -9516,9 +9516,10 @@ static StringRef getAttributeName(const clang::CountAttributedType *CAT) {
95169516 }
95179517}
95189518
9519- bool ClangImporter::Implementation::swiftifyImpl (
9520- SwiftifyInfoPrinter &printer, const AbstractFunctionDecl *MappedDecl,
9521- const clang::FunctionDecl *ClangDecl) {
9519+ static bool swiftifyImpl (ClangImporter::Implementation &Self,
9520+ SwiftifyInfoPrinter &printer,
9521+ const AbstractFunctionDecl *MappedDecl,
9522+ const clang::FunctionDecl *ClangDecl) {
95229523 SIW_DBG (" Checking " << *ClangDecl << " for bounds and lifetime info\n " );
95239524
95249525 // FIXME: for private macro generated functions we do not serialize the
@@ -9534,6 +9535,8 @@ bool ClangImporter::Implementation::swiftifyImpl(
95349535 return false ;
95359536 }
95369537
9538+ clang::ASTContext &clangASTContext = Self.getClangASTContext ();
9539+
95379540 // We only attach the macro if it will produce an overload. Any __counted_by
95389541 // will produce an overload, since UnsafeBufferPointer is still an improvement
95399542 // over UnsafePointer, but std::span will only produce an overload if it also
@@ -9550,7 +9553,7 @@ bool ClangImporter::Implementation::swiftifyImpl(
95509553 bool returnIsStdSpan = printer.registerStdSpanTypeMapping (
95519554 swiftReturnTy, ClangDecl->getReturnType ());
95529555 auto *CAT = ClangDecl->getReturnType ()->getAs <clang::CountAttributedType>();
9553- if (SwiftifiableCAT (getClangASTContext () , CAT, swiftReturnTy)) {
9556+ if (SwiftifiableCAT (clangASTContext , CAT, swiftReturnTy)) {
95549557 printer.printCountedBy (CAT, SwiftifyInfoPrinter::RETURN_VALUE_INDEX);
95559558 SIW_DBG (" Found bounds info '" << clang::QualType (CAT, 0 ) << " ' on return value\n " );
95569559 attachMacro = true ;
@@ -9598,14 +9601,15 @@ bool ClangImporter::Implementation::swiftifyImpl(
95989601 bool paramHasBoundsInfo = false ;
95999602 auto *CAT = clangParamTy->getAs <clang::CountAttributedType>();
96009603 if (CAT && mappedIndex == SwiftifyInfoPrinter::SELF_PARAM_INDEX) {
9601- diagnose (HeaderLoc (clangParam->getLocation ()),
9602- diag::warn_clang_ignored_bounds_on_self, getAttributeName (CAT));
9604+ Self.diagnose (HeaderLoc (clangParam->getLocation ()),
9605+ diag::warn_clang_ignored_bounds_on_self,
9606+ getAttributeName (CAT));
96039607 auto swiftName = ClangDecl->getAttr <clang::SwiftNameAttr>();
96049608 ASSERT (swiftName &&
96059609 " free function mapped to instance method without swift_name??" );
9606- diagnose (HeaderLoc (swiftName->getLocation ()),
9607- diag::note_swift_name_instance_method);
9608- } else if (SwiftifiableCAT (getClangASTContext () , CAT, swiftParamTy)) {
9610+ Self. diagnose (HeaderLoc (swiftName->getLocation ()),
9611+ diag::note_swift_name_instance_method);
9612+ } else if (SwiftifiableCAT (clangASTContext , CAT, swiftParamTy)) {
96099613 printer.printCountedBy (CAT, mappedIndex);
96109614 SIW_DBG (" Found bounds info '" << clangParamTy
96119615 << " ' on parameter '" << *clangParam << " '\n " );
@@ -9668,7 +9672,7 @@ void ClangImporter::Implementation::swiftify(AbstractFunctionDecl *MappedDecl) {
96689672 out << " @_SwiftifyImport" ;
96699673
96709674 SwiftifyInfoPrinter printer (getClangASTContext (), SwiftContext, out, *SwiftifyImportDecl);
9671- if (!swiftifyImpl (printer, MappedDecl, ClangDecl))
9675+ if (!swiftifyImpl (* this , printer, MappedDecl, ClangDecl))
96729676 return ;
96739677 printer.printAvailability ();
96749678 printer.printTypeMapping ();
0 commit comments