@@ -8820,6 +8820,8 @@ ClangImporter::Implementation::importSwiftAttrAttributes(Decl *MappedDecl) {
8820
8820
namespace {
8821
8821
class SwiftifyInfoPrinter {
8822
8822
public:
8823
+ static const ssize_t SELF_PARAM_INDEX = -2 ;
8824
+ static const ssize_t RETURN_VALUE_INDEX = -1 ;
8823
8825
clang::ASTContext &ctx;
8824
8826
llvm::raw_ostream &out;
8825
8827
bool firstParam = true ;
@@ -8891,9 +8893,9 @@ class SwiftifyInfoPrinter {
8891
8893
}
8892
8894
8893
8895
void printParamOrReturn (ssize_t pointerIndex) {
8894
- if (pointerIndex == - 2 )
8896
+ if (pointerIndex == SELF_PARAM_INDEX )
8895
8897
out << " .self" ;
8896
- else if (pointerIndex == - 1 )
8898
+ else if (pointerIndex == RETURN_VALUE_INDEX )
8897
8899
out << " .return" ;
8898
8900
else
8899
8901
out << " .param(" << pointerIndex + 1 << " )" ;
@@ -8935,16 +8937,17 @@ void ClangImporter::Implementation::swiftify(FuncDecl *MappedDecl) {
8935
8937
MappedDecl->getResultInterfaceType (), ClangDecl->getReturnType ());
8936
8938
if (auto CAT =
8937
8939
ClangDecl->getReturnType ()->getAs <clang::CountAttributedType>()) {
8938
- printer.printCountedBy (CAT, - 1 );
8940
+ printer.printCountedBy (CAT, SwiftifyInfoPrinter::RETURN_VALUE_INDEX );
8939
8941
attachMacro = true ;
8940
8942
}
8941
8943
bool returnHasLifetimeInfo = false ;
8942
- bool lifetimeDependenceOn = MappedDecl-> getASTContext (). LangOpts . hasFeature (
8943
- Feature::LifetimeDependence);
8944
+ bool lifetimeDependenceOn =
8945
+ SwiftContext. LangOpts . hasFeature ( Feature::LifetimeDependence);
8944
8946
if (SwiftDeclConverter::getImplicitObjectParamAnnotation<
8945
8947
clang::LifetimeBoundAttr>(ClangDecl) &&
8946
8948
lifetimeDependenceOn) {
8947
- printer.printLifetimeboundReturn (-2 , true );
8949
+ printer.printLifetimeboundReturn (SwiftifyInfoPrinter::SELF_PARAM_INDEX,
8950
+ true );
8948
8951
returnHasLifetimeInfo = true ;
8949
8952
}
8950
8953
for (auto [index, clangParam] : llvm::enumerate (ClangDecl->parameters ())) {
0 commit comments