@@ -223,7 +223,7 @@ namespace {
223
223
Bridgeability Bridging;
224
224
const clang::FunctionType *CompletionHandlerType;
225
225
std::optional<unsigned > CompletionHandlerErrorParamIndex;
226
- bool isSafePointer = false ;
226
+ bool isBoundsAnnotated = false ;
227
227
228
228
public:
229
229
SwiftTypeConverter (ClangImporter::Implementation &impl,
@@ -246,7 +246,7 @@ namespace {
246
246
return IR;
247
247
}
248
248
249
- bool hasSafePointer () { return isSafePointer ; }
249
+ bool hasBoundsAnnotation () { return isBoundsAnnotated ; }
250
250
251
251
ImportResult VisitType (const Type*) = delete;
252
252
@@ -422,7 +422,7 @@ namespace {
422
422
423
423
ImportResult VisitCountAttributedType (
424
424
const clang::CountAttributedType *type) {
425
- isSafePointer = true ;
425
+ isBoundsAnnotated = true ;
426
426
return Visit (type->desugar ());
427
427
}
428
428
@@ -493,7 +493,7 @@ namespace {
493
493
pointeeQualType, ImportTypeKind::Value, addImportDiagnostic,
494
494
AllowNSUIntegerAsInt, Bridgeability::None, ImportTypeAttrs (),
495
495
OTK_ImplicitlyUnwrappedOptional, /* resugarNSErrorPointer=*/ true ,
496
- &isSafePointer );
496
+ &isBoundsAnnotated );
497
497
498
498
// If this is imported as a reference type, ignore the innermost pointer.
499
499
// (`T *` becomes `T`, but `T **` becomes `UnsafeMutablePointer<T>`.)
@@ -1723,7 +1723,7 @@ ImportedType ClangImporter::Implementation::importType(
1723
1723
bool allowNSUIntegerAsInt, Bridgeability bridging, ImportTypeAttrs attrs,
1724
1724
OptionalTypeKind optionality, bool resugarNSErrorPointer,
1725
1725
std::optional<unsigned> completionHandlerErrorParamIndex,
1726
- bool *isSafePointer ) {
1726
+ bool *isBoundsAnnotated ) {
1727
1727
if (type.isNull ())
1728
1728
return {Type (), false };
1729
1729
@@ -1785,8 +1785,8 @@ ImportedType ClangImporter::Implementation::importType(
1785
1785
*this , addImportDiagnosticFn, allowNSUIntegerAsInt, bridging,
1786
1786
completionHandlerType, completionHandlerErrorParamIndex);
1787
1787
auto importResult = converter.Visit (type);
1788
- if (isSafePointer )
1789
- *isSafePointer |= converter.hasSafePointer ();
1788
+ if (isBoundsAnnotated )
1789
+ *isBoundsAnnotated |= converter.hasBoundsAnnotation ();
1790
1790
1791
1791
// Now fix up the type based on how we're concretely using it.
1792
1792
auto adjustedType = adjustTypeForConcreteImport (
@@ -1802,11 +1802,12 @@ Type ClangImporter::Implementation::importTypeIgnoreIUO(
1802
1802
llvm::function_ref<void (Diagnostic &&)> addImportDiagnosticFn,
1803
1803
bool allowNSUIntegerAsInt, Bridgeability bridging, ImportTypeAttrs attrs,
1804
1804
OptionalTypeKind optionality, bool resugarNSErrorPointer,
1805
- bool *isSafePointer ) {
1805
+ bool *isBoundsAnnotated ) {
1806
1806
1807
- auto importedType = importType (
1808
- type, importKind, addImportDiagnosticFn, allowNSUIntegerAsInt, bridging,
1809
- attrs, optionality, resugarNSErrorPointer, std::nullopt, isSafePointer);
1807
+ auto importedType =
1808
+ importType (type, importKind, addImportDiagnosticFn, allowNSUIntegerAsInt,
1809
+ bridging, attrs, optionality, resugarNSErrorPointer,
1810
+ std::nullopt, isBoundsAnnotated);
1810
1811
1811
1812
return importedType.getType ();
1812
1813
}
@@ -2191,7 +2192,7 @@ applyImportTypeAttrs(ImportTypeAttrs attrs, Type type,
2191
2192
2192
2193
ImportedType ClangImporter::Implementation::importFunctionReturnType (
2193
2194
DeclContext *dc, const clang::FunctionDecl *clangDecl,
2194
- bool allowNSUIntegerAsInt, bool *isSafePointer ) {
2195
+ bool allowNSUIntegerAsInt, bool *isBoundsAnnotated ) {
2195
2196
2196
2197
// Hardcode handling of certain result types for builtins.
2197
2198
if (auto builtinID = clangDecl->getBuiltinID ()) {
@@ -2306,7 +2307,7 @@ ImportedType ClangImporter::Implementation::importFunctionReturnType(
2306
2307
: ImportTypeKind::Result),
2307
2308
ImportDiagnosticAdder (*this , clangDecl, clangDecl->getLocation ()),
2308
2309
allowNSUIntegerAsInt, Bridgeability::Full, getImportTypeAttrs (clangDecl),
2309
- OptionalityOfReturn, isSafePointer );
2310
+ OptionalityOfReturn, isBoundsAnnotated );
2310
2311
}
2311
2312
2312
2313
static Type
@@ -2341,7 +2342,7 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2341
2342
DeclContext *dc, const clang::FunctionDecl *clangDecl,
2342
2343
ArrayRef<const clang::ParmVarDecl *> params, bool isVariadic,
2343
2344
bool isFromSystemModule, DeclName name, ParameterList *¶meterList,
2344
- ArrayRef<GenericTypeParamDecl *> genericParams, bool *hasSafePointer ) {
2345
+ ArrayRef<GenericTypeParamDecl *> genericParams, bool *hasBoundsAnnotation ) {
2345
2346
2346
2347
bool allowNSUIntegerAsInt =
2347
2348
shouldAllowNSUIntegerAsInt (isFromSystemModule, clangDecl);
@@ -2399,7 +2400,7 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2399
2400
// was supposed to be used (instead of the typedef type).
2400
2401
if (!importedType) {
2401
2402
importedType = importFunctionReturnType (
2402
- dc, clangDecl, allowNSUIntegerAsInt, hasSafePointer );
2403
+ dc, clangDecl, allowNSUIntegerAsInt, hasBoundsAnnotation );
2403
2404
if (!importedType) {
2404
2405
addDiag (Diagnostic (diag::return_type_not_imported));
2405
2406
return {Type (), false };
@@ -2411,7 +2412,7 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2411
2412
ArrayRef<Identifier> argNames = name.getArgumentNames ();
2412
2413
parameterList = importFunctionParameterList (
2413
2414
dc, clangDecl, params, isVariadic, allowNSUIntegerAsInt, argNames,
2414
- genericParams, swiftResultTy, hasSafePointer );
2415
+ genericParams, swiftResultTy, hasBoundsAnnotation );
2415
2416
if (!parameterList)
2416
2417
return {Type (), false };
2417
2418
@@ -2548,7 +2549,7 @@ ClangImporter::Implementation::importParameterType(
2548
2549
}
2549
2550
}
2550
2551
2551
- bool isSafePointer = false ;
2552
+ bool isBoundsAnnotated = false ;
2552
2553
if (!swiftParamTy) {
2553
2554
// If this is the throws error parameter, we don't need to convert any
2554
2555
// NSError** arguments to the sugared NSErrorPointer typealias form,
@@ -2562,7 +2563,7 @@ ClangImporter::Implementation::importParameterType(
2562
2563
paramTy, importKind, addImportDiagnosticFn, allowNSUIntegerAsInt,
2563
2564
Bridgeability::Full, attrs, optionalityOfParam,
2564
2565
/* resugarNSErrorPointer=*/ !paramIsError,
2565
- completionHandlerErrorParamIndex, &isSafePointer );
2566
+ completionHandlerErrorParamIndex, &isBoundsAnnotated );
2566
2567
if (!importedType)
2567
2568
return std::nullopt;
2568
2569
@@ -2580,7 +2581,7 @@ ClangImporter::Implementation::importParameterType(
2580
2581
isInOut = false ;
2581
2582
2582
2583
return ImportParameterTypeResult{swiftParamTy, isInOut, isConsuming,
2583
- isParamTypeImplicitlyUnwrapped, isSafePointer };
2584
+ isParamTypeImplicitlyUnwrapped, isBoundsAnnotated };
2584
2585
}
2585
2586
2586
2587
bool ClangImporter::Implementation::isDefaultArgSafeToImport (
@@ -2694,7 +2695,7 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2694
2695
ArrayRef<const clang::ParmVarDecl *> params, bool isVariadic,
2695
2696
bool allowNSUIntegerAsInt, ArrayRef<Identifier> argNames,
2696
2697
ArrayRef<GenericTypeParamDecl *> genericParams, Type resultType,
2697
- bool *hasSafePointerParam ) {
2698
+ bool *hasBoundsAnnotatedParam ) {
2698
2699
// Import the parameters.
2699
2700
SmallVector<ParamDecl *, 4 > parameters;
2700
2701
unsigned index = 0 ;
@@ -2735,8 +2736,8 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2735
2736
bool isConsuming = swiftParamTyOpt->isConsuming ;
2736
2737
bool isParamTypeImplicitlyUnwrapped =
2737
2738
swiftParamTyOpt->isParamTypeImplicitlyUnwrapped ;
2738
- if (swiftParamTyOpt->isSafePointer && hasSafePointerParam )
2739
- *hasSafePointerParam = true ;
2739
+ if (swiftParamTyOpt->isBoundsAnnotated && hasBoundsAnnotatedParam )
2740
+ *hasBoundsAnnotatedParam = true ;
2740
2741
2741
2742
// Retrieve the argument name.
2742
2743
Identifier name;
0 commit comments