;
73 if(!isa<ConstantArrayType>(AT) && !isa<IncompleteArrayType>(AT))
91 autoIsCharOrUnsignedChar = [](
const QualType&
T) {
92 const BuiltinType*BT = dyn_cast<BuiltinType>(
T.getTypePtr());
97 caseStringLiteralKind::UTF8:
107 caseStringLiteralKind::Ordinary:
111 return(SL->
getKind() == StringLiteralKind::UTF8 &&
125 caseStringLiteralKind::UTF16:
133 caseStringLiteralKind::UTF32:
141 caseStringLiteralKind::Wide:
149 caseStringLiteralKind::Unevaluated:
150assert(
false&&
"Unevaluated string literal in initialization");
154llvm_unreachable(
"missed a StringLiteral kind?");
175 if(isa<StringLiteral>(
E) || isa<ObjCEncodeExpr>(
E))
186 if(isa<CompoundLiteralExpr>(
E))
201 if(
const auto*VD = dyn_cast_if_present<VarDecl>(
D); VD && VD->isConstexpr())
211 Sema&S,
boolCheckC23ConstexprInit =
false) {
213 auto*ConstantArrayTy =
215uint64_t StrLength = ConstantArrayTy->getZExtSize();
217 if(CheckC23ConstexprInit)
224llvm::APInt ConstVal(32, StrLength);
250diag::err_initializer_string_for_char_array_too_long)
256diag::ext_initializer_string_for_char_array_too_long)
269 if(Field->hasAttr<ExplicitInitAttr>())
270S.
Diag(Field->getLocation(), diag::note_entity_declared_at) << Field;
311classInitListChecker {
313 boolhadError =
false;
315 boolTreatUnavailableAsInvalid;
316 boolInOverloadResolution;
321 unsignedCurEmbedIndex = 0;
332 unsigned&StructuredIndex);
336 boolTopLevelObject =
false);
339 boolSubobjectIsDesignatorContext,
342 unsigned&StructuredIndex,
343 boolTopLevelObject =
false);
348 unsigned&StructuredIndex,
349 boolDirectlyDesignated =
false);
354 unsigned&StructuredIndex);
359 unsigned&StructuredIndex);
364 unsigned&StructuredIndex);
368 unsigned&StructuredIndex);
373 boolSubobjectIsDesignatorContext,
unsigned&Index,
375 unsigned&StructuredIndex,
376 boolTopLevelObject =
false);
379llvm::APSInt elementIndex,
380 boolSubobjectIsDesignatorContext,
unsigned&Index,
382 unsigned&StructuredIndex);
388llvm::APSInt *NextElementIndex,
391 unsigned&StructuredIndex,
392 boolFinishSubobjectInit,
393 boolTopLevelObject);
397 unsignedStructuredIndex,
399 boolIsFullyOverwritten =
false);
400 voidUpdateStructuredListElement(
InitListExpr*StructuredList,
401 unsigned&StructuredIndex,
405 unsignedExpectedNumInits);
406 intnumArrayElements(
QualTypeDeclType);
407 intnumStructUnionElements(
QualTypeDeclType);
415 boolUnionOverride =
false,
416 boolFullyOverwritten =
true) {
421? (UnionOverride ? diag::ext_initializer_union_overrides
422: diag::ext_initializer_overrides)
423: diag::warn_initializer_overrides;
425 if(InOverloadResolution && SemaRef.
getLangOpts().CPlusPlus) {
446DiagID = diag::err_initializer_overrides_destructed;
466<< NewInitRange << FullyOverwritten << OldInit->
getType();
467SemaRef.
Diag(OldInit->
getBeginLoc(), diag::note_previous_initializer)
495 boolFillWithNoInit);
496 voidFillInEmptyInitForField(
unsigned Init,
FieldDecl*Field,
499 boolFillWithNoInit =
false);
503 boolFillWithNoInit =
false);
506 boolTopLevelObject);
511 Expr*Result =
nullptr;
523assert(AType &&
"expected array type when initializing array");
525 if(
const auto*CAType = dyn_cast<ConstantArrayType>(AType))
526ElsCount = std::min(CAType->getSize().getZExtValue(),
527ElsCount - CurEmbedIndex);
535Result =
new(SemaRef.
Context)
537CurEmbedIndex, ElsCount);
538CurEmbedIndex += ElsCount;
549 boolVerifyOnly,
boolTreatUnavailableAsInvalid,
550 boolInOverloadResolution =
false,
555: InitListChecker(S, Entity, IL,
T,
true,
558&AggrDeductionCandidateParamTypes) {}
560 boolHadError() {
returnhadError; }
564 InitListExpr*getFullyStructuredList()
const{
returnFullyStructuredList; }
581 boolEmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
594InitExpr = VerifyOnly ? &DummyInitList
611 if(!InitSeq && EmptyInitList && InitSeq.getFailureKind() ==
615InitSeq.getFailedCandidateSet()
616.BestViableFunction(SemaRef,
Kind.getLocation(), Best);
618assert(O ==
OR_Success&&
"Inconsistent overload resolution");
625 boolIsInStd =
false;
627ND && !IsInStd; ND = dyn_cast<NamespaceDecl>(ND->getParent())) {
632 if(IsInStd && llvm::StringSwitch<bool>(R->
getName())
633.Cases(
"basic_string",
"deque",
"forward_list",
true)
634.Cases(
"list",
"map",
"multimap",
"multiset",
true)
635.Cases(
"priority_queue",
"queue",
"set",
"stack",
true)
636.Cases(
"unordered_map",
"unordered_set",
"vector",
true)
638InitSeq.InitializeFrom(
642TreatUnavailableAsInvalid);
647diag::warn_invalid_initializer_from_system_header);
650diag::note_used_in_initialization_here);
652SemaRef.
Diag(
Loc, diag::note_used_in_initialization_here);
659InitSeq.Diagnose(SemaRef, Entity, Kind, SubInit);
662diag::note_in_omitted_aggregate_initializer)
665 boolIsTrailingArrayNewMember =
668SemaRef.
Diag(
Loc, diag::note_in_omitted_aggregate_initializer)
669<< (IsTrailingArrayNewMember ? 2 :
0)
678: InitSeq.Perform(SemaRef, Entity,
Kind, SubInit);
686 if(FullyStructuredList)
688PerformEmptyInit(
Loc, Entity);
691voidInitListChecker::FillInEmptyInitForBase(
694 bool&RequiresSecondPass,
boolFillWithNoInit) {
696SemaRef.
Context, &
Base,
false, &ParentEntity);
701: PerformEmptyInit(ILE->
getEndLoc(), BaseEntity);
708assert(Init < ILE->getNumInits() &&
"should have been expanded");
713FillInEmptyInitializations(BaseEntity, InnerILE, RequiresSecondPass,
714ILE,
Init, FillWithNoInit);
716dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(
Init))) {
717FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
718RequiresSecondPass, ILE,
Init,
723voidInitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl*Field,
726 bool&RequiresSecondPass,
727 boolFillWithNoInit) {
735 if(!RType->getDecl()->isUnion())
736assert((
Init< NumInits || VerifyOnly) &&
737 "This ILE should have been expanded");
739 if(FillWithNoInit) {
740assert(!VerifyOnly &&
"should not fill with no-init in verify-only mode");
742 if(
Init< NumInits)
749 if(!VerifyOnly &&
Field->hasAttr<ExplicitInitAttr>()) {
750SemaRef.
Diag(ILE->
getExprLoc(), diag::warn_field_requires_explicit_init)
752SemaRef.
Diag(
Field->getLocation(), diag::note_entity_declared_at)
760 if(
Field->hasInClassInitializer()) {
786 if(
Init< NumInits)
790RequiresSecondPass =
true;
795 if(
Field->getType()->isReferenceType()) {
801SemaRef.
Diag(
Loc, diag::err_init_reference_member_uninitialized)
805SemaRef.
Diag(
Field->getLocation(), diag::note_uninit_reference_member);
811 ExprResultMemberInit = PerformEmptyInit(
Loc, MemberEntity);
817 if(hadError || VerifyOnly) {
819}
else if(
Init< NumInits) {
821}
else if(!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
827RequiresSecondPass =
true;
830= dyn_cast<InitListExpr>(ILE->
getInit(
Init))) {
831FillInEmptyInitializations(MemberEntity, InnerILE,
832RequiresSecondPass, ILE,
Init, FillWithNoInit);
834dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(
Init))) {
835FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
836RequiresSecondPass, ILE,
Init,
847 bool&RequiresSecondPass,
850 boolFillWithNoInit) {
852 "Should not have void type");
856 if(FillWithNoInit && VerifyOnly)
866 structUpdateOuterILEWithUpdatedInit {
869~UpdateOuterILEWithUpdatedInit() {
873} UpdateOuterRAII = {OuterILE, OuterIndex};
884RequiresSecondPass, FillWithNoInit);
886assert((!RDecl->
isUnion() || !isa<CXXRecordDecl>(RDecl) ||
887!cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) &&
888 "We should have computed initialized fields already");
892 unsignedNumElems = numStructUnionElements(ILE->
getType());
895 if(!VerifyOnly && ILE->
getNumInits() < NumElems)
900 if(
auto*CXXRD = dyn_cast<CXXRecordDecl>(RDecl)) {
901 for(
auto&
Base: CXXRD->bases()) {
905FillInEmptyInitForBase(
Init,
Base, Entity, ILE, RequiresSecondPass,
911 for(
auto*Field : RDecl->
fields()) {
912 if(
Field->isUnnamedBitField())
918FillInEmptyInitForField(
Init, Field, Entity, ILE, RequiresSecondPass,
940ElementType = AType->getElementType();
941 if(
const auto*CAType = dyn_cast<ConstantArrayType>(AType))
942NumElements = CAType->getZExtSize();
950ElementType = VType->getElementType();
951NumElements = VType->getNumElements();
955ElementType = ILE->
getType();
957 boolSkipEmptyInitChecks =
false;
958 for(uint64_t
Init= 0;
Init!= NumElements; ++
Init) {
970 if(!InitExpr && Init < NumInits && ILE->hasArrayFiller())
975 if(SkipEmptyInitChecks)
978 Expr*Filler =
nullptr;
984PerformEmptyInit(ILE->
getEndLoc(), ElementEntity);
995}
else if(VerifyOnly) {
996SkipEmptyInitChecks =
true;
997}
else if(
Init< NumInits) {
1012 if(!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
1018RequiresSecondPass =
true;
1022= dyn_cast_or_null<InitListExpr>(InitExpr)) {
1023FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
1024ILE,
Init, FillWithNoInit);
1026dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr)) {
1027FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
1028RequiresSecondPass, ILE,
Init,
1036 if(isa_and_nonnull<DesignatedInitExpr>(
Init))
1041InitListChecker::InitListChecker(
1043 boolVerifyOnly,
boolTreatUnavailableAsInvalid,
boolInOverloadResolution,
1045: SemaRef(S), VerifyOnly(VerifyOnly),
1046TreatUnavailableAsInvalid(TreatUnavailableAsInvalid),
1047InOverloadResolution(InOverloadResolution),
1048AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes) {
1050FullyStructuredList =
1059CheckExplicitInitList(Entity, IL,
T, FullyStructuredList,
1062 if(!hadError && !AggrDeductionCandidateParamTypes && FullyStructuredList) {
1063 boolRequiresSecondPass =
false;
1064FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass,
1066 if(RequiresSecondPass && !hadError)
1067FillInEmptyInitializations(Entity, FullyStructuredList,
1068RequiresSecondPass,
nullptr, 0);
1070 if(hadError && FullyStructuredList)
1074intInitListChecker::numArrayElements(
QualTypeDeclType) {
1076 intmaxElements = 0x7FFFFFFF;
1079maxElements =
static_cast<int>(CAT->getZExtSize());
1084intInitListChecker::numStructUnionElements(
QualTypeDeclType) {
1086 intInitializableMembers = 0;
1087 if(
auto*CXXRD = dyn_cast<CXXRecordDecl>(structDecl))
1088InitializableMembers += CXXRD->getNumBases();
1089 for(
const auto*Field : structDecl->
fields())
1090 if(!
Field->isUnnamedBitField())
1091++InitializableMembers;
1094 returnstd::min(InitializableMembers, 1);
1100 returnRT->getDecl();
1102 returnInject->getDecl();
1132 if(
CXXRecordDecl*CXXRD = dyn_cast<CXXRecordDecl>(ParentRD)) {
1133 if(CXXRD->getNumBases()) {
1137 autoFieldIt = ParentRD->field_begin();
1138assert(FieldIt != ParentRD->field_end() &&
1139 "no fields but have initializer for member?");
1140 return++FieldIt == ParentRD->field_end();
1156 unsigned&StructuredIndex) {
1157 intmaxElements = 0;
1160maxElements = numArrayElements(
T);
1162maxElements = numStructUnionElements(
T);
1166llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
1168 if(maxElements == 0) {
1171diag::err_implicit_empty_initializer);
1178 InitListExpr*StructuredSubobjectInitList = getStructuredSubobjectInit(
1179ParentIList, Index,
T, StructuredList, StructuredIndex,
1182 unsignedStructuredSubobjectInitIndex = 0;
1185 unsignedStartIndex = Index;
1186CheckListElementTypes(Entity, ParentIList,
T,
1188StructuredSubobjectInitList,
1189StructuredSubobjectInitIndex);
1191 if(StructuredSubobjectInitList) {
1192StructuredSubobjectInitList->
setType(
T);
1194 unsignedEndIndex = (Index == StartIndex? StartIndex : Index - 1);
1197 if(EndIndex < ParentIList->getNumInits() &&
1198ParentIList->
getInit(EndIndex)) {
1209diag::warn_missing_braces)
1212StructuredSubobjectInitList->
getBeginLoc(),
"{")
1215StructuredSubobjectInitList->
getEndLoc()),
1221 if(!VerifyOnly && CXXRD && CXXRD->hasUserDeclaredConstructor()) {
1223diag::warn_cxx20_compat_aggregate_init_with_ctors)
1239 unsignedDiagID = 0;
1251DiagID = diag::warn_braces_around_init;
1258DiagID = diag::warn_braces_around_init;
1284llvm_unreachable(
"unexpected braced scalar init");
1303 boolTopLevelObject) {
1304 unsignedIndex = 0, StructuredIndex = 0;
1305CheckListElementTypes(Entity, IList,
T,
true,
1306Index, StructuredList, StructuredIndex, TopLevelObject);
1307 if(StructuredList) {
1313StructuredList->
setType(ExprTy);
1321 boolExtraInitsIsError = SemaRef.
getLangOpts().CPlusPlus ||
1323hadError = ExtraInitsIsError;
1326}
else if(StructuredIndex == 1 &&
1331? diag::err_excess_initializers_in_char_array_initializer
1332: diag::ext_excess_initializers_in_char_array_initializer;
1336 unsignedDK = ExtraInitsIsError
1337? diag::err_excess_initializers_for_sizeless_type
1338: diag::ext_excess_initializers_for_sizeless_type;
1348 unsignedDK = ExtraInitsIsError ? diag::err_excess_initializers
1349: diag::ext_excess_initializers;
1357!isa<InitListExpr>(IList->
getInit(0)))
1363 if(CXXRD && CXXRD->hasUserDeclaredConstructor()) {
1366 boolHasEquivCtor =
false;
1369HasEquivCtor = CD && !CD->
isDeleted();
1372 if(!HasEquivCtor) {
1374diag::warn_cxx20_compat_aggregate_init_with_ctors)
1384 boolSubobjectIsDesignatorContext,
1387 unsigned&StructuredIndex,
1388 boolTopLevelObject) {
1392CheckComplexType(Entity, IList, DeclType, Index,
1393StructuredList, StructuredIndex);
1395CheckScalarType(Entity, IList, DeclType, Index,
1396StructuredList, StructuredIndex);
1398CheckVectorType(Entity, IList, DeclType, Index,
1399StructuredList, StructuredIndex);
1400}
else if(
const RecordDecl*RD = getRecordDecl(DeclType)) {
1406 "non-aggregate records should be handed in CheckSubElementType");
1407 if(
auto*CXXRD = dyn_cast<CXXRecordDecl>(RD))
1408Bases = CXXRD->bases();
1410Bases = cast<CXXRecordDecl>(RD)->bases();
1412CheckStructUnionTypes(Entity, IList, DeclType, Bases, RD->field_begin(),
1413SubobjectIsDesignatorContext, Index, StructuredList,
1414StructuredIndex, TopLevelObject);
1419CheckArrayType(Entity, IList, DeclType, Zero,
1420SubobjectIsDesignatorContext, Index,
1421StructuredList, StructuredIndex);
1426SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1430CheckReferenceType(Entity, IList, DeclType, Index,
1431StructuredList, StructuredIndex);
1434SemaRef.
Diag(IList->
getBeginLoc(), diag::err_init_objc_class) << DeclType;
1439CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1446assert(AggrDeductionCandidateParamTypes);
1447AggrDeductionCandidateParamTypes->push_back(DeclType);
1450SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1461 unsigned&StructuredIndex,
1462 boolDirectlyDesignated) {
1466 returnCheckReferenceType(Entity, IList, ElemType, Index,
1467StructuredList, StructuredIndex);
1470 if(SubInitList->getNumInits() == 1 &&
1475 expr= SubInitList->getInit(0);
1478}
else if(isa<ImplicitValueInitExpr>(
expr)) {
1482 "found implicit initialization for the wrong type");
1483UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1505 if(TmpEntity.getType()->isDependentType()) {
1510assert(AggrDeductionCandidateParamTypes);
1524 if(isa<InitListExpr, DesignatedInitExpr>(
expr) ||
1525!isa_and_present<ConstantArrayType>(
1528AggrDeductionCandidateParamTypes->push_back(ElemType);
1540 if(
Seq|| isa<InitListExpr>(
expr)) {
1541 if(
auto*Embed = dyn_cast<EmbedExpr>(
expr)) {
1542 expr= HandleEmbed(Embed, Entity);
1546 if(Result.isInvalid())
1549UpdateStructuredListElement(StructuredList, StructuredIndex,
1550Result.getAs<
Expr>());
1551}
else if(!
Seq) {
1553}
else if(StructuredList) {
1554UpdateStructuredListElement(StructuredList, StructuredIndex,
1559 if(AggrDeductionCandidateParamTypes)
1560AggrDeductionCandidateParamTypes->push_back(ElemType);
1568 returnCheckScalarType(Entity, IList, ElemType, Index,
1569StructuredList, StructuredIndex);
1583UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1612UpdateStructuredListElement(StructuredList, StructuredIndex,
1630CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1635 if(DirectlyDesignated && SemaRef.
getLangOpts().CPlusPlus && !hadError) {
1636 if(InOverloadResolution)
1639SemaRef.
Diag(
expr->getBeginLoc(),
1640diag::ext_designated_init_brace_elision)
1641<<
expr->getSourceRange()
1656assert(
Copy.isInvalid() &&
1657 "expected non-aggregate initialization to fail");
1669 unsigned&StructuredIndex) {
1670assert(Index == 0 &&
"Index in explicit init list must be zero");
1680 returnCheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1685 if(!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1686SemaRef.
Diag(IList->
getBeginLoc(), diag::ext_complex_component_init)
1694 for(
unsignedi = 0; i < 2; ++i) {
1696CheckSubElementType(ElementEntity, IList, elementType, Index,
1697StructuredList, StructuredIndex);
1705 unsigned&StructuredIndex) {
1712? diag::warn_cxx98_compat_empty_sizeless_initializer
1713: diag::err_empty_sizeless_initializer)
1718? diag::warn_cxx98_compat_empty_scalar_initializer
1719: diag::err_empty_scalar_initializer)
1735SemaRef.
Diag(SubIList->getBeginLoc(), diag::ext_many_braces_around_init)
1738CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1741}
else if(isa<DesignatedInitExpr>(
expr)) {
1743SemaRef.
Diag(
expr->getBeginLoc(),
1744diag::err_designator_for_scalar_or_sizeless_init)
1746<<
expr->getSourceRange();
1751}
else if(
auto*Embed = dyn_cast<EmbedExpr>(
expr)) {
1752 expr= HandleEmbed(Embed, Entity);
1758Result = getDummyInit();
1767 Expr*ResultExpr =
nullptr;
1769 if(Result.isInvalid())
1772ResultExpr = Result.getAs<
Expr>();
1774 if(ResultExpr !=
expr&& !VerifyOnly && !CurEmbed) {
1777IList->
setInit(Index, ResultExpr);
1781UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1784 if(AggrDeductionCandidateParamTypes)
1785AggrDeductionCandidateParamTypes->push_back(DeclType);
1792 unsigned&StructuredIndex) {
1800diag::err_init_reference_member_uninitialized)
1809 if(isa<InitListExpr>(
expr) && !SemaRef.
getLangOpts().CPlusPlus11) {
1811SemaRef.
Diag(IList->
getBeginLoc(), diag::err_init_non_aggr_init_list)
1822Result = getDummyInit();
1831 if(Result.isInvalid())
1836 if(!VerifyOnly &&
expr)
1839UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1841 if(AggrDeductionCandidateParamTypes)
1842AggrDeductionCandidateParamTypes->push_back(DeclType);
1849 unsigned&StructuredIndex) {
1852 unsignednumEltsInit = 0;
1857CheckEmptyInitializable(
1867 if(!isa<InitListExpr>(
Init) &&
Init->getType()->isVectorType()) {
1871Result = getDummyInit();
1880 Expr*ResultExpr =
nullptr;
1881 if(Result.isInvalid())
1884ResultExpr = Result.getAs<
Expr>();
1886 if(ResultExpr !=
Init&& !VerifyOnly) {
1889IList->
setInit(Index, ResultExpr);
1892UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1894 if(AggrDeductionCandidateParamTypes)
1895AggrDeductionCandidateParamTypes->push_back(elementType);
1902 for(
unsignedi = 0; i < maxElements; ++i, ++numEltsInit) {
1905CheckEmptyInitializable(ElementEntity, IList->
getEndLoc());
1910CheckSubElementType(ElementEntity, IList, elementType, Index,
1911StructuredList, StructuredIndex);
1919 if(isBigEndian && (
T->getVectorKind() == VectorKind::Neon ||
1920 T->getVectorKind() == VectorKind::NeonPoly)) {
1932diag::warn_neon_vector_initializer_non_portable);
1934 const char*typeCode;
1944llvm_unreachable(
"Invalid element type!");
1948? diag::note_neon_vector_initializer_non_portable_q
1949: diag::note_neon_vector_initializer_non_portable)
1950<< typeCode << typeSize;
1960 for(
unsignedi = 0; i < maxElements; ++i) {
1969CheckSubElementType(ElementEntity, IList, elementType, Index,
1970StructuredList, StructuredIndex);
1982CheckSubElementType(ElementEntity, IList, VecType, Index,
1983StructuredList, StructuredIndex);
1984numEltsInit += numIElts;
1989 if(numEltsInit != maxElements) {
1992diag::err_vector_incorrect_num_elements)
1993<< (numEltsInit < maxElements) << maxElements << numEltsInit
2020SemaRef.
PDiag(diag::err_access_dtor_temp)
2034InitType =
Parent->getType();
2040ExprList.size() == 1
2041? dyn_cast_if_present<EmbedExpr>(ExprList[0]->IgnoreParens())
2056llvm::APSInt elementIndex,
2057 boolSubobjectIsDesignatorContext,
2060 unsigned&StructuredIndex) {
2078 if(Index < IList->getNumInits()) {
2091 if(StructuredList) {
2092UpdateStructuredListElement(StructuredList, StructuredIndex,
2097 if(AggrDeductionCandidateParamTypes)
2098AggrDeductionCandidateParamTypes->push_back(DeclType);
2119SemaRef.
Diag(VAT->getSizeExpr()->getBeginLoc(),
2120diag::err_variable_object_no_init)
2121<< VAT->getSizeExpr()->getSourceRange();
2130llvm::APSInt maxElements(elementIndex.getBitWidth(),
2131elementIndex.isUnsigned());
2132 boolmaxElementsKnown =
false;
2134maxElements = CAT->getSize();
2135elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
2136elementIndex.setIsUnsigned(maxElements.isUnsigned());
2137maxElementsKnown =
true;
2141 while(Index < IList->getNumInits()) {
2147 if(!SubobjectIsDesignatorContext)
2152 if(CheckDesignatedInitializer(Entity, IList, DIE, 0,
2153DeclType,
nullptr, &elementIndex, Index,
2154StructuredList, StructuredIndex,
true,
2160 if(elementIndex.getBitWidth() > maxElements.getBitWidth())
2161maxElements = maxElements.extend(elementIndex.getBitWidth());
2162 else if(elementIndex.getBitWidth() < maxElements.getBitWidth())
2163elementIndex = elementIndex.extend(maxElements.getBitWidth());
2164elementIndex.setIsUnsigned(maxElements.isUnsigned());
2168 if(!maxElementsKnown && elementIndex > maxElements)
2169maxElements = elementIndex;
2176 if(maxElementsKnown && elementIndex == maxElements)
2180SemaRef.
Context, StructuredIndex, Entity);
2182 unsignedEmbedElementIndexBeforeInit = CurEmbedIndex;
2184CheckSubElementType(ElementEntity, IList, elementType, Index,
2185StructuredList, StructuredIndex);
2187 if((CurEmbed || isa<EmbedExpr>(
Init)) && elementType->
isScalarType()) {
2190elementIndex + CurEmbedIndex - EmbedElementIndexBeforeInit - 1;
2192 autoEmbed = cast<EmbedExpr>(
Init);
2194EmbedElementIndexBeforeInit - 1;
2200 if(!maxElementsKnown && elementIndex > maxElements)
2201maxElements = elementIndex;
2206llvm::APSInt
Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
2210SemaRef.
Diag(IList->
getBeginLoc(), diag::ext_typecheck_zero_array_size);
2214elementType, maxElements,
nullptr, ArraySizeModifier::Normal, 0);
2221 if((maxElementsKnown && elementIndex < maxElements) ||
2223CheckEmptyInitializable(
2232 boolTopLevelObject) {
2234 unsignedFlexArrayDiag;
2235 if(isa<InitListExpr>(InitExpr) &&
2236cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
2238FlexArrayDiag = diag::ext_flexible_array_init;
2239}
else if(!TopLevelObject) {
2241FlexArrayDiag = diag::err_flexible_array_init;
2244FlexArrayDiag = diag::err_flexible_array_init;
2245}
else if(cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
2247FlexArrayDiag = diag::err_flexible_array_init;
2250FlexArrayDiag = diag::ext_flexible_array_init;
2256SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
2260 returnFlexArrayDiag != diag::ext_flexible_array_init;
2264 returnStructuredList && StructuredList->
getNumInits() == 1U;
2267voidInitListChecker::CheckStructUnionTypes(
2270 boolSubobjectIsDesignatorContext,
unsigned&Index,
2271 InitListExpr*StructuredList,
unsigned&StructuredIndex,
2272 boolTopLevelObject) {
2273 const RecordDecl*RD = getRecordDecl(DeclType);
2295 if(isa<CXXRecordDecl>(RD) &&
2296cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
2297 if(!StructuredList)
2300Field != FieldEnd; ++Field) {
2301 if(
Field->hasInClassInitializer() ||
2302(
Field->isAnonymousStructOrUnion() &&
2303 Field->getType()->getAsCXXRecordDecl()->hasInClassInitializer())) {
2309llvm_unreachable(
"Couldn't find in-class initializer");
2315Field != FieldEnd; ++Field) {
2316 if(!
Field->isUnnamedBitField()) {
2317CheckEmptyInitializable(
2328 boolInitializedSomething =
false;
2331 for(
autoI = Bases.begin(),
E= Bases.end(); I !=
E; ++I) {
2337 if(isa_and_nonnull<DesignatedInitExpr>(
Init))
2354 if(AggrDeductionCandidateParamTypes &&
Base.isPackExpansion()) {
2355AggrDeductionCandidateParamTypes->push_back(
2360 if(Index < IList->getNumInits())
2372CheckSubElementType(BaseEntity, IList,
Base.getType(), Index,
2373StructuredList, StructuredIndex);
2374InitializedSomething =
true;
2376CheckEmptyInitializable(BaseEntity, InitLoc);
2391 size_tNumRecordDecls = llvm::count_if(RD->
decls(), [&](
const Decl*
D) {
2392return isa<FieldDecl>(D) || isa<RecordDecl>(D);
2394 boolHasDesignatedInit =
false;
2398 while(Index < IList->getNumInits()) {
2406 if(!SubobjectIsDesignatorContext)
2409HasDesignatedInit =
true;
2413 boolDesignatedInitFailed = CheckDesignatedInitializer(
2414Entity, IList, DIE, 0, DeclType, &Field,
nullptr, Index,
2415StructuredList, StructuredIndex,
true, TopLevelObject);
2416 if(DesignatedInitFailed)
2421 if(!VerifyOnly &&
D->isFieldDesignator()) {
2423InitializedFields.insert(F);
2424 if(!DesignatedInitFailed) {
2433InitializedSomething =
true;
2450 if(NumRecordDecls == 1)
2452 if(
const auto*IL = dyn_cast<IntegerLiteral>(I))
2453 returnIL->getValue().isZero();
2461SemaRef.
Diag(InitLoc, diag::err_non_designated_init_used);
2466 if(Field == FieldEnd) {
2472 if(InitializedSomething && RD->
isUnion())
2476 if(
Field->getType()->isIncompleteArrayType())
2479 if(
Field->isUnnamedBitField()) {
2488InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2509CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
2510StructuredList, StructuredIndex);
2511InitializedSomething =
true;
2512InitializedFields.insert(*Field);
2524 boolIsCDesignatedInitializer =
2525HasDesignatedInit && !SemaRef.
getLangOpts().CPlusPlus;
2526 if(!VerifyOnly && InitializedSomething && !RD->
isUnion() &&
2528!IsCDesignatedInitializer) {
2535 if(HasDesignatedInit && InitializedFields.count(*it))
2538 if(!it->isUnnamedBitField() && !it->hasInClassInitializer() &&
2539!it->getType()->isIncompleteArrayType()) {
2540 auto Diag= HasDesignatedInit
2541? diag::warn_missing_designated_field_initializers
2542: diag::warn_missing_field_initializers;
2551 if(!StructuredList && Field != FieldEnd && !RD->
isUnion() &&
2552!
Field->getType()->isIncompleteArrayType()) {
2553 for(;
Field!= FieldEnd && !hadError; ++
Field) {
2554 if(!
Field->isUnnamedBitField() && !
Field->hasInClassInitializer())
2555CheckEmptyInitializable(
2576 if(Field == FieldEnd || !
Field->getType()->isIncompleteArrayType() ||
2580 if(CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
2590 if(isa<InitListExpr>(IList->
getInit(Index)) ||
2591AggrDeductionCandidateParamTypes)
2592CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
2593StructuredList, StructuredIndex);
2595CheckImplicitInitList(MemberEntity, IList,
Field->getType(), Index,
2596StructuredList, StructuredIndex);
2617PE = IndirectField->
chain_end(); PI != PE; ++PI) {
2625assert(isa<FieldDecl>(*PI));
2626Replacements.back().setFieldDecl(cast<FieldDecl>(*PI));
2633&Replacements[0] + Replacements.size());
2640 for(
unsignedI = 0; I < NumIndexExprs; ++I)
2654 explicitFieldInitializerValidatorCCC(
const RecordDecl*RD)
2662std::unique_ptr<CorrectionCandidateCallback>
clone()
override{
2663 returnstd::make_unique<FieldInitializerValidatorCCC>(*
this);
2716llvm::APSInt *NextElementIndex,
2719 unsigned&StructuredIndex,
2720 boolFinishSubobjectInit,
2721 boolTopLevelObject) {
2722 if(DesigIdx == DIE->
size()) {
2729assert(isa<InitListExpr>(
Init) &&
2730 "designator result in direct non-list initialization?");
2735 if(StructuredList) {
2739UpdateStructuredListElement(StructuredList, StructuredIndex,
2743 if(AggrDeductionCandidateParamTypes)
2744AggrDeductionCandidateParamTypes->push_back(CurrentObjectType);
2749 boolprevHadError = hadError;
2754 unsignedOldIndex = Index;
2757CheckSubElementType(Entity, IList, CurrentObjectType, Index, StructuredList,
2758StructuredIndex,
true);
2764IList->
setInit(OldIndex, DIE);
2766 returnhadError && !prevHadError;
2770 boolIsFirstDesignator = (DesigIdx == 0);
2771 if(IsFirstDesignator ? FullyStructuredList : StructuredList) {
2774 if(IsFirstDesignator)
2775StructuredList = FullyStructuredList;
2777 Expr*ExistingInit = StructuredIndex < StructuredList->getNumInits() ?
2778StructuredList->getInit(StructuredIndex) :
nullptr;
2779 if(!ExistingInit && StructuredList->hasArrayFiller())
2780ExistingInit = StructuredList->getArrayFiller();
2783StructuredList = getStructuredSubobjectInit(
2784IList, Index, CurrentObjectType, StructuredList, StructuredIndex,
2786 else if(
InitListExpr*Result = dyn_cast<InitListExpr>(ExistingInit))
2787StructuredList = Result;
2800diagnoseInitOverride(ExistingInit,
2807dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2808StructuredList =
E->getUpdater();
2813StructuredList->updateInit(SemaRef.
Context, StructuredIndex, DIUE);
2822StructuredList =
nullptr;
2828 if(
D->isFieldDesignator()) {
2838 RecordDecl*RD = getRecordDecl(CurrentObjectType);
2842 Loc=
D->getFieldLoc();
2844SemaRef.
Diag(
Loc, diag::err_field_designator_non_aggr)
2845<< SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2854 if(
auto*FD = dyn_cast_if_present<FieldDecl>(VD)) {
2856}
else if(
auto*IFD = dyn_cast_if_present<IndirectFieldDecl>(VD)) {
2862KnownField = cast<FieldDecl>(*IFD->chain_begin());
2878!Lookup.
empty()) {
2879SemaRef.
Diag(
D->getFieldLoc(), diag::err_field_designator_nonfield)
2881SemaRef.
Diag(Lookup.front()->getLocation(),
2882diag::note_field_designator_found);
2889FieldInitializerValidatorCCC CCC(RD);
2896SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2897<< FieldName << CurrentObjectType);
2898KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2909SemaRef.
Diag(
Loc, diag::err_field_designator_unknown)
2917 unsignedNumBases = 0;
2918 if(
auto*CXXRD = dyn_cast<CXXRecordDecl>(RD))
2919NumBases = CXXRD->getNumBases();
2921 unsignedFieldIndex = NumBases;
2923 for(
auto*FI : RD->
fields()) {
2924 if(FI->isUnnamedBitField())
2940 if(StructuredList) {
2941 FieldDecl*CurrentField = StructuredList->getInitializedFieldInUnion();
2943assert(StructuredList->getNumInits() == 1
2944&&
"A union should never have more than one initializer!");
2946 Expr*ExistingInit = StructuredList->getInit(0);
2949diagnoseInitOverride(
2957StructuredList->resizeInits(SemaRef.
Context, 0);
2958StructuredList->setInitializedFieldInUnion(
nullptr);
2961StructuredList->setInitializedFieldInUnion(*Field);
2968InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2991 if(IsFirstDesignator && !VerifyOnly && SemaRef.
getLangOpts().CPlusPlus &&
2994(*NextField)->getFieldIndex() >
Field->getFieldIndex() + 1)) {
2998 if(FI->isUnnamedBitField())
3009diag::ext_designated_init_reordered)
3012 unsignedOldIndex = StructuredIndex - 1;
3013 if(StructuredList && OldIndex <= StructuredList->getNumInits()) {
3014 if(
Expr*PrevInit = StructuredList->getInit(OldIndex)) {
3015SemaRef.
Diag(PrevInit->getBeginLoc(),
3016diag::note_previous_field_init)
3026 D->setFieldDecl(*Field);
3030 if(StructuredList && FieldIndex >= StructuredList->getNumInits())
3031StructuredList->resizeInits(SemaRef.
Context, FieldIndex + 1);
3034 if(
Field->getType()->isIncompleteArrayType()) {
3036 if((DesigIdx + 1) != DIE->
size()) {
3043diag::err_designator_into_flexible_array_member)
3045SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
3051 if(!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
3052!isa<StringLiteral>(DIE->
getInit())) {
3056diag::err_flexible_array_init_needs_braces)
3058SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
3065 if(!
Invalid&& CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
3075 boolprevHadError = hadError;
3076 unsignednewStructuredIndex = FieldIndex;
3077 unsignedOldIndex = Index;
3082CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
3083StructuredList, newStructuredIndex);
3085IList->
setInit(OldIndex, DIE);
3086 if(hadError && !prevHadError) {
3090*NextField =
Field;
3091StructuredIndex = FieldIndex;
3097 unsignednewStructuredIndex = FieldIndex;
3101 if(CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
3102FieldType,
nullptr,
nullptr, Index,
3103StructuredList, newStructuredIndex,
3104FinishSubobjectInit,
false))
3115 if(IsFirstDesignator) {
3120*NextField =
Field;
3122StructuredIndex = FieldIndex;
3126 if(!FinishSubobjectInit)
3134 boolprevHadError = hadError;
3139CheckStructUnionTypes(Entity, IList, CurrentObjectType, NoBases, Field,
3140 false, Index, StructuredList, FieldIndex);
3141 returnhadError && !prevHadError;
3162SemaRef.
Diag(
D->getLBracketLoc(), diag::err_array_designator_non_array)
3163<< CurrentObjectType;
3168 Expr*IndexExpr =
nullptr;
3169llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
3170 if(
D->isArrayDesignator()) {
3173DesignatedEndIndex = DesignatedStartIndex;
3175assert(
D->isArrayRangeDesignator() &&
"Need array-range designator");
3177DesignatedStartIndex =
3179DesignatedEndIndex =
3188 if(DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
3193 if(isa<ConstantArrayType>(AT)) {
3194llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
3195DesignatedStartIndex
3196= DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
3197DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
3199= DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
3200DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
3201 if(DesignatedEndIndex >= MaxElements) {
3204diag::err_array_designator_too_large)
3211 unsignedDesignatedIndexBitWidth =
3213DesignatedStartIndex =
3214DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
3215DesignatedEndIndex =
3216DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
3217DesignatedStartIndex.setIsUnsigned(
true);
3218DesignatedEndIndex.setIsUnsigned(
true);
3221 boolIsStringLiteralInitUpdate =
3222StructuredList && StructuredList->isStringLiteralInit();
3223 if(IsStringLiteralInitUpdate && VerifyOnly) {
3226StructuredList =
nullptr;
3227}
else if(IsStringLiteralInitUpdate) {
3240 unsignedPromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
3242 if(
StringLiteral*SL = dyn_cast<StringLiteral>(SubExpr)) {
3245 if(cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
3246StrLen = cast<ConstantArrayType>(AT)->getZExtSize();
3247StructuredList->resizeInits(Context, StrLen);
3251 for(
unsignedi = 0, e = StrLen; i != e; ++i) {
3252llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
3254Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
3255 if(CharTy != PromotedCharTy)
3259StructuredList->updateInit(Context, i,
Init);
3268 if(cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
3269StrLen = cast<ConstantArrayType>(AT)->getZExtSize();
3270StructuredList->resizeInits(Context, StrLen);
3274 for(
unsignedi = 0, e = StrLen; i != e; ++i) {
3275llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
3277Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
3278 if(CharTy != PromotedCharTy)
3282StructuredList->updateInit(Context, i,
Init);
3289 if(StructuredList &&
3290DesignatedEndIndex.getZExtValue() >= StructuredList->getNumInits())
3291StructuredList->resizeInits(SemaRef.
Context,
3292DesignatedEndIndex.getZExtValue() + 1);
3298 unsignedElementIndex = DesignatedStartIndex.getZExtValue();
3299 unsignedOldIndex = Index;
3304 while(DesignatedStartIndex <= DesignatedEndIndex) {
3310 if(CheckDesignatedInitializer(
3311ElementEntity, IList, DIE, DesigIdx + 1, ElementType,
nullptr,
3312 nullptr, Index, StructuredList, ElementIndex,
3313FinishSubobjectInit && (DesignatedStartIndex == DesignatedEndIndex),
3318++DesignatedStartIndex;
3319ElementIndex = DesignatedStartIndex.getZExtValue();
3324 if(IsFirstDesignator) {
3325 if(NextElementIndex)
3326*NextElementIndex = DesignatedStartIndex;
3327StructuredIndex = ElementIndex;
3331 if(!FinishSubobjectInit)
3335 boolprevHadError = hadError;
3336CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
3338StructuredList, ElementIndex);
3339 returnhadError && !prevHadError;
3345InitListChecker::getStructuredSubobjectInit(
InitListExpr*IList,
unsignedIndex,
3348 unsignedStructuredIndex,
3350 boolIsFullyOverwritten) {
3351 if(!StructuredList)
3354 Expr*ExistingInit =
nullptr;
3355 if(StructuredIndex < StructuredList->getNumInits())
3356ExistingInit = StructuredList->
getInit(StructuredIndex);
3358 if(
InitListExpr*Result = dyn_cast_or_null<InitListExpr>(ExistingInit))
3367 if(!IsFullyOverwritten)
3390diagnoseInitOverride(ExistingInit, InitRange);
3393 unsignedExpectedNumInits = 0;
3394 if(Index < IList->getNumInits()) {
3395 if(
auto*
Init= dyn_cast_or_null<InitListExpr>(IList->
getInit(Index)))
3396ExpectedNumInits =
Init->getNumInits();
3398ExpectedNumInits = IList->
getNumInits() - Index;
3402createInitListExpr(CurrentObjectType, InitRange, ExpectedNumInits);
3411InitListChecker::createInitListExpr(
QualTypeCurrentObjectType,
3413 unsignedExpectedNumInits) {
3417 QualTypeResultType = CurrentObjectType;
3420Result->setType(ResultType);
3423 unsignedNumElements = 0;
3428NumElements = CAType->getZExtSize();
3431 if(NumElements > ExpectedNumInits)
3435NumElements = VType->getNumElements();
3437NumElements = numStructUnionElements(CurrentObjectType);
3442Result->reserveInits(SemaRef.
Context, NumElements);
3449voidInitListChecker::UpdateStructuredListElement(
InitListExpr*StructuredList,
3450 unsigned&StructuredIndex,
3453 if(!StructuredList)
3457StructuredIndex,
expr)) {
3463diagnoseInitOverride(PrevInit,
expr->getSourceRange());
3472InitListChecker Check(*
this, Entity, From,
Type,
true,
3475 return!Check.HadError();
3492 if(
Result.isInvalid())
3495 if(
Value.isSigned() &&
Value.isNegative())
3496 returnS.
Diag(
Loc, diag::err_array_designator_negative)
3499 Value.setIsUnsigned(
true);
3517 if(
D.isFieldDesignator()) {
3518Designators.push_back(ASTDesignator::CreateFieldDesignator(
3519 D.getFieldDecl(),
D.getDotLoc(),
D.getFieldLoc()));
3520}
else if(
D.isArrayDesignator()) {
3521 Expr*Index =
static_cast<Expr*
>(
D.getArrayIndex());
3522llvm::APSInt IndexValue;
3523 if(!Index->isTypeDependent() && !Index->isValueDependent())
3528Designators.push_back(ASTDesignator::CreateArrayDesignator(
3529InitExpressions.size(),
D.getLBracketLoc(),
D.getRBracketLoc()));
3530InitExpressions.push_back(Index);
3532}
else if(
D.isArrayRangeDesignator()) {
3533 Expr*StartIndex =
static_cast<Expr*
>(
D.getArrayRangeStart());
3534 Expr*EndIndex =
static_cast<Expr*
>(
D.getArrayRangeEnd());
3535llvm::APSInt StartValue;
3536llvm::APSInt EndValue;
3541 if(!StartDependent)
3547 if(!StartIndex || !EndIndex)
3551 if(StartDependent || EndDependent) {
3553}
else if(StartValue.getBitWidth() > EndValue.getBitWidth())
3554EndValue = EndValue.extend(StartValue.getBitWidth());
3555 else if(StartValue.getBitWidth() < EndValue.getBitWidth())
3556StartValue = StartValue.extend(EndValue.getBitWidth());
3558 if(!StartDependent && !EndDependent && EndValue < StartValue) {
3559 Diag(
D.getEllipsisLoc(), diag::err_array_designator_empty_range)
3564Designators.push_back(ASTDesignator::CreateArrayRangeDesignator(
3565InitExpressions.size(),
D.getLBracketLoc(),
D.getEllipsisLoc(),
3566 D.getRBracketLoc()));
3567InitExpressions.push_back(StartIndex);
3568InitExpressions.push_back(EndIndex);
3578EqualOrColonLoc, GNUSyntax,
3586InitializedEntity::InitializedEntity(
ASTContext&Context,
unsignedIndex,
3591Kind = EK_ArrayElement;
3594Kind = EK_VectorElement;
3598assert(CT &&
"Unexpected type");
3599 Kind= EK_ComplexElement;
3607 boolIsInheritedVirtualBase,
3612 Result.Base = {
Base, IsInheritedVirtualBase};
3630 return Variable.VariableOrMember->getDeclName();
3652llvm_unreachable(
"Invalid EntityKind!");
3686llvm_unreachable(
"Invalid EntityKind!");
3721unsignedInitializedEntity::dumpImpl(raw_ostream &OS)
const{
3724 for(
unsignedI = 0; I != Depth; ++I)
3733 case EK_Result: OS <<
"Result";
break;
3741 case EK_New: OS <<
"New";
break;
3745 case EK_Base: OS <<
"Base";
break;
3752OS <<
"Block (lambda)";
3755OS <<
"LambdaCapture ";
3762 D->printQualifiedName(OS);
3765OS <<
" '"<<
getType() <<
"'\n";
3771dumpImpl(llvm::errs());
3826 for(
const Step&S : llvm::reverse(Steps)) {
3886llvm_unreachable(
"Invalid EntityKind!");
3894InitializationSequence
3897 boolHadMultipleCandidates) {
3901S.Function.HadMultipleCandidates = HadMultipleCandidates;
3903S.Function.FoundDecl =
Found;
3922 boolBindingTemporary) {
3947 boolHadMultipleCandidates) {
3951S.Function.HadMultipleCandidates = HadMultipleCandidates;
3953S.Function.FoundDecl = FoundDecl;
3992 boolTopLevelOfInitList) {
4010 boolHadMultipleCandidates,
boolFromInitList,
boolAsInitList) {
4016S.Function.HadMultipleCandidates = HadMultipleCandidates;
4017S.Function.Function = Constructor;
4018S.Function.FoundDecl = FoundDecl;
4061Steps.insert(Steps.begin(), S);
4081Steps.push_back(
s);
4122 "Can only unwrap trivial init lists.");
4126Steps.insert(Steps.begin(), S);
4132 "Can only rewrap trivial init lists.");
4136Steps.insert(Steps.begin(), S);
4140S.WrappingSyntacticList = Syntactic;
4147this->Failure = Failure;
4148this->FailedOverloadResult =
Result;
4169 if(!
Init.empty()) {
4189 "consuming an object of unretainable type?");
4209 boolTreatUnavailableAsInvalid) {
4224 Expr*OVEAsExpr = &OVE;
4227TreatUnavailableAsInvalid);
4237 boolTreatUnavailableAsInvalid);
4248 boolTreatUnavailableAsInvalid) {
4262List->getNumInits()),
4267List->getExprLoc(), List->getBeginLoc(), List->getEndLoc());
4269TreatUnavailableAsInvalid);
4296 boolCopyInitializing,
boolAllowExplicit,
boolOnlyListConstructors,
4297 boolIsListInit,
boolRequireActualConstructor,
4298 boolSecondStepOfCopyInit =
false) {
4304 if(!Info.Constructor || Info.Constructor->isInvalidDecl())
4321 boolSuppressUserConversions =
4322SecondStepOfCopyInit ||
4323(IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
4326 if(Info.ConstructorTmpl)
4328Info.ConstructorTmpl, Info.FoundDecl,
4329 nullptr, Args, CandidateSet, SuppressUserConversions,
4330 false, AllowExplicit);
4339 boolAllowExplicitConv = AllowExplicit && !CopyInitializing &&
4343CandidateSet, SuppressUserConversions,
4344 false, AllowExplicit,
4360 if(S.
getLangOpts().CPlusPlus17 && Args.size() == 1 &&
4361!RequireActualConstructor && !SecondStepOfCopyInit) {
4363 auto*SourceRD =
Initializer->getType()->getAsCXXRecordDecl();
4365 const auto&Conversions = SourceRD->getVisibleConversionFunctions();
4366 for(
autoI = Conversions.begin(),
E= Conversions.end(); I !=
E; ++I) {
4369 D=
D->getUnderlyingDecl();
4376Conv = cast<CXXConversionDecl>(
D);
4380ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
4381CandidateSet, AllowExplicit, AllowExplicit,
4385DestType, CandidateSet, AllowExplicit,
4412 boolIsListInit =
false,
4413 boolIsInitListCopy =
false) {
4414assert(((!IsListInit && !IsInitListCopy) ||
4415(Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
4416 "IsListInit/IsInitListCopy must come with a single initializer list " 4419(IsListInit || IsInitListCopy) ? cast<InitListExpr>(Args[0]) :
nullptr;
4429 boolRequireActualConstructor =
4435 boolCopyElisionPossible =
false;
4436 autoElideConstructor = [&] {
4452 if(S.
getLangOpts().CPlusPlus17 && !RequireActualConstructor &&
4453UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isPRValue() &&
4475assert(!IsInitListCopy &&
4476 "IsInitListCopy only possible with aggregate types");
4477CopyElisionPossible =
true;
4485assert(DestRecordType &&
"Constructor initialization requires record type");
4487= cast<CXXRecordDecl>(DestRecordType->
getDecl());
4495 boolAllowExplicit = Kind.AllowExplicit() || IsListInit;
4505 boolAsInitializerList =
false;
4517AsInitializerList =
true;
4523S, Kind.getLocation(), Args, CandidateSet, DestType, Ctors, Best,
4524CopyInitialization, AllowExplicit,
4525 true, IsListInit, RequireActualConstructor);
4540AsInitializerList =
false;
4542S, Kind.getLocation(), UnwrappedArgs, CandidateSet, DestType, Ctors,
4543Best, CopyInitialization, AllowExplicit,
4544 false, IsListInit, RequireActualConstructor);
4556 boolHadMultipleCandidates = (CandidateSet.
size() > 1);
4560 if(
auto*CD = dyn_cast<CXXConversionDecl>(Best->Function)) {
4562 QualTypeConvType = CD->getConversionType();
4564 "should not have selected this conversion function");
4566HadMultipleCandidates);
4579DestRecordDecl !=
nullptr&& DestRecordDecl->
isAggregate() &&
4581S.
Diag(Kind.getLocation(), diag::warn_field_requires_explicit_init)
4582<<
1 << DestRecordDecl;
4607 if(IsListInit && !Kind.AllowExplicit() && CtorDecl->
isExplicit()) {
4627Best->FoundDecl, CtorDecl, DestArrayType, HadMultipleCandidates,
4628IsListInit | IsInitListCopy, AsInitializerList);
4641 boolHadMultipleCandidates =
false;
4644UnqualifiedTargetType,
4646&HadMultipleCandidates)) {
4648HadMultipleCandidates);
4649SourceType = Fn->getType();
4668 boolTopLevelOfInitList);
4682 boolTreatUnavailableAsInvalid) {
4722T1Quals, cv2T2, T2, T2Quals, Sequence,
4753TreatUnavailableAsInvalid);
4785 boolTreatUnavailableAsInvalid) {
4797TreatUnavailableAsInvalid);
4835!IsDesignatedInit) {
4840 Expr*InitListAsExpr = InitList;
4859 if(isa<ConstantArrayType>(DestAT) &&
4861isa<DecompositionDecl>(Entity.
getDecl())) {
4864 "Deduced to other type?");
4868Entity, SubInit[0], DestType, Sequence,
4869TreatUnavailableAsInvalid);
4875 if(!isa<VariableArrayType>(DestAT) &&
4885TreatUnavailableAsInvalid);
4918TreatUnavailableAsInvalid))
4922 Expr*InitListAsExpr = InitList;
4924DestType, Sequence,
true);
4942ET && ET->getDecl()->isFixed() &&
4991 if(
Init->getType()->isRecordType() ||
5002TreatUnavailableAsInvalid);
5009InitListChecker CheckInitList(S, Entity, InitList,
5010DestType,
true, TreatUnavailableAsInvalid);
5011 if(CheckInitList.HadError()) {
5033 "Must have incompatible references when binding via conversion");
5044 boolAllowExplicitCtors =
false;
5045 boolAllowExplicitConvs = Kind.allowExplicitConversionFunctionsInRefBinding();
5056 if(!Info.Constructor)
5059 if(!Info.Constructor->isInvalidDecl() &&
5060Info.Constructor->isConvertingConstructor(
true)) {
5061 if(Info.ConstructorTmpl)
5063Info.ConstructorTmpl, Info.FoundDecl,
5066 false, AllowExplicitCtors);
5069Info.Constructor, Info.FoundDecl,
Initializer, CandidateSet,
5071 false, AllowExplicitCtors);
5086 for(
autoI = Conversions.begin(),
E= Conversions.end(); I !=
E; ++I) {
5089 if(isa<UsingShadowDecl>(
D))
5090 D= cast<UsingShadowDecl>(
D)->getTargetDecl();
5097Conv = cast<CXXConversionDecl>(
D);
5105 if((AllowRValues ||
5109ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
5111 false, AllowExplicitConvs);
5114Conv, I.getPair(), ActingDC,
Initializer, DestType, CandidateSet,
5115 false, AllowExplicitConvs);
5137 if(isa<CXXConversionDecl>(
Function))
5138cv3T3 =
Function->getReturnType();
5150 boolHadMultipleCandidates = (CandidateSet.
size() > 1);
5152HadMultipleCandidates);
5162assert(!isa<CXXConstructorDecl>(
Function) &&
5163 "should not have conversion after constructor");
5167ICS.
Standard= Best->FinalConversion;
5188 if(RefConv & Sema::ReferenceConversions::DerivedToBase)
5190 else if(RefConv & Sema::ReferenceConversions::ObjC)
5192 else if(RefConv & Sema::ReferenceConversions::Function)
5194 else if(RefConv & Sema::ReferenceConversions::Qualification) {
5211 boolTopLevelOfInitList) {
5229T1Quals, cv2T2, T2, T2Quals, Sequence,
5230TopLevelOfInitList);
5254 boolTopLevelOfInitList) {
5278 if(isLValueRef || T1Function) {
5281(Kind.isCStyleOrFunctionalCast() &&
5285 if(RefConv & (Sema::ReferenceConversions::DerivedToBase |
5286Sema::ReferenceConversions::ObjC)) {
5289 if(RefConv & (Sema::ReferenceConversions::Qualification))
5293 if(RefConv & Sema::ReferenceConversions::DerivedToBase)
5297}
else if(RefConv & Sema::ReferenceConversions::Qualification) {
5301}
else if(RefConv & Sema::ReferenceConversions::Function) {
5321(isLValueRef || InitCategory.
isRValue())) {
5326isLValueRef, Sequence);
5353 else if(!InitCategory.
isLValue())
5361 switch(RefRelationship) {
5373llvm_unreachable(
"unexpected kind of compatible initializer");
5397(Kind.isCStyleOrFunctionalCast() &&
5426 autoT1QualsIgnoreAS = T1Quals;
5427 autoT2QualsIgnoreAS = T2Quals;
5430T2QualsIgnoreAS.removeAddressSpace();
5433 if(T1QualsIgnoreAS != T2QualsIgnoreAS)
5443cv1T4 = cv1T4WithAS;
5448 if(RefConv & Sema::ReferenceConversions::DerivedToBase)
5450 else if(RefConv & Sema::ReferenceConversions::ObjC)
5452 else if(RefConv & Sema::ReferenceConversions::Qualification) {
5469isLValueRef, Sequence);
5509Sema::AllowedExplicit::None,
5511Kind.isCStyleOrFunctionalCast(),
5514 if(ICS.
isBad()) {
5530TopLevelOfInitList);
5539((T1CVRQuals | T2CVRQuals) != T1CVRQuals ||
5584assert((!InitList || InitList->
getNumInits() == 0) &&
5585 "Shouldn't use value-init for non-empty init lists");
5591assert(!
T->
isVoidType() &&
"Cannot value-init void");
5597 if(
CXXRecordDecl*ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
5598 boolNeedZeroInitialization =
true;
5613NeedZeroInitialization =
false;
5621 if(NeedZeroInitialization)
5635ClassDecl->hasUninitializedReferenceMember()) {
5643 Expr*InitListAsExpr = InitList;
5645 boolInitListSyntax = InitList;
5650S, Entity, Kind, Args,
T, Entity.
getType(), Sequence, InitListSyntax);
5674Entity.
getType(), Sequence);
5700 unsignedEntityIndexToProcess = 0;
5703 Expr*ArrayFiller =
nullptr;
5704 FieldDecl*InitializedFieldInUnion =
nullptr;
5708 Expr*Arg,
Expr**InitExpr =
nullptr) {
5710S, SubEntity, SubKind,
5715IS.
Diagnose(S, SubEntity, SubKind,
5726ER = IS.
Perform(S, SubEntity, SubKind,
5733*InitExpr = ER.
get();
5735InitExprs.push_back(ER.
get());
5743uint64_t ArrayLength;
5751ArrayLength = CAT->getZExtSize();
5752ResultType = Entity.
getType();
5759 const Expr*SE = VAT->getSizeExpr();
5765ArrayLength = Args.size();
5767EntityIndexToProcess = ArrayLength;
5771 for(
Expr*
E: Args) {
5776 if(!HandleInitializedEntity(SubEntity, SubKind,
E))
5784Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
true);
5785 if(!HandleInitializedEntity(SubEntity, SubKind,
nullptr, &ArrayFiller))
5789 if(ResultType.
isNull()) {
5796 const CXXRecordDecl*RD = cast<CXXRecordDecl>(RT->getDecl());
5810 if(EntityIndexToProcess < Args.size()) {
5816 Expr*
E= Args[EntityIndexToProcess];
5819 if(!HandleInitializedEntity(SubEntity, SubKind,
E))
5827Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
5829 if(!HandleInitializedEntity(SubEntity, SubKind,
nullptr))
5832EntityIndexToProcess++;
5845 if(EntityIndexToProcess < Args.size()) {
5847 Expr*
E= Args[EntityIndexToProcess];
5856S.
Diag(FD->
getLocation(), diag::note_flexible_array_member) << FD;
5865 if(!HandleInitializedEntity(SubEntity, SubKind,
E))
5873InitializedFieldInUnion = FD;
5874EntityIndexToProcess = 1;
5880 if(!VerifyOnly && FD->
hasAttr<ExplicitInitAttr>()) {
5881S.
Diag(Kind.getLocation(), diag::warn_field_requires_explicit_init)
5892Kind.getParenOrBraceRange().getEnd(), FD);
5896InitExprs.push_back(DIE.
get());
5906S.
Diag(SR.
getEnd(), diag::err_init_reference_member_uninitialized)
5913Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
true);
5914 if(!HandleInitializedEntity(SubEntity, SubKind,
nullptr))
5918EntityIndexToProcess++;
5920ResultType = Entity.
getType();
5925 if(EntityIndexToProcess < Args.size()) {
5930 SourceRangeExcessInitSR(Args[EntityIndexToProcess]->getBeginLoc(),
5931Args.back()->getEndLoc());
5932S.
Diag(Kind.getLocation(), diag::err_excess_initializers)
5933<< InitKind << ExcessInitSR;
5947CPLIE->setArrayFiller(ArrayFiller);
5948 if(InitializedFieldInUnion)
5949CPLIE->setInitializedFieldInUnion(InitializedFieldInUnion);
5951S.
Diag(Kind.getLocation(),
5952diag::warn_cxx17_compat_aggregate_init_paren_list)
5953<< Kind.getLocation() << SR << ResultType;
5965 boolTopLevelOfInitList) {
5966assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
5969 "Must have a class type to perform a user-defined conversion");
5979 boolAllowExplicit = Kind.AllowExplicit();
5985= cast<CXXRecordDecl>(DestRecordType->getDecl());
5991 if(!Info.Constructor)
5994 if(!Info.Constructor->isInvalidDecl() &&
5995Info.Constructor->isConvertingConstructor(
true)) {
5996 if(Info.ConstructorTmpl)
5998Info.ConstructorTmpl, Info.FoundDecl,
6001 false, AllowExplicit);
6006 false, AllowExplicit);
6022= cast<CXXRecordDecl>(SourceRecordType->getDecl());
6024 const auto&Conversions =
6026 for(
autoI = Conversions.begin(),
E= Conversions.end(); I !=
E; ++I) {
6029 if(isa<UsingShadowDecl>(
D))
6030 D= cast<UsingShadowDecl>(
D)->getTargetDecl();
6037Conv = cast<CXXConversionDecl>(
D);
6041ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
6042CandidateSet, AllowExplicit, AllowExplicit);
6045DestType, CandidateSet, AllowExplicit,
6071 boolHadMultipleCandidates = (CandidateSet.
size() > 1);
6073 if(isa<CXXConstructorDecl>(
Function)) {
6079HadMultipleCandidates);
6108HadMultipleCandidates);
6121 Function->getReturnType()->isReferenceType() ||
6131 if(Best->FinalConversion.First || Best->FinalConversion.Second ||
6132Best->FinalConversion.Third) {
6135ICS.
Standard= Best->FinalConversion;
6153isa<CXXBoolLiteralExpr>(
Init) &&
6154!cast<CXXBoolLiteralExpr>(
Init)->getValue() &&
6163 boolisAddressOf,
bool&isWeakAccess) {
6169 if(op->getOpcode() == UO_AddrOf)
6174}
else if(
CastExpr*ce = dyn_cast<CastExpr>(e)) {
6175 switch(ce->getCastKind()) {
6178 caseCK_LValueBitCast:
6182 caseCK_ArrayToPointerDecay:
6185 caseCK_NullToPointer:
6193}
else if(isa<DeclRefExpr>(e)) {
6197isWeakAccess =
true;
6201 VarDecl*var = dyn_cast<VarDecl>(cast<DeclRefExpr>(e)->getDecl());
6215}
else if(isa<ArraySubscriptExpr>(e)) {
6231 boolisWeakAccess =
false;
6235 if(S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
6267 boolArrayDecay =
false;
6272ArgPointee = ArgArrayType->getElementType();
6284 boolShouldCopy =
true;
6355 "cl_intel_device_side_avc_motion_estimation", S.
getLangOpts()) &&
6357 if(DestType->isOCLIntelSubgroupAVCMcePayloadType() ||
6358DestType->isOCLIntelSubgroupAVCMceResultType())
6372 MultiExprArgArgs,
boolTopLevelOfInitList,
boolTreatUnavailableAsInvalid)
6376TreatUnavailableAsInvalid);
6382 auto*DRE = dyn_cast<DeclRefExpr>(
E);
6383 if(!DRE || !isa<FunctionDecl>(DRE->getDecl()))
6387cast<FunctionDecl>(DRE->getDecl()));
6404 returnisa<DecompositionDecl>(Entity.
getDecl());
6430 boolTopLevelOfInitList,
6431 boolTreatUnavailableAsInvalid) {
6438 for(
unsignedI = 0,
E= Args.size(); I !=
E; ++I)
6439 if(Args[I]->getType()->isNonOverloadPlaceholderType()) {
6446Args[I] = result.
get();
6468 if(Args.size() == 1) {
6486TreatUnavailableAsInvalid);
6497S.
Diag(Var->
getLocation(), diag::warn_field_requires_explicit_init)
6511 if(Args.size() != 1)
6517 else if(isa<InitListExpr>(Args[0]))
6521TopLevelOfInitList);
6547 if(
Initializer&& isa<VariableArrayType>(DestAT)) {
6579 if(
Initializer&& isa<ConstantArrayType>(DestAT) &&
6584TreatUnavailableAsInvalid);
6592isa<CompoundLiteralExpr>(
Initializer->IgnoreParens()) &&
6610*
this, TreatUnavailableAsInvalid);
6612}
else if(S.
getLangOpts().CPlusPlus20 && !TopLevelOfInitList &&
6628 boolallowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
6637assert(
Initializer&&
"Initializer must be non-null");
6639 if(allowObjCWritebackConversion &&
6665SourceType, DestType))))) {
6672 if(
const auto*RD =
6677S.
getLangOpts().CPlusPlus20 && RD && RD->hasDefinition() &&
6678RD->isAggregate() &&
Failed() &&
6691S, Kind.getLocation(), Best);
6709assert(
Initializer&&
"Initializer must be non-null");
6711TopLevelOfInitList);
6716assert(Args.size() >= 1 &&
"Zero-argument case handled above");
6722(SourceType.
isNull() ||
6726 for(
auto*Arg : Args) {
6727 if(Arg->getType()->isExtVectorType()) {
6728 const auto*VTy = Arg->getType()->castAs<
ExtVectorType>();
6730 for(
unsignedIdx = 0; Idx < Elm; ++Idx) {
6736VTy->getElementType(), Arg->
getValueKind(), Arg->getObjectKind(),
6740InitArgs.emplace_back(Arg);
6750 if(Args.size() > 1) {
6753}
else if(isa<InitListExpr>(Args[0])) {
6761assert(
Initializer&&
"Initializer must be non-null");
6764 boolNeedAtomicConversion =
false;
6768 Atomic->getValueType())) {
6769DestType =
Atomic->getValueType();
6770NeedAtomicConversion =
true;
6775TopLevelOfInitList);
6777 if(!
Failed() && NeedAtomicConversion)
6804Sema::AllowedExplicit::None,
6806Kind.isCStyleOrFunctionalCast(),
6807allowObjCWritebackConversion);
6815 boolShouldCopy =
true;
6831}
else if(ICS.
isBad()) {
6839 else if(
Initializer->getType()->isFunctionType() &&
6852 for(
auto&S : Steps)
6860 boolDiagnose =
false) {
6911llvm_unreachable(
"Invalid EntityKind!");
6945llvm_unreachable(
"missed an InitializedEntity kind?");
6979llvm_unreachable(
"missed an InitializedEntity kind?");
7018llvm_unreachable(
"missed an InitializedEntity kind?");
7045 boolIsExtraneousCopy) {
7070S,
Loc, CurInitExpr, CandidateSet,
T, Ctors, Best,
7082? diag::ext_rvalue_to_reference_temp_copy_no_viable
7083: diag::err_temp_copy_no_viable)
7101S.
Diag(
Loc, diag::err_temp_copy_deleted)
7108 boolHadMultipleCandidates = CandidateSet.
size() > 1;
7117 if(IsExtraneousCopy) {
7128 for(
unsignedI = 1, N = Constructor->getNumParams(); I != N; ++I) {
7131diag::err_call_incomplete_argument))
7172Best->Function->getParamDecl(0)->getType().getNonReferenceType(),
7177 Loc,
T, Best->FoundDecl, Constructor, Elidable, ConstructorArgs,
7178HadMultipleCandidates,
7194 Expr*CurInitExpr) {
7213S,
Loc, CurInitExpr, CandidateSet, CurInitExpr->
getType(), Ctors, Best,
7226Best->FoundDecl, Entity,
Diag);
7247voidInitializationSequence::PrintInitLocationNote(
Sema&S,
7262diag::note_method_return_type_change)
7280 switch(Kind.getKind()) {
7286 returnNumArgs != 1;
7298 bool&ConstructorInitRequiresZeroInit,
7299 boolIsListInitialization,
7300 boolIsStdInitListInitialization,
7303 unsignedNumArgs = Args.size();
7311? Kind.getEqualLoc()
7312: Kind.getLocation();
7318assert(Constructor->getParent() &&
"No parent class for constructor.");
7319 if(Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
7320Constructor->isTrivial() && !Constructor->isUsed(
false)) {
7335 boolAllowExplicitConv =
7336Kind.AllowExplicit() && !Kind.isCopyInit() && Args.size() == 1 &&
7341 if(NumArgs == 1 && !Kind.isExplicitCast())
7343Entity.
getType(), Args.front()->getType(), Kind.getLocation());
7348ConstructorArgs, AllowExplicitConv,
7349IsListInitialization))
7358Constructor->isImplicit()) {
7363 if(I >= ConstructorArgs.size() && FD->
hasAttr<ExplicitInitAttr>()) {
7364S.
Diag(
Loc, diag::warn_field_requires_explicit_init)
7379: Kind.getParenOrBraceRange();
7382 if(
auto*Shadow = dyn_cast<ConstructorUsingShadowDecl>(
7392ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
7393IsListInitialization, IsStdInitListInitialization,
7394ConstructorInitRequiresZeroInit),
7410 if(IsListInitialization)
7411ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
7413ParenOrBraceRange = Kind.getParenOrBraceRange();
7422HadMultipleCandidates,
7423IsListInitialization,
7424IsStdInitListInitialization,
7425ConstructorInitRequiresZeroInit,
7433HadMultipleCandidates,
7434IsListInitialization,
7435IsStdInitListInitialization,
7436ConstructorInitRequiresZeroInit,
7467 const Expr*PostInit);
7474 boolIsReturnStmt) {
7485 unsignedDiagID = 0;
7488dyn_cast<CXXConstructExpr>(InitExpr->
IgnoreParens());
7515 if(VD->
hasAttr<BlocksAttr>())
7528 if(isa<ParmVarDecl>(VD))
7529DiagID = diag::warn_redundant_move_on_return;
7531DiagID = diag::warn_pessimizing_move_on_return;
7533DiagID = diag::warn_pessimizing_move_on_initialization;
7575 if(UO->getOpcode() == UO_Deref &&
7576UO->getSubExpr()->IgnoreParenCasts()->
7579S.
PDiag(diag::warn_binding_null_to_reference)
7580<< UO->getSubExpr()->getSourceRange());
7586 boolBoundToLvalueReference) {
7629 if(!PointeeTy.isNull() &&
7630PointeeTy.getAddressSpace() != ExprPointeeTy.getAddressSpace())
7631CK = CK_AddressSpaceConversion;
7633CK = CK_AddressSpaceConversion;
7648 if(!ZeroInitializationFixit.empty()) {
7650 const auto*VD = dyn_cast_or_null<VarDecl>(
D);
7656 if(!DestType->
isRecordType() && VD && VD->isConstexpr()) {
7658S.
Diag(Kind.getLocation(), diag::err_constexpr_var_requires_const_init)
7661ZeroInitializationFixit);
7663 unsignedDiagID = diag::err_default_init_const;
7665DiagID = diag::ext_default_init_const;
7667S.
Diag(Kind.getLocation(), DiagID)
7670ZeroInitializationFixit);
7690 if(isa<InitListExpr>((
Expr*)Args[0])) {
7694 if(
auto*DD = dyn_cast_or_null<DeclaratorDecl>(Entity.
getDecl())) {
7696 TypeLocTL = TInfo->getTypeLoc();
7699Brackets = ArrayLoc.getBracketsRange();
7706ArrayT->getSizeModifier(),
7707ArrayT->getIndexTypeCVRQualifiers(),
7714!Kind.isExplicitCast()) {
7716 SourceRangeParenRange = Kind.getParenOrBraceRange();
7721Kind.isExplicitCast() ||
7731Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
7737S.
Diag(
Init->getBeginLoc(), diag::warn_cxx98_compat_reference_list_init)
7738<<
Init->getSourceRange();
7741 if(S.
getLangOpts().MicrosoftExt && Args.size() == 1 &&
7747S.
Diag(
Init->getBeginLoc(), diag::ext_init_from_predefined) <<
Init;
7758S.
Diag(Args[0]->getBeginLoc(), diag::err_opencl_atomic_init)
7778isa<InitListExpr>(Args[0]);
7779(void)IsHLSLVectorInit;
7784 switch(Steps.front().Kind) {
7818assert(Args.size() == 1 || IsHLSLVectorInit);
7837isa_and_nonnull<InitListExpr>(CurInit.
get()));
7842 autocheckAbstractType = [&](
QualType T) ->
bool{
7847diag::err_allocation_of_abstract_type);
7852 boolConstructorInitRequiresZeroInit =
false;
7885 boolIgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
7897CK_DerivedToBase, CurInit.
get(),
7913 if(
auto*DRE = dyn_cast<DeclRefExpr>(CurInit.
get()->
IgnoreParens())) {
7914 if(
auto*FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
7927assert(CurInit.
get()->
isPRValue() &&
"not a temporary");
7959 if(checkAbstractType(
Step->
Type))
7985 boolCreatedObject =
false;
8001 Loc,
Step->
Type, FoundFn, Constructor, ConstructorArgs,
8002HadMultipleCandidates,
8014 CastKind= CK_ConstructorConversion;
8015CreatedObject =
true;
8025HadMultipleCandidates);
8029 CastKind= CK_UserDefinedConversion;
8033 if(CreatedObject && checkAbstractType(CurInit.
get()->
getType()))
8054S.
PDiag(diag::err_access_dtor_temp) <<
T);
8078 "function reference should be lvalue");
8084assert(CurInit.
get()->
isPRValue() &&
"cannot convert glvalue to atomic");
8092 if(
const auto*FromPtrType =
8095 if(FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
8096!ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
8099 if(!Kind.isStaticCast()) {
8101diag::warn_noderef_to_dereferenceable_pointer)
8120CurInit = CurInitExprRes;
8131 if(checkAbstractType(
Step->
Type))
8141InitListChecker PerformInitList(S, InitEntity,
8142InitList, Ty,
false,
8144 if(PerformInitList.HadError())
8152 if((*ResultType)->isRValueReferenceType())
8154 else if((*ResultType)->isLValueReferenceType())
8161PerformInitList.getFullyStructuredList();
8165: StructuredInitList;
8170 if(checkAbstractType(
Step->
Type))
8182assert(Args.size() == 1 &&
"expected a single argument for list init");
8184S.
Diag(InitList->
getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
8190ConstructorInitRequiresZeroInit,
8199CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
8216 if(checkAbstractType(
Step->
Type))
8228 boolIsStdInitListInit =
8230 Expr*Source = CurInit.
get();
8232? Kind.getParenOrBraceRange()
8235S, UseTemporary ? TempEntity : Entity, Kind,
8237ConstructorInitRequiresZeroInit,
8248 if(NextStep != StepEnd &&
8253ConstructorInitRequiresZeroInit =
true;
8256!Kind.isImplicitValueInit()) {
8260Kind.getRange().getBegin());
8264Kind.getRange().getEnd());
8281 if(
Result.isInvalid())
8294CurInit = CurInitExprRes;
8309S.
Diag(Kind.getLocation(), diag::err_c23_constexpr_pointer_not_null);
8316InitialCurInit.
get(),
8319PrintInitLocationNote(S, Entity);
8321}
else if(Complained)
8322PrintInitLocationNote(S, Entity);
8338CK_ObjCObjectLValueCast,
8350BaseExpr, Kind.getLocation(), IndexExpr, Kind.getLocation());
8351ArrayLoopCommonExprs.push_back(BaseExpr);
8356assert(!ArrayLoopCommonExprs.empty() &&
8357 "mismatched SK_ArrayLoopIndex and SK_ArrayLoopInit");
8358 Expr*Common = ArrayLoopCommonExprs.pop_back_val();
8367S.
Diag(Kind.getLocation(), diag::ext_array_init_copy)
8381IncompleteDest->getElementType(), ConstantSource->getSize(),
8391S.
Diag(Kind.getLocation(), diag::ext_array_init_parens)
8411diag::warn_cxx98_compat_initializer_list_init)
8424[[maybe_unused]]
boolIsStdInitializerList =
8426assert(IsStdInitializerList &&
8427 "StdInitializerList step to non-std::initializer_list");
8431 "std::initializer_list should have already be " 8432 "complete/instantiated by this point");
8434 autoInvalidType = [&] {
8436diag::err_std_initializer_list_malformed)
8441 if(
Record->isUnion() ||
Record->getNumBases() != 0 ||
8442 Record->isPolymorphic())
8443 returnInvalidType();
8446 if(Field ==
Record->field_end())
8447 returnInvalidType();
8450 if(!Field->getType()->isPointerType() ||
8453 returnInvalidType();
8455 if(++Field ==
Record->field_end())
8456 returnInvalidType();
8459 if(
const auto*PT = Field->getType()->getAs<
PointerType>()) {
8462 returnInvalidType();
8464 if(Field->isBitField() ||
8466 returnInvalidType();
8469 if(++Field !=
Record->field_end())
8470 returnInvalidType();
8497 "Sampler initialization on non-sampler type.");
8503S.
Diag(Kind.getLocation(), diag::err_sampler_argument_required)
8507 autoVar = cast<VarDecl>(DRE->getDecl());
8510 if(!Var->hasGlobalStorage()) {
8522 if(!Var->getInit() || !isa<ImplicitCastExpr>(Var->getInit()))
8524 Init= cast<ImplicitCastExpr>(
const_cast<Expr*
>(
8525Var->getInit()))->getSubExpr();
8526SourceType =
Init->getType();
8533 if(!
Init->isConstantInitializer(S.
Context,
false))
8538S.
Diag(Kind.getLocation(), diag::err_sampler_initializer_not_integer)
8546 constuint64_t SamplerValue =
Result.getLimitedValue();
8553 unsignedAddressingMode = (0x0E & SamplerValue) >> 1;
8554 unsignedFilterMode = (0x30 & SamplerValue) >> 4;
8555 if(FilterMode != 1 && FilterMode != 2 &&
8557 "cl_intel_device_side_avc_motion_estimation", S.
getLangOpts()))
8558S.
Diag(Kind.getLocation(),
8559diag::warn_sampler_initializer_invalid_bits)
8561 if(AddressingMode > 4)
8562S.
Diag(Kind.getLocation(),
8563diag::warn_sampler_initializer_invalid_bits)
8564<<
"Addressing Mode";
8570CK_IntToOCLSampler);
8576 "Wrong type for initialization of OpenCL opaque type.");
8579CK_ZeroToOCLOpaqueType,
8587 if(CurInit.
get() && ResultType)
8608cast<FieldDecl>(Entity.
getDecl())->isBitField())
8609S.CheckBitFieldInitialization(Kind.getLocation(),
8624S.
Diag(
Loc, diag::err_reference_without_init)
8625<<
T.getNonReferenceType();
8633 for(
const auto*FI : RD->
fields()) {
8634 if(FI->isUnnamedBitField())
8638S.
Diag(
Loc, diag::note_value_initialization_here) << RD;
8643 for(
const auto&BI : RD->
bases()) {
8645S.
Diag(
Loc, diag::note_value_initialization_here) << RD;
8680 if(fromDecl && destDecl && fromDecl->getDeclKind() == Decl::CXXRecord &&
8681destDecl->getDeclKind() == Decl::CXXRecord &&
8682!fromDecl->isInvalidDecl() && !destDecl->isInvalidDecl() &&
8683!fromDecl->hasDefinition() &&
8686S.
Diag(fromDecl->getLocation(), diag::note_forward_class_conversion)
8714 if(
auto*
D= Entity.
getDecl())
8716S.
Diag(
Loc, diag::note_in_reference_temporary_list_initializer) <<
T;
8720InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
8723assert(DiagnoseInitList.HadError() &&
8724 "Inconsistent init list check result.");
8739 if(Args.size() == 1) {
8740 auto*List = dyn_cast<InitListExpr>(Args[0]);
8741 if(List && List->getNumInits() == 1)
8742OnlyArg = List->getInit(0);
8751 if(
Expr*Resolved =
8771assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
8774S.
Diag(Kind.getLocation(), diag::err_reference_has_multiple_inits)
8775<<
SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
8778S.
Diag(Kind.getLocation(), diag::err_list_init_in_parens)
8779<< 1 << Entity.
getType() << Args[0]->getSourceRange();
8783S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 0;
8786S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 1;
8789S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 2;
8792S.
Diag(Kind.getLocation(), diag::err_array_init_narrow_string_into_wchar);
8795S.
Diag(Kind.getLocation(), diag::err_array_init_wide_string_into_char);
8798S.
Diag(Kind.getLocation(),
8799diag::err_array_init_incompat_wide_string_into_wchar);
8802S.
Diag(Kind.getLocation(),
8803diag::err_array_init_plain_string_into_char8_t);
8804S.
Diag(Args.front()->getBeginLoc(),
8805diag::note_array_init_plain_string_into_char8_t)
8809S.
Diag(Kind.getLocation(), diag::err_array_init_utf8_string_into_char)
8814S.
Diag(Kind.getLocation(),
8816? diag::err_array_init_different_type
8817: diag::err_array_init_non_constant_array))
8820<< Args[0]->getSourceRange();
8824S.
Diag(Kind.getLocation(), diag::err_variable_object_no_init)
8825<< Args[0]->getSourceRange();
8838 auto*FD = cast<FunctionDecl>(cast<DeclRefExpr>(OnlyArg)->getDecl());
8846 switch(FailedOverloadResult) {
8853? (S.
PDiag(diag::err_typecheck_ambiguous_condition)
8854<< OnlyArg->
getType() << DestType
8855<< Args[0]->getSourceRange())
8856: (S.
PDiag(diag::err_ref_init_ambiguous)
8857<< DestType << OnlyArg->
getType()
8858<< Args[0]->getSourceRange())),
8866diag::err_typecheck_nonviable_condition_incomplete,
8867OnlyArg->
getType(), Args[0]->getSourceRange()))
8868S.
Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
8870<< OnlyArg->
getType() << Args[0]->getSourceRange()
8882S.
Diag(Kind.getLocation(), diag::err_typecheck_deleted_function)
8884<< (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
8885<< Args[0]->getSourceRange();
8889llvm_unreachable(
"Inconsistent overload resolution?");
8895llvm_unreachable(
"Conversion did not fail!");
8900 if(isa<InitListExpr>(Args[0])) {
8901S.
Diag(Kind.getLocation(),
8902diag::err_lvalue_reference_bind_to_initlist)
8905<< Args[0]->getSourceRange();
8911S.
Diag(Kind.getLocation(),
8913? diag::err_lvalue_reference_bind_to_temporary
8914: diag::err_lvalue_reference_bind_to_unrelated)
8918<< Args[0]->getSourceRange();
8923 FieldDecl*BitField = Args[0]->getSourceBitField();
8924S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_bitfield)
8927<< (BitField !=
nullptr)
8928<< Args[0]->getSourceRange();
8935S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_vector_element)
8937<< Args[0]->getSourceRange();
8941S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_matrix_element)
8946S.
Diag(Kind.getLocation(), diag::err_lvalue_to_rvalue_ref)
8948<< Args[0]->getSourceRange();
8952S.
Diag(Kind.getLocation(), diag::err_reference_bind_temporary_addrspace)
8953<< DestType << Args[0]->getSourceRange();
8964S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
8965<< NonRefType << SourceType << 1
8966<< Args[0]->getSourceRange();
8968S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
8969<< NonRefType << SourceType << 0
8975S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
8976<< NonRefType << SourceType << 2
8977<< Args[0]->getSourceRange();
8982S.
Diag(Kind.getLocation(), diag::err_reference_bind_failed)
8987<< Args[0]->getSourceRange();
8998<< Args[0]->getSourceRange();
9000S.
Diag(Kind.getLocation(), PDiag);
9012 auto*InitList = dyn_cast<InitListExpr>(Args[0]);
9013 if(InitList && InitList->getNumInits() >= 1) {
9014R =
SourceRange(InitList->getInit(0)->getEndLoc(), InitList->getEndLoc());
9016assert(Args.size() > 1 &&
"Expected multiple initializers!");
9017R =
SourceRange(Args.front()->getEndLoc(), Args.back()->getEndLoc());
9021 if(Kind.isCStyleOrFunctionalCast())
9022S.
Diag(Kind.getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
9025S.
Diag(Kind.getLocation(), diag::err_excess_initializers)
9031S.
Diag(Kind.getLocation(), diag::err_list_init_in_parens)
9032<< 0 << Entity.
getType() << Args[0]->getSourceRange();
9036S.
Diag(Kind.getLocation(), diag::err_reference_bind_init_list)
9041S.
Diag(Kind.getLocation(), diag::err_init_list_bad_dest_type)
9042<< (DestType->
isRecordType()) << DestType << Args[0]->getSourceRange();
9050 SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
9053assert(Args.size() == 1 &&
9054 "List construction from other than 1 argument.");
9061 switch(FailedOverloadResult) {
9065S.
PDiag(diag::err_ovl_ambiguous_init)
9066<< DestType << ArgsRange),
9083 if(
autoInherited = Constructor->getInheritedConstructor())
9084InheritedFrom = Inherited.getShadowDecl()->getNominatedBaseClass();
9086S.
Diag(Kind.getLocation(), diag::err_missing_default_ctor)
9087<< (InheritedFrom ? 2 : Constructor->isImplicit() ? 1 : 0)
9099S.
Diag(Kind.getLocation(), diag::err_missing_default_ctor)
9100<< (InheritedFrom ? 2 : Constructor->isImplicit() ? 1 : 0)
9106diag::note_member_declared_at);
9111diag::note_previous_decl)
9120S.
PDiag(diag::err_ovl_no_viable_function_in_init)
9121<< DestType << ArgsRange),
9130S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
9131<< DestType << ArgsRange;
9132llvm_unreachable(
"Inconsistent overload resolution?");
9140S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_special_init)
9141<< llvm::to_underlying(
9143<< DestType << ArgsRange;
9146S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
9147<< DestType << (Msg !=
nullptr)
9148<< (Msg ? Msg->
getString() : StringRef()) << ArgsRange;
9156llvm_unreachable(
"Conversion did not fail!");
9168S.
Diag(Kind.getLocation(), diag::err_uninitialized_member_in_ctor)
9169<< (Constructor->getInheritedConstructor() ? 2 :
9170Constructor->isImplicit() ? 1 : 0)
9176}
else if(
const auto*VD = dyn_cast_if_present<VarDecl>(Entity.
getDecl());
9177VD && VD->isConstexpr()) {
9178S.
Diag(Kind.getLocation(), diag::err_constexpr_var_requires_const_init)
9181S.
Diag(Kind.getLocation(), diag::err_default_init_const)
9188diag::err_init_incomplete_type);
9204S.
Diag(Kind.getLocation(), diag::err_selected_explicit_constructor)
9205<< Args[0]->getSourceRange();
9210assert(Ovl ==
OR_Success&&
"Inconsistent overload resolution");
9213diag::note_explicit_ctor_deduction_guide_here) <<
false;
9224S.
Diag(Kind.getLocation(), diag::err_designated_init_for_non_aggregate)
9229PrintInitLocationNote(S, Entity);
9236OS <<
"Failed sequence: ";
9239OS <<
"too many initializers for reference";
9243OS <<
"parenthesized list init for reference";
9247OS <<
"array requires initializer list";
9251OS <<
"address of unaddressable function was taken";
9255OS <<
"array requires initializer list or string literal";
9259OS <<
"array requires initializer list or wide string literal";
9263OS <<
"narrow string into wide char array";
9267OS <<
"wide string into char array";
9271OS <<
"incompatible wide string into wide char array";
9275OS <<
"plain string literal into char8_t array";
9279OS <<
"u8 string literal into char array";
9283OS <<
"array type mismatch";
9287OS <<
"non-constant array initializer";
9291OS <<
"address of overloaded function failed";
9295OS <<
"overload resolution for reference initialization failed";
9299OS <<
"non-const lvalue reference bound to temporary";
9303OS <<
"non-const lvalue reference bound to bit-field";
9307OS <<
"non-const lvalue reference bound to vector element";
9311OS <<
"non-const lvalue reference bound to matrix element";
9315OS <<
"non-const lvalue reference bound to unrelated type";
9319OS <<
"rvalue reference bound to an lvalue";
9323OS <<
"reference initialization drops qualifiers";
9327OS <<
"reference with mismatching address space bound to temporary";
9331OS <<
"reference initialization failed";
9335OS <<
"conversion failed";
9339OS <<
"conversion from property failed";
9343OS <<
"too many initializers for scalar";
9347OS <<
"parenthesized list init for reference";
9351OS <<
"referencing binding to initializer list";
9355OS <<
"initializer list for non-aggregate, non-scalar type";
9359OS <<
"overloading failed for user-defined conversion";
9363OS <<
"constructor overloading failed";
9367OS <<
"default initialization of a const variable";
9371OS <<
"initialization of incomplete type";
9375OS <<
"list initialization checker failure";
9379OS <<
"variable length array has an initializer";
9383OS <<
"initializer expression isn't contextually valid";
9387OS <<
"list constructor overloading failed";
9391OS <<
"list copy initialization chose explicit constructor";
9395OS <<
"parenthesized list initialization failed";
9399OS <<
"designated initializer for non-aggregate type";
9407OS <<
"Dependent sequence\n";
9411OS <<
"Normal sequence: ";
9422OS <<
"resolve address of overloaded function";
9426OS <<
"derived-to-base (prvalue)";
9430OS <<
"derived-to-base (xvalue)";
9434OS <<
"derived-to-base (lvalue)";
9438OS <<
"bind reference to lvalue";
9442OS <<
"bind reference to a temporary";
9446OS <<
"final copy in class direct-initialization";
9450OS <<
"extraneous C++03 copy to temporary";
9454OS <<
"user-defined conversion via "<< *S->Function.Function;
9458OS <<
"qualification conversion (prvalue)";
9462OS <<
"qualification conversion (xvalue)";
9466OS <<
"qualification conversion (lvalue)";
9470OS <<
"function reference conversion";
9474OS <<
"non-atomic-to-atomic conversion";
9478OS <<
"implicit conversion sequence (";
9484OS <<
"implicit conversion sequence with narrowing prohibited (";
9490OS <<
"list aggregate initialization";
9494OS <<
"unwrap reference initializer list";
9498OS <<
"rewrap reference initializer list";
9502OS <<
"constructor initialization";
9506OS <<
"list initialization via constructor";
9510OS <<
"zero initialization";
9514OS <<
"C assignment";
9518OS <<
"string initialization";
9522OS <<
"Objective-C object conversion";
9526OS <<
"indexing for array initialization loop";
9530OS <<
"array initialization loop";
9534OS <<
"array initialization";
9538OS <<
"array initialization (GNU extension)";
9542OS <<
"parenthesized array initialization";
9546OS <<
"pass by indirect copy and restore";
9550OS <<
"pass by indirect restore";
9554OS <<
"Objective-C object retension";
9558OS <<
"std::initializer_list from initializer list";
9562OS <<
"list initialization from std::initializer_list";
9566OS <<
"OpenCL sampler_t from integer constant";
9570OS <<
"OpenCL opaque type from zero";
9573OS <<
"initialization from a parenthesized list of values";
9577OS <<
" ["<< S->Type <<
']';
9584 dump(llvm::errs());
9591 const Expr*PostInit) {
9607 autoMakeDiag = [&](
boolIsConstRef,
unsignedDefaultDiagID,
9608 unsignedConstRefDiagID,
unsignedWarnDiagID) {
9611 if(L.CPlusPlus11 && !L.HLSL &&
9613DiagID = IsConstRef ? ConstRefDiagID : DefaultDiagID;
9615DiagID = WarnDiagID;
9635MakeDiag(
T!= EntityType, diag::ext_init_list_type_narrowing,
9636diag::ext_init_list_type_narrowing_const_reference,
9637diag::warn_init_list_type_narrowing)
9639<<
T.getLocalUnqualifiedType();
9646diag::ext_init_list_constant_narrowing,
9647diag::ext_init_list_constant_narrowing_const_reference,
9648diag::warn_init_list_constant_narrowing)
9657diag::ext_init_list_variable_narrowing,
9658diag::ext_init_list_variable_narrowing_const_reference,
9659diag::warn_init_list_variable_narrowing)
9667llvm::raw_svector_ostream OS(StaticCast);
9668OS <<
"static_cast<";
9675OS << *TT->getDecl();
9684S.
Diag(PostInit->
getBeginLoc(), diag::note_init_list_narrowing_silence)
9695 Init->IgnoreParenImpCasts(), ToType,
false,
9696Sema::AllowedExplicit::None,
9712S.
Diag(
Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
9713<<
Value.getAsString(S.
Context, PreNarrowingType) << ToType;
9718S.
Diag(
Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
9719<< ToType << FromType;
9729llvm_unreachable(
"unhandled case in switch");
9741 for(
unsignedI = 0, N = SE->
getLength(); I != N; ++I) {
9746diag::err_c23_constexpr_init_not_representable)
9760 if(
Init.isInvalid())
9764assert(InitE &&
"No initialization expression");
9769 return!
Seq.Failed();
9776 boolTopLevelOfInitList,
9777 boolAllowExplicit) {
9778 if(
Init.isInvalid())
9782assert(InitE &&
"No initialization expression?");
9792 const boolShouldTrackCopy =
9794 if(ShouldTrackCopy) {
9796 Seq.SetOverloadFailure(
9802 const autoLastStep =
Seq.step_end() - 1;
9803assert(LastStep->Kind ==
9807llvm::find_if(
Seq.getFailedCandidateSet(),
9809return Candidate.Viable &&
9810Candidate.Function == Function &&
9811Candidate.Conversions.size() > 0;
9813 if(Candidate !=
Seq.getFailedCandidateSet().end() &&
9815Candidate->
Viable=
false;
9819 Function->getParamDecl(0)->getType());
9827 if(ShouldTrackCopy)
9836 autoNotSpecialization = [&] (
const CXXRecordDecl*Candidate) {
9837 auto*CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Candidate);
9840 return!(NotSpecialization(RD) && RD->
forallBases(NotSpecialization));
9846 auto*DeducedTST = dyn_cast<DeducedTemplateSpecializationType>(
9848assert(DeducedTST &&
"not a deduced template specialization type");
9859 if(
auto*
AliasTemplate= dyn_cast_or_null<TypeAliasTemplateDecl>(
9861 Diag(Kind.getLocation(),
9862diag::warn_cxx17_compat_ctad_for_alias_templates);
9865->getUnderlyingType()
9866.getCanonicalType();
9870 if(
const auto*TST =
9872Template = dyn_cast_or_null<ClassTemplateDecl>(
9873TST->getTemplateName().getAsTemplateDecl());
9874}
else if(
const auto*RT = UnderlyingType->getAs<
RecordType>()) {
9878 if(
const auto*CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(
9879RT->getAsCXXRecordDecl()))
9880Template = CTSD->getSpecializedTemplate();
9885 Diag(Kind.getLocation(),
9886diag::err_deduced_non_class_or_alias_template_specialization_type)
9896diag::warn_cxx14_compat_class_template_argument_deduction)
9924? dyn_cast<InitListExpr>(Inits[0])
9940 boolAllowExplicit = !Kind.isCopyInit() ||
ListInit;
9946 boolOnlyListConstructors,
9947 boolAllowAggregateDeductionCandidate) {
9953 if(!AllowExplicit) {
9960 if(GD->getMinRequiredArguments() > 1 ||
9961(GD->getNumParams() == 0 && !GD->isVariadic()))
9971 if(!AllowAggregateDeductionCandidate &&
9986 for(
Expr*
E: Inits)
9987 if(
auto*DI = dyn_cast<DesignatedInitExpr>(
E))
9988TmpInits.push_back(DI->getInit());
9990TmpInits.push_back(
E);
9992TD, FoundDecl,
nullptr, TmpInits, Candidates,
9994 false, AllowExplicit, ADLCallKind::NotADL,
9995{}, AllowAggregateDeductionCandidate);
9999 false, AllowExplicit);
10003 boolFoundDeductionGuide =
false;
10005 autoTryToResolveOverload =
10008 boolHasAnyDeductionGuide =
false;
10011 auto*Pattern = Template;
10012 while(Pattern->getInstantiatedFromMemberTemplate()) {
10013 if(Pattern->isMemberSpecialization())
10015Pattern = Pattern->getInstantiatedFromMemberTemplate();
10018 auto*RD = cast<CXXRecordDecl>(Pattern->getTemplatedDecl());
10024InitListChecker CheckInitList(*
this, Entity,
ListInit, Ty, ElementTypes);
10025 if(!CheckInitList.HadError()) {
10034 for(
intI = 0,
E=
ListInit->getNumInits();
10035I <
E&& !isa<PackExpansionType>(ElementTypes[I]); ++I)
10036 if(ElementTypes[I]->isArrayType()) {
10037 if(isa<InitListExpr, DesignatedInitExpr>(
ListInit->getInit(I)))
10039 else if(isa<StringLiteral>(
10040 ListInit->getInit(I)->IgnoreParenImpCasts()))
10047LookupTemplateDecl, ElementTypes,
10051OnlyListConstructors,
10053HasAnyDeductionGuide =
true;
10058 for(
autoI = Guides.
begin(),
E= Guides.
end(); I !=
E; ++I) {
10063 auto*TD = dyn_cast<FunctionTemplateDecl>(
D);
10064 auto*GD = dyn_cast_if_present<CXXDeductionGuideDecl>(
10069 if(!GD->isImplicit())
10070HasAnyDeductionGuide =
true;
10072addDeductionCandidate(TD, GD, I.getPair(), OnlyListConstructors,
10087}
else if(Inits.size()) {
10092Inits, Inits.back()->getEndLoc());
10093SynthesizeAggrGuide(&TempListInit);
10097FoundDeductionGuide = FoundDeductionGuide || HasAnyDeductionGuide;
10107 boolTryListConstructors =
true;
10113 auto*FD = dyn_cast<FunctionDecl>(
D->getUnderlyingDecl());
10114 if(FD && FD->getMinRequiredArguments() == 0) {
10115TryListConstructors =
false;
10119}
else if(
ListInit->getNumInits() == 1) {
10127 if(!isa<InitListExpr>(
E) && RD &&
10130TryListConstructors =
false;
10133 if(TryListConstructors)
10134 Result= TryToResolveOverload(
true);
10143 Result= TryToResolveOverload(
false);
10152Kind.getLocation(),
10153 PDiag(diag::err_deduced_class_template_ctor_ambiguous)
10160cast<ClassTemplateDecl>(Template)->getTemplatedDecl();
10165Kind.getLocation(),
10166 PDiag(
Complete? diag::err_deduced_class_template_ctor_no_viable
10167: diag::err_deduced_class_template_incomplete)
10177 Diag(Kind.getLocation(), diag::err_deduced_class_template_deleted)
10187 if(Kind.isCopyInit() &&
ListInit&&
10188cast<CXXDeductionGuideDecl>(Best->Function)->isExplicit()) {
10189 boolIsDeductionGuide = !Best->Function->isImplicit();
10190 Diag(Kind.getLocation(), diag::err_deduced_class_template_explicit)
10192 Diag(Best->Function->getLocation(),
10193diag::note_explicit_ctor_deduction_guide_here)
10194<< IsDeductionGuide;
10211diag::warn_cxx14_compat_class_template_argument_deduction)
10216 if(!FoundDeductionGuide) {
10218diag::warn_ctad_maybe_unsupported)
10220 Diag(Template->getLocation(), diag::note_suppress_ctad_maybe_unsupported);
Defines the clang::ASTContext interface.
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
static bool isRValueRef(QualType ParamType)
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static void CheckForNullPointerDereference(Sema &S, Expr *E)
static bool isExprAnUnaddressableFunction(Sema &S, const Expr *E)
Tries to get a FunctionDecl out of E.
static void updateStringLiteralType(Expr *E, QualType Ty)
Update the type of a string literal, including any surrounding parentheses, to match the type of the ...
static void updateGNUCompoundLiteralRValue(Expr *E)
Fix a compound literal initializing an array so it's correctly marked as an rvalue.
static bool initializingConstexprVariable(const InitializedEntity &Entity)
static void warnBracedScalarInit(Sema &S, const InitializedEntity &Entity, SourceRange Braces)
Warn that Entity was of scalar type and was initialized by a single-element braced initializer list.
static bool shouldDestroyEntity(const InitializedEntity &Entity)
Whether the given entity, when initialized with an object created for that initialization,...
static SourceLocation getInitializationLoc(const InitializedEntity &Entity, Expr *Initializer)
Get the location at which initialization diagnostics should appear.
static bool hasAnyDesignatedInits(const InitListExpr *IL)
static bool tryObjCWritebackConversion(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity, Expr *Initializer)
static DesignatedInitExpr * CloneDesignatedInitExpr(Sema &SemaRef, DesignatedInitExpr *DIE)
static ExprResult CopyObject(Sema &S, QualType T, const InitializedEntity &Entity, ExprResult CurInit, bool IsExtraneousCopy)
Make a (potentially elidable) temporary copy of the object provided by the given initializer by calli...
static void TryOrBuildParenListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args, InitializationSequence &Sequence, bool VerifyOnly, ExprResult *Result=nullptr)
static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, bool IsReturnStmt)
Provide warnings when std::move is used on construction.
static void CheckC23ConstexprInitStringLiteral(const StringLiteral *SE, Sema &SemaRef, QualType &TT)
static void CheckCXX98CompatAccessibleCopy(Sema &S, const InitializedEntity &Entity, Expr *CurInitExpr)
Check whether elidable copy construction for binding a reference to a temporary would have succeeded ...
static bool isOrIsDerivedFromSpecializationOf(CXXRecordDecl *RD, ClassTemplateDecl *CTD)
Determine whether RD is, or is derived from, a specialization of CTD.
static bool canInitializeArrayWithEmbedDataString(ArrayRef< Expr * > ExprList, const InitializedEntity &Entity, ASTContext &Context)
static bool TryInitializerListConstruction(Sema &S, InitListExpr *List, QualType DestType, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
When initializing from init list via constructor, handle initialization of an object of type std::ini...
static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT, ASTContext &Context)
Check whether the array of type AT can be initialized by the Init expression by means of string initi...
static void TryArrayCopy(Sema &S, const InitializationKind &Kind, const InitializedEntity &Entity, Expr *Initializer, QualType DestType, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Initialize an array from another array.
static bool isInitializedStructuredList(const InitListExpr *StructuredList)
@ SIF_PlainStringIntoUTF8Char
@ SIF_IncompatWideStringIntoWideChar
@ SIF_UTF8StringIntoPlainChar
@ SIF_NarrowStringIntoWideChar
static void TryDefaultInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence)
Attempt default initialization (C++ [dcl.init]p6).
static bool TryOCLSamplerInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
static bool maybeRecoverWithZeroInitialization(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Tries to add a zero initializer. Returns true if that worked.
static ExprResult CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value)
Check that the given Index expression is a valid array designator value.
static bool canPerformArrayCopy(const InitializedEntity &Entity)
Determine whether we can perform an elementwise array copy for this kind of entity.
static bool IsZeroInitializer(Expr *Initializer, Sema &S)
static void TryReferenceInitializationCore(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, QualType cv1T1, QualType T1, Qualifiers T1Quals, QualType cv2T2, QualType T2, Qualifiers T2Quals, InitializationSequence &Sequence, bool TopLevelOfInitList)
Reference initialization without resolving overloaded functions.
static void CheckC23ConstexprInitConversion(Sema &S, QualType FromType, QualType ToType, Expr *Init)
static void ExpandAnonymousFieldDesignator(Sema &SemaRef, DesignatedInitExpr *DIE, unsigned DesigIdx, IndirectFieldDecl *IndirectField)
Expand a field designator that refers to a member of an anonymous struct or union into a series of fi...
static void TryValueInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence, InitListExpr *InitList=nullptr)
Attempt value initialization (C++ [dcl.init]p7).
static void TryUserDefinedConversion(Sema &S, QualType DestType, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt a user-defined conversion between two types (C++ [dcl.init]), which enumerates all conversion...
static OverloadingResult ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, MultiExprArg Args, OverloadCandidateSet &CandidateSet, QualType DestType, DeclContext::lookup_result Ctors, OverloadCandidateSet::iterator &Best, bool CopyInitializing, bool AllowExplicit, bool OnlyListConstructors, bool IsListInit, bool RequireActualConstructor, bool SecondStepOfCopyInit=false)
static AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
static void TryListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Attempt list initialization (C++0x [dcl.init.list])
static void TryStringLiteralInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence)
Attempt character array initialization from a string literal (C++ [dcl.init.string],...
static bool checkDestructorReference(QualType ElementType, SourceLocation Loc, Sema &SemaRef)
Check if the type of a class element has an accessible destructor, and marks it referenced.
static void TryReferenceInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt reference initialization (C++0x [dcl.init.ref])
static void DiagnoseNarrowingInInitList(Sema &S, const ImplicitConversionSequence &ICS, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit)
static bool hasCompatibleArrayTypes(ASTContext &Context, const ArrayType *Dest, const ArrayType *Source)
Determine whether we have compatible array types for the purposes of GNU by-copy array initialization...
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, Sema &S, bool CheckC23ConstexprInit=false)
static bool isExplicitTemporary(const InitializedEntity &Entity, const InitializationKind &Kind, unsigned NumArgs)
Returns true if the parameters describe a constructor initialization of an explicit temporary object,...
static bool isNonReferenceableGLValue(Expr *E)
Determine whether an expression is a non-referenceable glvalue (one to which a reference can never bi...
static bool TryOCLZeroOpaqueTypeInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
static bool IsWideCharCompatible(QualType T, ASTContext &Context)
Check whether T is compatible with a wide character type (wchar_t, char16_t or char32_t).
static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, InitListExpr *InitList)
static OverloadingResult TryRefInitWithConversionFunction(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, bool AllowRValues, bool IsLValueRef, InitializationSequence &Sequence)
Try a reference initialization that involves calling a conversion function.
void emitUninitializedExplicitInitFields(Sema &S, const RecordDecl *R)
static void TryConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType DestType, QualType DestArrayType, InitializationSequence &Sequence, bool IsListInit=false, bool IsInitListCopy=false)
Attempt initialization by constructor (C++ [dcl.init]), which enumerates the constructors of the init...
static void emitBadConversionNotes(Sema &S, const InitializedEntity &entity, Expr *op)
Emit notes associated with an initialization that failed due to a "simple" conversion failure.
static bool isIdiomaticBraceElisionEntity(const InitializedEntity &Entity)
Determine whether Entity is an entity for which it is idiomatic to elide the braces in aggregate init...
static void MaybeProduceObjCObject(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
static void checkIndirectCopyRestoreSource(Sema &S, Expr *src)
Check whether the given expression is a valid operand for an indirect copy/restore.
static bool shouldBindAsTemporary(const InitializedEntity &Entity)
Whether we should bind a created object as a temporary when initializing the given entity.
static bool ResolveOverloadedFunctionForReferenceBinding(Sema &S, Expr *Initializer, QualType &SourceType, QualType &UnqualifiedSourceType, QualType UnqualifiedTargetType, InitializationSequence &Sequence)
InvalidICRKind
The non-zero enum values here are indexes into diagnostic alternatives.
static ExprResult PerformConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, const InitializationSequence::Step &Step, bool &ConstructorInitRequiresZeroInit, bool IsListInitialization, bool IsStdInitListInitialization, SourceLocation LBraceLoc, SourceLocation RBraceLoc)
static void TryReferenceListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Attempt list initialization of a reference.
static bool isLibstdcxxPointerReturnFalseHack(Sema &S, const InitializedEntity &Entity, const Expr *Init)
An egregious hack for compatibility with libstdc++-4.2: in <tr1/hashtable>, a function with a pointer...
static bool hasCopyOrMoveCtorParam(ASTContext &Ctx, const ConstructorInfo &Info)
Determine if the constructor has the signature of a copy or move constructor for the type T of the cl...
static bool DiagnoseUninitializedReference(Sema &S, SourceLocation Loc, QualType T)
Somewhere within T there is an uninitialized reference subobject.
static InvalidICRKind isInvalidICRSource(ASTContext &C, Expr *e, bool isAddressOf, bool &isWeakAccess)
Determines whether this expression is an acceptable ICR source.
This file declares semantic analysis for Objective-C.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
__device__ __2f16 float __ockl_bool s
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
bool isNullPointer() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getRecordType(const RecordDecl *Decl) const
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getWideCharType() const
Return the type of wide characters.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Represents a loop initializing the elements of an array.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
QualType getType() const
Retrieves the type of the base class.
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Represents a C++ constructor within a class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
Represents a C++ conversion function within a class.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a C++ deduction guide declaration.
Represents a C++ destructor within a class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Represents a C++ struct/union/class.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
CXXRecordDecl * getDefinition() const
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
llvm::iterator_range< base_class_iterator > base_class_range
llvm::iterator_range< base_class_const_iterator > base_class_const_range
bool forallBases(ForallBasesCallback BaseMatches) const
Determines if the given callback holds for all the direct or indirect base classes of this type.
An expression "T()" which creates an rvalue of a non-class type T.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr * > Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCallToStdMove() const
SourceLocation getRParenLoc() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
SourceLocation getBegin() const
Declaration of a class template.
void setExprNeedsCleanups(bool SideEffects)
Complex values, per C99 6.2.5p11.
QualType getElementType() const
ConditionalOperator - The ?: ternary operator.
Represents the canonical version of C arrays with a specified constant size.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
virtual std::unique_ptr< CorrectionCandidateCallback > clone()=0
Clone this CorrectionCandidateCallback.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
The results of name lookup within a DeclContext.
decl_iterator - Iterates through the declarations stored within this context.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
A reference to a declared variable, function, enum, etc.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
bool isInvalidDecl() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
The name of a declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Represents a single C99 designator.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getFieldLoc() const
SourceLocation getDotLoc() const
Represents a C99 designated initializer expression.
bool isDirectInit() const
Whether this designated initializer should result in direct-initialization of the designated subobjec...
Expr * getArrayRangeEnd(const Designator &D) const
Expr * getSubExpr(unsigned Idx) const
llvm::MutableArrayRef< Designator > designators()
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Expr * getArrayRangeStart(const Designator &D) const
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Expr * getArrayIndex(const Designator &D) const
Designator * getDesignator(unsigned Idx)
Expr * getInit() const
Retrieve the initializer value.
unsigned size() const
Returns the number of designators in this initializer.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression,...
InitListExpr * getUpdater() const
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
Designator - A designator in a C99 designated initializer.
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a reference to #emded data.
StringLiteral * getDataStringLiteral() const
EmbedDataStorage * getData() const
SourceLocation getLocation() const
size_t getDataElementCount() const
RAII object that enters a new expression evaluation context.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
The return type of classify().
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToMatrixElement() const
Returns whether this expression refers to a matrix element.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
QualType getReturnType() const
bool isDeleted() const
Whether this function has been deleted.
bool isDefaulted() const
Whether this function is defaulted.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
One of these records is kept for each identifier that is lexed.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
Represents an implicitly-generated value initialization of an object of a given type.
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
chain_iterator chain_end() const
chain_iterator chain_begin() const
ArrayRef< NamedDecl * >::const_iterator chain_iterator
Describes an C or C++ initializer list.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
void setSyntacticForm(InitListExpr *Init)
void markError()
Mark the semantic form of the InitListExpr as error when the semantic analysis fails.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setInit(unsigned Init, Expr *expr)
SourceLocation getLBraceLoc() const
Expr * updateInit(const ASTContext &C, unsigned Init, Expr *expr)
Updates the initializer at index Init with the new expression expr, and returns the old expression at...
void setArrayFiller(Expr *filler)
InitListExpr * getSyntacticForm() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
SourceLocation getRBraceLoc() const
const Expr * getInit(unsigned Init) const
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
SourceLocation getEndLoc() const LLVM_READONLY
void setInitializedFieldInUnion(FieldDecl *FD)
bool isSyntacticForm() const
ArrayRef< Expr * > inits()
void setRBraceLoc(SourceLocation Loc)
void sawArrayRangeDesignator(bool ARD=true)
Expr ** getInits()
Retrieve the set of initializers.
Describes the kind of initialization being performed, along with location information for tokens rela...
@ IK_DirectList
Direct list-initialization.
@ IK_Value
Value initialization.
@ IK_Direct
Direct initialization.
@ IK_Copy
Copy initialization.
@ IK_Default
Default initialization.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
A single step in the initialization sequence.
StepKind Kind
The kind of conversion or initialization step we are taking.
InitListExpr * WrappingSyntacticList
When Kind = SK_RewrapInitList, the syntactic form of the wrapping list.
ImplicitConversionSequence * ICS
When Kind = SK_ConversionSequence, the implicit conversion sequence.
struct F Function
When Kind == SK_ResolvedOverloadedFunction or Kind == SK_UserConversion, the function that the expres...
Describes the sequence of initializations required to initialize a given object or reference with a s...
step_iterator step_begin() const
void AddListInitializationStep(QualType T)
Add a list-initialization step.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
void AddStringInitStep(QualType T)
Add a string init step.
void AddStdInitializerListConstructionStep(QualType T)
Add a step to construct a std::initializer_list object from an initializer list.
void AddConstructorInitializationStep(DeclAccessPair FoundDecl, CXXConstructorDecl *Constructor, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
Add a constructor-initialization step.
@ SK_StdInitializerListConstructorCall
Perform initialization via a constructor taking a single std::initializer_list argument.
@ SK_AtomicConversion
Perform a conversion adding _Atomic to a type.
@ SK_ObjCObjectConversion
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
@ SK_GNUArrayInit
Array initialization (from an array rvalue) as a GNU extension.
@ SK_CastDerivedToBaseLValue
Perform a derived-to-base cast, producing an lvalue.
@ SK_ProduceObjCObject
Produce an Objective-C object pointer.
@ SK_FunctionReferenceConversion
Perform a function reference conversion, see [dcl.init.ref]p4.
@ SK_BindReference
Reference binding to an lvalue.
@ SK_ArrayLoopInit
Array initialization by elementwise copy.
@ SK_ConstructorInitialization
Perform initialization via a constructor.
@ SK_OCLSamplerInit
Initialize an OpenCL sampler from an integer.
@ SK_StringInit
Initialization by string.
@ SK_ZeroInitialization
Zero-initialize the object.
@ SK_CastDerivedToBaseXValue
Perform a derived-to-base cast, producing an xvalue.
@ SK_QualificationConversionXValue
Perform a qualification conversion, producing an xvalue.
@ SK_UserConversion
Perform a user-defined conversion, either via a conversion function or via a constructor.
@ SK_CastDerivedToBasePRValue
Perform a derived-to-base cast, producing an rvalue.
@ SK_BindReferenceToTemporary
Reference binding to a temporary.
@ SK_PassByIndirectRestore
Pass an object by indirect restore.
@ SK_ParenthesizedArrayInit
Array initialization from a parenthesized initializer list.
@ SK_ParenthesizedListInit
Initialize an aggreagate with parenthesized list of values.
@ SK_ArrayInit
Array initialization (from an array rvalue).
@ SK_ExtraneousCopyToTemporary
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
@ SK_ArrayLoopIndex
Array indexing for initialization by elementwise copy.
@ SK_ConversionSequenceNoNarrowing
Perform an implicit conversion sequence without narrowing.
@ SK_RewrapInitList
Rewrap the single-element initializer list for a reference.
@ SK_CAssignment
C assignment.
@ SK_ConstructorInitializationFromList
Perform initialization via a constructor, taking arguments from a single InitListExpr.
@ SK_PassByIndirectCopyRestore
Pass an object by indirect copy-and-restore.
@ SK_ResolveAddressOfOverloadedFunction
Resolve the address of an overloaded function to a specific function declaration.
@ SK_UnwrapInitList
Unwrap the single-element initializer list for a reference.
@ SK_FinalCopy
Direct-initialization from a reference-related object in the final stage of class copy-initialization...
@ SK_QualificationConversionLValue
Perform a qualification conversion, producing an lvalue.
@ SK_StdInitializerList
Construct a std::initializer_list from an initializer list.
@ SK_QualificationConversionPRValue
Perform a qualification conversion, producing a prvalue.
@ SK_ConversionSequence
Perform an implicit conversion sequence.
@ SK_ListInitialization
Perform list-initialization without a constructor.
@ SK_OCLZeroOpaqueType
Initialize an opaque OpenCL type (event_t, queue_t, etc.) with zero.
void AddUserConversionStep(FunctionDecl *Function, DeclAccessPair FoundDecl, QualType T, bool HadMultipleCandidates)
Add a new step invoking a conversion function, which is either a constructor or a conversion function...
void SetZeroInitializationFixit(const std::string &Fixit, SourceLocation L)
Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied...
InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList=false, bool TreatUnavailableAsInvalid=true)
Try to perform initialization of the given entity, creating a record of the steps required to perform...
void AddQualificationConversionStep(QualType Ty, ExprValueKind Category)
Add a new step that performs a qualification conversion to the given type.
void AddFunctionReferenceConversionStep(QualType Ty)
Add a new step that performs a function reference conversion to the given type.
~InitializationSequence()
void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category)
Add a new step in the initialization that performs a derived-to- base cast.
FailureKind getFailureKind() const
Determine why initialization failed.
void InitializeFrom(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList, bool TreatUnavailableAsInvalid)
void AddParenthesizedListInitStep(QualType T)
void SetFailed(FailureKind Failure)
Note that this initialization sequence failed.
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
void AddUnwrapInitListInitStep(InitListExpr *Syntactic)
Only used when initializing structured bindings from an array with direct-list-initialization.
void AddOCLZeroOpaqueTypeStep(QualType T)
Add a step to initialzie an OpenCL opaque type (event_t, queue_t, etc.) from a zero constant.
void AddFinalCopy(QualType T)
Add a new step that makes a copy of the input to an object of the given type, as the final step in cl...
void setSequenceKind(enum SequenceKind SK)
Set the kind of sequence computed.
void AddObjCObjectConversionStep(QualType T)
Add an Objective-C object conversion step, which is always a no-op.
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
step_iterator step_end() const
void AddParenthesizedArrayInitStep(QualType T)
Add a parenthesized array initialization step.
void AddExtraneousCopyToTemporary(QualType T)
Add a new step that makes an extraneous copy of the input to a temporary of the same class type.
void setIncompleteTypeFailure(QualType IncompleteType)
Note that this initialization sequence failed due to an incomplete type.
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
void AddCAssignmentStep(QualType T)
Add a C assignment step.
void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy)
Add a step to pass an object by indirect copy-restore.
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic)
Add steps to unwrap a initializer list for a reference around a single element and rewrap it at the e...
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
bool Failed() const
Determine whether the initialization sequence is invalid.
void AddAtomicConversionStep(QualType Ty)
Add a new step that performs conversion from non-atomic to atomic type.
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes.
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
Add a new step that applies an implicit conversion sequence.
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
void AddProduceObjCObjectStep(QualType T)
Add a step to "produce" an Objective-C object (by retaining it).
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
SequenceKind
Describes the kind of initialization sequence computed.
@ NormalSequence
A normal sequence.
@ FailedSequence
A failed initialization sequence.
@ DependentSequence
A dependent initialization, which could not be type-checked due to the presence of dependent types or...
void AddReferenceBindingStep(QualType T, bool BindingTemporary)
Add a new step binding a reference to an object.
FailureKind
Describes why initialization failed.
@ FK_UserConversionOverloadFailed
Overloading for a user-defined conversion failed.
@ FK_NarrowStringIntoWideCharArray
Initializing a wide char array with narrow string literal.
@ FK_ArrayTypeMismatch
Array type mismatch.
@ FK_ParenthesizedListInitForReference
Reference initialized from a parenthesized initializer list.
@ FK_NonConstLValueReferenceBindingToVectorElement
Non-const lvalue reference binding to a vector element.
@ FK_ReferenceInitDropsQualifiers
Reference binding drops qualifiers.
@ FK_InitListBadDestinationType
Initialization of some unused destination type with an initializer list.
@ FK_ConversionFromPropertyFailed
Implicit conversion failed.
@ FK_NonConstLValueReferenceBindingToUnrelated
Non-const lvalue reference binding to an lvalue of unrelated type.
@ FK_ListConstructorOverloadFailed
Overloading for list-initialization by constructor failed.
@ FK_ReferenceInitFailed
Reference binding failed.
@ FK_DesignatedInitForNonAggregate
@ FK_ArrayNeedsInitList
Array must be initialized with an initializer list.
@ FK_PlainStringIntoUTF8Char
Initializing char8_t array with plain string literal.
@ FK_NonConstantArrayInit
Non-constant array initializer.
@ FK_NonConstLValueReferenceBindingToTemporary
Non-const lvalue reference binding to a temporary.
@ FK_ConversionFailed
Implicit conversion failed.
@ FK_ArrayNeedsInitListOrStringLiteral
Array must be initialized with an initializer list or a string literal.
@ FK_ParenthesizedListInitForScalar
Scalar initialized from a parenthesized initializer list.
@ FK_PlaceholderType
Initializer has a placeholder type which cannot be resolved by initialization.
@ FK_IncompatWideStringIntoWideChar
Initializing wide char array with incompatible wide string literal.
@ FK_NonConstLValueReferenceBindingToMatrixElement
Non-const lvalue reference binding to a matrix element.
@ FK_TooManyInitsForReference
Too many initializers provided for a reference.
@ FK_NonConstLValueReferenceBindingToBitfield
Non-const lvalue reference binding to a bit-field.
@ FK_ReferenceAddrspaceMismatchTemporary
Reference with mismatching address space binding to temporary.
@ FK_ListInitializationFailed
List initialization failed at some point.
@ FK_TooManyInitsForScalar
Too many initializers for scalar.
@ FK_AddressOfOverloadFailed
Cannot resolve the address of an overloaded function.
@ FK_VariableLengthArrayHasInitializer
Variable-length array must not have an initializer.
@ FK_ArrayNeedsInitListOrWideStringLiteral
Array must be initialized with an initializer list or a wide string literal.
@ FK_RValueReferenceBindingToLValue
Rvalue reference binding to an lvalue.
@ FK_Incomplete
Initialization of an incomplete type.
@ FK_WideStringIntoCharArray
Initializing char array with wide string literal.
@ FK_ExplicitConstructor
List-copy-initialization chose an explicit constructor.
@ FK_ReferenceInitOverloadFailed
Overloading due to reference initialization failed.
@ FK_ConstructorOverloadFailed
Overloading for initialization by constructor failed.
@ FK_ReferenceBindingToInitList
Reference initialization from an initializer list.
@ FK_DefaultInitOfConst
Default-initialization of a 'const' object.
@ FK_ParenthesizedListInitFailed
Parenthesized list initialization failed at some point.
@ FK_AddressOfUnaddressableFunction
Trying to take the address of a function that doesn't support having its address taken.
@ FK_UTF8StringIntoPlainChar
Initializing char array with UTF-8 string literal.
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init....
void AddArrayInitLoopStep(QualType T, QualType EltTy)
Add an array initialization loop step.
void AddAddressOverloadResolutionStep(FunctionDecl *Function, DeclAccessPair Found, bool HadMultipleCandidates)
Add a new step in the initialization that resolves the address of an overloaded function to a specifi...
void AddArrayInitStep(QualType T, bool IsGNUExtension)
Add an array initialization step.
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
SmallVectorImpl< Step >::const_iterator step_iterator
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
Describes an entity that is being initialized.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
VD Variable
When Kind == EK_Variable, EK_Member, EK_Binding, or EK_TemplateParameter, the variable,...
EntityKind getKind() const
Determine the kind of initialization.
DeclarationName getName() const
Retrieve the name of the entity being initialized.
QualType getType() const
Retrieve type being initialized.
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
bool isImplicitMemberInitializer() const
Is this the implicit initialization of a member of a class from a defaulted constructor?
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
void setElementIndex(unsigned Index)
If this is already the initializer for an array or vector element, sets the element index.
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda.
bool isParamOrTemplateParamKind() const
llvm::PointerIntPair< const CXXBaseSpecifier *, 1 > Base
When Kind == EK_Base, the base specifier that provides the base class.
bool allowsNRVO() const
Determine whether this initialization allows the named return value optimization, which also applies ...
bool isParameterKind() const
void dump() const
Dump a representation of the initialized entity to standard error, for debugging purposes.
EntityKind
Specifies the kind of entity being initialized.
@ EK_Variable
The entity being initialized is a variable.
@ EK_Temporary
The entity being initialized is a temporary object.
@ EK_Binding
The entity being initialized is a structured binding of a decomposition declaration.
@ EK_BlockElement
The entity being initialized is a field of block descriptor for the copied-in c++ object.
@ EK_Parameter_CF_Audited
The entity being initialized is a function parameter; function is member of group of audited CF APIs.
@ EK_LambdaToBlockConversionBlockElement
The entity being initialized is a field of block descriptor for the copied-in lambda object that's us...
@ EK_Member
The entity being initialized is a non-static data member subobject.
@ EK_Base
The entity being initialized is a base member subobject.
@ EK_Result
The entity being initialized is the result of a function call.
@ EK_TemplateParameter
The entity being initialized is a non-type template parameter.
@ EK_StmtExprResult
The entity being initialized is the result of a statement expression.
@ EK_ParenAggInitMember
The entity being initialized is a non-static data member subobject of an object initialized via paren...
@ EK_VectorElement
The entity being initialized is an element of a vector.
@ EK_New
The entity being initialized is an object (or array of objects) allocated via new.
@ EK_CompoundLiteralInit
The entity being initialized is the initializer for a compound literal.
@ EK_Parameter
The entity being initialized is a function parameter.
@ EK_Delegating
The initialization is being done by a delegating constructor.
@ EK_ComplexElement
The entity being initialized is the real or imaginary part of a complex number.
@ EK_ArrayElement
The entity being initialized is an element of an array.
@ EK_LambdaCapture
The entity being initialized is the field that captures a variable in a lambda.
@ EK_Exception
The entity being initialized is an exception object that is being thrown.
@ EK_RelatedResult
The entity being implicitly initialized back to the formal result type.
static InitializedEntity InitializeMemberFromParenAggInit(FieldDecl *Member)
Create the initialization entity for a member subobject initialized via parenthesized aggregate init.
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
unsigned Index
When Kind == EK_ArrayElement, EK_VectorElement, or EK_ComplexElement, the index of the array or vecto...
bool isVariableLengthArrayNew() const
Determine whether this is an array new with an unknown bound.
llvm::PointerIntPair< ParmVarDecl *, 1 > Parameter
When Kind == EK_Parameter, the ParmVarDecl, with the integer indicating whether the parameter is "con...
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
ObjCMethodDecl * getMethodDecl() const
Retrieve the ObjectiveC method being initialized.
The injected class name of a C++ class template or class template partial specialization.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
Represents the results of name lookup.
bool empty() const
Return true if no decls were found.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represent a C++ namespace.
Represents a place-holder for an object not to be initialized by anything.
ObjCEncodeExpr, used for @encode in Objective-C.
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
void setDestAS(LangAS AS)
@ CSK_InitByConstructor
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor,...
@ CSK_InitByUserDefinedConversion
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void addAddressSpace(LangAS space)
@ OCL_Weak
Reading or writing from this object requires a barrier call.
bool hasQualifiers() const
Return true if the set contains any qualifiers.
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
bool hasAddressSpace() const
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
Qualifiers withoutAddressSpace() const
void removeAddressSpace()
static Qualifiers fromCVRMask(unsigned CVR)
bool hasObjCLifetime() const
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasFlexibleArrayMember() const
field_iterator field_end() const
field_range fields() const
bool isRandomized() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool hasUninitializedExplicitInitFields() const
specific_decl_iterator< FieldDecl > field_iterator
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Base for LValueReferenceType and RValueReferenceType.
bool isSpelledAsLValue() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type,...
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
Sema - This implements semantic analysis and AST building for C.
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
bool DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, RecordDecl *ClassDecl, const IdentifierInfo *Name)
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
bool IsStringInit(Expr *Init, const ArrayType *AT)
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true, bool HasMatchedPackOnParmToNonPackOnArg=false)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, QualType DeclInitType, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
FunctionTemplateDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
FPOptionsOverride CurFPFeatureOverrides()
ExpressionEvaluationContextRecord & parentEvaluationContext()
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool HasMatchedPackOnParmToNonPackOnArg=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized.
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_PRValue, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, unsigned ByteNo) const
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ Compatible
Compatible - the types are compatible according to the standard.
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL,...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, ReferenceConversions *Conv=nullptr)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary â that is,...
SourceManager & SourceMgr
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
QualType SubstAutoTypeDependent(QualType TypeWithAuto)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool isAtStartOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the beginning of the immediate macro expansion.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
void setFromType(QualType T)
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
ImplicitConversionKind First
First â The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion,...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
void setToType(unsigned Idx, QualType T)
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
void setAllToTypes(QualType T)
QualType getToType(unsigned Idx) const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
unsigned getLength() const
StringLiteralKind getKind() const
int64_t getCodeUnitS(size_t I, uint64_t BitWidth) const
StringRef getString() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool isDependent() const
Determines whether this is a dependent template name.
Represents a type template specialization; the template must be a class template, a type alias templa...
Base wrapper for a particular "section" of type source info.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBooleanType() const
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isRValueReferenceType() const
bool isConstantArrayType() const
bool isPointerType() const
bool isArrayParameterType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isSizelessBuiltinType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isExtVectorType() const
bool isOCLIntelSubgroupAVCType() const
bool isLValueReferenceType() const
bool isOpenCLSpecificType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isAnyComplexType() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isAtomicType() const
bool isFunctionProtoType() const
bool isObjCObjectType() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isFloatingType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
bool isObjCRetainableType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Simple class containing the result of Sema::CorrectTypo.
DeclClass * getCorrectionDeclAs() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
const Expr * getInit() const
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorKind getVectorKind() const
QualType getElementType() const
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool Zero(InterpState &S, CodePtr OpPC)
void checkInitLifetime(Sema &SemaRef, const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for initializing the ent...
The JSON file list parser is used to communicate input to InstallAPI.
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ ovl_fail_bad_conversion
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ SD_Automatic
Automatic storage duration (most local variables).
@ Result
The result type of a method or function.
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Writeback_Conversion
Objective-C ARC writeback conversion.
ActionResult< Expr * > ExprResult
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Expr * IgnoreParensSingleStep(Expr *E)
const FunctionProtoType * T
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Braces
New-expression has a C++11 list-initializer.
CheckedConversionKind
The kind of conversion being performed.
@ Implicit
An implicit conversion.
@ CStyleCast
A C-style cast.
@ OtherCast
A cast other than a C-style cast.
@ FunctionalCast
A functional-style cast.
MutableArrayRef< Expr * > MultiExprArg
CXXConstructorDecl * Constructor
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
bool HadMultipleCandidates
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
unsigned char FailureKind
FailureKind - The reason why this candidate is not viable.
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
unsigned Viable
Viable - True to indicate that this overload candidate is viable.
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
std::optional< InitializationContext > DelayedDefaultInitializationContext
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4