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