Lines Matching +full:first +full:- +full:conversion +full:- +full:delay
1 //===--- SemaExprCXX.cpp - Semantic Analysis for Expressions --------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
63 // Convert the nested-name-specifier into a type. in getInheritingConstructorName()
65 switch (NNS->getKind()) { in getInheritingConstructorName()
68 Type = QualType(NNS->getAsType(), 0); in getInheritingConstructorName()
72 // Strip off the last layer of the nested-name-specifier and build a in getInheritingConstructorName()
74 assert(NNS->getAsIdentifier() == &Name && "not a constructor name"); in getInheritingConstructorName()
76 ElaboratedTypeKeyword::None, NNS->getPrefix(), NNS->getAsIdentifier()); in getInheritingConstructorName()
87 // final identifier in the qualified-id. in getInheritingConstructorName()
96 assert(CurClass && &II == CurClass->getIdentifier() && in getConstructorName()
102 if (CurClass->isDependentContext() && !EnteringContext && SS.getScopeRep()) { in getConstructorName()
111 // Find the injected-class-name declaration. Note that we make no attempt to in getConstructorName()
112 // diagnose cases where the injected-class-name is shadowed: the only in getConstructorName()
113 // declaration that can validly shadow the injected-class-name is a in getConstructorName()
114 // non-static data member, and if the class contains both a non-static data in getConstructorName()
115 // member and a constructor then it is ill-formed (we check that in in getConstructorName()
118 for (NamedDecl *ND : CurClass->lookup(&II)) { in getConstructorName()
120 if (RD && RD->isInjectedClassName()) { in getConstructorName()
126 if (!CurClass->isInvalidDecl()) { in getConstructorName()
153 // this appears to be ill-formed: in getDestructorName()
162 // s->N::S<int>::~S(); in getDestructorName()
168 // be interpreted as a correct destructor name, issuing off-by-default in getDestructorName()
171 // nested-name-specifier prefix, the complete nested-name-specifier, and in getDestructorName()
185 // pseudo-destructor-expression or a member access expression, and in getDestructorName()
190 auto CheckLookupResult = [&](LookupResult &Found) -> ParsedType { in getDestructorName()
191 auto IsAcceptableResult = [&](NamedDecl *D) -> bool { in getDestructorName()
192 auto *Type = dyn_cast<TypeDecl>(D->getUnderlyingDecl()); in getDestructorName()
196 if (SearchType.isNull() || SearchType->isDependentType()) in getDestructorName()
209 // found by both its injected-class-name and by the name in the enclosing in getDestructorName()
212 if (RD->isInjectedClassName()) in getDestructorName()
213 D = cast<NamedDecl>(RD->getParent()); in getDestructorName()
219 // As an extension, attempt to "fix" an ambiguity by erasing all non-type in getDestructorName()
220 // results, and all non-matching results if we have a search type. It's not in getDestructorName()
229 if (auto *TD = dyn_cast<TypeDecl>(D->getUnderlyingDecl())) in getDestructorName()
230 Diag(D->getLocation(), diag::note_destructor_type_here) in getDestructorName()
233 Diag(D->getLocation(), diag::note_destructor_nontype_here); in getDestructorName()
247 MarkAnyDeclReferenced(Type->getLocation(), Type, /*OdrUse=*/false); in getDestructorName()
259 auto LookupInObjectType = [&]() -> ParsedType { in getDestructorName()
263 IsDependent |= SearchType->isDependentType(); in getDestructorName()
273 auto LookupInNestedNameSpec = [&](CXXScopeSpec &LookupSS) -> ParsedType { in getDestructorName()
291 auto LookupInScope = [&]() -> ParsedType { in getDestructorName()
301 // In a qualified-id of the form in getDestructorName()
303 // nested-name-specifier[opt] type-name :: ~ type-name in getDestructorName()
305 // the second type-name is looked up in the same scope as the first. in getDestructorName()
307 // We interpret this as meaning that if you do a dual-scope lookup for the in getDestructorName()
308 // first name, you also do a dual-scope lookup for the second name, per in getDestructorName()
311 // If the id-expression in a class member access is a qualified-id of the in getDestructorName()
314 // class-name-or-namespace-name :: ... in getDestructorName()
316 // the class-name-or-namespace-name following the . or -> is first looked in getDestructorName()
319 // postfix-expression. in getDestructorName()
324 // If the unqualified-id is ~ type-name, the type-name is looked up in getDestructorName()
325 // in the context of the entire postfix-expression. If the type T in getDestructorName()
326 // of the object expression is of a class type C, the type-name is in getDestructorName()
330 // FIXME: The intent is unclear here. Should type-name::~type-name look in in getDestructorName()
331 // the scope anyway if it finds a non-matching name declared in the class? in getDestructorName()
333 // we retain? (Same question for p->~type-name().) in getDestructorName()
336 SS.isSet() ? SS.getScopeRep()->getPrefix() : nullptr) { in getDestructorName()
339 // nested-name-specifier type-name :: ~ type-name in getDestructorName()
341 // Look for the second type-name in the nested-name-specifier. in getDestructorName()
349 // type-name :: ~ type-name in getDestructorName()
350 // ~ type-name in getDestructorName()
365 // FIXME: What if we have no nested-name-specifier? in getDestructorName()
372 // The remaining cases are all non-standard extensions imitating the behavior in getDestructorName()
379 // nested-name-specifier :: ~ type-name in getDestructorName()
381 // also looks for type-name within the nested-name-specifier. in getDestructorName()
392 // nested-name-specifier type-name :: ~ type-name in getDestructorName()
394 // also looks for type-name in the scope. Unfortunately, we can't in getDestructorName()
395 // reasonably apply this fallback for dependent nested-name-specifiers. in getDestructorName()
396 if (SS.isValid() && SS.getScopeRep()->getPrefix()) { in getDestructorName()
400 Diag(FoundDecls.back()->getLocation(), diag::note_destructor_type_here) in getDestructorName()
413 // List types before non-types. in getDestructorName()
416 return isa<TypeDecl>(A->getUnderlyingDecl()) > in getDestructorName()
417 isa<TypeDecl>(B->getUnderlyingDecl()); in getDestructorName()
425 Destroyed = SearchType->getAsCXXRecordDecl(); in getDestructorName()
427 Destroyed = dyn_cast_or_null<CXXRecordDecl>(S->getEntity()); in getDestructorName()
430 Destroyed->getNameAsString()); in getDestructorName()
435 // FIXME: Attempt typo-correction? in getDestructorName()
439 if (auto *TD = dyn_cast<TypeDecl>(FoundDecls[0]->getUnderlyingDecl())) { in getDestructorName()
456 if (auto *TD = dyn_cast<TypeDecl>(FoundD->getUnderlyingDecl())) in getDestructorName()
457 Diag(FoundD->getLocation(), diag::note_destructor_type_here) in getDestructorName()
460 Diag(FoundD->getLocation(), diag::note_destructor_nontype_here) in getDestructorName()
484 if (!SearchType.isNull() && !SearchType->isDependentType() && in getDestructorTypeForDecltype()
501 // double operator"" _Bq(long double); // ill-formed, no diagnostic required in checkLiteralOperatorId()
503 ReservedIdentifierStatus Status = II->isReserved(PP.getLangOpts()); in checkLiteralOperatorId()
508 (StringRef("operator\"\"") + II->getName()).str()); in checkLiteralOperatorId()
521 switch (SS.getScopeRep()->getKind()) { in checkLiteralOperatorId()
526 // namespace scope. Therefore, this unqualified-id cannot name anything. in checkLiteralOperatorId()
548 // The top-level cv-qualifiers of the lvalue expression or the type-id in BuildCXXTypeId()
550 // If the type of the type-id is a class type or a reference to a class in BuildCXXTypeId()
551 // type, the class shall be completely-defined. in BuildCXXTypeId()
554 = Context.getUnqualifiedArrayType(Operand->getType().getNonReferenceType(), in BuildCXXTypeId()
556 if (T->getAs<RecordType>() && in BuildCXXTypeId()
560 if (T->isVariablyModifiedType()) in BuildCXXTypeId()
575 if (E && !E->isTypeDependent()) { in BuildCXXTypeId()
576 if (E->hasPlaceholderType()) { in BuildCXXTypeId()
582 QualType T = E->getType(); in BuildCXXTypeId()
583 if (const RecordType *RecordT = T->getAs<RecordType>()) { in BuildCXXTypeId()
584 CXXRecordDecl *RecordD = cast<CXXRecordDecl>(RecordT->getDecl()); in BuildCXXTypeId()
587 // shall be completely-defined. in BuildCXXTypeId()
595 if (RecordD->isPolymorphic() && E->isGLValue()) { in BuildCXXTypeId()
617 // [...] If the type of the type-id is a reference to a possibly in BuildCXXTypeId()
618 // cv-qualified type, the result of the typeid expression refers to a in BuildCXXTypeId()
619 // std::type_info object representing the cv-unqualified referenced in BuildCXXTypeId()
625 E = ImpCastExprToType(E, UnqualT, CK_NoOp, E->getValueKind()).get(); in BuildCXXTypeId()
629 if (E->getType()->isVariablyModifiedType()) in BuildCXXTypeId()
631 << E->getType()); in BuildCXXTypeId()
633 E->HasSideEffects(Context, WasEvaluated)) { in BuildCXXTypeId()
636 Diag(E->getExprLoc(), WasEvaluated in BuildCXXTypeId()
645 /// ActOnCXXTypeidOfType - Parse typeid( type-id ) or typeid (expression);
700 if (CTE->isPotentiallyEvaluated() && !CTE->isMostDerived(Context)) in ActOnCXXTypeid()
714 if (QT->isPointerType() || QT->isReferenceType()) in getUuidAttrOfType()
715 Ty = QT->getPointeeType().getTypePtr(); in getUuidAttrOfType()
716 else if (QT->isArrayType()) in getUuidAttrOfType()
717 Ty = Ty->getBaseElementTypeUnsafe(); in getUuidAttrOfType()
719 const auto *TD = Ty->getAsTagDecl(); in getUuidAttrOfType()
723 if (const auto *Uuid = TD->getMostRecentDecl()->getAttr<UuidAttr>()) { in getUuidAttrOfType()
730 const TemplateArgumentList &TAL = CTSD->getTemplateArgs(); in getUuidAttrOfType()
736 getUuidAttrOfType(SemaRef, TA.getAsDecl()->getType(), UuidAttrs); in getUuidAttrOfType()
749 if (!Operand->getType()->isDependentType()) { in BuildCXXUuidof()
751 getUuidAttrOfType(*this, Operand->getType(), UuidAttrs); in BuildCXXUuidof()
756 Guid = UuidAttrs.back()->getGuidDecl(); in BuildCXXUuidof()
766 if (!E->getType()->isDependentType()) { in BuildCXXUuidof()
767 if (E->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { in BuildCXXUuidof()
768 // A null pointer results in {00000000-0000-0000-0000-000000000000}. in BuildCXXUuidof()
772 getUuidAttrOfType(*this, E->getType(), UuidAttrs); in BuildCXXUuidof()
777 Guid = UuidAttrs.back()->getGuidDecl(); in BuildCXXUuidof()
785 /// ActOnCXXUuidof - Parse __uuidof( type-id ) or __uuidof (expression);
831 // - in a throw-expression, when the operand is the name of a in ActOnCXXThrow()
832 // non-volatile automatic object (other than a function or catch- in ActOnCXXThrow()
834 // innermost enclosing try-block (if there is one), the copy/move in ActOnCXXThrow()
838 if (const auto *DRE = dyn_cast<DeclRefExpr>(Ex->IgnoreParens())) in ActOnCXXThrow()
839 if (const auto *Var = dyn_cast<VarDecl>(DRE->getDecl()); in ActOnCXXThrow()
840 Var && Var->hasLocalStorage() && in ActOnCXXThrow()
841 !Var->getType().isVolatileQualified()) { in ActOnCXXThrow()
842 for (; S; S = S->getParent()) { in ActOnCXXThrow()
843 if (S->isDeclScope(Var)) { in ActOnCXXThrow()
849 if (S->getFlags() & in ActOnCXXThrow()
869 // Delay error emission for the OpenMP device code. in BuildCXXThrow()
882 if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope()) in BuildCXXThrow()
885 // Exceptions that escape a compute construct are ill-formed. in BuildCXXThrow()
887 getCurScope()->isInOpenACCComputeConstructScope(Scope::TryScope)) in BuildCXXThrow()
891 if (Ex && !Ex->isTypeDependent()) { in BuildCXXThrow()
899 // - in a throw-expression, when the operand is the name of a in BuildCXXThrow()
900 // non-volatile automatic object (other than a function or in BuildCXXThrow()
901 // catch-clause in BuildCXXThrow()
903 // innermost enclosing try-block (if there is one), the copy/move in BuildCXXThrow()
910 QualType ExceptionObjectTy = Context.getExceptionObjectType(Ex->getType()); in BuildCXXThrow()
922 // PPC MMA non-pointer types are not allowed as throw expr types. in BuildCXXThrow()
924 PPC().CheckPPCMMAType(Ex->getType(), Ex->getBeginLoc()); in BuildCXXThrow()
936 for (const CXXBaseSpecifier &BS : RD->bases()) { in collectPublicBases()
937 CXXRecordDecl *BaseDecl = BS.getType()->getAsCXXRecordDecl(); in collectPublicBases()
939 // Virtual bases constitute the same subobject. Non-virtual bases are in collectPublicBases()
982 // to an incomplete type other than (cv) void the program is ill-formed. in CheckCXXThrowOperand()
985 if (const PointerType* Ptr = Ty->getAs<PointerType>()) { in CheckCXXThrowOperand()
986 Ty = Ptr->getPointeeType(); in CheckCXXThrowOperand()
992 Diag(ThrowLoc, diag::err_wasm_reftype_tc) << 0 << E->getSourceRange(); in CheckCXXThrowOperand()
998 Diag(ThrowLoc, diag::err_wasm_table_art) << 2 << E->getSourceRange(); in CheckCXXThrowOperand()
1002 if (!isPointer || !Ty->isVoidType()) { in CheckCXXThrowOperand()
1006 E->getSourceRange())) in CheckCXXThrowOperand()
1009 if (!isPointer && Ty->isSizelessType()) { in CheckCXXThrowOperand()
1010 Diag(ThrowLoc, diag::err_throw_sizeless) << Ty << E->getSourceRange(); in CheckCXXThrowOperand()
1020 CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); in CheckCXXThrowOperand()
1033 if (!RD->hasIrrelevantDestructor()) { in CheckCXXThrowOperand()
1035 MarkFunctionReferenced(E->getExprLoc(), Destructor); in CheckCXXThrowOperand()
1036 CheckDestructorAccess(E->getExprLoc(), Destructor, in CheckCXXThrowOperand()
1038 if (DiagnoseUseOfDecl(Destructor, E->getExprLoc())) in CheckCXXThrowOperand()
1045 // if the object is caught by value and has a non-trivial copy constructor. in CheckCXXThrowOperand()
1059 if (!CD || CD->isDeleted()) in CheckCXXThrowOperand()
1063 MarkFunctionReferenced(E->getExprLoc(), CD); in CheckCXXThrowOperand()
1067 if (CD->isTrivial()) in CheckCXXThrowOperand()
1070 // The copy constructor is non-trivial, create a mapping from this class in CheckCXXThrowOperand()
1073 // particular throw-site. Lookup will be performed at the catch-site to in CheckCXXThrowOperand()
1080 for (unsigned I = 1, E = CD->getNumParams(); I != E; ++I) { in CheckCXXThrowOperand()
1081 if (CheckCXXDefaultArgExpr(ThrowLoc, CD, CD->getParamDecl(I))) in CheckCXXThrowOperand()
1102 if (CXXDestructorDecl *Dtor = RD->getDestructor()) { in CheckCXXThrowOperand()
1103 auto Ty = Dtor->getType(); in CheckCXXThrowOperand()
1104 if (auto *FT = Ty.getTypePtr()->getAs<FunctionProtoType>()) { in CheckCXXThrowOperand()
1105 if (!isUnresolvedExceptionSpec(FT->getExceptionSpecType()) && in CheckCXXThrowOperand()
1106 !FT->isNothrow()) in CheckCXXThrowOperand()
1119 QualType ClassType = ThisTy->getPointeeType(); in adjustCVQualifiersForCXXThisWithinLambda()
1124 // the outermost lambda, checking if '*this' is ever captured by copy - since in adjustCVQualifiersForCXXThisWithinLambda()
1125 // that could change the cv-qualifiers of the '*this' object. in adjustCVQualifiersForCXXThisWithinLambda()
1126 // The object referred to by '*this' starts out with the cv-qualifiers of its in adjustCVQualifiersForCXXThisWithinLambda()
1128 // outward checking to see if any lambda performs a by-copy capture of '*this' in adjustCVQualifiersForCXXThisWithinLambda()
1129 // - and if so, any nested lambda must respect the 'constness' of that in adjustCVQualifiersForCXXThisWithinLambda()
1139 // operator (which might even be instantiated at the end of the TU) - at which in adjustCVQualifiersForCXXThisWithinLambda()
1141 // reliably - we use a two pronged approach to walk through all the lexically in adjustCVQualifiersForCXXThisWithinLambda()
1145 // a Lambda (i.e. LambdaScopeInfo) AND each LSI's 'closure-type' is lexically in adjustCVQualifiersForCXXThisWithinLambda()
1146 // enclosed by the call-operator of the LSI below it on the stack (while in adjustCVQualifiersForCXXThisWithinLambda()
1160 I-- && isa<LambdaScopeInfo>(FunctionScopes[I]) && in adjustCVQualifiersForCXXThisWithinLambda()
1161 (!CurLSI || !CurLSI->Lambda || CurLSI->Lambda->getDeclContext() == in adjustCVQualifiersForCXXThisWithinLambda()
1162 cast<LambdaScopeInfo>(FunctionScopes[I])->CallOperator); in adjustCVQualifiersForCXXThisWithinLambda()
1166 if (!CurLSI->isCXXThisCaptured()) in adjustCVQualifiersForCXXThisWithinLambda()
1169 auto C = CurLSI->getCXXThisCapture(); in adjustCVQualifiersForCXXThisWithinLambda()
1172 if (CurLSI->lambdaCaptureShouldBeConst()) in adjustCVQualifiersForCXXThisWithinLambda()
1182 assert(isGenericLambdaCallOperatorSpecialization(CurLSI->CallOperator) && in adjustCVQualifiersForCXXThisWithinLambda()
1183 "While computing 'this' capture-type for a generic lambda, when we " in adjustCVQualifiersForCXXThisWithinLambda()
1185 "lambda-call-operator we must be (i.e. Current LSI) in a generic " in adjustCVQualifiersForCXXThisWithinLambda()
1187 assert(CurDC == getLambdaAwareParentOfDeclContext(CurLSI->CallOperator)); in adjustCVQualifiersForCXXThisWithinLambda()
1193 for (auto &&C : Closure->captures()) { in adjustCVQualifiersForCXXThisWithinLambda()
1197 if (Closure->getLambdaCallOperator()->isConst()) in adjustCVQualifiersForCXXThisWithinLambda()
1207 CXXRecordDecl *Closure = cast<CXXRecordDecl>(CurDC->getParent()); in adjustCVQualifiersForCXXThisWithinLambda()
1215 Closure = isLambdaCallOperator(Closure->getParent()) in adjustCVQualifiersForCXXThisWithinLambda()
1216 ? cast<CXXRecordDecl>(Closure->getParent()->getParent()) in adjustCVQualifiersForCXXThisWithinLambda()
1228 if (method && method->isImplicitObjectMemberFunction()) in getCurrentThisType()
1229 ThisTy = method->getThisType().getNonReferenceType(); in getCurrentThisType()
1239 // There are no cv-qualifiers for 'this' within default initializers, in getCurrentThisType()
1244 // If we are within a lambda's call operator, the cv-qualifiers of 'this' in getCurrentThisType()
1264 Record = Template->getTemplatedDecl(); in CXXThisScopeRAII()
1274 this->Enabled = true; in CXXThisScopeRAII()
1285 SourceLocation DiagLoc = LSI->IntroducerRange.getEnd(); in buildLambdaThisCaptureFixit()
1286 assert(!LSI->isCXXThisCaptured()); in buildLambdaThisCaptureFixit()
1288 if (LSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_LambdaByval && in buildLambdaThisCaptureFixit()
1293 DiagLoc, LSI->NumExplicitCaptures > 0 ? ", this" : "this"); in buildLambdaThisCaptureFixit()
1307 : FunctionScopes.size() - 1; in CheckCXXThisCapture()
1310 // by the capturing-entity/closure (lambda/block/etc) at in CheckCXXThisCapture()
1311 // MaxFunctionScopesIndex-deep on the FunctionScopes stack. in CheckCXXThisCapture()
1313 // Note: The *enclosing object* can only be captured by-value by a in CheckCXXThisCapture()
1316 // Every other capture of the *enclosing object* results in its by-reference in CheckCXXThisCapture()
1321 // - 'L' has an explicit byref or byval capture of the *enclosing object* in CheckCXXThisCapture()
1322 // - or, 'L' has an implicit capture. in CheckCXXThisCapture()
1324 // -- there is no enclosing closure in CheckCXXThisCapture()
1325 // -- or, there is some enclosing closure 'E' that has already captured the in CheckCXXThisCapture()
1328 // -- or, every enclosing closure can implicitly capture the in CheckCXXThisCapture()
1333 for (int idx = MaxFunctionScopesIndex; idx >= 0; idx--) { in CheckCXXThisCapture()
1336 if (CSI->CXXThisCaptureIndex != 0) { in CheckCXXThisCapture()
1338 CSI->Captures[CSI->CXXThisCaptureIndex - 1].markUsed(BuildAndDiagnose); in CheckCXXThisCapture()
1342 if (LSI && isGenericLambdaCallOperatorSpecialization(LSI->CallOperator)) { in CheckCXXThisCapture()
1345 LSI->CallOperator->setInvalidDecl(); in CheckCXXThisCapture()
1353 if (CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_LambdaByref || in CheckCXXThisCapture()
1354 CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_LambdaByval || in CheckCXXThisCapture()
1355 CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_Block || in CheckCXXThisCapture()
1356 CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_CapturedRegion || in CheckCXXThisCapture()
1358 // Regarding (Explicit && idx == MaxFunctionScopesIndex): only the first in CheckCXXThisCapture()
1368 LSI->CallOperator->setInvalidDecl(); in CheckCXXThisCapture()
1382 // (including implicit by-reference captures in any enclosing closures). in CheckCXXThisCapture()
1385 // the capture (i.e. first iteration through the loop below). Ignore it for in CheckCXXThisCapture()
1395 --idx, --NumCapturingClosures) { in CheckCXXThisCapture()
1400 QualType CaptureType = ByCopy ? ThisTy->getPointeeType() : ThisTy; in CheckCXXThisCapture()
1403 CSI->addThisCapture(isNested, Loc, CaptureType, ByCopy); in CheckCXXThisCapture()
1411 // implicit object member function is invoked or a non-static in ActOnCXXThis()
1428 // "pointer to cv-qualifier-seq X" wherever X is the current class between in CheckCXXThisType()
1429 // the optional cv-qualifier-seq and the end of the function-definition, in CheckCXXThisType()
1430 // member-declarator, or declarator. It shall not appear within the in CheckCXXThisType()
1437 if (Method && Method->isExplicitObjectMemberFunction()) { in CheckCXXThisType()
1455 CheckCXXThisCapture(This->getExprLoc()); in MarkThisReferenced()
1456 if (This->isTypeDependent()) in MarkThisReferenced()
1460 // object parameter, and mark it as type-dependent as well if so. in MarkThisReferenced()
1467 if (LSI->Lambda && !LSI->Lambda->Encloses(CurContext) && in MarkThisReferenced()
1468 LSI->AfterParameterList) in MarkThisReferenced()
1475 if (LSI->isCXXThisCaptured()) { in MarkThisReferenced()
1476 if (!LSI->getCXXThisCapture().isCopyCapture()) in MarkThisReferenced()
1479 const auto *MD = LSI->CallOperator; in MarkThisReferenced()
1480 if (MD->getType().isNull()) in MarkThisReferenced()
1483 const auto *Ty = MD->getType()->getAs<FunctionProtoType>(); in MarkThisReferenced()
1484 return Ty && MD->isExplicitObjectMemberFunction() && in MarkThisReferenced()
1485 Ty->getParamType(0)->isDependentType(); in MarkThisReferenced()
1491 This->setCapturedByCopyInLambdaWithExplicitObjectParameter(IsDependent); in MarkThisReferenced()
1502 CXXRecordDecl *Class = BaseType->getAsCXXRecordDecl(); in isThisOutsideMemberFunctionBody()
1503 return Class && Class->isBeingDefined(); in isThisOutsideMemberFunctionBody()
1522 // Avoid creating a non-type-dependent expression that contains typos. in ActOnCXXTypeConstructExpr()
1523 // Non-type-dependent expressions are liable to be discarded without in ActOnCXXTypeConstructExpr()
1525 if (!Result.isInvalid() && Result.get()->isInstantiationDependent() && in ActOnCXXTypeConstructExpr()
1526 !Result.get()->isTypeDependent()) in ActOnCXXTypeConstructExpr()
1529 Result = CreateRecoveryExpr(TInfo->getTypeLoc().getBeginLoc(), in ActOnCXXTypeConstructExpr()
1540 QualType Ty = TInfo->getType(); in BuildCXXTypeConstructExpr()
1541 SourceLocation TyBeginLoc = TInfo->getTypeLoc().getBeginLoc(); in BuildCXXTypeConstructExpr()
1565 DeducedType *Deduced = Ty->getContainedDeducedType(); in BuildCXXTypeConstructExpr()
1566 if (Deduced && !Deduced->isDeduced() && in BuildCXXTypeConstructExpr()
1573 } else if (Deduced && !Deduced->isDeduced()) { in BuildCXXTypeConstructExpr()
1577 Inits = MultiExprArg(ILE->getInits(), ILE->getNumInits()); in BuildCXXTypeConstructExpr()
1585 return ExprError(Diag(FirstBad->getBeginLoc(), in BuildCXXTypeConstructExpr()
1590 if (Ty->getAs<AutoType>()) in BuildCXXTypeConstructExpr()
1596 Diag(Deduce->getBeginLoc(), diag::err_auto_expr_init_paren_braces) in BuildCXXTypeConstructExpr()
1599 TemplateDeductionInfo Info(Deduce->getExprLoc()); in BuildCXXTypeConstructExpr()
1601 DeduceAutoType(TInfo->getTypeLoc(), Deduce, DeducedType, Info); in BuildCXXTypeConstructExpr()
1605 << Ty << Deduce->getType() << FullRange in BuildCXXTypeConstructExpr()
1606 << Deduce->getSourceRange()); in BuildCXXTypeConstructExpr()
1616 if (Ty->isDependentType() || CallExpr::hasAnyTypeDependentArguments(Exprs)) in BuildCXXTypeConstructExpr()
1623 // conversion expression is equivalent (in definedness, and if defined in in BuildCXXTypeConstructExpr()
1634 if (Ty->isArrayType()) { in BuildCXXTypeConstructExpr()
1645 if (Ty->isFunctionType()) in BuildCXXTypeConstructExpr()
1652 if (!Ty->isVoidType() && in BuildCXXTypeConstructExpr()
1658 // result object is direct-initialized (11.6) with the initializer. in BuildCXXTypeConstructExpr()
1667 Inner = BTE->getSubExpr(); in BuildCXXTypeConstructExpr()
1669 CE && CE->isImmediateInvocation()) in BuildCXXTypeConstructExpr()
1670 Inner = CE->getSubExpr(); in BuildCXXTypeConstructExpr()
1675 // the syntactic form of a functional-style cast that was used here. in BuildCXXTypeConstructExpr()
1681 QualType ResultType = Result.get()->getType(); in BuildCXXTypeConstructExpr()
1705 Method->getDeclContext()->lookup(Method->getDeclName()); in isUsualDeallocationFunction()
1717 bool Result = Method->isUsualDeallocationFunction(PreventedBy); in isUsualDeallocationFunction()
1722 // In case of CUDA, return true if none of the 1-argument deallocator in isUsualDeallocationFunction()
1725 assert(FD->getNumParams() == 1 && in isUsualDeallocationFunction()
1726 "Only single-operand functions should be in PreventedBy"); in isUsualDeallocationFunction()
1731 /// Determine whether the given function is a non-placement
1737 if (FD->getOverloadedOperator() != OO_Delete && in isNonPlacementDeallocationFunction()
1738 FD->getOverloadedOperator() != OO_Array_Delete) in isNonPlacementDeallocationFunction()
1743 if (S.getLangOpts().SizedDeallocation && UsualParams < FD->getNumParams() && in isNonPlacementDeallocationFunction()
1745 FD->getParamDecl(UsualParams)->getType(), in isNonPlacementDeallocationFunction()
1749 if (S.getLangOpts().AlignedAllocation && UsualParams < FD->getNumParams() && in isNonPlacementDeallocationFunction()
1751 FD->getParamDecl(UsualParams)->getType(), in isNonPlacementDeallocationFunction()
1755 return UsualParams == FD->getNumParams(); in isNonPlacementDeallocationFunction()
1762 : Found(Found), FD(dyn_cast<FunctionDecl>(Found->getUnderlyingDecl())), in UsualDeallocFnInfo()
1769 if (FD->isDestroyingOperatorDelete()) { in UsualDeallocFnInfo()
1774 if (NumBaseParams < FD->getNumParams() && in UsualDeallocFnInfo()
1776 FD->getParamDecl(NumBaseParams)->getType(), in UsualDeallocFnInfo()
1782 if (NumBaseParams < FD->getNumParams() && in UsualDeallocFnInfo()
1783 FD->getParamDecl(NumBaseParams)->getType()->isAlignValT()) { in UsualDeallocFnInfo()
1799 // A destroying operator delete is preferred over a non-destroying in isBetterThan()
1805 // If the type has new-extended alignment, a function with a parameter in isBetterThan()
1825 /// Determine whether a type has new-extended alignment. This may be called when
1826 /// the type is incomplete (for a delete-expression with an incomplete pointee
1836 /// deallocation functions (either global or class-scope).
1851 BestFns->push_back(Info); in resolveDeallocationOverload()
1858 // If more than one preferred function is found, all non-preferred in resolveDeallocationOverload()
1861 BestFns->clear(); in resolveDeallocationOverload()
1865 BestFns->push_back(Info); in resolveDeallocationOverload()
1874 /// trivially-destructible).
1878 allocType->getBaseElementTypeUnsafe()->getAs<RecordType>(); in doesUsualArrayDeleteWantSize()
1886 S.LookupQualifiedName(ops, record->getDecl()); in doesUsualArrayDeleteWantSize()
1939 if (!NumElts->isTypeDependent() && !NumElts->isValueDependent()) { in ActOnCXXNew()
1943 // C++1y [expr.new]p6: Every constant-expression in a noptr-new-declarator in ActOnCXXNew()
1965 QualType AllocType = TInfo->getType(); in ActOnCXXNew()
1971 DirectInitRange = List->getSourceRange(); in ActOnCXXNew()
1984 return IsCPlusPlus20 || PLE->getNumExprs() == 0; in isLegalArrayNewInitializer()
1988 return !CCE->isListInitialization() && in isLegalArrayNewInitializer()
1989 CCE->getConstructor()->isDefaultConstructor(); in isLegalArrayNewInitializer()
2038 SourceRange TypeRange = AllocTypeInfo->getTypeLoc().getSourceRange(); in BuildCXXNew()
2057 "paren init for non-call init"); in BuildCXXNew()
2058 Exprs = MultiExprArg(List->getExprs(), List->getNumExprs()); in BuildCXXNew()
2062 // A new-expression that creates an object of type T initializes that in BuildCXXNew()
2066 // - If the new-initializer is omitted, the object is default- in BuildCXXNew()
2071 // - Otherwise, the new-initializer is interpreted according to the in BuildCXXNew()
2072 // initialization rules of 8.5 for direct-initialization. in BuildCXXNew()
2079 Initializer->getBeginLoc(), in BuildCXXNew()
2080 Initializer->getEndLoc()); in BuildCXXNew()
2086 auto *Deduced = AllocType->getContainedDeducedType(); in BuildCXXNew()
2087 if (Deduced && !Deduced->isDeduced() && in BuildCXXNew()
2091 Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.getBegin(), in BuildCXXNew()
2094 << (*ArraySize ? (*ArraySize)->getSourceRange() : TypeRange)); in BuildCXXNew()
2102 } else if (Deduced && !Deduced->isDeduced()) { in BuildCXXNew()
2107 Inits = MultiExprArg(ILE->getInits(), ILE->getNumInits()); in BuildCXXNew()
2115 return ExprError(Diag(FirstBad->getBeginLoc(), in BuildCXXNew()
2120 Diag(Initializer->getBeginLoc(), diag::ext_auto_new_list_init) in BuildCXXNew()
2125 Diag(Deduce->getBeginLoc(), diag::err_auto_expr_init_paren_braces) in BuildCXXNew()
2128 TemplateDeductionInfo Info(Deduce->getExprLoc()); in BuildCXXNew()
2130 DeduceAutoType(AllocTypeInfo->getTypeLoc(), Deduce, DeducedType, Info); in BuildCXXNew()
2134 << AllocType << Deduce->getType() << TypeRange in BuildCXXNew()
2135 << Deduce->getSourceRange()); in BuildCXXNew()
2148 ArraySize = IntegerLiteral::Create(Context, Array->getSize(), in BuildCXXNew()
2151 AllocType = Array->getElementType(); in BuildCXXNew()
2164 AllocType->isObjCLifetimeType()) { in BuildCXXNew()
2166 AllocType->getObjCARCImplicitLifetime()); in BuildCXXNew()
2172 (*ArraySize)->getType()->isNonOverloadPlaceholderType()) { in BuildCXXNew()
2177 // C++98 5.3.4p6: "The expression in a direct-new-declarator shall have in BuildCXXNew()
2178 // integral or enumeration type with a non-negative value." in BuildCXXNew()
2180 // enumeration type, or a class type for which a single non-explicit in BuildCXXNew()
2181 // conversion function to integral or unscoped enumeration type exists. in BuildCXXNew()
2185 if (ArraySize && *ArraySize && !(*ArraySize)->isTypeDependent()) { in BuildCXXNew()
2194 (*ArraySize)->getType()->getAs<RecordType>()) in BuildCXXNew()
2195 // Diagnose the compatibility of this conversion. in BuildCXXNew()
2197 << (*ArraySize)->getType() << 0 << "'size_t'"; in BuildCXXNew()
2217 << T << ArraySize->getSourceRange(); in BuildCXXNew()
2227 return S.Diag(Conv->getLocation(), diag::note_array_size_conversion) in BuildCXXNew()
2228 << ConvTy->isEnumeralType() << ConvTy; in BuildCXXNew()
2238 return S.Diag(Conv->getLocation(), diag::note_array_size_conversion) in BuildCXXNew()
2239 << ConvTy->isEnumeralType() << ConvTy; in BuildCXXNew()
2249 << T << ConvTy->isEnumeralType() << ConvTy; in BuildCXXNew()
2260 QualType SizeType = (*ArraySize)->getType(); in BuildCXXNew()
2262 if (!SizeType->isIntegralOrUnscopedEnumerationType()) in BuildCXXNew()
2266 // The expression in a direct-new-declarator shall have integral type in BuildCXXNew()
2267 // with a non-negative value. in BuildCXXNew()
2273 // We've already performed any required implicit conversion to integer or in BuildCXXNew()
2279 (*ArraySize)->getIntegerConstantExpr(Context)) { in BuildCXXNew()
2280 if (Value->isSigned() && Value->isNegative()) { in BuildCXXNew()
2281 return ExprError(Diag((*ArraySize)->getBeginLoc(), in BuildCXXNew()
2283 << (*ArraySize)->getSourceRange()); in BuildCXXNew()
2286 if (!AllocType->isDependentType()) { in BuildCXXNew()
2291 Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large) in BuildCXXNew()
2292 << toString(*Value, 10) << (*ArraySize)->getSourceRange()); in BuildCXXNew()
2295 KnownArraySize = Value->getZExtValue(); in BuildCXXNew()
2297 // Can't have dynamic array size when the type-id is in parentheses. in BuildCXXNew()
2298 Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst) in BuildCXXNew()
2299 << (*ArraySize)->getSourceRange() in BuildCXXNew()
2313 AllocType->isDependentType() ? 0 : Context.getTypeAlign(AllocType); in BuildCXXNew()
2322 if (!AllocType->isDependentType() && in BuildCXXNew()
2333 if (ArraySize && !AllocType->isDependentType()) in BuildCXXNew()
2339 auto *Proto = OperatorNew->getType()->castAs<FunctionProtoType>(); in BuildCXXNew()
2340 VariadicCallType CallType = Proto->isVariadic() ? VariadicFunction in BuildCXXNew()
2344 // arguments. Skip the first parameter because we don't have a corresponding in BuildCXXNew()
2369 if (!ArraySize && !AllocType->isDependentType()) { in BuildCXXNew()
2370 // For non-array operator new, we only want to allocate one element. in BuildCXXNew()
2372 } else if (KnownArraySize && !AllocType->isDependentType()) { in BuildCXXNew()
2386 // Otherwise, if we failed to constant-fold the allocation size, we'll in BuildCXXNew()
2387 // just give up and pass-in something opaque, that isn't a null pointer. in BuildCXXNew()
2421 // Warn if the type is over-aligned and is being allocated by (unaligned) in BuildCXXNew()
2424 (OperatorNew->isImplicit() || in BuildCXXNew()
2425 (OperatorNew->getBeginLoc().isValid() && in BuildCXXNew()
2426 getSourceManager().isInSystemHeader(OperatorNew->getBeginLoc())))) { in BuildCXXNew()
2440 SourceRange InitRange(Exprs.front()->getBeginLoc(), in BuildCXXNew()
2441 Exprs.back()->getEndLoc()); in BuildCXXNew()
2448 if (!AllocType->isDependentType() && in BuildCXXNew()
2473 // FIXME: We should not create these in the first place. in BuildCXXNew()
2476 FullInit = Binder->getSubExpr(); in BuildCXXNew()
2484 auto *CAT = Context.getAsConstantArrayType(Initializer->getType()); in BuildCXXNew()
2489 Context, CAT->getSize(), Context.getSizeType(), TypeRange.getEnd()); in BuildCXXNew()
2492 << Initializer->getSourceRange(); in BuildCXXNew()
2520 if (AllocType->isFunctionType()) in CheckAllocatedType()
2523 else if (AllocType->isReferenceType()) in CheckAllocatedType()
2526 else if (!AllocType->isDependentType() && in CheckAllocatedType()
2533 else if (AllocType->isVariablyModifiedType()) in CheckAllocatedType()
2545 BaseAllocType->isObjCLifetimeType()) in CheckAllocatedType()
2564 NamedDecl *D = (*Alloc)->getUnderlyingDecl(); in resolveAllocationOverload()
2584 FunctionDecl *FnDecl = Best->Function; in resolveAllocationOverload()
2586 Best->FoundDecl) == Sema::AR_inaccessible) in resolveAllocationOverload()
2596 // new-extended alignment, the alignment argument is removed from the in resolveAllocationOverload()
2629 (Args[1]->getType()->isObjectPointerType() || in resolveAllocationOverload()
2630 Args[1]->getType()->isArrayType())) { in resolveAllocationOverload()
2648 return C.Function->getNumParams() > 1 && in resolveAllocationOverload()
2649 C.Function->getParamDecl(1)->getType()->isAlignValT(); in resolveAllocationOverload()
2657 AlignedCands = AlignedCandidates->CompleteCandidates( in resolveAllocationOverload()
2670 AlignedCandidates->NoteCandidates(S, AlignedArgs, AlignedCands, "", in resolveAllocationOverload()
2689 Candidates, Best->Function, Args); in resolveAllocationOverload()
2704 // --- Choosing an allocation function --- in FindAllocationFunctions()
2705 // C++ 5.3.4p8 - 14 & 18 in FindAllocationFunctions()
2711 // 3) The first argument is always size_t. Append the arguments from the in FindAllocationFunctions()
2739 // If the allocated type is a non-array type, the allocation in FindAllocationFunctions()
2754 // If the new-expression begins with a unary :: operator, the allocation in FindAllocationFunctions()
2758 if (AllocElemType->isRecordType() && NewScope != AFS_Global) in FindAllocationFunctions()
2759 LookupQualifiedName(R, AllocElemType->getAsCXXRecordDecl()); in FindAllocationFunctions()
2797 // We don't need an operator delete if we're running under -fno-exceptions. in FindAllocationFunctions()
2804 // non-array by resolveAllocationOverload. in FindAllocationFunctions()
2806 OperatorNew->getDeclName().getCXXOverloadedOperator() == OO_Array_New in FindAllocationFunctions()
2812 // If the new-expression begins with a unary :: operator, the in FindAllocationFunctions()
2820 if (AllocElemType->isRecordType() && DeleteScope != AFS_Global) { in FindAllocationFunctions()
2822 cast<CXXRecordDecl>(AllocElemType->castAs<RecordType>()->getDecl()); in FindAllocationFunctions()
2835 auto *FD = dyn_cast<FunctionDecl>(Filter.next()->getUnderlyingDecl()); in FindAllocationFunctions()
2836 if (FD && FD->isDestroyingOperatorDelete()) in FindAllocationFunctions()
2865 // parameter-declaration-clause is anything other than (size_t). in FindAllocationFunctions()
2867 // FIXME: Should (size_t, std::align_val_t) also be considered non-placement? in FindAllocationFunctions()
2869 // type uses the sized or non-sized form of aligned operator delete. in FindAllocationFunctions()
2870 bool isPlacementNew = !PlaceArgs.empty() || OperatorNew->param_size() != 1 || in FindAllocationFunctions()
2871 OperatorNew->isVariadic(); in FindAllocationFunctions()
2878 // (8.3.5), all parameter types except the first are in FindAllocationFunctions()
2886 auto *Proto = OperatorNew->getType()->castAs<FunctionProtoType>(); in FindAllocationFunctions()
2890 for (unsigned I = 1, N = Proto->getNumParams(); I < N; ++I) in FindAllocationFunctions()
2891 ArgTypes.push_back(Proto->getParamType(I)); in FindAllocationFunctions()
2895 EPI.Variadic = Proto->isVariadic(); in FindAllocationFunctions()
2906 dyn_cast<FunctionTemplateDecl>((*D)->getUnderlyingDecl())) { in FindAllocationFunctions()
2914 Fn = cast<FunctionDecl>((*D)->getUnderlyingDecl()); in FindAllocationFunctions()
2916 if (Context.hasSameType(adjustCCAndNoReturn(Fn->getType(), in FindAllocationFunctions()
2928 // For a non-placement allocation function, the normal deallocation in FindAllocationFunctions()
2932 // without a size_t argument, but prefers a non-member operator delete in FindAllocationFunctions()
2961 // is ill-formed. in FindAllocationFunctions()
2966 // Core issue, per mail to core reflector, 2016-10-09: in FindAllocationFunctions()
2968 // non-sized member operator delete, this isn't /really/ a sized in FindAllocationFunctions()
2983 : SourceRange(PlaceArgs.front()->getBeginLoc(), in FindAllocationFunctions()
2984 PlaceArgs.back()->getEndLoc()); in FindAllocationFunctions()
2986 if (!OperatorDelete->isImplicit()) in FindAllocationFunctions()
2987 Diag(OperatorDelete->getLocation(), diag::note_previous_decl) in FindAllocationFunctions()
2993 Matches[0].first); in FindAllocationFunctions()
3002 Diag(Match.second->getLocation(), in FindAllocationFunctions()
3063 getStdBadAlloc()->setImplicit(true); in DeclareGlobalNewDelete()
3068 getStdBadAlloc()->setModuleOwnershipKind( in DeclareGlobalNewDelete()
3070 getStdBadAlloc()->setLocalOwningModule(TheGlobalModuleFragment); in DeclareGlobalNewDelete()
3083 AlignValT->setModuleOwnershipKind( in DeclareGlobalNewDelete()
3085 AlignValT->setLocalOwningModule(TheGlobalModuleFragment); in DeclareGlobalNewDelete()
3088 AlignValT->setIntegerType(Context.getSizeType()); in DeclareGlobalNewDelete()
3089 AlignValT->setPromotionType(Context.getSizeType()); in DeclareGlobalNewDelete()
3090 AlignValT->setImplicit(true); in DeclareGlobalNewDelete()
3138 /// DeclareGlobalAllocationFunction - Declares a single implicit global
3146 DeclContext::lookup_result R = GlobalCtx->lookup(Name); in DeclareGlobalAllocationFunction()
3149 // Only look at non-template functions, as it is the predefined, in DeclareGlobalAllocationFunction()
3150 // non-templated allocation function we are trying to declare here. in DeclareGlobalAllocationFunction()
3152 if (Func->getNumParams() == Params.size()) { in DeclareGlobalAllocationFunction()
3154 for (auto *P : Func->parameters()) in DeclareGlobalAllocationFunction()
3156 Context.getCanonicalType(P->getType().getUnqualifiedType())); in DeclareGlobalAllocationFunction()
3159 // an unimported module. It either is an implicitly-declared global in DeclareGlobalAllocationFunction()
3161 Func->setVisibleDespiteOwningModule(); in DeclareGlobalAllocationFunction()
3196 Alloc->setImplicit(); in DeclareGlobalAllocationFunction()
3198 Alloc->setVisibleDespiteOwningModule(); in DeclareGlobalAllocationFunction()
3202 Alloc->addAttr( in DeclareGlobalAllocationFunction()
3203 ReturnsNonNullAttr::CreateImplicit(Context, Alloc->getLocation())); in DeclareGlobalAllocationFunction()
3216 Alloc->setModuleOwnershipKind( in DeclareGlobalAllocationFunction()
3218 Alloc->setLocalOwningModule(TheGlobalModuleFragment); in DeclareGlobalAllocationFunction()
3222 Alloc->addAttr(VisibilityAttr::CreateImplicit( in DeclareGlobalAllocationFunction()
3234 ParamDecls.back()->setImplicit(); in DeclareGlobalAllocationFunction()
3236 Alloc->setParams(ParamDecls); in DeclareGlobalAllocationFunction()
3238 Alloc->addAttr(ExtraAttr); in DeclareGlobalAllocationFunction()
3240 Context.getTranslationUnitDecl()->addDecl(Alloc); in DeclareGlobalAllocationFunction()
3248 // defined or re-declared independently. in DeclareGlobalAllocationFunction()
3264 // user-declared variadic operator delete or the enable_if attribute. We in FindUsualDeallocationFunction()
3283 // If there's no class-specific operator delete, look up the global in FindDeallocationFunctionForDestructor()
3284 // non-array delete. in FindDeallocationFunctionForDestructor()
3318 if (Operator->isDeleted()) { in FindDeallocationFunction()
3320 StringLiteral *Msg = Operator->getDeletedMessage(); in FindDeallocationFunction()
3322 << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef()); in FindDeallocationFunction()
3343 Diag(Match.FD->getLocation(), diag::note_member_declared_here) << Name; in FindDeallocationFunction()
3356 Diag(D->getUnderlyingDecl()->getLocation(), in FindDeallocationFunction()
3367 /// Checks whether delete-expression, and new-expression used for
3385 /// delete-expression was encountered.
3390 /// Checks whether pointee of a delete-expression is initialized with
3391 /// matching form of new-expression.
3394 /// point where delete-expression is encountered, then a warning will be
3396 /// delete-expression is seen, then member will be analyzed at the end of
3403 /// \param DeleteWasArrayForm Array form-ness of the delete-expression used
3407 /// List of mismatching new-expressions used for initialization of the pointee
3409 /// Indicates whether delete-expression was in array form.
3417 /// \param E Expression used for initializing pointee in delete-expression.
3418 /// E can be a single-element \c InitListExpr consisting of new-expression.
3421 /// \c new either by the member initializer or in-class initialization.
3442 /// constructor isn't defined at the point where delete-expression is seen, or
3449 /// in-class initializer.
3457 assert(DE && "Expected delete-expression"); in analyzeDeleteExpr()
3458 IsArrayForm = DE->isArrayForm(); in analyzeDeleteExpr()
3459 const Expr *E = DE->getArgument()->IgnoreParenImpCasts(); in analyzeDeleteExpr()
3472 E = E->IgnoreParenImpCasts(); in getNewExprFromInitListOrExpr()
3474 if (ILE->getNumInits() == 1) in getNewExprFromInitListOrExpr()
3475 E = dyn_cast<const CXXNewExpr>(ILE->getInit(0)->IgnoreParenImpCasts()); in getNewExprFromInitListOrExpr()
3484 if (Field == CI->getMember() && in hasMatchingNewInCtorInit()
3485 (NE = getNewExprFromInitListOrExpr(CI->getInit()))) { in hasMatchingNewInCtorInit()
3486 if (NE->isArray() == IsArrayForm) in hasMatchingNewInCtorInit()
3496 if (CD->isImplicit()) in hasMatchingNewInCtor()
3499 if (!CD->isThisDeclarationADefinition() && !CD->isDefined(Definition)) { in hasMatchingNewInCtor()
3503 for (const auto *CI : cast<const CXXConstructorDecl>(Definition)->inits()) { in hasMatchingNewInCtor()
3513 const Expr *InitExpr = Field->getInClassInitializer(); in analyzeInClassInitializer()
3517 if (NE->isArray() != IsArrayForm) { in analyzeInClassInitializer()
3529 this->Field = Field; in analyzeField()
3531 const CXXRecordDecl *RD = cast<const CXXRecordDecl>(Field->getParent()); in analyzeField()
3532 for (const auto *CD : RD->ctors()) { in analyzeField()
3540 return Field->hasInClassInitializer() ? analyzeInClassInitializer() in analyzeField()
3547 if (FieldDecl *F = dyn_cast<FieldDecl>(ME->getMemberDecl())) in analyzeMemberExpr()
3554 if (const VarDecl *VD = dyn_cast<const VarDecl>(D->getDecl())) { in hasMatchingVarInit()
3555 if (VD->hasInit() && (NE = getNewExprFromInitListOrExpr(VD->getInit())) && in hasMatchingVarInit()
3556 NE->isArray() != IsArrayForm) { in hasMatchingVarInit()
3581 SemaRef.Diag(NE->getExprLoc(), diag::note_allocated_here) in DiagnoseMismatchedNewDelete()
3592 DiagnoseMismatchedNewDelete(*this, DE->getBeginLoc(), Detector); in AnalyzeDeleteExprMismatch()
3597 std::make_pair(DE->getBeginLoc(), DE->isArrayForm())); in AnalyzeDeleteExprMismatch()
3627 // non-explicit conversion function to a pointer type. The result has type in ActOnCXXDelete()
3637 if (!Ex.get()->isTypeDependent()) { in ActOnCXXDelete()
3638 // Perform lvalue-to-rvalue cast, if needed. in ActOnCXXDelete()
3643 QualType Type = Ex.get()->getType(); in ActOnCXXDelete()
3652 if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>()) in ActOnCXXDelete()
3653 if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType()) in ActOnCXXDelete()
3676 return S.Diag(Conv->getLocation(), diag::note_delete_conversion) in ActOnCXXDelete()
3687 return S.Diag(Conv->getLocation(), diag::note_delete_conversion) in ActOnCXXDelete()
3694 llvm_unreachable("conversion functions are permitted"); in ActOnCXXDelete()
3701 Type = Ex.get()->getType(); in ActOnCXXDelete()
3707 QualType Pointee = Type->castAs<PointerType>()->getPointeeType(); in ActOnCXXDelete()
3712 return Diag(Ex.get()->getBeginLoc(), in ActOnCXXDelete()
3718 if (Pointee->isVoidType() && !isSFINAEContext()) { in ActOnCXXDelete()
3719 // The C++ standard bans deleting a pointer to a non-object type, which in ActOnCXXDelete()
3726 << Ex.get()->getSourceRange(); in ActOnCXXDelete()
3727 } else if (Pointee->isFunctionType() || Pointee->isVoidType() || in ActOnCXXDelete()
3728 Pointee->isSizelessType()) { in ActOnCXXDelete()
3730 << Type << Ex.get()->getSourceRange()); in ActOnCXXDelete()
3731 } else if (!Pointee->isDependentType()) { in ActOnCXXDelete()
3739 if (const RecordType *RT = PointeeElem->getAs<RecordType>()) in ActOnCXXDelete()
3740 PointeeRD = cast<CXXRecordDecl>(RT->getDecl()); in ActOnCXXDelete()
3744 if (Pointee->isArrayType() && !ArrayForm) { in ActOnCXXDelete()
3746 << Type << Ex.get()->getSourceRange() in ActOnCXXDelete()
3778 if (!PointeeRD->hasIrrelevantDestructor()) in ActOnCXXDelete()
3786 CheckVirtualDtorCall(PointeeRD->getDestructor(), StartLoc, in ActOnCXXDelete()
3816 CheckDestructorAccess(Ex.get()->getExprLoc(), Dtor, in ActOnCXXDelete()
3818 IsVirtualDelete = Dtor->isVirtual(); in ActOnCXXDelete()
3824 // Convert the operand to the type of the first parameter of operator in ActOnCXXDelete()
3826 // delete that we are going to call (non-virtually); converting to void* in ActOnCXXDelete()
3828 QualType ParamType = OperatorDelete->getParamDecl(0)->getType(); in ActOnCXXDelete()
3829 if (!IsVirtualDelete && !ParamType->getPointeeType()->isVoidType()) { in ActOnCXXDelete()
3832 // Qualifiers are irrelevant to this conversion; we're only looking in ActOnCXXDelete()
3859 LookupResult R(S, NewName, TheCall->getBeginLoc(), Sema::LookupOrdinaryName); in resolveBuiltinNewDeleteOverload()
3867 SmallVector<Expr *, 8> Args(TheCall->arguments()); in resolveBuiltinNewDeleteOverload()
3874 NamedDecl *D = (*FnOvl)->getUnderlyingDecl(); in resolveBuiltinNewDeleteOverload()
3889 SourceRange Range = TheCall->getSourceRange(); in resolveBuiltinNewDeleteOverload()
3896 FunctionDecl *FnDecl = Best->Function; in resolveBuiltinNewDeleteOverload()
3900 if (!FnDecl->isReplaceableGlobalAllocationFunction()) { in resolveBuiltinNewDeleteOverload()
3903 S.Diag(FnDecl->getLocation(), diag::note_non_usual_function_declared_here) in resolveBuiltinNewDeleteOverload()
3904 << R.getLookupName() << FnDecl->getSourceRange(); in resolveBuiltinNewDeleteOverload()
3930 Candidates, Best->Function, Args); in resolveBuiltinNewDeleteOverload()
3940 Diag(TheCall->getExprLoc(), diag::err_builtin_requires_language) in BuiltinOperatorNewDeleteOverloaded()
3955 DiagnoseUseOfDecl(OperatorNewOrDelete, TheCall->getExprLoc()); in BuiltinOperatorNewDeleteOverloaded()
3956 MarkFunctionReferenced(TheCall->getExprLoc(), OperatorNewOrDelete); in BuiltinOperatorNewDeleteOverloaded()
3958 TheCall->setType(OperatorNewOrDelete->getReturnType()); in BuiltinOperatorNewDeleteOverloaded()
3959 for (unsigned i = 0; i != TheCall->getNumArgs(); ++i) { in BuiltinOperatorNewDeleteOverloaded()
3960 QualType ParamTy = OperatorNewOrDelete->getParamDecl(i)->getType(); in BuiltinOperatorNewDeleteOverloaded()
3964 Entity, TheCall->getArg(i)->getBeginLoc(), TheCall->getArg(i)); in BuiltinOperatorNewDeleteOverloaded()
3967 TheCall->setArg(i, Arg.get()); in BuiltinOperatorNewDeleteOverloaded()
3969 auto Callee = dyn_cast<ImplicitCastExpr>(TheCall->getCallee()); in BuiltinOperatorNewDeleteOverloaded()
3970 assert(Callee && Callee->getCastKind() == CK_BuiltinFnToFnPtr && in BuiltinOperatorNewDeleteOverloaded()
3972 Callee->setType(OperatorNewOrDelete->getType()); in BuiltinOperatorNewDeleteOverloaded()
3981 if (!dtor || dtor->isVirtual() || !CallCanBeVirtual || isUnevaluatedContext()) in CheckVirtualDtorCall()
3985 // In the first alternative (delete object), if the static type of the in CheckVirtualDtorCall()
3991 const CXXRecordDecl *PointeeRD = dtor->getParent(); in CheckVirtualDtorCall()
3993 if (!PointeeRD->isPolymorphic() || PointeeRD->hasAttr<FinalAttr>()) in CheckVirtualDtorCall()
3999 if (getSourceManager().isInSystemHeader(PointeeRD->getLocation())) in CheckVirtualDtorCall()
4002 QualType ClassType = dtor->getFunctionObjectParameterType(); in CheckVirtualDtorCall()
4003 if (PointeeRD->isAbstract()) { in CheckVirtualDtorCall()
4036 if (ConditionVar->isInvalidDecl()) in CheckConditionVariable()
4039 QualType T = ConditionVar->getType(); in CheckConditionVariable()
4043 if (T->isFunctionType()) in CheckConditionVariable()
4044 return ExprError(Diag(ConditionVar->getLocation(), in CheckConditionVariable()
4046 << ConditionVar->getSourceRange()); in CheckConditionVariable()
4047 else if (T->isArrayType()) in CheckConditionVariable()
4048 return ExprError(Diag(ConditionVar->getLocation(), in CheckConditionVariable()
4050 << ConditionVar->getSourceRange()); in CheckConditionVariable()
4053 ConditionVar, ConditionVar->getType().getNonReferenceType(), VK_LValue, in CheckConditionVariable()
4054 ConditionVar->getLocation()); in CheckConditionVariable()
4074 // implicitly converted to type bool. If that conversion is ill-formed, the in CheckCXXBooleanCondition()
4075 // program is ill-formed. in CheckCXXBooleanCondition()
4086 if (!IsConstexpr || E.isInvalid() || E.get()->isValueDependent()) in CheckCXXBooleanCondition()
4101 From = Cast->getSubExpr(); in IsStringLiteralToNonConstPointerConversion()
4107 if (StringLiteral *StrLit = dyn_cast<StringLiteral>(From->IgnoreParens())) in IsStringLiteralToNonConstPointerConversion()
4108 if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) in IsStringLiteralToNonConstPointerConversion()
4110 = ToPtrType->getPointeeType()->getAs<BuiltinType>()) { in IsStringLiteralToNonConstPointerConversion()
4111 // This conversion is considered only when there is an in IsStringLiteralToNonConstPointerConversion()
4113 if (!ToPtrType->getPointeeType().hasQualifiers()) { in IsStringLiteralToNonConstPointerConversion()
4114 switch (StrLit->getKind()) { in IsStringLiteralToNonConstPointerConversion()
4121 return (ToPointeeType->getKind() == BuiltinType::Char_U || in IsStringLiteralToNonConstPointerConversion()
4122 ToPointeeType->getKind() == BuiltinType::Char_S); in IsStringLiteralToNonConstPointerConversion()
4175 assert(!From->getType()->isPointerType() && "Arg can't have pointer type!"); in BuildCXXCastArgument()
4187 // Record usage of conversion in an implicit cast. in BuildCXXCastArgument()
4188 Result = ImplicitCastExpr::Create(S.Context, Result.get()->getType(), in BuildCXXCastArgument()
4190 nullptr, Result.get()->getValueKind(), in BuildCXXCastArgument()
4205 !From->getType()->isRecordType()) in PerformImplicitConversion()
4223 assert(FD && "no conversion function for user-defined conversion seq"); in PerformImplicitConversion()
4227 // If the user-defined conversion is specified by a conversion function, in PerformImplicitConversion()
4228 // the initial standard conversion sequence converts the source type to in PerformImplicitConversion()
4229 // the implicit object parameter of the conversion function. in PerformImplicitConversion()
4230 BeforeToType = Context.getTagDeclType(Conv->getParent()); in PerformImplicitConversion()
4234 // Do no conversion if dealing with ... for the first conversion. in PerformImplicitConversion()
4236 // If the user-defined conversion is specified by a constructor, the in PerformImplicitConversion()
4237 // initial standard conversion sequence converts the source type to in PerformImplicitConversion()
4239 BeforeToType = Ctor->getParamDecl(0)->getType().getNonReferenceType(); in PerformImplicitConversion()
4242 // Watch out for ellipsis conversion. in PerformImplicitConversion()
4254 *this, From->getBeginLoc(), ToType.getNonReferenceType(), CastKind, in PerformImplicitConversion()
4264 // [...] the second standard conversion sequence of a user-defined in PerformImplicitConversion()
4265 // conversion sequence is not applied. in PerformImplicitConversion()
4274 ICS.DiagnoseAmbiguousConversion(*this, From->getExprLoc(), in PerformImplicitConversion()
4276 << From->getSourceRange()); in PerformImplicitConversion()
4281 llvm_unreachable("bad conversion"); in PerformImplicitConversion()
4285 CheckAssignmentConstraints(From->getExprLoc(), ToType, From->getType()); in PerformImplicitConversion()
4287 ConvTy == Compatible ? Incompatible : ConvTy, From->getExprLoc(), in PerformImplicitConversion()
4288 ToType, From->getType(), From, Action); in PerformImplicitConversion()
4289 assert(Diagnosed && "failed to diagnose bad conversion"); (void)Diagnosed; in PerformImplicitConversion()
4297 // adjustVectorType - Compute the intermediate cast type casting elements of the
4301 auto *ToVec = ToType->castAs<VectorType>(); in adjustVectorType()
4302 QualType ElType = ToVec->getElementType(); in adjustVectorType()
4305 if (!FromTy->isVectorType()) in adjustVectorType()
4307 auto *FromVec = FromTy->castAs<VectorType>(); in adjustVectorType()
4308 return Context.getExtVectorType(ElType, FromVec->getNumElements()); in adjustVectorType()
4321 // information that is computed when we try the implicit conversion initially, in PerformImplicitConversion()
4323 QualType FromType = From->getType(); in PerformImplicitConversion()
4327 assert(!ToType->isReferenceType()); in PerformImplicitConversion()
4357 if (DiagnoseUseOfDecl(Fn, From->getBeginLoc())) in PerformImplicitConversion()
4371 FromType = From->getType(); in PerformImplicitConversion()
4374 // If we're converting to an atomic type, first convert to the corresponding in PerformImplicitConversion()
4375 // non-atomic type. in PerformImplicitConversion()
4377 if (const AtomicType *ToAtomic = ToType->getAs<AtomicType>()) { in PerformImplicitConversion()
4379 ToType = ToAtomic->getValueType(); in PerformImplicitConversion()
4383 // Perform the first implicit conversion. in PerformImplicitConversion()
4384 switch (SCS.First) { in PerformImplicitConversion()
4386 if (const AtomicType *FromAtomic = FromType->getAs<AtomicType>()) { in PerformImplicitConversion()
4387 FromType = FromAtomic->getValueType().getUnqualifiedType(); in PerformImplicitConversion()
4395 assert(From->getObjectKind() != OK_ObjCProperty); in PerformImplicitConversion()
4401 FromType = From->getType(); in PerformImplicitConversion()
4427 llvm_unreachable("Improper first standard conversion"); in PerformImplicitConversion()
4430 // Perform the second implicit conversion in PerformImplicitConversion()
4463 if (ToType->isVectorType()) in PerformImplicitConversion()
4465 if (ElTy->isBooleanType()) { in PerformImplicitConversion()
4466 assert(FromType->castAs<EnumType>()->getDecl()->isFixed() && in PerformImplicitConversion()
4483 if (ToType->isVectorType()) in PerformImplicitConversion()
4493 QualType FromEl = From->getType()->castAs<ComplexType>()->getElementType(); in PerformImplicitConversion()
4494 QualType ToEl = ToType->castAs<ComplexType>()->getElementType(); in PerformImplicitConversion()
4496 if (FromEl->isRealFloatingType()) { in PerformImplicitConversion()
4497 if (ToEl->isRealFloatingType()) in PerformImplicitConversion()
4501 } else if (ToEl->isRealFloatingType()) { in PerformImplicitConversion()
4515 if (ToType->isVectorType()) in PerformImplicitConversion()
4517 if (ElTy->isRealFloatingType()) in PerformImplicitConversion()
4529 assert((FromType->isFixedPointType() || ToType->isFixedPointType()) && in PerformImplicitConversion()
4530 "Attempting implicit fixed point conversion without a fixed " in PerformImplicitConversion()
4532 if (FromType->isFloatingType()) in PerformImplicitConversion()
4536 else if (ToType->isFloatingType()) in PerformImplicitConversion()
4540 else if (FromType->isIntegralType(Context)) in PerformImplicitConversion()
4544 else if (ToType->isIntegralType(Context)) in PerformImplicitConversion()
4548 else if (ToType->isBooleanType()) in PerformImplicitConversion()
4559 From = ImpCastExprToType(From, ToType, CK_NoOp, From->getValueKind(), in PerformImplicitConversion()
4566 // Diagnose incompatible Objective-C conversions in PerformImplicitConversion()
4568 Diag(From->getBeginLoc(), in PerformImplicitConversion()
4570 << ToType << From->getType() << Action << From->getSourceRange() in PerformImplicitConversion()
4573 Diag(From->getBeginLoc(), in PerformImplicitConversion()
4575 << From->getType() << ToType << Action << From->getSourceRange() in PerformImplicitConversion()
4578 if (From->getType()->isObjCObjectPointerType() && in PerformImplicitConversion()
4579 ToType->isObjCObjectPointerType()) in PerformImplicitConversion()
4583 From->getType())) { in PerformImplicitConversion()
4585 Diag(From->getBeginLoc(), diag::err_arc_weak_unavailable_assign); in PerformImplicitConversion()
4587 Diag(From->getBeginLoc(), diag::err_arc_convesion_of_weak_unavailable) in PerformImplicitConversion()
4588 << (Action == AA_Casting) << From->getType() << ToType in PerformImplicitConversion()
4589 << From->getSourceRange(); in PerformImplicitConversion()
4592 // Defer address space conversion to the third conversion. in PerformImplicitConversion()
4593 QualType FromPteeType = From->getType()->getPointeeType(); in PerformImplicitConversion()
4594 QualType ToPteeType = ToType->getPointeeType(); in PerformImplicitConversion()
4601 if (ToType->isObjCObjectPointerType()) in PerformImplicitConversion()
4603 else if (ToType->isBlockPointerType()) in PerformImplicitConversion()
4637 // to up until this exact point. Attempt to lock-in it's inheritance model. in PerformImplicitConversion()
4639 (void)isCompleteType(From->getExprLoc(), From->getType()); in PerformImplicitConversion()
4640 (void)isCompleteType(From->getExprLoc(), ToType); in PerformImplicitConversion()
4649 // Perform half-to-boolean conversion via float. in PerformImplicitConversion()
4650 if (From->getType()->isHalfType()) { in PerformImplicitConversion()
4656 if (FromType->isVectorType()) { in PerformImplicitConversion()
4659 ElTy = FromType->castAs<VectorType>()->getElementType(); in PerformImplicitConversion()
4672 From->getType(), ToType.getNonReferenceType(), From->getBeginLoc(), in PerformImplicitConversion()
4673 From->getSourceRange(), &BasePath, CStyle)) in PerformImplicitConversion()
4677 CK_DerivedToBase, From->getValueKind(), in PerformImplicitConversion()
4705 // Case 1. x -> _Complex y in PerformImplicitConversion()
4706 if (const ComplexType *ToComplex = ToType->getAs<ComplexType>()) { in PerformImplicitConversion()
4707 QualType ElType = ToComplex->getElementType(); in PerformImplicitConversion()
4708 bool isFloatingComplex = ElType->isRealFloatingType(); in PerformImplicitConversion()
4710 // x -> y in PerformImplicitConversion()
4711 if (Context.hasSameUnqualifiedType(ElType, From->getType())) { in PerformImplicitConversion()
4713 } else if (From->getType()->isRealFloatingType()) { in PerformImplicitConversion()
4717 assert(From->getType()->isIntegerType()); in PerformImplicitConversion()
4721 // y -> _Complex y in PerformImplicitConversion()
4726 // Case 2. _Complex x -> y in PerformImplicitConversion()
4728 auto *FromComplex = From->getType()->castAs<ComplexType>(); in PerformImplicitConversion()
4729 QualType ElType = FromComplex->getElementType(); in PerformImplicitConversion()
4730 bool isFloatingComplex = ElType->isRealFloatingType(); in PerformImplicitConversion()
4732 // _Complex x -> x in PerformImplicitConversion()
4739 // x -> y in PerformImplicitConversion()
4742 } else if (ToType->isRealFloatingType()) { in PerformImplicitConversion()
4749 assert(ToType->isIntegerType()); in PerformImplicitConversion()
4761 ToType->castAs<BlockPointerType>()->getPointeeType().getAddressSpace(); in PerformImplicitConversion()
4763 FromType->castAs<BlockPointerType>()->getPointeeType().getAddressSpace(); in PerformImplicitConversion()
4782 "Improper transparent union conversion"); in PerformImplicitConversion()
4791 From->getValueKind()).get(); in PerformImplicitConversion()
4805 llvm_unreachable("Improper second standard conversion"); in PerformImplicitConversion()
4813 assert((!From->getType()->isMatrixType() && !ToType->isMatrixType()) && in PerformImplicitConversion()
4814 "Dimension conversion for matrix types is not implemented yet."); in PerformImplicitConversion()
4815 assert(ToType->isVectorType() && in PerformImplicitConversion()
4816 "Dimension conversion is only supported for vector types."); in PerformImplicitConversion()
4827 // Note: HLSL built-in vectors are ExtVectors. Since this truncates a in PerformImplicitConversion()
4830 assert(From->getType()->isExtVectorType() && ToType->isExtVectorType() && in PerformImplicitConversion()
4832 auto *FromVec = From->getType()->castAs<VectorType>(); in PerformImplicitConversion()
4833 auto *ToVec = ToType->castAs<VectorType>(); in PerformImplicitConversion()
4834 QualType ElType = FromVec->getElementType(); in PerformImplicitConversion()
4836 Context.getExtVectorType(ElType, ToVec->getNumElements()); in PerformImplicitConversion()
4838 From->getValueKind()) in PerformImplicitConversion()
4844 llvm_unreachable("Improper element standard conversion"); in PerformImplicitConversion()
4865 ExprValueKind VK = From->getValueKind(); in PerformImplicitConversion()
4868 if (ToType->isReferenceType() && in PerformImplicitConversion()
4869 ToType->getPointeeType().getAddressSpace() != in PerformImplicitConversion()
4870 From->getType().getAddressSpace()) in PerformImplicitConversion()
4873 if (ToType->isPointerType() && in PerformImplicitConversion()
4874 ToType->getPointeeType().getAddressSpace() != in PerformImplicitConversion()
4875 From->getType()->getPointeeType().getAddressSpace()) in PerformImplicitConversion()
4879 !ToType->getPointeeType().getQualifiers().hasUnaligned() && in PerformImplicitConversion()
4880 From->getType()->getPointeeType().getQualifiers().hasUnaligned()) { in PerformImplicitConversion()
4881 Diag(From->getBeginLoc(), diag::warn_imp_cast_drops_unaligned) in PerformImplicitConversion()
4891 Diag(From->getBeginLoc(), in PerformImplicitConversion()
4902 llvm_unreachable("Improper third standard conversion"); in PerformImplicitConversion()
4905 // If this conversion sequence involved a scalar -> atomic conversion, perform in PerformImplicitConversion()
4906 // that conversion now. in PerformImplicitConversion()
4909 ToAtomicType->castAs<AtomicType>()->getValueType(), From->getType())); in PerformImplicitConversion()
4918 if (ToType->isReferenceType() && From->isPRValue()) { in PerformImplicitConversion()
4925 // If this conversion sequence succeeded and involved implicitly converting a in PerformImplicitConversion()
4929 From->getBeginLoc()); in PerformImplicitConversion()
4940 if (!T->getType()->isVariableArrayType()) in DiagnoseVLAInCXXTypeTrait()
4943 S.Diag(T->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported) in DiagnoseVLAInCXXTypeTrait()
4970 // Fall-through in CheckUnaryTypeTraitTypeCompleteness()
5000 // Fall-through in CheckUnaryTypeTraitTypeCompleteness()
5018 // If T is a non-union class type, T shall be a complete type. in CheckUnaryTypeTraitTypeCompleteness()
5022 if (const auto *RD = ArgTy->getAsCXXRecordDecl()) in CheckUnaryTypeTraitTypeCompleteness()
5023 if (!RD->isUnion()) in CheckUnaryTypeTraitTypeCompleteness()
5032 if (ArgTy->getAsCXXRecordDecl()) in CheckUnaryTypeTraitTypeCompleteness()
5039 if (ArgTy->isArrayType() || ArgTy->isVoidType()) in CheckUnaryTypeTraitTypeCompleteness()
5076 ArgTy = QualType(ArgTy->getBaseElementTypeUnsafe(), 0); in CheckUnaryTypeTraitTypeCompleteness()
5084 if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType()) in CheckUnaryTypeTraitTypeCompleteness()
5098 CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()); in HasNoThrowOperator()
5099 if ((RD->*HasTrivial)() && !(RD->*HasNonTrivial)()) in HasNoThrowOperator()
5114 if((Operator->*IsDesiredOp)()) { in HasNoThrowOperator()
5116 auto *CPT = Operator->getType()->castAs<FunctionProtoType>(); in HasNoThrowOperator()
5118 if (!CPT || !CPT->isNothrow()) in HasNoThrowOperator()
5130 if (Decl->isUnion()) in HasNonDeletedDefaultedEqualityComparison()
5132 if (Decl->isLambda()) in HasNonDeletedDefaultedEqualityComparison()
5133 return Decl->isCapturelessLambda(); in HasNonDeletedDefaultedEqualityComparison()
5144 Decl->getTypeForDecl()->getCanonicalTypeUnqualified().withConst(), in HasNonDeletedDefaultedEqualityComparison()
5158 const auto *Callee = CallExpr->getDirectCallee(); in HasNonDeletedDefaultedEqualityComparison()
5159 auto ParamT = Callee->getParamDecl(0)->getType(); in HasNonDeletedDefaultedEqualityComparison()
5160 if (!Callee->isDefaulted()) in HasNonDeletedDefaultedEqualityComparison()
5162 if (!ParamT->isReferenceType() && !Decl->isTriviallyCopyable()) in HasNonDeletedDefaultedEqualityComparison()
5164 if (ParamT.getNonReferenceType()->getUnqualifiedDesugaredType() != in HasNonDeletedDefaultedEqualityComparison()
5165 Decl->getTypeForDecl()) in HasNonDeletedDefaultedEqualityComparison()
5169 return llvm::all_of(Decl->bases(), in HasNonDeletedDefaultedEqualityComparison()
5171 if (const auto *RD = BS.getType()->getAsCXXRecordDecl()) in HasNonDeletedDefaultedEqualityComparison()
5176 llvm::all_of(Decl->fields(), [&](const FieldDecl *FD) { in HasNonDeletedDefaultedEqualityComparison()
5177 auto Type = FD->getType(); in HasNonDeletedDefaultedEqualityComparison()
5178 if (Type->isArrayType()) in HasNonDeletedDefaultedEqualityComparison()
5179 Type = Type->getBaseElementTypeUnsafe() in HasNonDeletedDefaultedEqualityComparison()
5180 ->getCanonicalTypeUnqualified(); in HasNonDeletedDefaultedEqualityComparison()
5182 if (Type->isReferenceType() || Type->isEnumeralType()) in HasNonDeletedDefaultedEqualityComparison()
5184 if (const auto *RD = Type->getAsCXXRecordDecl()) in HasNonDeletedDefaultedEqualityComparison()
5192 if (CanonicalType->isIncompleteType() || CanonicalType->isDependentType() || in isTriviallyEqualityComparableType()
5193 CanonicalType->isEnumeralType() || CanonicalType->isArrayType()) in isTriviallyEqualityComparableType()
5196 if (const auto *RD = CanonicalType->getAsCXXRecordDecl()) { in isTriviallyEqualityComparableType()
5208 QualType T = TInfo->getType(); in EvaluateUnaryTypeTrait()
5209 assert(!T->isDependentType() && "Cannot evaluate traits of dependent type"); in EvaluateUnaryTypeTrait()
5217 return T->isVoidType(); in EvaluateUnaryTypeTrait()
5219 return T->isIntegralType(C); in EvaluateUnaryTypeTrait()
5221 return T->isFloatingType(); in EvaluateUnaryTypeTrait()
5223 // Zero-sized arrays aren't considered arrays in partial specializations, in EvaluateUnaryTypeTrait()
5226 return CAT->getSize() != 0; in EvaluateUnaryTypeTrait()
5227 return T->isArrayType(); in EvaluateUnaryTypeTrait()
5231 // Zero-sized arrays aren't considered arrays in partial specializations, in EvaluateUnaryTypeTrait()
5234 return CAT->getSize() != 0; in EvaluateUnaryTypeTrait()
5235 return T->isArrayType() && !T->isIncompleteArrayType(); in EvaluateUnaryTypeTrait()
5239 return T->isIncompleteArrayType(); in EvaluateUnaryTypeTrait()
5241 return T->isAnyPointerType(); in EvaluateUnaryTypeTrait()
5243 return T->isNullPtrType(); in EvaluateUnaryTypeTrait()
5245 return T->isLValueReferenceType(); in EvaluateUnaryTypeTrait()
5247 return T->isRValueReferenceType(); in EvaluateUnaryTypeTrait()
5249 return T->isMemberFunctionPointerType(); in EvaluateUnaryTypeTrait()
5251 return T->isMemberDataPointerType(); in EvaluateUnaryTypeTrait()
5253 return T->isEnumeralType(); in EvaluateUnaryTypeTrait()
5255 return T->isScopedEnumeralType(); in EvaluateUnaryTypeTrait()
5257 return T->isUnionType(); in EvaluateUnaryTypeTrait()
5259 return T->isClassType() || T->isStructureType() || T->isInterfaceType(); in EvaluateUnaryTypeTrait()
5261 return T->isFunctionType(); in EvaluateUnaryTypeTrait()
5266 return T->isReferenceType(); in EvaluateUnaryTypeTrait()
5268 return T->isArithmeticType() && !T->isEnumeralType(); in EvaluateUnaryTypeTrait()
5270 return T->isFundamentalType(); in EvaluateUnaryTypeTrait()
5272 return T->isObjectType(); in EvaluateUnaryTypeTrait()
5274 // Note: semantic analysis depends on Objective-C lifetime types to be in EvaluateUnaryTypeTrait()
5277 // operations), so we report them as non-scalar. in EvaluateUnaryTypeTrait()
5278 if (T->isObjCLifetimeType()) { in EvaluateUnaryTypeTrait()
5291 return T->isScalarType(); in EvaluateUnaryTypeTrait()
5293 return T->isCompoundType(); in EvaluateUnaryTypeTrait()
5295 return T->isMemberPointerType(); in EvaluateUnaryTypeTrait()
5308 return T->isStandardLayoutType(); in EvaluateUnaryTypeTrait()
5312 return T->isLiteralType(C); in EvaluateUnaryTypeTrait()
5314 if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5315 return !RD->isUnion() && RD->isEmpty(); in EvaluateUnaryTypeTrait()
5318 if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5319 return !RD->isUnion() && RD->isPolymorphic(); in EvaluateUnaryTypeTrait()
5322 if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5323 return !RD->isUnion() && RD->isAbstract(); in EvaluateUnaryTypeTrait()
5329 return T->isAggregateType() || T->isVectorType() || T->isExtVectorType() || in EvaluateUnaryTypeTrait()
5330 T->isAnyComplexType(); in EvaluateUnaryTypeTrait()
5338 if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5339 return RD->hasAttr<FinalAttr>(); in EvaluateUnaryTypeTrait()
5344 return T->isFloatingType() || in EvaluateUnaryTypeTrait()
5345 (T->isSignedIntegerType() && !T->isEnumeralType()); in EvaluateUnaryTypeTrait()
5348 return T->isUnsignedIntegerType() && !T->isEnumeralType(); in EvaluateUnaryTypeTrait()
5356 // 1: http://gcc.gnu/.org/onlinedocs/gcc/Type-Traits.html in EvaluateUnaryTypeTrait()
5360 // has both a trivial and a non-trivial special member of a particular kind, in EvaluateUnaryTypeTrait()
5366 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: in EvaluateUnaryTypeTrait()
5372 if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5373 return RD->hasTrivialDefaultConstructor() && in EvaluateUnaryTypeTrait()
5374 !RD->hasNonTrivialDefaultConstructor(); in EvaluateUnaryTypeTrait()
5382 if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5383 return RD->hasTrivialMoveConstructor() && !RD->hasNonTrivialMoveConstructor(); in EvaluateUnaryTypeTrait()
5386 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: in EvaluateUnaryTypeTrait()
5391 if (T.isPODType(C) || T->isReferenceType()) in EvaluateUnaryTypeTrait()
5393 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5394 return RD->hasTrivialCopyConstructor() && in EvaluateUnaryTypeTrait()
5395 !RD->hasNonTrivialCopyConstructor(); in EvaluateUnaryTypeTrait()
5403 if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5404 return RD->hasTrivialMoveAssignment() && !RD->hasNonTrivialMoveAssignment(); in EvaluateUnaryTypeTrait()
5407 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: in EvaluateUnaryTypeTrait()
5423 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5424 return RD->hasTrivialCopyAssignment() && in EvaluateUnaryTypeTrait()
5425 !RD->hasNonTrivialCopyAssignment(); in EvaluateUnaryTypeTrait()
5432 if (T->isReferenceType()) in EvaluateUnaryTypeTrait()
5435 // Objective-C++ ARC: autorelease types don't require destruction. in EvaluateUnaryTypeTrait()
5436 if (T->isObjCLifetimeType() && in EvaluateUnaryTypeTrait()
5443 if (T->isIncompleteType() || T->isFunctionType()) in EvaluateUnaryTypeTrait()
5446 // A type that requires destruction (via a non-trivial destructor or ARC in EvaluateUnaryTypeTrait()
5447 // lifetime semantics) is not trivially-destructible. in EvaluateUnaryTypeTrait()
5453 // expression std::declval<U&>().~U() is well-formed when treated as an in EvaluateUnaryTypeTrait()
5455 if (auto *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) { in EvaluateUnaryTypeTrait()
5461 // explicitly, other than to declare it, is ill-formed. in EvaluateUnaryTypeTrait()
5462 if (Destructor->isDeleted()) in EvaluateUnaryTypeTrait()
5464 if (C.getLangOpts().AccessControl && Destructor->getAccess() != AS_public) in EvaluateUnaryTypeTrait()
5467 auto *CPT = Destructor->getType()->castAs<FunctionProtoType>(); in EvaluateUnaryTypeTrait()
5469 if (!CPT || !CPT->isNothrow()) in EvaluateUnaryTypeTrait()
5476 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html in EvaluateUnaryTypeTrait()
5482 if (T.isPODType(C) || T->isReferenceType()) in EvaluateUnaryTypeTrait()
5485 // Objective-C++ ARC: autorelease types don't require destruction. in EvaluateUnaryTypeTrait()
5486 if (T->isObjCLifetimeType() && in EvaluateUnaryTypeTrait()
5490 if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5491 return RD->hasTrivialDestructor(); in EvaluateUnaryTypeTrait()
5495 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: in EvaluateUnaryTypeTrait()
5504 if (T->isReferenceType()) in EvaluateUnaryTypeTrait()
5506 if (T.isPODType(C) || T->isObjCLifetimeType()) in EvaluateUnaryTypeTrait()
5509 if (const RecordType *RT = T->getAs<RecordType>()) in EvaluateUnaryTypeTrait()
5522 if (const RecordType *RT = C.getBaseElementType(T)->getAs<RecordType>()) in EvaluateUnaryTypeTrait()
5529 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: in EvaluateUnaryTypeTrait()
5534 if (T.isPODType(C) || T->isReferenceType() || T->isObjCLifetimeType()) in EvaluateUnaryTypeTrait()
5536 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) { in EvaluateUnaryTypeTrait()
5537 if (RD->hasTrivialCopyConstructor() && in EvaluateUnaryTypeTrait()
5538 !RD->hasNonTrivialCopyConstructor()) in EvaluateUnaryTypeTrait()
5547 if (isa<FunctionTemplateDecl>(ND->getUnderlyingDecl())) in EvaluateUnaryTypeTrait()
5552 auto *Constructor = cast<CXXConstructorDecl>(ND->getUnderlyingDecl()); in EvaluateUnaryTypeTrait()
5553 if (Constructor->isCopyConstructor(FoundTQs)) { in EvaluateUnaryTypeTrait()
5555 auto *CPT = Constructor->getType()->castAs<FunctionProtoType>(); in EvaluateUnaryTypeTrait()
5561 if (!CPT->isNothrow() || CPT->getNumParams() > 1) in EvaluateUnaryTypeTrait()
5570 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html in EvaluateUnaryTypeTrait()
5575 if (T.isPODType(C) || T->isObjCLifetimeType()) in EvaluateUnaryTypeTrait()
5577 if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) { in EvaluateUnaryTypeTrait()
5578 if (RD->hasTrivialDefaultConstructor() && in EvaluateUnaryTypeTrait()
5579 !RD->hasNonTrivialDefaultConstructor()) in EvaluateUnaryTypeTrait()
5585 if (isa<FunctionTemplateDecl>(ND->getUnderlyingDecl())) in EvaluateUnaryTypeTrait()
5590 auto *Constructor = cast<CXXConstructorDecl>(ND->getUnderlyingDecl()); in EvaluateUnaryTypeTrait()
5591 if (Constructor->isDefaultConstructor()) { in EvaluateUnaryTypeTrait()
5593 auto *CPT = Constructor->getType()->castAs<FunctionProtoType>(); in EvaluateUnaryTypeTrait()
5599 if (!CPT->isNothrow() || CPT->getNumParams() > 0) in EvaluateUnaryTypeTrait()
5607 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: in EvaluateUnaryTypeTrait()
5610 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) in EvaluateUnaryTypeTrait()
5612 return Destructor->isVirtual(); in EvaluateUnaryTypeTrait()
5622 return !T->isIncompleteType(); in EvaluateUnaryTypeTrait()
5632 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl(); RD && !T.hasQualifiers()) in EvaluateUnaryTypeTrait()
5633 return RD->canPassInRegisters(); in EvaluateUnaryTypeTrait()
5648 QualType LhsT = Lhs->getType(); in CheckConvertibilityForTypeTraits()
5649 QualType RhsT = Rhs->getType(); in CheckConvertibilityForTypeTraits()
5660 // well-formed, including any implicit conversions to the return in CheckConvertibilityForTypeTraits()
5669 // of the return-statement (including conversions to the return type) in CheckConvertibilityForTypeTraits()
5672 // We model the initialization as a copy-initialization of a temporary in CheckConvertibilityForTypeTraits()
5677 if (RhsT->isFunctionType() || RhsT->isArrayType()) in CheckConvertibilityForTypeTraits()
5680 // A function definition requires a complete, non-abstract return type. in CheckConvertibilityForTypeTraits()
5681 if (!Self.isCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT) || in CheckConvertibilityForTypeTraits()
5682 Self.isAbstractType(Rhs->getTypeLoc().getBeginLoc(), RhsT)) in CheckConvertibilityForTypeTraits()
5686 if (LhsT->isObjectType() || LhsT->isFunctionType()) in CheckConvertibilityForTypeTraits()
5749 // following variable definition would be well-formed for some invented in EvaluateBooleanTypeTrait()
5756 // complete types, (possibly cv-qualified) void, or arrays of in EvaluateBooleanTypeTrait()
5759 QualType ArgTy = TSI->getType(); in EvaluateBooleanTypeTrait()
5760 if (ArgTy->isVoidType() || ArgTy->isIncompleteArrayType()) in EvaluateBooleanTypeTrait()
5768 // Make sure the first argument is not incomplete nor a function type. in EvaluateBooleanTypeTrait()
5769 QualType T = Args[0]->getType(); in EvaluateBooleanTypeTrait()
5770 if (T->isIncompleteType() || T->isFunctionType()) in EvaluateBooleanTypeTrait()
5773 // Make sure the first argument is not an abstract type. in EvaluateBooleanTypeTrait()
5774 CXXRecordDecl *RD = T->getAsCXXRecordDecl(); in EvaluateBooleanTypeTrait()
5775 if (RD && RD->isAbstract()) in EvaluateBooleanTypeTrait()
5780 ArgExprs.reserve(Args.size() - 1); in EvaluateBooleanTypeTrait()
5782 QualType ArgTy = Args[I]->getType(); in EvaluateBooleanTypeTrait()
5783 if (ArgTy->isObjectType() || ArgTy->isFunctionType()) in EvaluateBooleanTypeTrait()
5787 OpaqueValueExpr(Args[I]->getTypeLoc().getBeginLoc(), in EvaluateBooleanTypeTrait()
5818 if (!T->isReferenceType()) in EvaluateBooleanTypeTrait()
5827 QualType U = Args[1]->getType(); in EvaluateBooleanTypeTrait()
5828 if (U->isReferenceType()) in EvaluateBooleanTypeTrait()
5844 // Under Objective-C ARC and Weak, if the destination has non-trivial in EvaluateBooleanTypeTrait()
5845 // Objective-C lifetime, this is a non-trivial construction. in EvaluateBooleanTypeTrait()
5849 // The initialization succeeded; now make sure there are no non-trivial in EvaluateBooleanTypeTrait()
5851 return !Result.get()->hasNonTrivialCall(S.Context); in EvaluateBooleanTypeTrait()
5928 *this, Kind, KWLoc, Args[0]->getType())) in BuildTypeTrait()
5935 if (Args[I]->getType()->isDependentType()) { in BuildTypeTrait()
5972 QualType LhsT = Lhs->getType(); in EvaluateBinaryTypeTrait()
5973 QualType RhsT = Rhs->getType(); in EvaluateBinaryTypeTrait()
5975 assert(!LhsT->isDependentType() && !RhsT->isDependentType() && in EvaluateBinaryTypeTrait()
5981 // Base is a base class of Derived without regard to cv-qualifiers or in EvaluateBinaryTypeTrait()
5983 // regard to cv-qualifiers. in EvaluateBinaryTypeTrait()
5985 const RecordType *lhsRecord = LhsT->getAs<RecordType>(); in EvaluateBinaryTypeTrait()
5986 const RecordType *rhsRecord = RhsT->getAs<RecordType>(); in EvaluateBinaryTypeTrait()
5988 const ObjCObjectType *LHSObjTy = LhsT->getAs<ObjCObjectType>(); in EvaluateBinaryTypeTrait()
5989 const ObjCObjectType *RHSObjTy = RhsT->getAs<ObjCObjectType>(); in EvaluateBinaryTypeTrait()
5993 ObjCInterfaceDecl *BaseInterface = LHSObjTy->getInterface(); in EvaluateBinaryTypeTrait()
5994 ObjCInterfaceDecl *DerivedInterface = RHSObjTy->getInterface(); in EvaluateBinaryTypeTrait()
5999 Rhs->getTypeLoc().getBeginLoc(), RhsT, in EvaluateBinaryTypeTrait()
6003 return BaseInterface->isSuperClassOf(DerivedInterface); in EvaluateBinaryTypeTrait()
6011 if (lhsRecord && lhsRecord->getDecl()->isUnion()) in EvaluateBinaryTypeTrait()
6013 if (rhsRecord && rhsRecord->getDecl()->isUnion()) in EvaluateBinaryTypeTrait()
6021 // (ignoring possible cv-qualifiers) then Derived shall be a in EvaluateBinaryTypeTrait()
6024 Rhs->getTypeLoc().getBeginLoc(), RhsT, in EvaluateBinaryTypeTrait()
6028 return cast<CXXRecordDecl>(rhsRecord->getDecl()) in EvaluateBinaryTypeTrait()
6029 ->isDerivedFrom(cast<CXXRecordDecl>(lhsRecord->getDecl())); in EvaluateBinaryTypeTrait()
6034 // GCC ignores cv-qualifiers on arrays for this builtin. in EvaluateBinaryTypeTrait()
6043 if (RhsT->isVoidType()) in EvaluateBinaryTypeTrait()
6044 return LhsT->isVoidType(); in EvaluateBinaryTypeTrait()
6066 // The expression declval<T>() = declval<U>() is well-formed when in EvaluateBinaryTypeTrait()
6069 // For both, T and U shall be complete types, (possibly cv-qualified) in EvaluateBinaryTypeTrait()
6071 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() && in EvaluateBinaryTypeTrait()
6073 Lhs->getTypeLoc().getBeginLoc(), LhsT, in EvaluateBinaryTypeTrait()
6076 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() && in EvaluateBinaryTypeTrait()
6078 Rhs->getTypeLoc().getBeginLoc(), RhsT, in EvaluateBinaryTypeTrait()
6083 if (LhsT->isVoidType() || RhsT->isVoidType()) in EvaluateBinaryTypeTrait()
6088 if (LhsT->isObjectType() || LhsT->isFunctionType()) in EvaluateBinaryTypeTrait()
6090 if (RhsT->isObjectType() || RhsT->isFunctionType()) in EvaluateBinaryTypeTrait()
6108 // Treat the assignment as unused for the purpose of -Wdeprecated-volatile. in EvaluateBinaryTypeTrait()
6121 // Under Objective-C ARC and Weak, if the destination has non-trivial in EvaluateBinaryTypeTrait()
6122 // Objective-C lifetime, this is a non-trivial assignment. in EvaluateBinaryTypeTrait()
6126 return !Result.get()->hasNonTrivialCall(Self.Context); in EvaluateBinaryTypeTrait()
6133 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType()) in EvaluateBinaryTypeTrait()
6134 Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT, in EvaluateBinaryTypeTrait()
6136 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType()) in EvaluateBinaryTypeTrait()
6137 Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT, in EvaluateBinaryTypeTrait()
6146 if (LhsT->isStructureOrClassType() && RhsT->isStructureOrClassType() && in EvaluateBinaryTypeTrait()
6148 Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT, in EvaluateBinaryTypeTrait()
6163 TSTToBeDeduced->getTemplateName().getAsTemplateDecl(), RhsT, in EvaluateBinaryTypeTrait()
6188 assert(!T->isDependentType() && "Cannot evaluate traits of dependent type"); in EvaluateArrayTypeTrait()
6192 if (T->isArrayType()) { in EvaluateArrayTypeTrait()
6196 T = AT->getElementType(); in EvaluateArrayTypeTrait()
6211 << DimExpr->getSourceRange(); in EvaluateArrayTypeTrait()
6216 if (T->isArrayType()) { in EvaluateArrayTypeTrait()
6225 T = AT->getElementType(); in EvaluateArrayTypeTrait()
6228 if (Matched && T->isArrayType()) { in EvaluateArrayTypeTrait()
6230 return CAT->getLimitedSize(); in EvaluateArrayTypeTrait()
6244 QualType T = TSInfo->getType(); in BuildArrayTypeTrait()
6249 if (!T->isDependentType()) in BuildArrayTypeTrait()
6276 case ET_IsLValueExpr: return E->isLValue(); in EvaluateExpressionTrait()
6278 return E->isPRValue(); in EvaluateExpressionTrait()
6287 if (Queried->isTypeDependent()) { in BuildExpressionTrait()
6288 // Delay type-checking for type-dependent expressions. in BuildExpressionTrait()
6289 } else if (Queried->hasPlaceholderType()) { in BuildExpressionTrait()
6305 assert(!LHS.get()->hasPlaceholderType() && !RHS.get()->hasPlaceholderType() && in CheckPointerToMemberOperands()
6308 // The LHS undergoes lvalue conversions if this is ->*, and undergoes the in CheckPointerToMemberOperands()
6309 // temporary materialization conversion otherwise. in CheckPointerToMemberOperands()
6312 else if (LHS.get()->isPRValue()) in CheckPointerToMemberOperands()
6321 const char *OpSpelling = isIndirect ? "->*" : ".*"; in CheckPointerToMemberOperands()
6323 // The binary operator .* [p3: ->*] binds its second operand, which shall in CheckPointerToMemberOperands()
6324 // be of type "pointer to member of T" (where T is a completely-defined in CheckPointerToMemberOperands()
6326 QualType RHSType = RHS.get()->getType(); in CheckPointerToMemberOperands()
6327 const MemberPointerType *MemPtr = RHSType->getAs<MemberPointerType>(); in CheckPointerToMemberOperands()
6330 << OpSpelling << RHSType << RHS.get()->getSourceRange(); in CheckPointerToMemberOperands()
6334 QualType Class(MemPtr->getClass(), 0); in CheckPointerToMemberOperands()
6336 // Note: C++ [expr.mptr.oper]p2-3 says that the class type into which the in CheckPointerToMemberOperands()
6337 // member pointer points must be completely-defined. However, there is no in CheckPointerToMemberOperands()
6343 // [...] to its first operand, which shall be of class T or of a class of in CheckPointerToMemberOperands()
6346 QualType LHSType = LHS.get()->getType(); in CheckPointerToMemberOperands()
6348 if (const PointerType *Ptr = LHSType->getAs<PointerType>()) in CheckPointerToMemberOperands()
6349 LHSType = Ptr->getPointeeType(); in CheckPointerToMemberOperands()
6367 << (int)isIndirect << LHS.get()->getType(); in CheckPointerToMemberOperands()
6374 SourceRange(LHS.get()->getBeginLoc(), RHS.get()->getEndLoc()), in CheckPointerToMemberOperands()
6382 ExprValueKind VK = isIndirect ? VK_PRValue : LHS.get()->getValueKind(); in CheckPointerToMemberOperands()
6387 if (isa<CXXScalarValueInitExpr>(RHS.get()->IgnoreParens())) { in CheckPointerToMemberOperands()
6388 // Diagnose use of pointer-to-member type which when used as in CheckPointerToMemberOperands()
6389 // the functional cast in a pointer-to-member expression. in CheckPointerToMemberOperands()
6399 QualType Result = MemPtr->getPointeeType(); in CheckPointerToMemberOperands()
6404 // ill-formed if the second operand is a pointer to member function with in CheckPointerToMemberOperands()
6405 // ref-qualifier &. In a ->* expression or in a .* expression whose object in CheckPointerToMemberOperands()
6406 // expression is an lvalue, the program is ill-formed if the second operand in CheckPointerToMemberOperands()
6407 // is a pointer to member function with ref-qualifier &&. in CheckPointerToMemberOperands()
6408 if (const FunctionProtoType *Proto = Result->getAs<FunctionProtoType>()) { in CheckPointerToMemberOperands()
6409 switch (Proto->getRefQualifier()) { in CheckPointerToMemberOperands()
6415 if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) { in CheckPointerToMemberOperands()
6416 // C++2a allows functions with ref-qualifier & if their cv-qualifier-seq in CheckPointerToMemberOperands()
6418 if (Proto->isConst() && !Proto->isVolatile()) in CheckPointerToMemberOperands()
6424 << RHSType << 1 << LHS.get()->getSourceRange(); in CheckPointerToMemberOperands()
6429 if (isIndirect || !LHS.get()->Classify(Context).isRValue()) in CheckPointerToMemberOperands()
6431 << RHSType << 0 << LHS.get()->getSourceRange(); in CheckPointerToMemberOperands()
6439 // first operand. The result of a .* expression whose second in CheckPointerToMemberOperands()
6441 // result of an ->* expression is an lvalue if its second operand in CheckPointerToMemberOperands()
6443 if (Result->isFunctionType()) { in CheckPointerToMemberOperands()
6449 VK = LHS.get()->getValueKind(); in CheckPointerToMemberOperands()
6459 /// converted to each other. This function does the conversion in one direction.
6460 /// It returns true if the program is ill-formed and has already been diagnosed
6467 ToType = To->getType(); in TryClassUnification()
6470 InitializationKind::CreateCopy(To->getBeginLoc(), SourceLocation()); in TryClassUnification()
6475 // -- If E2 is an lvalue: E1 can be converted to match E2 if E1 can be in TryClassUnification()
6477 // constraint that in the conversion the reference must bind directly to in TryClassUnification()
6479 // -- If E2 is an xvalue: E1 can be converted to match E2 if E1 can be in TryClassUnification()
6482 if (To->isGLValue()) { in TryClassUnification()
6497 // -- If E2 is an rvalue, or if the conversion above cannot be done: in TryClassUnification()
6498 // -- if E1 and E2 have class type, and the underlying class types are in TryClassUnification()
6500 QualType FTy = From->getType(); in TryClassUnification()
6501 QualType TTy = To->getType(); in TryClassUnification()
6502 const RecordType *FRec = FTy->getAs<RecordType>(); in TryClassUnification()
6503 const RecordType *TRec = TTy->getAs<RecordType>(); in TryClassUnification()
6528 // -- Otherwise: E1 can be converted to match E2 if E1 can be in TryClassUnification()
6533 // This actually refers very narrowly to the lvalue-to-rvalue conversion, not in TryClassUnification()
6534 // to the array-to-pointer or function-to-pointer conversions. in TryClassUnification()
6551 /// conversion to a common type.
6565 LHS.get(), Best->BuiltinParamTypes[0], Best->Conversions[0], in FindConditionalOverload()
6572 RHS.get(), Best->BuiltinParamTypes[1], Best->Conversions[1], in FindConditionalOverload()
6577 if (Best->Function) in FindConditionalOverload()
6578 Self.MarkFunctionReferenced(QuestionLoc, Best->Function); in FindConditionalOverload()
6591 << LHS.get()->getType() << RHS.get()->getType() in FindConditionalOverload()
6592 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); in FindConditionalOverload()
6597 << LHS.get()->getType() << RHS.get()->getType() in FindConditionalOverload()
6598 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); in FindConditionalOverload()
6604 llvm_unreachable("Conditional operator has only built-in overloads"); in FindConditionalOverload()
6609 /// Perform an "extended" implicit conversion as returned by
6614 InitializationKind::CreateCopy(E.get()->getBeginLoc(), SourceLocation()); in ConvertForConditional()
6629 if (!CondTy->isVectorType() && !CondTy->isExtVectorType()) in isValidVectorForConditionalCondition()
6632 cast<VectorType>(CondTy.getCanonicalType())->getElementType(); in isValidVectorForConditionalCondition()
6633 assert(!EltTy->isEnumeralType() && "Vectors cant be enum types"); in isValidVectorForConditionalCondition()
6634 return EltTy->isIntegralType(Ctx); in isValidVectorForConditionalCondition()
6639 if (!CondTy->isSveVLSBuiltinType()) in isValidSizelessVectorForConditionalCondition()
6642 cast<BuiltinType>(CondTy.getCanonicalType())->getSveEltType(Ctx); in isValidSizelessVectorForConditionalCondition()
6643 assert(!EltTy->isEnumeralType() && "Vectors cant be enum types"); in isValidSizelessVectorForConditionalCondition()
6644 return EltTy->isIntegralType(Ctx); in isValidSizelessVectorForConditionalCondition()
6653 QualType CondType = Cond.get()->getType(); in CheckVectorConditionalTypes()
6654 const auto *CondVT = CondType->castAs<VectorType>(); in CheckVectorConditionalTypes()
6655 QualType CondElementTy = CondVT->getElementType(); in CheckVectorConditionalTypes()
6656 unsigned CondElementCount = CondVT->getNumElements(); in CheckVectorConditionalTypes()
6657 QualType LHSType = LHS.get()->getType(); in CheckVectorConditionalTypes()
6658 const auto *LHSVT = LHSType->getAs<VectorType>(); in CheckVectorConditionalTypes()
6659 QualType RHSType = RHS.get()->getType(); in CheckVectorConditionalTypes()
6660 const auto *RHSVT = RHSType->getAs<VectorType>(); in CheckVectorConditionalTypes()
6697 if (ResultElementTy->isEnumeralType()) { in CheckVectorConditionalTypes()
6702 if (CondType->isExtVectorType()) in CheckVectorConditionalTypes()
6704 Context.getExtVectorType(ResultElementTy, CondVT->getNumElements()); in CheckVectorConditionalTypes()
6707 ResultElementTy, CondVT->getNumElements(), VectorKind::Generic); in CheckVectorConditionalTypes()
6713 assert(!ResultType.isNull() && ResultType->isVectorType() && in CheckVectorConditionalTypes()
6714 (!CondType->isExtVectorType() || ResultType->isExtVectorType()) && in CheckVectorConditionalTypes()
6716 auto *ResultVectorTy = ResultType->castAs<VectorType>(); in CheckVectorConditionalTypes()
6717 QualType ResultElementTy = ResultVectorTy->getElementType(); in CheckVectorConditionalTypes()
6718 unsigned ResultElementCount = ResultVectorTy->getNumElements(); in CheckVectorConditionalTypes()
6743 QualType CondType = Cond.get()->getType(); in CheckSizelessVectorConditionalTypes()
6744 const auto *CondBT = CondType->castAs<BuiltinType>(); in CheckSizelessVectorConditionalTypes()
6745 QualType CondElementTy = CondBT->getSveEltType(Context); in CheckSizelessVectorConditionalTypes()
6749 QualType LHSType = LHS.get()->getType(); in CheckSizelessVectorConditionalTypes()
6751 LHSType->isSveVLSBuiltinType() ? LHSType->getAs<BuiltinType>() : nullptr; in CheckSizelessVectorConditionalTypes()
6752 QualType RHSType = RHS.get()->getType(); in CheckSizelessVectorConditionalTypes()
6754 RHSType->isSveVLSBuiltinType() ? RHSType->getAs<BuiltinType>() : nullptr; in CheckSizelessVectorConditionalTypes()
6783 if (ResultElementTy->isEnumeralType()) { in CheckSizelessVectorConditionalTypes()
6796 assert(!ResultType.isNull() && ResultType->isSveVLSBuiltinType() && in CheckSizelessVectorConditionalTypes()
6798 auto *ResultBuiltinTy = ResultType->castAs<BuiltinType>(); in CheckSizelessVectorConditionalTypes()
6799 QualType ResultElementTy = ResultBuiltinTy->getSveEltType(Context); in CheckSizelessVectorConditionalTypes()
6823 // FIXME: Handle C99's complex types, block pointers and Obj-C++ interface in CXXCheckConditionalOperands()
6826 // Assume r-value. in CXXCheckConditionalOperands()
6830 isValidVectorForConditionalCondition(Context, Cond.get()->getType()); in CXXCheckConditionalOperands()
6834 Cond.get()->getType()); in CXXCheckConditionalOperands()
6837 // The first expression is contextually converted to bool. in CXXCheckConditionalOperands()
6838 if (!Cond.get()->isTypeDependent()) { in CXXCheckConditionalOperands()
6846 // To implement C++, the first expression typically doesn't alter the result in CXXCheckConditionalOperands()
6849 // know if this is a vector extension here, delay the conversion of the in CXXCheckConditionalOperands()
6856 if (LHS.get()->isTypeDependent() || RHS.get()->isTypeDependent()) in CXXCheckConditionalOperands()
6861 QualType LTy = LHS.get()->getType(); in CXXCheckConditionalOperands()
6862 QualType RTy = RHS.get()->getType(); in CXXCheckConditionalOperands()
6863 bool LVoid = LTy->isVoidType(); in CXXCheckConditionalOperands()
6864 bool RVoid = RTy->isVoidType(); in CXXCheckConditionalOperands()
6867 // -- The second or the third operand (but not both) is a (possibly in CXXCheckConditionalOperands()
6868 // parenthesized) throw-expression; the result is of the type in CXXCheckConditionalOperands()
6870 bool LThrow = isa<CXXThrowExpr>(LHS.get()->IgnoreParenImpCasts()); in CXXCheckConditionalOperands()
6871 bool RThrow = isa<CXXThrowExpr>(RHS.get()->IgnoreParenImpCasts()); in CXXCheckConditionalOperands()
6873 // Void expressions aren't legal in the vector-conditional expressions. in CXXCheckConditionalOperands()
6876 LVoid ? LHS.get()->getSourceRange() : RHS.get()->getSourceRange(); in CXXCheckConditionalOperands()
6885 VK = NonThrow->getValueKind(); in CXXCheckConditionalOperands()
6886 // DR (no number yet): the result is a bit-field if the in CXXCheckConditionalOperands()
6887 // non-throw-expression operand is a bit-field. in CXXCheckConditionalOperands()
6888 OK = NonThrow->getObjectKind(); in CXXCheckConditionalOperands()
6889 return NonThrow->getType(); in CXXCheckConditionalOperands()
6892 // -- Both the second and third operands have type void; the result is of in CXXCheckConditionalOperands()
6900 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); in CXXCheckConditionalOperands()
6912 if (LTy->isWebAssemblyTableType() || RTy->isWebAssemblyTableType()) { in CXXCheckConditionalOperands()
6914 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); in CXXCheckConditionalOperands()
6923 (LTy->isRecordType() || RTy->isRecordType())) { in CXXCheckConditionalOperands()
6932 // If both can be converted, [...] the program is ill-formed. in CXXCheckConditionalOperands()
6935 << LTy << RTy << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); in CXXCheckConditionalOperands()
6939 // If exactly one conversion is possible, that conversion is applied to in CXXCheckConditionalOperands()
6945 LTy = LHS.get()->getType(); in CXXCheckConditionalOperands()
6949 RTy = RHS.get()->getType(); in CXXCheckConditionalOperands()
6955 // for cv-qualification, an attempt is made to convert each of those in CXXCheckConditionalOperands()
6959 // one of the operands is reference-compatible with the other, in order in CXXCheckConditionalOperands()
6964 ExprValueKind LVK = LHS.get()->getValueKind(); in CXXCheckConditionalOperands()
6965 ExprValueKind RVK = RHS.get()->getValueKind(); in CXXCheckConditionalOperands()
6967 // DerivedToBase was already handled by the class-specific case above. in CXXCheckConditionalOperands()
6980 !RHS.get()->refersToBitField() && !RHS.get()->refersToVectorElement()) { in CXXCheckConditionalOperands()
6982 RTy = RHS.get()->getType(); in CXXCheckConditionalOperands()
6986 !LHS.get()->refersToBitField() && in CXXCheckConditionalOperands()
6987 !LHS.get()->refersToVectorElement()) { in CXXCheckConditionalOperands()
6989 LTy = LHS.get()->getType(); in CXXCheckConditionalOperands()
6996 // value category and it is a bit-field if the second or the third in CXXCheckConditionalOperands()
6997 // operand is a bit-field, or if both are bit-fields. in CXXCheckConditionalOperands()
6999 // l-values. in CXXCheckConditionalOperands()
7002 LHS.get()->isOrdinaryOrBitFieldObject() && in CXXCheckConditionalOperands()
7003 RHS.get()->isOrdinaryOrBitFieldObject()) { in CXXCheckConditionalOperands()
7004 VK = LHS.get()->getValueKind(); in CXXCheckConditionalOperands()
7005 if (LHS.get()->getObjectKind() == OK_BitField || in CXXCheckConditionalOperands()
7006 RHS.get()->getObjectKind() == OK_BitField) in CXXCheckConditionalOperands()
7014 if (!Same && (LTy->isRecordType() || RTy->isRecordType())) { in CXXCheckConditionalOperands()
7017 // program is ill-formed. in CXXCheckConditionalOperands()
7023 // Lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard in CXXCheckConditionalOperands()
7029 LTy = LHS.get()->getType(); in CXXCheckConditionalOperands()
7030 RTy = RHS.get()->getType(); in CXXCheckConditionalOperands()
7033 // -- The second and third operands have the same type; the result in CXXCheckConditionalOperands()
7036 // copy-initialized from either the second operand or the third in CXXCheckConditionalOperands()
7037 // operand depending on the value of the first operand. in CXXCheckConditionalOperands()
7039 if (LTy->isRecordType()) { in CXXCheckConditionalOperands()
7058 if (LTy->isVectorType() || RTy->isVectorType()) in CXXCheckConditionalOperands()
7065 // -- The second and third operands have arithmetic or enumeration type; in CXXCheckConditionalOperands()
7068 if (LTy->isArithmeticType() && RTy->isArithmeticType()) { in CXXCheckConditionalOperands()
7076 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); in CXXCheckConditionalOperands()
7086 // -- The second and third operands have pointer type, or one has pointer in CXXCheckConditionalOperands()
7088 // pointer constants, at least one of which is non-integral; pointer in CXXCheckConditionalOperands()
7092 // -- The second and third operands have pointer to member type, or one has in CXXCheckConditionalOperands()
7095 // performed to bring them to a common type, whose cv-qualification in CXXCheckConditionalOperands()
7096 // shall match the cv-qualification of either the second or the third in CXXCheckConditionalOperands()
7102 // Similarly, attempt to find composite type of two objective-c pointers. in CXXCheckConditionalOperands()
7109 // Check if we are using a null with a non-pointer type. in CXXCheckConditionalOperands()
7114 << LHS.get()->getType() << RHS.get()->getType() in CXXCheckConditionalOperands()
7115 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); in CXXCheckConditionalOperands()
7127 QualType T1 = E1->getType(), T2 = E2->getType(); in FindCompositePointerType()
7131 bool T1IsPointerLike = T1->isAnyPointerType() || T1->isMemberPointerType() || in FindCompositePointerType()
7132 T1->isNullPtrType(); in FindCompositePointerType()
7133 bool T2IsPointerLike = T2->isAnyPointerType() || T2->isMemberPointerType() || in FindCompositePointerType()
7134 T2->isNullPtrType(); in FindCompositePointerType()
7138 // - if both p1 and p2 are null pointer constants, std::nullptr_t; in FindCompositePointerType()
7142 // - if either p1 or p2 is a null pointer constant, T2 or T1, respectively; in FindCompositePointerType()
7144 E2->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { in FindCompositePointerType()
7146 E2 = ImpCastExprToType(E2, T1, T1->isMemberPointerType() in FindCompositePointerType()
7152 E1->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { in FindCompositePointerType()
7154 E1 = ImpCastExprToType(E1, T2, T2->isMemberPointerType() in FindCompositePointerType()
7163 assert(!T1->isNullPtrType() && !T2->isNullPtrType() && in FindCompositePointerType()
7170 /// The class for a pointer-to-member; a constant array type with a bound in FindCompositePointerType()
7187 return Ctx.getConstantArrayType(T, CAT->getSize(), nullptr, in FindCompositePointerType()
7198 // - if T1 is "pointer to cv1 C1" and T2 is "pointer to cv2 C2", where C1 in FindCompositePointerType()
7199 // is reference-related to C2 or C2 is reference-related to C1 (8.6.3), in FindCompositePointerType()
7200 // the cv-combined type of T1 and T2 or the cv-combined type of T2 and T1, in FindCompositePointerType()
7202 // - if T1 is "pointer to member of C1 of type cv1 U1" and T2 is "pointer in FindCompositePointerType()
7203 // to member of C2 of type cv2 U2" for some non-function type U, where in FindCompositePointerType()
7204 // C1 is reference-related to C2 or C2 is reference-related to C1, the in FindCompositePointerType()
7205 // cv-combined type of T2 and T1 or the cv-combined type of T1 and T2, in FindCompositePointerType()
7207 // - if T1 and T2 are similar types (4.5), the cv-combined type of T1 and in FindCompositePointerType()
7211 // and to prepare to form the cv-combined type if so. in FindCompositePointerType()
7222 // Top-level qualifiers are ignored. Merge at all lower levels. in FindCompositePointerType()
7229 // Under one level of pointer or pointer-to-member, we can change to an in FindCompositePointerType()
7254 else if (T1->isVoidPointerType() || T2->isVoidPointerType()) in FindCompositePointerType()
7262 else if (T1->isVoidPointerType() || T2->isVoidPointerType()) in FindCompositePointerType()
7269 NeedConstBefore = Steps.size() - 1; in FindCompositePointerType()
7279 if (CAT1 && CAT2 && CAT1->getSize() == CAT2->getSize()) { in FindCompositePointerType()
7280 Composite1 = Arr1->getElementType(); in FindCompositePointerType()
7281 Composite2 = Arr2->getElementType(); in FindCompositePointerType()
7294 Composite1 = Arr1->getElementType(); in FindCompositePointerType()
7295 Composite2 = Arr2->getElementType(); in FindCompositePointerType()
7304 if ((Ptr1 = Composite1->getAs<PointerType>()) && in FindCompositePointerType()
7305 (Ptr2 = Composite2->getAs<PointerType>())) { in FindCompositePointerType()
7306 Composite1 = Ptr1->getPointeeType(); in FindCompositePointerType()
7307 Composite2 = Ptr2->getPointeeType(); in FindCompositePointerType()
7313 if ((ObjPtr1 = Composite1->getAs<ObjCObjectPointerType>()) && in FindCompositePointerType()
7314 (ObjPtr2 = Composite2->getAs<ObjCObjectPointerType>())) { in FindCompositePointerType()
7315 Composite1 = ObjPtr1->getPointeeType(); in FindCompositePointerType()
7316 Composite2 = ObjPtr2->getPointeeType(); in FindCompositePointerType()
7322 if ((MemPtr1 = Composite1->getAs<MemberPointerType>()) && in FindCompositePointerType()
7323 (MemPtr2 = Composite2->getAs<MemberPointerType>())) { in FindCompositePointerType()
7324 Composite1 = MemPtr1->getPointeeType(); in FindCompositePointerType()
7325 Composite2 = MemPtr2->getPointeeType(); in FindCompositePointerType()
7327 // At the top level, we can perform a base-to-derived pointer-to-member in FindCompositePointerType()
7328 // conversion: in FindCompositePointerType()
7330 // - [...] where C1 is reference-related to C2 or C2 is in FindCompositePointerType()
7331 // reference-related to C1 in FindCompositePointerType()
7333 // (Note that the only kinds of reference-relatedness in scope here are in FindCompositePointerType()
7337 QualType Cls1(MemPtr1->getClass(), 0); in FindCompositePointerType()
7338 QualType Cls2(MemPtr2->getClass(), 0); in FindCompositePointerType()
7340 Class = MemPtr1->getClass(); in FindCompositePointerType()
7342 Class = IsDerivedFrom(Loc, Cls1, Cls2) ? MemPtr1->getClass() : in FindCompositePointerType()
7343 IsDerivedFrom(Loc, Cls2, Cls1) ? MemPtr2->getClass() : nullptr; in FindCompositePointerType()
7351 // Special case: at the top level, we can decompose an Objective-C pointer in FindCompositePointerType()
7353 if (Steps.empty() && ((Composite1->isVoidPointerType() && in FindCompositePointerType()
7354 Composite2->isObjCObjectPointerType()) || in FindCompositePointerType()
7355 (Composite1->isObjCObjectPointerType() && in FindCompositePointerType()
7356 Composite2->isVoidPointerType()))) { in FindCompositePointerType()
7357 Composite1 = Composite1->getPointeeType(); in FindCompositePointerType()
7358 Composite2 = Composite2->getPointeeType(); in FindCompositePointerType()
7369 // - if T1 or T2 is "pointer to noexcept function" and the other type is in FindCompositePointerType()
7372 // - if T1 or T2 is "pointer to member of C1 of type function", the other in FindCompositePointerType()
7374 // is reference-related to C2 or C2 is reference-related to C1, where in FindCompositePointerType()
7382 // - [Clang] If T1 and T2 are both of type "pointer to function" or in FindCompositePointerType()
7384 // by a function pointer conversion, that conversion is applied in FindCompositePointerType()
7395 // consider this conversion when determining type similarity and model it as in FindCompositePointerType()
7396 // a qualification conversion. in FindCompositePointerType()
7398 if (auto *FPT1 = Composite1->getAs<FunctionProtoType>()) { in FindCompositePointerType()
7399 if (auto *FPT2 = Composite2->getAs<FunctionProtoType>()) { in FindCompositePointerType()
7400 FunctionProtoType::ExtProtoInfo EPI1 = FPT1->getExtProtoInfo(); in FindCompositePointerType()
7401 FunctionProtoType::ExtProtoInfo EPI2 = FPT2->getExtProtoInfo(); in FindCompositePointerType()
7415 Composite1 = Context.getFunctionType(FPT1->getReturnType(), in FindCompositePointerType()
7416 FPT1->getParamTypes(), EPI1); in FindCompositePointerType()
7417 Composite2 = Context.getFunctionType(FPT2->getReturnType(), in FindCompositePointerType()
7418 FPT2->getParamTypes(), EPI2); in FindCompositePointerType()
7426 // - if T1 or T2 is "pointer to cv1 void" and the other type is in FindCompositePointerType()
7429 if (Composite1->isVoidType() && Composite2->isObjectType()) in FindCompositePointerType()
7431 else if (Composite2->isVoidType() && Composite1->isObjectType()) in FindCompositePointerType()
7433 // - if T1 is "pointer to cv1 C1" and T2 is "pointer to cv2 C2", where C1 in FindCompositePointerType()
7434 // is reference-related to C2 or C2 is reference-related to C1 (8.6.3), in FindCompositePointerType()
7435 // the cv-combined type of T1 and T2 or the cv-combined type of T2 and in FindCompositePointerType()
7439 // base class of T2" case in the definition of reference-related. in FindCompositePointerType()
7495 assert(!isa<CXXBindTemporaryExpr>(E) && "Double-bound temporary?"); in MaybeBindToTemporary()
7498 if (E->isGLValue()) in MaybeBindToTemporary()
7504 E->getType()->isObjCRetainableType()) { in MaybeBindToTemporary()
7511 Expr *Callee = Call->getCallee()->IgnoreParens(); in MaybeBindToTemporary()
7512 QualType T = Callee->getType(); in MaybeBindToTemporary()
7515 // Handle pointer-to-members. in MaybeBindToTemporary()
7517 T = BinOp->getRHS()->getType(); in MaybeBindToTemporary()
7519 T = Mem->getMemberDecl()->getType(); in MaybeBindToTemporary()
7522 if (const PointerType *Ptr = T->getAs<PointerType>()) in MaybeBindToTemporary()
7523 T = Ptr->getPointeeType(); in MaybeBindToTemporary()
7524 else if (const BlockPointerType *Ptr = T->getAs<BlockPointerType>()) in MaybeBindToTemporary()
7525 T = Ptr->getPointeeType(); in MaybeBindToTemporary()
7526 else if (const MemberPointerType *MemPtr = T->getAs<MemberPointerType>()) in MaybeBindToTemporary()
7527 T = MemPtr->getPointeeType(); in MaybeBindToTemporary()
7529 auto *FTy = T->castAs<FunctionType>(); in MaybeBindToTemporary()
7530 ReturnsRetained = FTy->getExtInfo().getProducesResult(); in MaybeBindToTemporary()
7537 // We hit this case with the lambda conversion-to-block optimization; in MaybeBindToTemporary()
7540 isa<BlockExpr>(cast<CastExpr>(E)->getSubExpr())) { in MaybeBindToTemporary()
7549 D = Send->getMethodDecl(); in MaybeBindToTemporary()
7551 D = BoxedExpr->getBoxingMethod(); in MaybeBindToTemporary()
7553 // Don't do reclaims if we're using the zero-element array in MaybeBindToTemporary()
7555 if (ArrayLit->getNumElements() == 0 && in MaybeBindToTemporary()
7559 D = ArrayLit->getArrayWithObjectsMethod(); in MaybeBindToTemporary()
7562 // Don't do reclaims if we're using the zero-element dictionary in MaybeBindToTemporary()
7564 if (DictLit->getNumElements() == 0 && in MaybeBindToTemporary()
7568 D = DictLit->getDictWithObjectsMethod(); in MaybeBindToTemporary()
7571 ReturnsRetained = (D && D->hasAttr<NSReturnsRetainedAttr>()); in MaybeBindToTemporary()
7577 D && D->getMethodFamily() == OMF_performSelector) in MaybeBindToTemporary()
7582 if (!ReturnsRetained && E->getType()->isObjCARCImplicitlyUnretainedType()) in MaybeBindToTemporary()
7589 return ImplicitCastExpr::Create(Context, E->getType(), ck, E, nullptr, in MaybeBindToTemporary()
7593 if (E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct) in MaybeBindToTemporary()
7601 const Type *T = Context.getCanonicalType(E->getType().getTypePtr()); in MaybeBindToTemporary()
7604 switch (T->getTypeClass()) { in MaybeBindToTemporary()
7612 T = cast<ArrayType>(T)->getElementType().getTypePtr(); in MaybeBindToTemporary()
7621 CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()); in MaybeBindToTemporary()
7622 if (RD->isInvalidDecl() || RD->isDependentContext()) in MaybeBindToTemporary()
7630 MarkFunctionReferenced(E->getExprLoc(), Destructor); in MaybeBindToTemporary()
7631 CheckDestructorAccess(E->getExprLoc(), Destructor, in MaybeBindToTemporary()
7633 << E->getType()); in MaybeBindToTemporary()
7634 if (DiagnoseUseOfDecl(Destructor, E->getExprLoc())) in MaybeBindToTemporary()
7638 if (Destructor->isTrivial()) in MaybeBindToTemporary()
7675 ExprCleanupObjects.size() - FirstCleanup); in MaybeCreateExprWithCleanups()
7685 assert(SubStmt && "sub-statement can't be null!"); in MaybeCreateStmtWithCleanups()
7717 // -- if the function call is either in ActOnDecltypeExpression()
7718 // -- the operand of a decltype-specifier, or in ActOnDecltypeExpression()
7719 // -- the right operand of a comma operator that is the operand of a in ActOnDecltypeExpression()
7720 // decltype-specifier, in ActOnDecltypeExpression()
7726 ExprResult SubExpr = ActOnDecltypeExpression(PE->getSubExpr()); in ActOnDecltypeExpression()
7729 if (SubExpr.get() == PE->getSubExpr()) in ActOnDecltypeExpression()
7731 return ActOnParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.get()); in ActOnDecltypeExpression()
7734 if (BO->getOpcode() == BO_Comma) { in ActOnDecltypeExpression()
7735 ExprResult RHS = ActOnDecltypeExpression(BO->getRHS()); in ActOnDecltypeExpression()
7738 if (RHS.get() == BO->getRHS()) in ActOnDecltypeExpression()
7740 return BinaryOperator::Create(Context, BO->getLHS(), RHS.get(), BO_Comma, in ActOnDecltypeExpression()
7741 BO->getType(), BO->getValueKind(), in ActOnDecltypeExpression()
7742 BO->getObjectKind(), BO->getOperatorLoc(), in ActOnDecltypeExpression()
7743 BO->getFPFeatures()); in ActOnDecltypeExpression()
7748 CallExpr *TopCall = TopBind ? dyn_cast<CallExpr>(TopBind->getSubExpr()) in ActOnDecltypeExpression()
7776 if (CheckCallReturnType(Call->getCallReturnType(Context), in ActOnDecltypeExpression()
7777 Call->getBeginLoc(), Call, Call->getDirectCallee())) in ActOnDecltypeExpression()
7782 // and non-deleted, and annotate them on the temporaries. in ActOnDecltypeExpression()
7790 CXXTemporary *Temp = Bind->getTemporary(); in ActOnDecltypeExpression()
7793 Bind->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl(); in ActOnDecltypeExpression()
7795 Temp->setDestructor(Destructor); in ActOnDecltypeExpression()
7797 MarkFunctionReferenced(Bind->getExprLoc(), Destructor); in ActOnDecltypeExpression()
7798 CheckDestructorAccess(Bind->getExprLoc(), Destructor, in ActOnDecltypeExpression()
7800 << Bind->getType()); in ActOnDecltypeExpression()
7801 if (DiagnoseUseOfDecl(Destructor, Bind->getExprLoc())) in ActOnDecltypeExpression()
7812 /// Note a set of 'operator->' functions that were used for a member access.
7819 // Produce Limit-1 normal notes and one 'skipping' note. in noteOperatorArrows()
7820 SkipStart = (Limit - 1) / 2 + (Limit - 1) % 2; in noteOperatorArrows()
7821 SkipCount = OperatorArrows.size() - (Limit - 1); in noteOperatorArrows()
7826 S.Diag(OperatorArrows[I]->getLocation(), in noteOperatorArrows()
7831 S.Diag(OperatorArrows[I]->getLocation(), diag::note_operator_arrow_here) in noteOperatorArrows()
7832 << OperatorArrows[I]->getCallResultType(); in noteOperatorArrows()
7852 QualType BaseType = Base->getType(); in ActOnStartCXXMemberReference()
7854 if (BaseType->isDependentType()) { in ActOnStartCXXMemberReference()
7855 // If we have a pointer to a dependent type and are using the -> operator, in ActOnStartCXXMemberReference()
7859 if (const PointerType *Ptr = BaseType->getAs<PointerType>()) in ActOnStartCXXMemberReference()
7860 BaseType = Ptr->getPointeeType(); in ActOnStartCXXMemberReference()
7868 // [...] When operator->returns, the operator-> is applied to the value in ActOnStartCXXMemberReference()
7880 while (BaseType->isRecordType()) { in ActOnStartCXXMemberReference()
7883 << StartingType << getLangOpts().ArrowDepth << Base->getSourceRange(); in ActOnStartCXXMemberReference()
7892 // When in a template specialization and on the first loop iteration, in ActOnStartCXXMemberReference()
7896 (FirstIteration && CurFD && CurFD->isFunctionTemplateSpecialization()) in ActOnStartCXXMemberReference()
7903 << BaseType << 1 << Base->getSourceRange() in ActOnStartCXXMemberReference()
7909 << BaseType << Base->getSourceRange(); in ActOnStartCXXMemberReference()
7911 if (Decl *CD = (CE ? CE->getCalleeDecl() : nullptr)) { in ActOnStartCXXMemberReference()
7912 Diag(CD->getBeginLoc(), in ActOnStartCXXMemberReference()
7920 OperatorArrows.push_back(OpCall->getDirectCallee()); in ActOnStartCXXMemberReference()
7921 BaseType = Base->getType(); in ActOnStartCXXMemberReference()
7932 if (BaseType->isPointerType()) in ActOnStartCXXMemberReference()
7933 BaseType = BaseType->getPointeeType(); in ActOnStartCXXMemberReference()
7935 BaseType = AT->getElementType(); in ActOnStartCXXMemberReference()
7939 // Objective-C properties allow "." access on Objective-C pointer types, in ActOnStartCXXMemberReference()
7941 if (BaseType->isObjCObjectPointerType()) in ActOnStartCXXMemberReference()
7942 BaseType = BaseType->getPointeeType(); in ActOnStartCXXMemberReference()
7946 // type, the unqualified-id is looked up in the context of the complete in ActOnStartCXXMemberReference()
7947 // postfix-expression. in ActOnStartCXXMemberReference()
7949 // This also indicates that we could be parsing a pseudo-destructor-name. in ActOnStartCXXMemberReference()
7950 // Note that Objective-C class and object types can be pseudo-destructor in ActOnStartCXXMemberReference()
7952 // it's legal for the type to be incomplete if this is a pseudo-destructor in ActOnStartCXXMemberReference()
7953 // call. We'll do more incomplete-type checks later in the lookup process, in ActOnStartCXXMemberReference()
7955 if (!BaseType->isRecordType()) { in ActOnStartCXXMemberReference()
7966 if (!BaseType->isDependentType() && in ActOnStartCXXMemberReference()
7970 return CreateRecoveryExpr(Base->getBeginLoc(), Base->getEndLoc(), {Base}); in ActOnStartCXXMemberReference()
7974 // If the id-expression in a class member access (5.2.5) is an in ActOnStartCXXMemberReference()
7975 // unqualified-id, and the type of the object expression is of a class in ActOnStartCXXMemberReference()
7976 // type C (or of pointer to a class type C), the unqualified-id is looked in ActOnStartCXXMemberReference()
7984 if (Base->hasPlaceholderType()) { in CheckArrow()
7989 ObjectType = Base->getType(); in CheckArrow()
7992 // The left-hand side of the dot operator shall be of scalar type. The in CheckArrow()
7993 // left-hand side of the arrow operator shall be of pointer to scalar type. in CheckArrow()
8001 if (ObjectType->isPointerType() || ObjectType->isArrayType() || in CheckArrow()
8002 ObjectType->isFunctionType()) { in CheckArrow()
8007 ObjectType = Base->getType(); in CheckArrow()
8010 if (const PointerType *Ptr = ObjectType->getAs<PointerType>()) { in CheckArrow()
8011 ObjectType = Ptr->getPointeeType(); in CheckArrow()
8012 } else if (!Base->isTypeDependent()) { in CheckArrow()
8013 // The user wrote "p->" when they probably meant "p."; fix it. in CheckArrow()
8033 if (auto *RD = DestructedType->getAsCXXRecordDecl()) { in canRecoverDotPseudoDestructorCallsOnPointerObjects()
8034 if (RD->hasDefinition()) in canRecoverDotPseudoDestructorCallsOnPointerObjects()
8040 // Otherwise, check if it's a type for which it's valid to use a pseudo-dtor. in canRecoverDotPseudoDestructorCallsOnPointerObjects()
8041 return DestructedType->isDependentType() || DestructedType->isScalarType() || in canRecoverDotPseudoDestructorCallsOnPointerObjects()
8042 DestructedType->isVectorType(); in canRecoverDotPseudoDestructorCallsOnPointerObjects()
8059 if (!ObjectType->isDependentType() && !ObjectType->isScalarType() && in BuildPseudoDestructorExpr()
8060 !ObjectType->isVectorType()) { in BuildPseudoDestructorExpr()
8061 if (getLangOpts().MSVCCompat && ObjectType->isVoidType()) in BuildPseudoDestructorExpr()
8062 Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange(); in BuildPseudoDestructorExpr()
8065 << ObjectType << Base->getSourceRange(); in BuildPseudoDestructorExpr()
8071 // [...] The cv-unqualified versions of the object type and of the type in BuildPseudoDestructorExpr()
8072 // designated by the pseudo-destructor-name shall be the same type. in BuildPseudoDestructorExpr()
8074 QualType DestructedType = DestructedTypeInfo->getType(); in BuildPseudoDestructorExpr()
8076 DestructedTypeInfo->getTypeLoc().getBeginLoc(); in BuildPseudoDestructorExpr()
8077 if (!DestructedType->isDependentType() && !ObjectType->isDependentType()) { in BuildPseudoDestructorExpr()
8082 if (OpKind == tok::period && ObjectType->isPointerType() && in BuildPseudoDestructorExpr()
8084 ObjectType->getPointeeType())) { in BuildPseudoDestructorExpr()
8087 << ObjectType << /*IsArrow=*/0 << Base->getSourceRange(); in BuildPseudoDestructorExpr()
8092 Diagnostic << FixItHint::CreateReplacement(OpLoc, "->"); in BuildPseudoDestructorExpr()
8095 // operator to '->'. in BuildPseudoDestructorExpr()
8100 << ObjectType << DestructedType << Base->getSourceRange() in BuildPseudoDestructorExpr()
8101 << DestructedTypeInfo->getTypeLoc().getSourceRange(); in BuildPseudoDestructorExpr()
8113 // Okay: just pretend that the user provided the correctly-qualified in BuildPseudoDestructorExpr()
8117 << ObjectType << DestructedType << Base->getSourceRange() in BuildPseudoDestructorExpr()
8118 << DestructedTypeInfo->getTypeLoc().getSourceRange(); in BuildPseudoDestructorExpr()
8131 // [...] Furthermore, the two type-names in a pseudo-destructor-name of the in BuildPseudoDestructorExpr()
8134 // ::[opt] nested-name-specifier[opt] type-name :: ~ type-name in BuildPseudoDestructorExpr()
8138 QualType ScopeType = ScopeTypeInfo->getType(); in BuildPseudoDestructorExpr()
8139 if (!ScopeType->isDependentType() && !ObjectType->isDependentType() && in BuildPseudoDestructorExpr()
8142 Diag(ScopeTypeInfo->getTypeLoc().getSourceRange().getBegin(), in BuildPseudoDestructorExpr()
8144 << ObjectType << ScopeType << Base->getSourceRange() in BuildPseudoDestructorExpr()
8145 << ScopeTypeInfo->getTypeLoc().getSourceRange(); in BuildPseudoDestructorExpr()
8174 "Invalid first type name in pseudo-destructor"); in ActOnPseudoDestructorExpr()
8177 "Invalid second type name in pseudo-destructor"); in ActOnPseudoDestructorExpr()
8187 if (ObjectType->isRecordType()) in ActOnPseudoDestructorExpr()
8189 else if (ObjectType->isDependentType()) in ActOnPseudoDestructorExpr()
8194 // type (with source-location information). in ActOnPseudoDestructorExpr()
8205 (!SS.isSet() && ObjectType->isDependentType()))) { in ActOnPseudoDestructorExpr()
8224 // Resolve the template-id to a type. in ActOnPseudoDestructorExpr()
8226 ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(), in ActOnPseudoDestructorExpr()
8227 TemplateId->NumArgs); in ActOnPseudoDestructorExpr()
8230 TemplateId->TemplateKWLoc, in ActOnPseudoDestructorExpr()
8231 TemplateId->Template, in ActOnPseudoDestructorExpr()
8232 TemplateId->Name, in ActOnPseudoDestructorExpr()
8233 TemplateId->TemplateNameLoc, in ActOnPseudoDestructorExpr()
8234 TemplateId->LAngleLoc, in ActOnPseudoDestructorExpr()
8236 TemplateId->RAngleLoc, in ActOnPseudoDestructorExpr()
8245 // If we've performed some kind of recovery, (re-)build the type source in ActOnPseudoDestructorExpr()
8277 // Resolve the template-id to a type. in ActOnPseudoDestructorExpr()
8279 ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(), in ActOnPseudoDestructorExpr()
8280 TemplateId->NumArgs); in ActOnPseudoDestructorExpr()
8283 TemplateId->TemplateKWLoc, in ActOnPseudoDestructorExpr()
8284 TemplateId->Template, in ActOnPseudoDestructorExpr()
8285 TemplateId->Name, in ActOnPseudoDestructorExpr()
8286 TemplateId->TemplateNameLoc, in ActOnPseudoDestructorExpr()
8287 TemplateId->LAngleLoc, in ActOnPseudoDestructorExpr()
8289 TemplateId->RAngleLoc, in ActOnPseudoDestructorExpr()
8336 cast<PackIndexingType>(T.getTypePtr())->getPattern(), in ActOnPseudoDestructorExpr()
8355 // If the operand is an unresolved lookup expression, the expression is ill- in BuildCXXNoexceptExpr()
8368 if (!inTemplateInstantiation() && !Operand->isInstantiationDependent() && in BuildCXXNoexceptExpr()
8369 Operand->HasSideEffects(Context, false)) { in BuildCXXNoexceptExpr()
8372 Diag(Operand->getExprLoc(), diag::warn_side_effects_unevaluated_context); in BuildCXXNoexceptExpr()
8391 if (BO->getLHS()->getType()->isDependentType() || in MaybeDecrementCount()
8392 BO->getRHS()->getType()->isDependentType()) { in MaybeDecrementCount()
8393 if (BO->getOpcode() != BO_Assign) in MaybeDecrementCount()
8395 } else if (!BO->isAssignmentOp()) in MaybeDecrementCount()
8398 IsCompoundAssign = BO->isCompoundAssignmentOp(); in MaybeDecrementCount()
8399 LHS = dyn_cast<DeclRefExpr>(BO->getLHS()); in MaybeDecrementCount()
8401 if (COCE->getOperator() != OO_Equal) in MaybeDecrementCount()
8403 LHS = dyn_cast<DeclRefExpr>(COCE->getArg(0)); in MaybeDecrementCount()
8405 if (!UO->isIncrementDecrementOp()) in MaybeDecrementCount()
8408 LHS = dyn_cast<DeclRefExpr>(UO->getSubExpr()); in MaybeDecrementCount()
8412 VarDecl *VD = dyn_cast<VarDecl>(LHS->getDecl()); in MaybeDecrementCount()
8417 // potential unused-but-set-variable warning. in MaybeDecrementCount()
8419 VD->getType().isVolatileQualified()) in MaybeDecrementCount()
8424 iter->getSecond()--; in MaybeDecrementCount()
8432 if (E->hasPlaceholderType()) { in IgnoredValueConversions()
8439 // The C++11 standard defines the notion of a discarded-value expression; in IgnoredValueConversions()
8441 // volatile lvalue with a special form, we perform an lvalue-to-rvalue in IgnoredValueConversions()
8442 // conversion. in IgnoredValueConversions()
8443 if (getLangOpts().CPlusPlus11 && E->isReadIfDiscardedInCPlusPlus11()) { in IgnoredValueConversions()
8450 // it occurs as a discarded-value expression. in IgnoredValueConversions()
8455 // If the expression is a prvalue after this optional conversion, the in IgnoredValueConversions()
8456 // temporary materialization conversion is applied. in IgnoredValueConversions()
8463 E->isPRValue() && !E->getType()->isVoidType()) { in IgnoredValueConversions()
8476 if (E->isPRValue()) { in IgnoredValueConversions()
8478 // are r-values, but we still want to do function-to-pointer decay in IgnoredValueConversions()
8481 if (!getLangOpts().CPlusPlus && E->getType()->isFunctionType()) in IgnoredValueConversions()
8488 if (const EnumType *T = E->getType()->getAs<EnumType>()) { in IgnoredValueConversions()
8489 if (!T->getDecl()->isComplete()) { in IgnoredValueConversions()
8501 if (!E->getType()->isVoidType()) in IgnoredValueConversions()
8502 RequireCompleteType(E->getExprLoc(), E->getType(), in IgnoredValueConversions()
8517 // - if the variable and its initializer are non-dependent, then
8519 // - if the initializer is not value dependent - we can determine whether
8523 // - FXIME: if the initializer is dependent, we can still do some analysis and
8524 // identify certain cases unambiguously as non-const by using a Visitor:
8525 // - such as those that involve odr-use of a ParmVarDecl, involve a new
8526 // delete, lambda-expr, dynamic-cast, reinterpret-cast etc...
8532 // If there is no initializer - this can not be a constant expression. in VariableCanNeverBeAConstantExpression()
8533 const Expr *Init = Var->getAnyInitializer(DefVD); in VariableCanNeverBeAConstantExpression()
8537 if (DefVD->isWeak()) in VariableCanNeverBeAConstantExpression()
8540 if (Var->getType()->isDependentType() || Init->isValueDependent()) { in VariableCanNeverBeAConstantExpression()
8541 // FIXME: Teach the constant evaluator to deal with the non-dependent parts in VariableCanNeverBeAConstantExpression()
8542 // of value-dependent expressions, and use it here to determine whether the in VariableCanNeverBeAConstantExpression()
8547 return !Var->isUsableInConstantExpressions(Context); in VariableCanNeverBeAConstantExpression()
8553 /// potential-capture, go ahead and do so. Also, check to see if any
8554 /// variables are uncaptureable or do not involve an odr-use so do not
8561 assert(S.CurContext->isDependentContext()); in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8565 DC = DC->getParent(); in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8567 CurrentLSI->CallOperator == DC && in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8571 const bool IsFullExprInstantiationDependent = FE->isInstantiationDependent(); in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8575 // outer lambda that is enclosed within a non-dependent context. in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8576 CurrentLSI->visitPotentialCaptures([&](ValueDecl *Var, Expr *VarExpr) { in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8577 // If the variable is clearly identified as non-odr-used and the full in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8581 // Even though 'x' is not odr-used, it should be captured. in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8588 if (CurrentLSI->isVariableExprMarkedAsNonODRUsed(VarExpr) && in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8592 VarDecl *UnderlyingVar = Var->getPotentiallyDecomposedVarDecl(); in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8596 // If we have a capture-capable lambda for the variable, go ahead and in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8601 S.MarkCaptureUsedInEnclosingContext(Var, VarExpr->getExprLoc(), *Index); in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8606 // can not be used in a constant expression - which means in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8607 // this variable must be odr-used here, so diagnose a in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8608 // capture violation early, if the variable is un-captureable. in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8612 SourceLocation ExprLoc = VarExpr->getExprLoc(); in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8628 if (CurrentLSI->hasPotentialThisCapture()) { in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8629 // If we have a capture-capable lambda for 'this', go ahead and capture in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8635 S.CheckCXXThisCapture(CurrentLSI->PotentialThisCaptureLocation, in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8641 // Reset all the potential captures at the end of each full-expression. in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8642 CurrentLSI->clearPotentialCaptures(); in CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures()
8660 R.setLookupName(ND->getDeclName()); in attemptRecovery()
8662 if (ND->isCXXClassMember()) { in attemptRecovery()
8666 Record = NNS->getAsType()->getAsCXXRecordDecl(); in attemptRecovery()
8669 dyn_cast<CXXRecordDecl>(ND->getDeclContext()->getRedeclContext()); in attemptRecovery()
8682 Ivar->getIdentifier()); in attemptRecovery()
8728 ? TypoCorrection() : State.Consumer->getCurrentCorrection(); in EmitAllDiagnostics()
8746 /// Try to advance the typo correction state of the first unfinished TypoExpr.
8755 /// We need to be sure that we're making progress - it's possible that the
8764 if (!State.Consumer->hasMadeAnyCorrectionProgress()) in CheckAndAdvanceTypoExprCorrectionStreams()
8766 if (!State.Consumer->finished()) in CheckAndAdvanceTypoExprCorrectionStreams()
8768 State.Consumer->resetCorrectionStream(); in CheckAndAdvanceTypoExprCorrectionStreams()
8780 return DRE->getFoundDecl(); in getDeclFromExpr()
8782 return ME->getFoundDecl(); in getDeclFromExpr()
8826 // Sema's TypoExprs - they were created in our `RecursiveTransformLoop`. in CheckForRecursiveTypos()
8892 SemaRef.getTypoExprState(TE).Consumer->saveCurrentPosition(); in RecursiveTransformLoop()
8894 TypoCorrection TC = SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection(); in RecursiveTransformLoop()
8904 SemaRef.getTypoExprState(TE).Consumer->resetCorrectionStream(); in RecursiveTransformLoop()
8910 } while ((Next = SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection()) && in RecursiveTransformLoop()
8917 SemaRef.getTypoExprState(TE).Consumer->restoreSavedPosition(); in RecursiveTransformLoop()
8957 ResultCall = BE->getSubExpr(); in RebuildCallExpr()
8959 OverloadResolution[OE] = CE->getCallee(); in RebuildCallExpr()
8984 // first one that was encountered. in TransformTypoExpr()
8993 // For the first TypoExpr and an uncached TypoExpr, find the next likely in TransformTypoExpr()
8995 while (TypoCorrection TC = State.Consumer->getNextCorrection()) { in TransformTypoExpr()
8998 // FIXME: If we would typo-correct to an invalid declaration, it's in TransformTypoExpr()
9008 if ((Next = State.Consumer->peekNextCorrection()) && in TransformTypoExpr()
9015 "Typo was transformed into a valid-but-null ExprResult"); in TransformTypoExpr()
9032 (E->isTypeDependent() || E->isValueDependent() || in CorrectDelayedTyposInExpr()
9033 E->isInstantiationDependent())) { in CorrectDelayedTyposInExpr()
9036 TyposResolved -= DelayedTypos.size(); in CorrectDelayedTyposInExpr()
9038 ExprEvalContexts.back().NumTypos -= TyposResolved; in CorrectDelayedTyposInExpr()
9043 return this->SemaRef.CreateRecoveryExpr(E->getBeginLoc(), in CorrectDelayedTyposInExpr()
9044 E->getEndLoc(), {}); in CorrectDelayedTyposInExpr()
9068 // Top-level expressions default to 'id' when we're in a debugger. in ActOnFinishFullExpr()
9070 FullExpr.get()->getType() == Context.UnknownAnyTy) { in ActOnFinishFullExpr()
9096 // have the outer capture-able lambda try and capture it. in ActOnFinishFullExpr()
9104 // f(x, b); <-- requires x to be captured by L and M in ActOnFinishFullExpr()
9105 // f(y, a); <-- requires y to be captured by L, but not all Ms in ActOnFinishFullExpr()
9111 // the gnu-extension statement-expressions or even lambda-init-captures: in ActOnFinishFullExpr()
9119 // Here, we see +n, and then the full-expression 0; ends, so we don't in ActOnFinishFullExpr()
9121 // and then the full-expression +n + ({ 0; }); ends, but it's too late in ActOnFinishFullExpr()
9134 // - Add to Sema an integer holding the smallest (outermost) scope in ActOnFinishFullExpr()
9138 // - Teach the handful of places that iterate over FunctionScopes to in ActOnFinishFullExpr()
9142 DC = DC->getParent(); in ActOnFinishFullExpr()
9145 CurrentLSI->hasPotentialCaptures() && !FullExpr.isInvalid()) in ActOnFinishFullExpr()
9227 ASTTemplateArgsPtr ArgsPtr(TemplateId->getTemplateArgs(), in ActOnTypeRequirement()
9228 TemplateId->NumArgs); in ActOnTypeRequirement()
9230 TemplateId->TemplateKWLoc, in ActOnTypeRequirement()
9231 TemplateId->Template, TemplateId->Name, in ActOnTypeRequirement()
9232 TemplateId->TemplateNameLoc, in ActOnTypeRequirement()
9233 TemplateId->LAngleLoc, ArgsPtr, in ActOnTypeRequirement()
9234 TemplateId->RAngleLoc); in ActOnTypeRequirement()
9256 // parameter T declared with the constrained-parameter. Form a new in ActOnCompoundRequirement()
9257 // cv-qualifier-seq cv by taking the union of const and volatile specifiers in ActOnCompoundRequirement()
9258 // around the constrained-parameter. F has a single parameter whose in ActOnCompoundRequirement()
9259 // type-specifier is cv T followed by the abstract-declarator. [...] in ActOnCompoundRequirement()
9261 // The cv part is done in the calling function - we get the concept with in ActOnCompoundRequirement()
9264 auto &II = Context.Idents.get("expr-type"); in ActOnCompoundRequirement()
9295 if (E->isInstantiationDependent() || E->getType()->isPlaceholderType() || in BuildExprRequirement()
9304 // The immediately-declared constraint ([temp]) of decltype((E)) shall in BuildExprRequirement()
9313 auto *Param = cast<TemplateTypeParmDecl>(TPL->getParam(0)); in BuildExprRequirement()
9316 MLTAL.addOuterRetainedLevels(TPL->getDepth()); in BuildExprRequirement()
9317 const TypeConstraint *TC = Param->getTypeConstraint(); in BuildExprRequirement()
9319 auto *IDC = TC->getImmediatelyDeclaredConstraint(); in BuildExprRequirement()
9324 concepts::createSubstDiagAt(*this, IDC->getExprLoc(), in BuildExprRequirement()
9326 IDC->printPretty(OS, /*Helper=*/nullptr, in BuildExprRequirement()
9333 if (!SubstitutedConstraintExpr->isSatisfied()) in BuildExprRequirement()
9369 if (!Constraint->isInstantiationDependent() && in BuildNestedRequirement()
9371 Constraint->getSourceRange(), Satisfaction)) in BuildNestedRequirement()
9397 if (Param->hasDefaultArg()) in ActOnStartRequiresExpr()
9399 // [...] A local parameter of a requires-expression shall not have a in ActOnStartRequiresExpr()
9401 Diag(Param->getDefaultArgRange().getBegin(), in ActOnStartRequiresExpr()
9405 Param->setDeclContext(Body); in ActOnStartRequiresExpr()
9407 if (Param->getIdentifier()) { in ActOnStartRequiresExpr()
9417 CurContext = CurContext->getLexicalParent(); in ActOnFinishRequiresExpr()