@@ -5213,9 +5213,10 @@ ClangTypeEscapability::evaluate(Evaluator &evaluator,
5213
5213
} else
5214
5214
nonPackArgs.push_back (arg);
5215
5215
for (auto nonPackArg : nonPackArgs) {
5216
- if (nonPackArg.getKind () != clang::TemplateArgument::Type) {
5217
- desc.impl .diagnose (loc, diag::type_template_parameter_expected,
5218
- argToCheck.second );
5216
+ if (nonPackArg.getKind () != clang::TemplateArgument::Type &&
5217
+ desc.impl ) {
5218
+ desc.impl ->diagnose (loc, diag::type_template_parameter_expected,
5219
+ argToCheck.second );
5219
5220
return CxxEscapability::Unknown;
5220
5221
}
5221
5222
@@ -5236,8 +5237,9 @@ ClangTypeEscapability::evaluate(Evaluator &evaluator,
5236
5237
}
5237
5238
}
5238
5239
5239
- for (auto name : conditionalParams)
5240
- desc.impl .diagnose (loc, diag::unknown_template_parameter, name);
5240
+ if (desc.impl )
5241
+ for (auto name : conditionalParams)
5242
+ desc.impl ->diagnose (loc, diag::unknown_template_parameter, name);
5241
5243
5242
5244
return hadUnknown ? CxxEscapability::Unknown : CxxEscapability::Escapable;
5243
5245
}
@@ -8216,9 +8218,7 @@ CustomRefCountingOperationResult CustomRefCountingOperation::evaluate(
8216
8218
}
8217
8219
8218
8220
// / Check whether the given Clang type involves an unsafe type.
8219
- static bool hasUnsafeType (
8220
- Evaluator &evaluator, ASTContext &swiftContext, clang::QualType clangType
8221
- ) {
8221
+ static bool hasUnsafeType (Evaluator &evaluator, clang::QualType clangType) {
8222
8222
// Handle pointers.
8223
8223
auto pointeeType = clangType->getPointeeType ();
8224
8224
if (!pointeeType.isNull ()) {
@@ -8239,10 +8239,9 @@ static bool hasUnsafeType(
8239
8239
8240
8240
// Handle records recursively.
8241
8241
if (auto recordDecl = clangType->getAsTagDecl ()) {
8242
- auto safety = evaluateOrDefault (
8243
- evaluator,
8244
- ClangDeclExplicitSafety ({recordDecl, swiftContext}),
8245
- ExplicitSafety::Unspecified);
8242
+ auto safety =
8243
+ evaluateOrDefault (evaluator, ClangDeclExplicitSafety ({recordDecl}),
8244
+ ExplicitSafety::Unspecified);
8246
8245
switch (safety) {
8247
8246
case ExplicitSafety::Unsafe:
8248
8247
return true ;
@@ -8285,7 +8284,10 @@ ExplicitSafety ClangDeclExplicitSafety::evaluate(
8285
8284
8286
8285
// Escapable and non-escapable annotations imply that the declaration is
8287
8286
// safe.
8288
- if (hasNonEscapableAttr (recordDecl) || hasEscapableAttr (recordDecl))
8287
+ if (evaluateOrDefault (
8288
+ evaluator,
8289
+ ClangTypeEscapability ({recordDecl->getTypeForDecl (), nullptr }),
8290
+ CxxEscapability::Unknown) != CxxEscapability::Unknown)
8289
8291
return ExplicitSafety::Safe;
8290
8292
8291
8293
// If we don't have a definition, leave it unspecified.
@@ -8296,14 +8298,14 @@ ExplicitSafety ClangDeclExplicitSafety::evaluate(
8296
8298
// If this is a C++ class, check its bases.
8297
8299
if (auto cxxRecordDecl = dyn_cast<clang::CXXRecordDecl>(recordDecl)) {
8298
8300
for (auto base : cxxRecordDecl->bases ()) {
8299
- if (hasUnsafeType (evaluator, desc. ctx , base.getType ()))
8301
+ if (hasUnsafeType (evaluator, base.getType ()))
8300
8302
return ExplicitSafety::Unsafe;
8301
8303
}
8302
8304
}
8303
8305
8304
8306
// Check the fields.
8305
8307
for (auto field : recordDecl->fields ()) {
8306
- if (hasUnsafeType (evaluator, desc. ctx , field->getType ()))
8308
+ if (hasUnsafeType (evaluator, field->getType ()))
8307
8309
return ExplicitSafety::Unsafe;
8308
8310
}
8309
8311
0 commit comments