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