@@ -216,7 +216,7 @@ namespace {
216
216
Bridgeability Bridging;
217
217
const clang::FunctionType *CompletionHandlerType;
218
218
std::optional<unsigned > CompletionHandlerErrorParamIndex;
219
- bool isSafePointer = false ;
219
+ bool isBoundsAnnotated = false ;
220
220
221
221
public:
222
222
SwiftTypeConverter (ClangImporter::Implementation &impl,
@@ -239,7 +239,7 @@ namespace {
239
239
return IR;
240
240
}
241
241
242
- bool hasSafePointer () { return isSafePointer ; }
242
+ bool hasBoundsAnnotation () { return isBoundsAnnotated ; }
243
243
244
244
ImportResult VisitType (const Type*) = delete;
245
245
@@ -415,17 +415,17 @@ namespace {
415
415
416
416
ImportResult VisitCountAttributedType (
417
417
const clang::CountAttributedType *type) {
418
- isSafePointer = true ;
418
+ isBoundsAnnotated = true ;
419
419
return Visit (type->desugar ());
420
420
}
421
421
ImportResult
422
422
VisitBoundsAttributedType (const clang::BoundsAttributedType *type) {
423
- isSafePointer = true ;
423
+ isBoundsAnnotated = true ;
424
424
return Visit (type->desugar ());
425
425
}
426
426
ImportResult
427
427
VisitValueTerminatedType (const clang::ValueTerminatedType *type) {
428
- isSafePointer = true ;
428
+ isBoundsAnnotated = true ;
429
429
return Visit (type->desugar ());
430
430
}
431
431
@@ -480,7 +480,7 @@ namespace {
480
480
pointeeQualType, ImportTypeKind::Value, addImportDiagnostic,
481
481
AllowNSUIntegerAsInt, Bridgeability::None, ImportTypeAttrs (),
482
482
OTK_ImplicitlyUnwrappedOptional, /* resugarNSErrorPointer=*/ true ,
483
- &isSafePointer );
483
+ &isBoundsAnnotated );
484
484
485
485
// If this is imported as a reference type, ignore the innermost pointer.
486
486
// (`T *` becomes `T`, but `T **` becomes `UnsafeMutablePointer<T>`.)
@@ -1710,7 +1710,7 @@ ImportedType ClangImporter::Implementation::importType(
1710
1710
bool allowNSUIntegerAsInt, Bridgeability bridging, ImportTypeAttrs attrs,
1711
1711
OptionalTypeKind optionality, bool resugarNSErrorPointer,
1712
1712
std::optional<unsigned> completionHandlerErrorParamIndex,
1713
- bool *isSafePointer ) {
1713
+ bool *isBoundsAnnotated ) {
1714
1714
if (type.isNull ())
1715
1715
return {Type (), false };
1716
1716
@@ -1772,8 +1772,8 @@ ImportedType ClangImporter::Implementation::importType(
1772
1772
*this , addImportDiagnosticFn, allowNSUIntegerAsInt, bridging,
1773
1773
completionHandlerType, completionHandlerErrorParamIndex);
1774
1774
auto importResult = converter.Visit (type);
1775
- if (isSafePointer )
1776
- *isSafePointer |= converter.hasSafePointer ();
1775
+ if (isBoundsAnnotated )
1776
+ *isBoundsAnnotated |= converter.hasBoundsAnnotation ();
1777
1777
1778
1778
// Now fix up the type based on how we're concretely using it.
1779
1779
auto adjustedType = adjustTypeForConcreteImport (
@@ -1789,11 +1789,12 @@ Type ClangImporter::Implementation::importTypeIgnoreIUO(
1789
1789
llvm::function_ref<void (Diagnostic &&)> addImportDiagnosticFn,
1790
1790
bool allowNSUIntegerAsInt, Bridgeability bridging, ImportTypeAttrs attrs,
1791
1791
OptionalTypeKind optionality, bool resugarNSErrorPointer,
1792
- bool *isSafePointer ) {
1792
+ bool *isBoundsAnnotated ) {
1793
1793
1794
- auto importedType = importType (
1795
- type, importKind, addImportDiagnosticFn, allowNSUIntegerAsInt, bridging,
1796
- attrs, optionality, resugarNSErrorPointer, std::nullopt, isSafePointer);
1794
+ auto importedType =
1795
+ importType (type, importKind, addImportDiagnosticFn, allowNSUIntegerAsInt,
1796
+ bridging, attrs, optionality, resugarNSErrorPointer,
1797
+ std::nullopt, isBoundsAnnotated);
1797
1798
1798
1799
return importedType.getType ();
1799
1800
}
@@ -2178,7 +2179,7 @@ applyImportTypeAttrs(ImportTypeAttrs attrs, Type type,
2178
2179
2179
2180
ImportedType ClangImporter::Implementation::importFunctionReturnType (
2180
2181
DeclContext *dc, const clang::FunctionDecl *clangDecl,
2181
- bool allowNSUIntegerAsInt, bool *isSafePointer ) {
2182
+ bool allowNSUIntegerAsInt, bool *isBoundsAnnotated ) {
2182
2183
2183
2184
// Hardcode handling of certain result types for builtins.
2184
2185
if (auto builtinID = clangDecl->getBuiltinID ()) {
@@ -2293,7 +2294,7 @@ ImportedType ClangImporter::Implementation::importFunctionReturnType(
2293
2294
: ImportTypeKind::Result),
2294
2295
ImportDiagnosticAdder (*this , clangDecl, clangDecl->getLocation ()),
2295
2296
allowNSUIntegerAsInt, Bridgeability::Full, getImportTypeAttrs (clangDecl),
2296
- OptionalityOfReturn, isSafePointer );
2297
+ OptionalityOfReturn, isBoundsAnnotated );
2297
2298
}
2298
2299
2299
2300
static Type
@@ -2328,7 +2329,7 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2328
2329
DeclContext *dc, const clang::FunctionDecl *clangDecl,
2329
2330
ArrayRef<const clang::ParmVarDecl *> params, bool isVariadic,
2330
2331
bool isFromSystemModule, DeclName name, ParameterList *¶meterList,
2331
- ArrayRef<GenericTypeParamDecl *> genericParams, bool *hasSafePointer ) {
2332
+ ArrayRef<GenericTypeParamDecl *> genericParams, bool *hasBoundsAnnotation ) {
2332
2333
2333
2334
bool allowNSUIntegerAsInt =
2334
2335
shouldAllowNSUIntegerAsInt (isFromSystemModule, clangDecl);
@@ -2386,7 +2387,7 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2386
2387
// was supposed to be used (instead of the typedef type).
2387
2388
if (!importedType) {
2388
2389
importedType = importFunctionReturnType (
2389
- dc, clangDecl, allowNSUIntegerAsInt, hasSafePointer );
2390
+ dc, clangDecl, allowNSUIntegerAsInt, hasBoundsAnnotation );
2390
2391
if (!importedType) {
2391
2392
addDiag (Diagnostic (diag::return_type_not_imported));
2392
2393
return {Type (), false };
@@ -2398,7 +2399,7 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2398
2399
ArrayRef<Identifier> argNames = name.getArgumentNames ();
2399
2400
parameterList = importFunctionParameterList (
2400
2401
dc, clangDecl, params, isVariadic, allowNSUIntegerAsInt, argNames,
2401
- genericParams, swiftResultTy, hasSafePointer );
2402
+ genericParams, swiftResultTy, hasBoundsAnnotation );
2402
2403
if (!parameterList)
2403
2404
return {Type (), false };
2404
2405
@@ -2535,7 +2536,7 @@ ClangImporter::Implementation::importParameterType(
2535
2536
}
2536
2537
}
2537
2538
2538
- bool isSafePointer = false ;
2539
+ bool isBoundsAnnotated = false ;
2539
2540
if (!swiftParamTy) {
2540
2541
// If this is the throws error parameter, we don't need to convert any
2541
2542
// NSError** arguments to the sugared NSErrorPointer typealias form,
@@ -2549,7 +2550,7 @@ ClangImporter::Implementation::importParameterType(
2549
2550
paramTy, importKind, addImportDiagnosticFn, allowNSUIntegerAsInt,
2550
2551
Bridgeability::Full, attrs, optionalityOfParam,
2551
2552
/* resugarNSErrorPointer=*/ !paramIsError,
2552
- completionHandlerErrorParamIndex, &isSafePointer );
2553
+ completionHandlerErrorParamIndex, &isBoundsAnnotated );
2553
2554
if (!importedType)
2554
2555
return std::nullopt;
2555
2556
@@ -2567,7 +2568,7 @@ ClangImporter::Implementation::importParameterType(
2567
2568
isInOut = false ;
2568
2569
2569
2570
return ImportParameterTypeResult{
2570
- swiftParamTy, isInOut, isParamTypeImplicitlyUnwrapped, isSafePointer };
2571
+ swiftParamTy, isInOut, isParamTypeImplicitlyUnwrapped, isBoundsAnnotated };
2571
2572
}
2572
2573
2573
2574
bool ClangImporter::Implementation::isDefaultArgSafeToImport (
@@ -2679,7 +2680,7 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2679
2680
ArrayRef<const clang::ParmVarDecl *> params, bool isVariadic,
2680
2681
bool allowNSUIntegerAsInt, ArrayRef<Identifier> argNames,
2681
2682
ArrayRef<GenericTypeParamDecl *> genericParams, Type resultType,
2682
- bool *hasSafePointerParam ) {
2683
+ bool *hasBoundsAnnotatedParam ) {
2683
2684
// Import the parameters.
2684
2685
SmallVector<ParamDecl *, 4 > parameters;
2685
2686
unsigned index = 0 ;
@@ -2719,8 +2720,8 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2719
2720
bool isInOut = swiftParamTyOpt->isInOut ;
2720
2721
bool isParamTypeImplicitlyUnwrapped =
2721
2722
swiftParamTyOpt->isParamTypeImplicitlyUnwrapped ;
2722
- if (swiftParamTyOpt->isSafePointer && hasSafePointerParam )
2723
- *hasSafePointerParam = true ;
2723
+ if (swiftParamTyOpt->isBoundsAnnotated && hasBoundsAnnotatedParam )
2724
+ *hasBoundsAnnotatedParam = true ;
2724
2725
2725
2726
// Retrieve the argument name.
2726
2727
Identifier name;
0 commit comments