@@ -8237,17 +8237,15 @@ static bool hasCopyTypeOperations(const clang::CXXRecordDecl *decl) {
8237
8237
}
8238
8238
8239
8239
static bool hasMoveTypeOperations (const clang::CXXRecordDecl *decl) {
8240
- if (llvm::any_of (decl->ctors (), [](clang::CXXConstructorDecl *ctor) {
8241
- return ctor->isMoveConstructor () &&
8242
- (ctor->isDeleted () || ctor->isIneligibleOrNotSelected () ||
8243
- ctor->getAccess () != clang::AS_public);
8244
- }))
8245
- return false ;
8240
+ if (decl->hasSimpleMoveConstructor ())
8241
+ return true ;
8246
8242
8247
8243
return llvm::any_of (decl->ctors (), [](clang::CXXConstructorDecl *ctor) {
8248
- return ctor->isMoveConstructor () &&
8244
+ return ctor->isMoveConstructor () && !ctor->isDeleted () &&
8245
+ !ctor->isIneligibleOrNotSelected () &&
8249
8246
// FIXME: Support default arguments (rdar://142414553)
8250
- ctor->getNumParams () == 1 ;
8247
+ ctor->getNumParams () == 1 &&
8248
+ ctor->getAccess () == clang::AS_public;
8251
8249
});
8252
8250
}
8253
8251
@@ -8379,46 +8377,48 @@ CxxValueSemantics::evaluate(Evaluator &evaluator,
8379
8377
return CxxValueSemanticsKind::Copyable;
8380
8378
}
8381
8379
8382
- auto injectedStlAnnotation =
8383
- recordDecl->isInStdNamespace ()
8384
- ? STLConditionalParams.find (recordDecl->getName ())
8385
- : STLConditionalParams.end ();
8386
- auto STLParams = injectedStlAnnotation != STLConditionalParams.end ()
8387
- ? injectedStlAnnotation->second
8388
- : std::vector<int >();
8389
- auto conditionalParams = getConditionalCopyableAttrParams (recordDecl);
8390
-
8391
- if (!STLParams.empty () || !conditionalParams.empty ()) {
8392
- HeaderLoc loc{recordDecl->getLocation ()};
8393
- std::function checkArgValueSemantics =
8394
- [&](clang::TemplateArgument &arg,
8395
- StringRef argToCheck) -> std::optional<CxxValueSemanticsKind> {
8396
- if (arg.getKind () != clang::TemplateArgument::Type && importerImpl) {
8397
- importerImpl->diagnose (loc, diag::type_template_parameter_expected,
8398
- argToCheck);
8399
- return CxxValueSemanticsKind::Unknown;
8400
- }
8380
+ if (!hasNonCopyableAttr (recordDecl)) {
8381
+ auto injectedStlAnnotation =
8382
+ recordDecl->isInStdNamespace ()
8383
+ ? STLConditionalParams.find (recordDecl->getName ())
8384
+ : STLConditionalParams.end ();
8385
+ auto STLParams = injectedStlAnnotation != STLConditionalParams.end ()
8386
+ ? injectedStlAnnotation->second
8387
+ : std::vector<int >();
8388
+ auto conditionalParams = getConditionalCopyableAttrParams (recordDecl);
8401
8389
8402
- auto argValueSemantics = evaluateOrDefault (
8403
- evaluator,
8404
- CxxValueSemantics (
8405
- {arg.getAsType ()->getUnqualifiedDesugaredType (), importerImpl}),
8406
- {});
8407
- if (argValueSemantics != CxxValueSemanticsKind::Copyable)
8408
- return argValueSemantics;
8409
- return std::nullopt ;
8410
- };
8390
+ if (!STLParams.empty () || !conditionalParams.empty ()) {
8391
+ HeaderLoc loc{recordDecl->getLocation ()};
8392
+ std::function checkArgValueSemantics =
8393
+ [&](clang::TemplateArgument &arg,
8394
+ StringRef argToCheck) -> std::optional<CxxValueSemanticsKind> {
8395
+ if (arg.getKind () != clang::TemplateArgument::Type && importerImpl) {
8396
+ importerImpl->diagnose (loc, diag::type_template_parameter_expected,
8397
+ argToCheck);
8398
+ return CxxValueSemanticsKind::Unknown;
8399
+ }
8411
8400
8412
- auto result = checkConditionalParams<CxxValueSemanticsKind>(
8413
- recordDecl, STLParams, conditionalParams, checkArgValueSemantics);
8414
- if (result.has_value ())
8415
- return result.value ();
8401
+ auto argValueSemantics = evaluateOrDefault (
8402
+ evaluator,
8403
+ CxxValueSemantics (
8404
+ {arg.getAsType ()->getUnqualifiedDesugaredType (), importerImpl}),
8405
+ {});
8406
+ if (argValueSemantics != CxxValueSemanticsKind::Copyable)
8407
+ return argValueSemantics;
8408
+ return std::nullopt ;
8409
+ };
8416
8410
8417
- if (importerImpl)
8418
- for (auto name : conditionalParams)
8419
- importerImpl->diagnose (loc, diag::unknown_template_parameter, name);
8411
+ auto result = checkConditionalParams<CxxValueSemanticsKind>(
8412
+ recordDecl, STLParams, conditionalParams, checkArgValueSemantics);
8413
+ if (result.has_value ())
8414
+ return result.value ();
8420
8415
8421
- return CxxValueSemanticsKind::Copyable;
8416
+ if (importerImpl)
8417
+ for (auto name : conditionalParams)
8418
+ importerImpl->diagnose (loc, diag::unknown_template_parameter, name);
8419
+
8420
+ return CxxValueSemanticsKind::Copyable;
8421
+ }
8422
8422
}
8423
8423
8424
8424
const auto cxxRecordDecl = dyn_cast<clang::CXXRecordDecl>(recordDecl);
@@ -8428,7 +8428,8 @@ CxxValueSemantics::evaluate(Evaluator &evaluator,
8428
8428
return CxxValueSemanticsKind::Copyable;
8429
8429
}
8430
8430
8431
- bool isCopyable = hasCopyTypeOperations (cxxRecordDecl);
8431
+ bool isCopyable = !hasNonCopyableAttr (cxxRecordDecl) &&
8432
+ hasCopyTypeOperations (cxxRecordDecl);
8432
8433
bool isMovable = hasMoveTypeOperations (cxxRecordDecl);
8433
8434
8434
8435
if (!hasDestroyTypeOperations (cxxRecordDecl) || (!isCopyable && !isMovable)) {
0 commit comments