44#include "llvm/ADT/APInt.h"
45#include "llvm/ADT/STLExtras.h"
46#include "llvm/Support/ErrorHandling.h"
47#include "llvm/Support/TypeSize.h"
81 llvm_unreachable(
"Nested name specifier is not a type for inheriting ctor");
93 bool EnteringContext) {
96 "not a constructor name");
117 auto *RD = dyn_cast<CXXRecordDecl>(ND);
118 if (RD && RD->isInjectedClassName()) {
119 InjectedClassName = RD;
123 if (!InjectedClassName) {
128 diag::err_incomplete_nested_name_spec) << CurClass << SS.
getRange();
145 bool EnteringContext) {
191 auto IsAcceptableResult = [&](
NamedDecl *D) ->
bool {
192 auto *
Type = dyn_cast<TypeDecl>(D->getUnderlyingDecl());
203 unsigned NumAcceptableResults = 0;
205 if (IsAcceptableResult(D))
206 ++NumAcceptableResults;
211 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
212 if (RD->isInjectedClassName())
213 D = cast<NamedDecl>(RD->getParent());
215 if (FoundDeclSet.insert(D).second)
216 FoundDecls.push_back(D);
224 if (Found.isAmbiguous() && NumAcceptableResults == 1) {
225 Diag(NameLoc, diag::ext_dtor_name_ambiguous);
235 if (!IsAcceptableResult(D))
241 if (Found.isAmbiguous())
245 if (IsAcceptableResult(
Type)) {
256 bool IsDependent =
false;
258 auto LookupInObjectType = [&]() ->
ParsedType {
259 if (Failed || SearchType.
isNull())
269 return CheckLookupResult(Found);
287 return CheckLookupResult(Found);
296 return CheckLookupResult(Found);
343 if (
ParsedType T = LookupInNestedNameSpec(PrefixSS))
373 unsigned NumNonExtensionDecls = FoundDecls.size();
381 if (
ParsedType T = LookupInNestedNameSpec(SS)) {
397 Diag(SS.
getEndLoc(), diag::ext_qualified_dtor_named_in_lexical_scope)
399 Diag(FoundDecls.back()->getLocation(), diag::note_destructor_type_here)
410 FoundDecls.resize(NumNonExtensionDecls);
413 std::stable_sort(FoundDecls.begin(), FoundDecls.end(),
415 return isa<TypeDecl>(A->getUnderlyingDecl()) >
416 isa<TypeDecl>(B->getUnderlyingDecl());
420 auto MakeFixItHint = [&]{
426 Destroyed = dyn_cast_or_null<CXXRecordDecl>(S->getEntity());
433 if (FoundDecls.empty()) {
435 Diag(NameLoc, diag::err_undeclared_destructor_name)
436 << &II << MakeFixItHint();
437 }
else if (!SearchType.
isNull() && FoundDecls.size() == 1) {
438 if (
auto *TD = dyn_cast<TypeDecl>(FoundDecls[0]->getUnderlyingDecl())) {
439 assert(!SearchType.
isNull() &&
440 "should only reject a type result if we have a search type");
442 Diag(NameLoc, diag::err_destructor_expr_type_mismatch)
443 << T << SearchType << MakeFixItHint();
445 Diag(NameLoc, diag::err_destructor_expr_nontype)
446 << &II << MakeFixItHint();
449 Diag(NameLoc, SearchType.
isNull() ? diag::err_destructor_name_nontype
450 : diag::err_destructor_expr_mismatch)
451 << &II << SearchType << MakeFixItHint();
455 if (
auto *TD = dyn_cast<TypeDecl>(FoundD->getUnderlyingDecl()))
456 Diag(FoundD->getLocation(), diag::note_destructor_type_here)
459 Diag(FoundD->getLocation(), diag::note_destructor_nontype_here)
477 "unexpected type in getDestructorType");
506 Diag(Loc, diag::warn_reserved_extern_symbol)
507 << II << static_cast<int>(Status)
509 Name.getSourceRange(),
510 (StringRef(
"operator\"\"") + II->
getName()).str());
525 Diag(Name.getBeginLoc(), diag::err_literal_operator_id_outside_namespace)
536 llvm_unreachable(
"unknown nested name specifier kind");
558 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid) << T);
572 bool WasEvaluated =
false;
582 CXXRecordDecl *RecordD = cast<CXXRecordDecl>(RecordT->getDecl());
628 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid)
635 ? diag::warn_side_effects_typeid
636 : diag::warn_side_effects_unevaluated_context);
649 return ExprError(
Diag(OpLoc, diag::err_openclcxx_not_supported)
655 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid));
669 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid));
673 return ExprError(
Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
697 if (
auto *CTE = dyn_cast<CXXTypeidExpr>(
Result.get()))
698 if (CTE->isPotentiallyEvaluated() && !CTE->isMostDerived(
Context))
699 Diag(OpLoc, diag::warn_no_typeid_with_rtti_disabled)
721 if (
const auto *Uuid = TD->getMostRecentDecl()->getAttr<UuidAttr>()) {
722 UuidAttrs.insert(Uuid);
727 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(TD)) {
730 const UuidAttr *UuidForTA =
nullptr;
737 UuidAttrs.insert(UuidForTA);
748 if (!Operand->getType()->isDependentType()) {
751 if (UuidAttrs.empty())
752 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
753 if (UuidAttrs.size() > 1)
754 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
755 Guid = UuidAttrs.back()->getGuidDecl();
773 if (UuidAttrs.empty())
774 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
775 if (UuidAttrs.size() > 1)
776 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
777 Guid = UuidAttrs.back()->getGuidDecl();
813 assert((Kind == tok::kw_true || Kind == tok::kw_false) &&
814 "Unknown C++ Boolean value!");
828 bool IsThrownVarInScope =
false;
842 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
843 if (Var->hasLocalStorage() && !Var->getType().isVolatileQualified()) {
844 for( ; S; S = S->getParent()) {
845 if (S->isDeclScope(Var)) {
846 IsThrownVarInScope =
true;
864 bool IsThrownVarInScope) {
869 targetDiag(OpLoc, diag::err_exceptions_disabled) <<
"throw";
878 Diag(OpLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"throw";
921 llvm::DenseMap<CXXRecordDecl *, unsigned> &SubobjectsSeen,
922 llvm::SmallPtrSetImpl<CXXRecordDecl *> &VBases,
923 llvm::SetVector<CXXRecordDecl *> &PublicSubobjectsSeen,
924 bool ParentIsPublic) {
926 CXXRecordDecl *BaseDecl = BS.getType()->getAsCXXRecordDecl();
931 NewSubobject = VBases.insert(BaseDecl).second;
936 ++SubobjectsSeen[BaseDecl];
939 bool PublicPath = ParentIsPublic && BS.getAccessSpecifier() ==
AS_public;
941 PublicSubobjectsSeen.insert(BaseDecl);
951 llvm::DenseMap<CXXRecordDecl *, unsigned> SubobjectsSeen;
952 llvm::SmallSet<CXXRecordDecl *, 2> VBases;
953 llvm::SetVector<CXXRecordDecl *> PublicSubobjectsSeen;
954 SubobjectsSeen[RD] = 1;
955 PublicSubobjectsSeen.insert(RD);
959 for (
CXXRecordDecl *PublicSubobject : PublicSubobjectsSeen) {
961 if (SubobjectsSeen[PublicSubobject] > 1)
964 Objects.push_back(PublicSubobject);
974 bool isPointer =
false;
981 isPointer ? diag::err_throw_incomplete_ptr
982 : diag::err_throw_incomplete,
992 diag::err_throw_abstract_type, E))
1014 PDiag(diag::err_access_dtor_exception) << Ty);
1030 for (
CXXRecordDecl *Subobject : UnambiguousPublicSubobjects) {
1057 for (
unsigned I = 1, E = CD->
getNumParams(); I != E; ++I) {
1071 if (ExnObjAlign < TypeAlign) {
1072 Diag(ThrowLoc, diag::warn_throw_underaligned_obj);
1073 Diag(ThrowLoc, diag::note_throw_underaligned_obj)
1126 for (
int I = FunctionScopes.size();
1127 I-- && isa<LambdaScopeInfo>(FunctionScopes[I]) &&
1129 cast<LambdaScopeInfo>(FunctionScopes[I])->CallOperator);
1131 CurLSI = cast<LambdaScopeInfo>(FunctionScopes[I]);
1138 if (
C.isCopyCapture()) {
1150 "While computing 'this' capture-type for a generic lambda, when we "
1151 "run out of enclosing LSI's, yet the enclosing DC is a "
1152 "lambda-call-operator we must be (i.e. Current LSI) in a generic "
1153 "lambda call oeprator");
1156 auto IsThisCaptured =
1161 if (
C.capturesThis()) {
1172 bool IsByCopyCapture =
false;
1173 bool IsConstCapture =
false;
1176 IsThisCaptured(Closure, IsByCopyCapture, IsConstCapture)) {
1177 if (IsByCopyCapture) {
1195 if (method && method->isInstance())
1196 ThisTy = method->getThisType();
1224 : S(S), OldCXXThisTypeOverride(S.CXXThisTypeOverride), Enabled(
false)
1226 if (!Enabled || !ContextDecl)
1231 Record = Template->getTemplatedDecl();
1233 Record = cast<CXXRecordDecl>(ContextDecl);
1240 this->Enabled =
true;
1257 Sema.
Diag(DiagLoc, diag::note_lambda_this_capture_fixit)
1263 bool BuildAndDiagnose,
const unsigned *
const FunctionScopeIndexToStopAt,
1264 const bool ByCopy) {
1269 assert((!ByCopy || Explicit) &&
"cannot implicitly capture *this by value");
1271 const int MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
1272 ? *FunctionScopeIndexToStopAt
1298 unsigned NumCapturingClosures = 0;
1299 for (
int idx = MaxFunctionScopesIndex; idx >= 0; idx--) {
1302 if (CSI->CXXThisCaptureIndex != 0) {
1304 CSI->Captures[CSI->CXXThisCaptureIndex - 1].markUsed(BuildAndDiagnose);
1310 if (BuildAndDiagnose) {
1311 Diag(Loc, diag::err_this_capture)
1312 << (Explicit && idx == MaxFunctionScopesIndex);
1322 (Explicit && idx == MaxFunctionScopesIndex)) {
1328 NumCapturingClosures++;
1332 if (BuildAndDiagnose)
1333 Diag(Loc, diag::err_this_capture)
1334 << (Explicit && idx == MaxFunctionScopesIndex);
1342 if (!BuildAndDiagnose)
return false;
1355 "Only a lambda can capture the enclosing object (referred to by "
1358 for (
int idx = MaxFunctionScopesIndex; NumCapturingClosures;
1359 --idx, --NumCapturingClosures) {
1366 bool isNested = NumCapturingClosures > 1;
1379 return Diag(Loc, diag::err_invalid_this_use);
1410 return Class && Class->isBeingDefined();
1422 bool ListInitialization) {
1432 RParenOrBraceLoc, ListInitialization);
1436 if (!
Result.isInvalid() &&
Result.get()->isInstantiationDependent() &&
1437 !
Result.get()->isTypeDependent())
1439 else if (
Result.isInvalid())
1441 RParenOrBraceLoc, exprs, Ty);
1450 bool ListInitialization) {
1454 assert((!ListInitialization || Exprs.size() == 1) &&
1455 "List initialization must have exactly one expression.");
1462 ? ListInitialization
1464 TyBeginLoc, LParenOrBraceLoc, RParenOrBraceLoc)
1478 isa<DeducedTemplateSpecializationType>(Deduced)) {
1484 }
else if (Deduced && !Deduced->
isDeduced()) {
1486 if (ListInitialization) {
1487 auto *ILE = cast<InitListExpr>(Exprs[0]);
1488 Inits =
MultiExprArg(ILE->getInits(), ILE->getNumInits());
1492 return ExprError(
Diag(TyBeginLoc, diag::err_auto_expr_init_no_expression)
1493 << Ty << FullRange);
1494 if (Inits.size() > 1) {
1495 Expr *FirstBad = Inits[1];
1497 diag::err_auto_expr_init_multiple_expressions)
1498 << Ty << FullRange);
1502 Diag(TyBeginLoc, diag::warn_cxx20_compat_auto_expr) << FullRange;
1504 Expr *Deduce = Inits[0];
1505 if (isa<InitListExpr>(Deduce))
1508 << ListInitialization << Ty << FullRange);
1514 return ExprError(
Diag(TyBeginLoc, diag::err_auto_expr_deduction_failure)
1515 << Ty << Deduce->
getType() << FullRange
1529 RParenOrBraceLoc, ListInitialization);
1535 if (Exprs.size() == 1 && !ListInitialization &&
1536 !isa<InitListExpr>(Exprs[0])) {
1537 Expr *Arg = Exprs[0];
1545 if (!ListInitialization)
1546 return ExprError(
Diag(TyBeginLoc, diag::err_value_init_for_array_type)
1556 return ExprError(
Diag(TyBeginLoc, diag::err_init_for_function_type)
1557 << Ty << FullRange);
1564 diag::err_invalid_incomplete_type_use, FullRange))
1577 Inner = BTE->getSubExpr();
1578 if (
auto *CE = dyn_cast<ConstantExpr>(Inner);
1579 CE && CE->isImmediateInvocation())
1580 Inner = CE->getSubExpr();
1581 if (!isa<CXXTemporaryObjectExpr>(Inner) &&
1582 !isa<CXXScalarValueInitExpr>(Inner)) {
1594 :
SourceRange(LParenOrBraceLoc, RParenOrBraceLoc);
1616 for (
const auto *D : R) {
1617 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1634 return llvm::none_of(PreventedBy, [&](
const FunctionDecl *FD) {
1636 "Only single-operand functions should be in PreventedBy");
1651 unsigned UsualParams = 1;
1653 if (S.
getLangOpts().SizedDeallocation && UsualParams < FD->getNumParams() &&
1659 if (S.
getLangOpts().AlignedAllocation && UsualParams < FD->getNumParams() &&
1669 struct UsualDeallocFnInfo {
1670 UsualDeallocFnInfo() : Found(), FD(nullptr) {}
1672 : Found(Found), FD(dyn_cast<
FunctionDecl>(Found->getUnderlyingDecl())),
1674 CUDAPref(
Sema::CFP_Native) {
1678 unsigned NumBaseParams = 1;
1679 if (FD->isDestroyingOperatorDelete()) {
1684 if (NumBaseParams < FD->getNumParams() &&
1686 FD->getParamDecl(NumBaseParams)->getType(),
1692 if (NumBaseParams < FD->getNumParams() &&
1693 FD->getParamDecl(NumBaseParams)->getType()->isAlignValT()) {
1695 HasAlignValT =
true;
1704 explicit operator bool()
const {
return FD; }
1706 bool isBetterThan(
const UsualDeallocFnInfo &Other,
bool WantSize,
1707 bool WantAlign)
const {
1711 if (Destroying !=
Other.Destroying)
1718 if (HasAlignValT !=
Other.HasAlignValT)
1719 return HasAlignValT == WantAlign;
1721 if (HasSizeT !=
Other.HasSizeT)
1722 return HasSizeT == WantSize;
1725 return CUDAPref >
Other.CUDAPref;
1730 bool Destroying, HasSizeT, HasAlignValT;
1750 UsualDeallocFnInfo Best;
1752 for (
auto I = R.
begin(), E = R.
end(); I != E; ++I) {
1753 UsualDeallocFnInfo Info(S, I.getPair());
1761 BestFns->push_back(Info);
1765 if (Best.isBetterThan(Info, WantSize, WantAlign))
1770 if (BestFns && Info.isBetterThan(Best, WantSize, WantAlign))
1775 BestFns->push_back(Info);
1789 if (!record)
return false;
1802 if (ops.
empty())
return false;
1814 return Best && Best.HasSizeT;
1838 std::optional<Expr *> ArraySize;
1864 if (
Expr *NumElts = (
Expr *)Array.NumElts) {
1865 if (!NumElts->isTypeDependent() && !NumElts->isValueDependent()) {
1880 NumElts,
nullptr, diag::err_new_array_nonconst,
AllowFold)
1897 DirectInitRange = List->getSourceRange();
1900 PlacementLParen, PlacementArgs, PlacementRParen,
1901 TypeIdParens, AllocType, TInfo, ArraySize, DirectInitRange,
1910 return PLE->getNumExprs() == 0;
1911 if (isa<ImplicitValueInitExpr>(Init))
1914 return !CCE->isListInitialization() &&
1915 CCE->getConstructor()->isDefaultConstructor();
1917 assert(isa<InitListExpr>(Init) &&
1918 "Shouldn't create list CXXConstructExprs for arrays.");
1930 std::optional<unsigned> AlignmentParam;
1943 StringRef OSName = AvailabilityAttr::getPlatformNameSourceSpelling(
1948 bool IsDelete = Kind == OO_Delete || Kind == OO_Array_Delete;
1949 Diag(Loc, diag::err_aligned_allocation_unavailable)
1951 << OSVersion.getAsString() << OSVersion.empty();
1952 Diag(Loc, diag::note_silence_aligned_allocation_unavailable);
1962 std::optional<Expr *> ArraySize,
1968 if (DirectInitRange.
isValid()) {
1969 assert(
Initializer &&
"Have parens but no initializer.");
1976 "Initializer expression that cannot have been implicitly created.");
1983 Exprs =
MultiExprArg(List->getExprs(), List->getNumExprs());
2004 DirectInitRange.
getEnd());
2008 if (Deduced && !Deduced->isDeduced() &&
2009 isa<DeducedTemplateSpecializationType>(Deduced)) {
2012 Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.
getBegin(),
2013 diag::err_deduced_class_template_compound_type)
2015 << (*ArraySize ? (*ArraySize)->getSourceRange() : TypeRange));
2020 AllocTypeInfo, Entity, Kind, Exprs);
2023 }
else if (Deduced && !Deduced->isDeduced()) {
2027 auto *ILE = cast<InitListExpr>(Exprs[0]);
2028 Inits =
MultiExprArg(ILE->getInits(), ILE->getNumInits());
2032 return ExprError(
Diag(StartLoc, diag::err_auto_new_requires_ctor_arg)
2033 << AllocType << TypeRange);
2034 if (Inits.size() > 1) {
2035 Expr *FirstBad = Inits[1];
2037 diag::err_auto_new_ctor_multiple_expressions)
2038 << AllocType << TypeRange);
2042 << AllocType << TypeRange;
2043 Expr *Deduce = Inits[0];
2044 if (isa<InitListExpr>(Deduce))
2047 << Braced << AllocType << TypeRange);
2053 return ExprError(
Diag(StartLoc, diag::err_auto_new_deduction_failure)
2054 << AllocType << Deduce->
getType() << TypeRange
2071 AllocType = Array->getElementType();
2091 if (ArraySize && *ArraySize &&
2092 (*ArraySize)->getType()->isNonOverloadPlaceholderType()) {
2095 ArraySize = result.
get();
2104 std::optional<uint64_t> KnownArraySize;
2105 if (ArraySize && *ArraySize && !(*ArraySize)->isTypeDependent()) {
2114 (*ArraySize)->getType()->getAs<
RecordType>())
2116 Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion)
2117 << (*ArraySize)->getType() << 0 <<
"'size_t'";
2124 SizeConvertDiagnoser(
Expr *ArraySize)
2126 ArraySize(ArraySize) {}
2130 return S.
Diag(Loc, diag::err_array_size_not_integral)
2136 return S.
Diag(Loc, diag::err_array_size_incomplete_type)
2142 return S.
Diag(Loc, diag::err_array_size_explicit_conversion) << T << ConvTy;
2153 return S.
Diag(Loc, diag::err_array_size_ambiguous_conversion) << T;
2167 ? diag::warn_cxx98_compat_array_size_conversion
2168 : diag::ext_array_size_conversion)
2171 } SizeDiagnoser(*ArraySize);
2179 ArraySize = ConvertedSize.
get();
2180 QualType SizeType = (*ArraySize)->getType();
2198 if (std::optional<llvm::APSInt>
Value =
2199 (*ArraySize)->getIntegerConstantExpr(
Context)) {
2200 if (
Value->isSigned() &&
Value->isNegative()) {
2202 diag::err_typecheck_negative_array_size)
2203 << (*ArraySize)->getSourceRange());
2207 unsigned ActiveSizeBits =
2211 Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large)
2215 KnownArraySize =
Value->getZExtValue();
2216 }
else if (TypeIdParens.
isValid()) {
2218 Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst)
2219 << (*ArraySize)->getSourceRange()
2232 unsigned Alignment =
2235 bool PassAlignment =
getLangOpts().AlignedAllocation &&
2236 Alignment > NewAlignment;
2243 AllocType, ArraySize.has_value(), PassAlignment, PlacementArgs,
2244 OperatorNew, OperatorDelete))
2249 bool UsualArrayDeleteWantsSize =
false;
2251 UsualArrayDeleteWantsSize =
2264 unsigned NumImplicitArgs = PassAlignment ? 2 : 1;
2266 NumImplicitArgs, PlacementArgs, AllPlaceArgs,
2270 if (!AllPlaceArgs.empty())
2271 PlacementArgs = AllPlaceArgs;
2281 llvm::APInt SingleEltSize(
2285 std::optional<llvm::APInt> AllocationSize;
2288 AllocationSize = SingleEltSize;
2292 AllocationSize = llvm::APInt(SizeTyWidth, *KnownArraySize)
2293 .umul_ov(SingleEltSize, Overflow);
2297 "Expected that all the overflows would have been handled already.");
2301 Context, AllocationSize.value_or(llvm::APInt::getZero(SizeTyWidth)),
2320 CK_IntegralCast, &AlignmentLiteral,
2325 CallArgs.reserve(NumImplicitArgs + PlacementArgs.size());
2326 CallArgs.emplace_back(AllocationSize
2327 ?
static_cast<Expr *
>(&AllocationSizeLiteral)
2328 : &OpaqueAllocationSize);
2330 CallArgs.emplace_back(&DesiredAlignment);
2331 CallArgs.insert(CallArgs.end(), PlacementArgs.begin(), PlacementArgs.end());
2335 checkCall(OperatorNew, Proto,
nullptr, CallArgs,
2336 false, StartLoc, Range, CallType);
2340 if (PlacementArgs.empty() && !PassAlignment &&
2344 if (Alignment > NewAlignment)
2345 Diag(StartLoc, diag::warn_overaligned_type)
2356 SourceRange InitRange(Exprs.front()->getBeginLoc(),
2357 Exprs.back()->getEndLoc());
2358 Diag(StartLoc, diag::err_new_array_init_args) << InitRange;
2378 InitType = AllocType;
2391 dyn_cast_or_null<CXXBindTemporaryExpr>(FullInit.
get()))
2392 FullInit = Binder->getSubExpr();
2399 if (ArraySize && !*ArraySize) {
2407 Diag(TypeRange.
getEnd(), diag::err_new_array_size_unknown_from_init)
2419 if (OperatorDelete) {
2426 PassAlignment, UsualArrayDeleteWantsSize,
2427 PlacementArgs, TypeIdParens, ArraySize, initStyle,
2439 return Diag(Loc, diag::err_bad_new_type)
2440 << AllocType << 0 << R;
2442 return Diag(Loc, diag::err_bad_new_type)
2443 << AllocType << 1 << R;
2446 Loc, AllocType, diag::err_new_incomplete_or_sizeless_type, R))
2449 diag::err_allocation_of_abstract_type))
2452 return Diag(Loc, diag::err_variably_modified_new_type)
2456 return Diag(Loc, diag::err_address_space_qualified_new)
2464 return Diag(Loc, diag::err_arc_new_array_without_ownership)
2479 Alloc != AllocEnd; ++Alloc) {
2516 if (PassAlignment) {
2517 PassAlignment =
false;
2519 Args.erase(Args.begin() + 1);
2521 Operator, &Candidates, AlignArg,
2547 (Args[1]->getType()->isObjectPointerType() ||
2548 Args[1]->getType()->isArrayType())) {
2549 S.
Diag(R.
getNameLoc(), diag::err_need_header_before_placement_new)
2564 if (AlignedCandidates) {
2566 return C.Function->getNumParams() > 1 &&
2567 C.Function->getParamDecl(1)->getType()->isAlignValT();
2571 AlignedArgs.reserve(Args.size() + 1);
2572 AlignedArgs.push_back(Args[0]);
2573 AlignedArgs.push_back(AlignArg);
2574 AlignedArgs.append(Args.begin() + 1, Args.end());
2587 if (AlignedCandidates)
2588 AlignedCandidates->
NoteCandidates(S, AlignedArgs, AlignedCands,
"",
2598 S.
PDiag(diag::err_ovl_ambiguous_call)
2608 S.
PDiag(diag::err_ovl_deleted_call)
2615 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
2637 AllocArgs.reserve((PassAlignment ? 2 : 1) + PlaceArgs.size());
2645 llvm::APInt::getZero(
2648 AllocArgs.push_back(&Size);
2651 if (PassAlignment) {
2657 AllocArgs.push_back(&Align);
2659 AllocArgs.insert(AllocArgs.end(), PlaceArgs.begin(), PlaceArgs.end());
2668 IsArray ? OO_Array_New : OO_New);
2700 if (PlaceArgs.empty()) {
2701 Diag(StartLoc, diag::err_openclcxx_not_supported) <<
"default new";
2703 Diag(StartLoc, diag::err_openclcxx_placement_new);
2708 assert(!R.
empty() &&
"implicitly declared allocation functions not found");
2709 assert(!R.
isAmbiguous() &&
"global allocation functions are ambiguous");
2715 OperatorNew,
nullptr,
2722 OperatorDelete =
nullptr;
2757 while (Filter.hasNext()) {
2758 auto *FD = dyn_cast<FunctionDecl>(Filter.next()->getUnderlyingDecl());
2759 if (FD && FD->isDestroyingOperatorDelete())
2765 bool FoundGlobalDelete = FoundDelete.
empty();
2766 if (FoundDelete.
empty()) {
2793 bool isPlacementNew = !PlaceArgs.empty() || OperatorNew->
param_size() != 1 ||
2796 if (isPlacementNew) {
2813 for (
unsigned I = 1, N = Proto->getNumParams(); I < N; ++I)
2814 ArgTypes.push_back(Proto->getParamType(I));
2818 EPI.
Variadic = Proto->isVariadic();
2820 ExpectedFunctionType
2825 DEnd = FoundDelete.
end();
2829 dyn_cast<FunctionTemplateDecl>((*D)->getUnderlyingDecl())) {
2837 Fn = cast<FunctionDecl>((*D)->getUnderlyingDecl());
2840 ExpectedFunctionType,
2842 ExpectedFunctionType))
2843 Matches.push_back(std::make_pair(D.getPair(), Fn));
2859 *
this, FoundDelete, FoundGlobalDelete,
2863 Matches.push_back(std::make_pair(Selected.Found, Selected.FD));
2867 for (
auto Fn : BestDeallocFns)
2868 Matches.push_back(std::make_pair(Fn.Found, Fn.FD));
2876 if (Matches.size() == 1) {
2877 OperatorDelete = Matches[0].second;
2887 UsualDeallocFnInfo Info(*
this,
2893 bool IsSizedDelete = Info.HasSizeT;
2894 if (IsSizedDelete && !FoundGlobalDelete) {
2895 auto NonSizedDelete =
2898 if (NonSizedDelete && !NonSizedDelete.HasSizeT &&
2899 NonSizedDelete.HasAlignValT == Info.HasAlignValT)
2900 IsSizedDelete =
false;
2903 if (IsSizedDelete) {
2907 PlaceArgs.back()->getEndLoc());
2908 Diag(StartLoc, diag::err_placement_new_non_placement_delete) << R;
2917 }
else if (!Matches.empty()) {
2921 Diag(StartLoc, diag::warn_ambiguous_suitable_delete_function_found)
2922 << DeleteName << AllocElemType;
2924 for (
auto &Match : Matches)
2925 Diag(Match.second->getLocation(),
2926 diag::note_member_declared_here) << DeleteName;
3014 if (TheGlobalModuleFragment) {
3029 if (TheGlobalModuleFragment) {
3030 AlignValT->setModuleOwnershipKind(
3032 AlignValT->setLocalOwningModule(TheGlobalModuleFragment);
3037 AlignValT->setImplicit(
true);
3050 Params.push_back(Param);
3053 bool HasSizedVariant =
getLangOpts().SizedDeallocation &&
3054 (Kind == OO_Delete || Kind == OO_Array_Delete);
3055 bool HasAlignedVariant =
getLangOpts().AlignedAllocation;
3057 int NumSizeVariants = (HasSizedVariant ? 2 : 1);
3058 int NumAlignVariants = (HasAlignedVariant ? 2 : 1);
3059 for (
int Sized = 0; Sized < NumSizeVariants; ++Sized) {
3061 Params.push_back(SizeT);
3063 for (
int Aligned = 0; Aligned < NumAlignVariants; ++Aligned) {
3076 DeclareGlobalAllocationFunctions(OO_New, VoidPtr, SizeT);
3077 DeclareGlobalAllocationFunctions(OO_Array_New, VoidPtr, SizeT);
3078 DeclareGlobalAllocationFunctions(OO_Delete,
Context.
VoidTy, VoidPtr);
3079 DeclareGlobalAllocationFunctions(OO_Array_Delete,
Context.
VoidTy, VoidPtr);
3082 PopGlobalModuleFragment();
3095 Alloc != AllocEnd; ++Alloc) {
3098 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(*Alloc)) {
3099 if (Func->getNumParams() == Params.size()) {
3101 for (
auto *
P : Func->parameters())
3102 FuncParams.push_back(
3108 Func->setVisibleDespiteOwningModule();
3116 false,
false,
true));
3119 bool HasBadAllocExceptionSpec
3120 = (Name.getCXXOverloadedOperator() == OO_New ||
3121 Name.getCXXOverloadedOperator() == OO_Array_New);
3122 if (HasBadAllocExceptionSpec) {
3125 assert(
StdBadAlloc &&
"Must have std::bad_alloc declared");
3137 auto CreateAllocationFunctionDecl = [&](
Attr *ExtraAttr) {
3147 if (HasBadAllocExceptionSpec &&
getLangOpts().NewInfallible)
3161 if (TheGlobalModuleFragment) {
3167 Alloc->
addAttr(VisibilityAttr::CreateImplicit(
3169 ? VisibilityAttr::Hidden
3170 : VisibilityAttr::Default));
3177 ParamDecls.back()->setImplicit();
3179 Alloc->setParams(ParamDecls);
3188 CreateAllocationFunctionDecl(
nullptr);
3192 CreateAllocationFunctionDecl(CUDAHostAttr::CreateImplicit(
Context));
3193 CreateAllocationFunctionDecl(CUDADeviceAttr::CreateImplicit(
Context));
3198 bool CanProvideSize,
3212 assert(
Result.FD &&
"operator delete missing from global scope?");
3224 return OperatorDelete;
3236 bool WantSize,
bool WantAligned) {
3254 Overaligned, &Matches);
3257 if (Matches.size() == 1) {
3258 Operator = cast<CXXMethodDecl>(Matches[0].FD);
3263 Diag(StartLoc, diag::err_deleted_function_use);
3279 if (!Matches.empty()) {
3281 Diag(StartLoc, diag::err_ambiguous_suitable_delete_member_function_found)
3283 for (
auto &Match : Matches)
3284 Diag(Match.FD->getLocation(), diag::note_member_declared_here) << Name;
3291 if (!Found.
empty()) {
3293 Diag(StartLoc, diag::err_no_suitable_delete_member_function_found)
3297 Diag(D->getUnderlyingDecl()->getLocation(),
3298 diag::note_member_declared_here) << Name;
3310class MismatchingNewDeleteDetector {
3312 enum MismatchResult {
3318 MemberInitMismatches,
3327 explicit MismatchingNewDeleteDetector(
bool EndOfTU)
3328 : Field(nullptr), IsArrayForm(
false), EndOfTU(EndOfTU),
3329 HasUndefinedConstructors(
false) {}
3346 MismatchResult analyzeField(
FieldDecl *Field,
bool DeleteWasArrayForm);
3356 bool HasUndefinedConstructors;
3368 MismatchResult analyzeMemberExpr(
const MemberExpr *ME);
3391 MismatchResult analyzeInClassInitializer();
3395MismatchingNewDeleteDetector::MismatchResult
3396MismatchingNewDeleteDetector::analyzeDeleteExpr(
const CXXDeleteExpr *DE) {
3398 assert(DE &&
"Expected delete-expression");
3401 if (
const MemberExpr *ME = dyn_cast<const MemberExpr>(E)) {
3402 return analyzeMemberExpr(ME);
3403 }
else if (
const DeclRefExpr *D = dyn_cast<const DeclRefExpr>(E)) {
3404 if (!hasMatchingVarInit(D))
3405 return VarInitMismatches;
3411MismatchingNewDeleteDetector::getNewExprFromInitListOrExpr(
const Expr *E) {
3412 assert(E !=
nullptr &&
"Expected a valid initializer expression");
3414 if (
const InitListExpr *ILE = dyn_cast<const InitListExpr>(E)) {
3415 if (ILE->getNumInits() == 1)
3416 E = dyn_cast<const CXXNewExpr>(ILE->getInit(0)->IgnoreParenImpCasts());
3419 return dyn_cast_or_null<const CXXNewExpr>(E);
3422bool MismatchingNewDeleteDetector::hasMatchingNewInCtorInit(
3426 (NE = getNewExprFromInitListOrExpr(CI->
getInit()))) {
3427 if (
NE->isArray() == IsArrayForm)
3430 NewExprs.push_back(NE);
3435bool MismatchingNewDeleteDetector::hasMatchingNewInCtor(
3441 HasUndefinedConstructors =
true;
3444 for (
const auto *CI : cast<const CXXConstructorDecl>(
Definition)->inits()) {
3445 if (hasMatchingNewInCtorInit(CI))
3451MismatchingNewDeleteDetector::MismatchResult
3452MismatchingNewDeleteDetector::analyzeInClassInitializer() {
3453 assert(Field !=
nullptr &&
"This should be called only for members");
3454 const Expr *InitExpr =
Field->getInClassInitializer();
3456 return EndOfTU ? NoMismatch : AnalyzeLater;
3457 if (
const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
3458 if (
NE->isArray() != IsArrayForm) {
3459 NewExprs.push_back(NE);
3460 return MemberInitMismatches;
3466MismatchingNewDeleteDetector::MismatchResult
3467MismatchingNewDeleteDetector::analyzeField(
FieldDecl *Field,
3468 bool DeleteWasArrayForm) {
3469 assert(Field !=
nullptr &&
"Analysis requires a valid class member.");
3470 this->Field =
Field;
3471 IsArrayForm = DeleteWasArrayForm;
3473 for (
const auto *CD : RD->
ctors()) {
3474 if (hasMatchingNewInCtor(CD))
3477 if (HasUndefinedConstructors)
3478 return EndOfTU ? NoMismatch : AnalyzeLater;
3479 if (!NewExprs.empty())
3480 return MemberInitMismatches;
3481 return Field->hasInClassInitializer() ? analyzeInClassInitializer()
3485MismatchingNewDeleteDetector::MismatchResult
3486MismatchingNewDeleteDetector::analyzeMemberExpr(
const MemberExpr *ME) {
3487 assert(ME !=
nullptr &&
"Expected a member expression");
3489 return analyzeField(F, IsArrayForm);
3493bool MismatchingNewDeleteDetector::hasMatchingVarInit(
const DeclRefExpr *D) {
3496 if (VD->hasInit() && (NE = getNewExprFromInitListOrExpr(VD->getInit())) &&
3497 NE->isArray() != IsArrayForm) {
3498 NewExprs.push_back(NE);
3501 return NewExprs.empty();
3506 const MismatchingNewDeleteDetector &Detector) {
3509 if (!Detector.IsArrayForm)
3518 SemaRef.
Diag(DeleteLoc, diag::warn_mismatched_delete_new)
3519 << Detector.IsArrayForm << H;
3521 for (
const auto *NE : Detector.NewExprs)
3522 SemaRef.
Diag(NE->getExprLoc(), diag::note_allocated_here)
3523 << Detector.IsArrayForm;
3526void Sema::AnalyzeDeleteExprMismatch(
const CXXDeleteExpr *DE) {
3529 MismatchingNewDeleteDetector Detector(
false);
3530 switch (Detector.analyzeDeleteExpr(DE)) {
3531 case MismatchingNewDeleteDetector::VarInitMismatches:
3532 case MismatchingNewDeleteDetector::MemberInitMismatches: {
3536 case MismatchingNewDeleteDetector::AnalyzeLater: {
3541 case MismatchingNewDeleteDetector::NoMismatch:
3547 bool DeleteWasArrayForm) {
3548 MismatchingNewDeleteDetector Detector(
true);
3549 switch (Detector.analyzeField(Field, DeleteWasArrayForm)) {
3550 case MismatchingNewDeleteDetector::VarInitMismatches:
3551 llvm_unreachable(
"This analysis should have been done for class members.");
3552 case MismatchingNewDeleteDetector::AnalyzeLater:
3553 llvm_unreachable(
"Analysis cannot be postponed any point beyond end of "
3554 "translation unit.");
3555 case MismatchingNewDeleteDetector::MemberInitMismatches:
3558 case MismatchingNewDeleteDetector::NoMismatch:
3569 bool ArrayForm,
Expr *ExE) {
3579 bool ArrayFormAsWritten = ArrayForm;
3580 bool UsualArrayDeleteWantsSize =
false;
3598 if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType())
3605 return S.
Diag(Loc, diag::err_delete_operand) << T;
3610 return S.
Diag(Loc, diag::err_delete_incomplete_class_type) << T;
3616 return S.
Diag(Loc, diag::err_delete_explicit_conversion) << T << ConvTy;
3627 return S.
Diag(Loc, diag::err_ambiguous_delete_operand) << T;
3639 llvm_unreachable(
"conversion functions are permitted");
3647 if (!Converter.match(
Type))
3658 diag::err_address_space_qualified_delete)
3667 Diag(StartLoc, diag::ext_delete_void_ptr_operand)
3677 diag::warn_delete_incomplete, Ex.
get())) {
3679 PointeeRD = cast<CXXRecordDecl>(RT->getDecl());
3684 Diag(StartLoc, diag::warn_delete_array_type)
3691 ArrayForm ? OO_Array_Delete : OO_Delete);
3705 UsualArrayDeleteWantsSize =
3710 else if (OperatorDelete && isa<CXXMethodDecl>(OperatorDelete))
3711 UsualArrayDeleteWantsSize =
3712 UsualDeallocFnInfo(*
this,
3731 if (!OperatorDelete) {
3733 Diag(StartLoc, diag::err_openclcxx_not_supported) <<
"default delete";
3738 bool CanProvideSize =
3739 IsComplete && (!ArrayForm || UsualArrayDeleteWantsSize ||
3745 Overaligned, DeleteName);
3752 bool IsVirtualDelete =
false;
3756 PDiag(diag::err_access_dtor) << PointeeElem);
3757 IsVirtualDelete = Dtor->isVirtual();
3786 UsualArrayDeleteWantsSize, OperatorDelete, Ex.
get(), StartLoc);
3787 AnalyzeDeleteExprMismatch(
Result);
3796 IsDelete ? OO_Delete : OO_New);
3800 assert(!R.
empty() &&
"implicitly declared allocation functions not found");
3801 assert(!R.
isAmbiguous() &&
"global allocation functions are ambiguous");
3810 FnOvl != FnOvlEnd; ++FnOvl) {
3813 NamedDecl *D = (*FnOvl)->getUnderlyingDecl();
3837 "class members should not be considered");
3840 S.
Diag(R.
getNameLoc(), diag::err_builtin_operator_new_delete_not_usual)
3841 << (IsDelete ? 1 : 0) << Range;
3842 S.
Diag(FnDecl->
getLocation(), diag::note_non_usual_function_declared_here)
3854 S.
PDiag(diag::err_ovl_no_viable_function_in_call)
3862 S.
PDiag(diag::err_ovl_ambiguous_call)
3875 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
3879Sema::SemaBuiltinOperatorNewDeleteOverloaded(
ExprResult TheCallResult,
3881 CallExpr *TheCall = cast<CallExpr>(TheCallResult.
get());
3884 << (IsDelete ?
"__builtin_operator_delete" :
"__builtin_operator_new")
3894 OperatorNewOrDelete))
3896 assert(OperatorNewOrDelete &&
"should be found");
3902 for (
unsigned i = 0; i != TheCall->
getNumArgs(); ++i) {
3913 assert(Callee &&
Callee->getCastKind() == CK_BuiltinFnToFnPtr &&
3914 "Callee expected to be implicit cast to a builtin function pointer");
3917 return TheCallResult;
3921 bool IsDelete,
bool CallCanBeVirtual,
3922 bool WarnOnNonAbstractTypes,
3949 Diag(Loc, diag::warn_delete_abstract_non_virtual_dtor) << (IsDelete ? 0 : 1)
3951 }
else if (WarnOnNonAbstractTypes) {
3954 Diag(Loc, diag::warn_delete_non_virtual_dtor) << (IsDelete ? 0 : 1)
3958 std::string TypeStr;
3960 Diag(DtorLoc, diag::note_delete_non_virtual)
3990 diag::err_invalid_use_of_function_type)
3994 diag::err_invalid_use_of_array_type)
4012 llvm_unreachable(
"unexpected condition kind");
4039 diag::err_constexpr_if_condition_expression_is_not_constant);
4051 From = Cast->getSubExpr();
4063 if (!ToPtrType->getPointeeType().hasQualifiers()) {
4064 switch (StrLit->getKind()) {
4071 return (ToPointeeType->getKind() == BuiltinType::Char_U ||
4072 ToPointeeType->getKind() == BuiltinType::Char_S);
4089 bool HadMultipleCandidates,
4092 default: llvm_unreachable(
"Unhandled cast kind!");
4093 case CK_ConstructorConversion: {
4098 diag::err_allocation_of_abstract_type))
4111 CastLoc, Ty, FoundDecl, cast<CXXConstructorDecl>(Method),
4112 ConstructorArgs, HadMultipleCandidates,
4113 false,
false,
false,
4121 case CK_UserDefinedConversion: {
4131 HadMultipleCandidates);
4136 CK_UserDefinedConversion,
Result.get(),
4137 nullptr,
Result.get()->getValueKind(),
4174 assert(FD &&
"no conversion function for user-defined conversion seq");
4176 CastKind = CK_UserDefinedConversion;
4184 CastKind = CK_ConstructorConversion;
4212 From = CastArg.
get();
4226 PDiag(diag::err_typecheck_ambiguous_condition)
4232 llvm_unreachable(
"bad conversion");
4239 ToType, From->
getType(), From, Action);
4240 assert(Diagnosed &&
"failed to diagnose bad conversion"); (void)Diagnosed;
4278 ConstructorArgs,
false,
4279 false,
false,
false,
4286 false,
false,
false,
4309 From = Checked.
get();
4317 ToAtomicType = ToType;
4318 ToType = ToAtomic->getValueType();
4321 QualType InitialFromType = FromType;
4323 switch (SCS.
First) {
4326 FromType = FromAtomic->getValueType().getUnqualifiedType();
4339 From = FromRes.
get();
4359 llvm_unreachable(
"Improper first standard conversion");
4396 "only enums with fixed underlying type can promote to bool");
4421 CK = CK_FloatingComplexCast;
4423 CK = CK_FloatingComplexToIntegralComplex;
4425 CK = CK_IntegralComplexToFloatingComplex;
4427 CK = CK_IntegralComplexCast;
4448 nullptr, CCK).
get();
4457 diag::ext_typecheck_convert_incompatible_pointer)
4462 diag::ext_typecheck_convert_incompatible_pointer)
4469 }
else if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
4475 Diag(From->
getBeginLoc(), diag::err_arc_convesion_of_weak_unavailable)
4504 if (Kind == CK_BlockPointerToObjCPointerCast) {
4558 &BasePath, CCK).
get();
4587 QualType ElType = ToComplex->getElementType();
4595 isFloatingComplex ? CK_FloatingCast : CK_FloatingToIntegral).
get();
4599 isFloatingComplex ? CK_IntegralToFloating : CK_IntegralCast).
get();
4603 isFloatingComplex ? CK_FloatingRealToComplex
4604 : CK_IntegralRealToComplex).
get();
4609 QualType ElType = FromComplex->getElementType();
4614 isFloatingComplex ? CK_FloatingComplexToReal
4615 : CK_IntegralComplexToReal,
4624 isFloatingComplex ? CK_FloatingCast
4625 : CK_IntegralToFloating,
4631 isFloatingComplex ? CK_FloatingToIntegral
4647 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
4660 From = FromRes.
get();
4662 "Improper transparent union conversion");
4670 CK_ZeroToOCLOpaqueType,
4682 llvm_unreachable(
"Improper second standard conversion");
4685 switch (SCS.
Third) {
4708 CK = CK_AddressSpaceConversion;
4713 CK = CK_AddressSpaceConversion;
4719 << InitialFromType << ToType;
4730 ? diag::ext_deprecated_string_literal_conversion
4731 : diag::warn_deprecated_string_literal_conversion)
4739 llvm_unreachable(
"Improper third standard conversion");
4744 if (!ToAtomicType.
isNull()) {
4790 default: llvm_unreachable(
"not a UTT");
4792 case UTT_IsCompleteType:
4800 case UTT_IsIntegral:
4801 case UTT_IsFloatingPoint:
4803 case UTT_IsBoundedArray:
4805 case UTT_IsNullPointer:
4806 case UTT_IsReferenceable:
4807 case UTT_IsLvalueReference:
4808 case UTT_IsRvalueReference:
4809 case UTT_IsMemberFunctionPointer:
4810 case UTT_IsMemberObjectPointer:
4812 case UTT_IsScopedEnum:
4815 case UTT_IsFunction:
4816 case UTT_IsReference:
4817 case UTT_IsArithmetic:
4818 case UTT_IsFundamental:
4821 case UTT_IsCompound:
4822 case UTT_IsMemberPointer:
4831 case UTT_IsVolatile:
4833 case UTT_IsUnboundedArray:
4834 case UTT_IsUnsigned:
4837 case UTT_IsInterfaceClass:
4843 case UTT_IsPolymorphic:
4844 case UTT_IsAbstract:
4848 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
4857 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
4861 case UTT_IsAggregate:
4866 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
4871 case UTT_IsTriviallyCopyable:
4872 case UTT_IsStandardLayout:
4877 case UTT_IsTriviallyRelocatable:
4878 case UTT_IsTriviallyEqualityComparable:
4879 case UTT_CanPassInRegs:
4883 case UTT_HasNothrowAssign:
4884 case UTT_HasNothrowMoveAssign:
4885 case UTT_HasNothrowConstructor:
4886 case UTT_HasNothrowCopy:
4887 case UTT_HasTrivialAssign:
4888 case UTT_HasTrivialMoveAssign:
4889 case UTT_HasTrivialDefaultConstructor:
4890 case UTT_HasTrivialMoveConstructor:
4891 case UTT_HasTrivialCopy:
4892 case UTT_HasTrivialDestructor:
4893 case UTT_HasVirtualDestructor:
4899 case UTT_IsDestructible:
4900 case UTT_IsNothrowDestructible:
4901 case UTT_IsTriviallyDestructible:
4902 case UTT_HasUniqueObjectRepresentations:
4907 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
4918 if ((RD->*HasTrivial)() && !(RD->*HasNonTrivial)())
4925 bool FoundOperator =
false;
4928 Op != OpEnd; ++Op) {
4929 if (isa<FunctionTemplateDecl>(*Op))
4933 if((Operator->*IsDesiredOp)()) {
4934 FoundOperator =
true;
4941 return FoundOperator;
4948 assert(!T->
isDependentType() &&
"Cannot evaluate traits of dependent type");
4952 default: llvm_unreachable(
"not a UTT");