33#include "llvm/ADT/APInt.h"
34#include "llvm/ADT/FoldingSet.h"
35#include "llvm/ADT/PointerIntPair.h"
36#include "llvm/ADT/STLForwardCompat.h"
37#include "llvm/ADT/SmallString.h"
38#include "llvm/ADT/SmallVector.h"
39#include "llvm/ADT/StringExtras.h"
40#include "llvm/Support/ErrorHandling.h"
41#include "llvm/Support/raw_ostream.h"
77 if (!isa<ConstantArrayType>(AT) && !isa<IncompleteArrayType>(AT))
95 auto IsCharOrUnsignedChar = [](
const QualType &
T) {
96 const BuiltinType *BT = dyn_cast<BuiltinType>(
T.getTypePtr());
101 case StringLiteralKind::UTF8:
111 case StringLiteralKind::Ordinary:
115 return (SL->
getKind() == StringLiteralKind::UTF8 &&
129 case StringLiteralKind::UTF16:
137 case StringLiteralKind::UTF32:
145 case StringLiteralKind::Wide:
153 case StringLiteralKind::Unevaluated:
154 assert(
false &&
"Unevaluated string literal in initialization");
158 llvm_unreachable(
"missed a StringLiteral kind?");
179 if (isa<StringLiteral>(
E) || isa<ObjCEncodeExpr>(
E))
190 if (isa<CompoundLiteralExpr>(
E))
205 if (
const auto *VD = dyn_cast_if_present<VarDecl>(
D); VD && VD->isConstexpr())
215 Sema &S,
bool CheckC23ConstexprInit =
false) {
217 auto *ConstantArrayTy =
219 uint64_t StrLength = ConstantArrayTy->getZExtSize();
221 if (CheckC23ConstexprInit)
228 llvm::APInt ConstVal(32, StrLength);
254 diag::err_initializer_string_for_char_array_too_long)
260 diag::ext_initializer_string_for_char_array_too_long)
308class InitListChecker {
310 bool hadError =
false;
312 bool TreatUnavailableAsInvalid;
313 bool InOverloadResolution;
318 unsigned CurEmbedIndex = 0;
329 unsigned &StructuredIndex);
333 bool TopLevelObject =
false);
336 bool SubobjectIsDesignatorContext,
339 unsigned &StructuredIndex,
340 bool TopLevelObject =
false);
345 unsigned &StructuredIndex,
346 bool DirectlyDesignated =
false);
351 unsigned &StructuredIndex);
356 unsigned &StructuredIndex);
361 unsigned &StructuredIndex);
365 unsigned &StructuredIndex);
370 bool SubobjectIsDesignatorContext,
unsigned &Index,
372 unsigned &StructuredIndex,
373 bool TopLevelObject =
false);
376 llvm::APSInt elementIndex,
377 bool SubobjectIsDesignatorContext,
unsigned &Index,
379 unsigned &StructuredIndex);
385 llvm::APSInt *NextElementIndex,
388 unsigned &StructuredIndex,
389 bool FinishSubobjectInit,
390 bool TopLevelObject);
394 unsigned StructuredIndex,
396 bool IsFullyOverwritten =
false);
397 void UpdateStructuredListElement(
InitListExpr *StructuredList,
398 unsigned &StructuredIndex,
402 unsigned ExpectedNumInits);
403 int numArrayElements(
QualType DeclType);
404 int numStructUnionElements(
QualType DeclType);
412 bool UnionOverride =
false,
413 bool FullyOverwritten =
true) {
418 ? (UnionOverride ? diag::ext_initializer_union_overrides
419 : diag::ext_initializer_overrides)
420 : diag::warn_initializer_overrides;
422 if (InOverloadResolution && SemaRef.
getLangOpts().CPlusPlus) {
443 DiagID = diag::err_initializer_overrides_destructed;
463 << NewInitRange << FullyOverwritten << OldInit->
getType();
492 bool FillWithNoInit);
493 void FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
496 bool FillWithNoInit =
false);
500 bool FillWithNoInit =
false);
503 bool TopLevelObject);
508 Expr *Result =
nullptr;
520 assert(AType &&
"expected array type when initializing array");
522 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
523 ElsCount = std::min(CAType->getSize().getZExtValue(),
524 ElsCount - CurEmbedIndex);
534 CurEmbedIndex, ElsCount);
535 CurEmbedIndex += ElsCount;
546 bool VerifyOnly,
bool TreatUnavailableAsInvalid,
547 bool InOverloadResolution =
false,
552 : InitListChecker(S, Entity, IL,
T,
true,
555 &AggrDeductionCandidateParamTypes) {}
557 bool HadError() {
return hadError; }
561 InitListExpr *getFullyStructuredList()
const {
return FullyStructuredList; }
578 bool EmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
591 InitExpr = VerifyOnly
609 if (!InitSeq && EmptyInitList && InitSeq.getFailureKind() ==
613 InitSeq.getFailedCandidateSet()
614 .BestViableFunction(SemaRef,
Kind.getLocation(), Best);
616 assert(O ==
OR_Success &&
"Inconsistent overload resolution");
623 bool IsInStd =
false;
625 ND && !IsInStd; ND = dyn_cast<NamespaceDecl>(ND->getParent())) {
630 if (IsInStd && llvm::StringSwitch<bool>(R->
getName())
631 .Cases(
"basic_string",
"deque",
"forward_list",
true)
632 .Cases(
"list",
"map",
"multimap",
"multiset",
true)
633 .Cases(
"priority_queue",
"queue",
"set",
"stack",
true)
634 .Cases(
"unordered_map",
"unordered_set",
"vector",
true)
636 InitSeq.InitializeFrom(
640 TreatUnavailableAsInvalid);
645 diag::warn_invalid_initializer_from_system_header);
648 diag::note_used_in_initialization_here);
650 SemaRef.
Diag(
Loc, diag::note_used_in_initialization_here);
657 InitSeq.Diagnose(SemaRef, Entity, Kind, SubInit);
660 diag::note_in_omitted_aggregate_initializer)
663 bool IsTrailingArrayNewMember =
666 SemaRef.
Diag(
Loc, diag::note_in_omitted_aggregate_initializer)
667 << (IsTrailingArrayNewMember ? 2 : 0)
676 : InitSeq.Perform(SemaRef, Entity,
Kind, SubInit);
684 if (FullyStructuredList)
686 PerformEmptyInit(
Loc, Entity);
689void InitListChecker::FillInEmptyInitForBase(
692 bool &RequiresSecondPass,
bool FillWithNoInit) {
699 : PerformEmptyInit(ILE->
getEndLoc(), BaseEntity);
706 assert(Init < ILE->getNumInits() &&
"should have been expanded");
711 FillInEmptyInitializations(BaseEntity, InnerILE, RequiresSecondPass,
712 ILE,
Init, FillWithNoInit);
714 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(
Init))) {
715 FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
716 RequiresSecondPass, ILE,
Init,
721void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
724 bool &RequiresSecondPass,
725 bool FillWithNoInit) {
733 if (!RType->getDecl()->isUnion())
734 assert((
Init < NumInits || VerifyOnly) &&
735 "This ILE should have been expanded");
737 if (FillWithNoInit) {
738 assert(!VerifyOnly &&
"should not fill with no-init in verify-only mode");
750 if (
Field->hasInClassInitializer()) {
764 RequiresSecondPass =
true;
769 if (
Field->getType()->isReferenceType()) {
775 SemaRef.
Diag(
Loc, diag::err_init_reference_member_uninitialized)
779 SemaRef.
Diag(
Field->getLocation(), diag::note_uninit_reference_member);
791 if (hadError || VerifyOnly) {
793 }
else if (
Init < NumInits) {
795 }
else if (!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
801 RequiresSecondPass =
true;
805 FillInEmptyInitializations(MemberEntity, InnerILE,
806 RequiresSecondPass, ILE,
Init, FillWithNoInit);
808 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(
Init))) {
809 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
810 RequiresSecondPass, ILE,
Init,
821 bool &RequiresSecondPass,
824 bool FillWithNoInit) {
826 "Should not have void type");
830 if (FillWithNoInit && VerifyOnly)
840 struct UpdateOuterILEWithUpdatedInit {
843 ~UpdateOuterILEWithUpdatedInit() {
847 } UpdateOuterRAII = {OuterILE, OuterIndex};
858 RequiresSecondPass, FillWithNoInit);
860 assert((!RDecl->
isUnion() || !isa<CXXRecordDecl>(RDecl) ||
861 !cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) &&
862 "We should have computed initialized fields already");
866 unsigned NumElems = numStructUnionElements(ILE->
getType());
874 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RDecl)) {
875 for (
auto &
Base : CXXRD->bases()) {
879 FillInEmptyInitForBase(
Init,
Base, Entity, ILE, RequiresSecondPass,
885 for (
auto *Field : RDecl->
fields()) {
886 if (
Field->isUnnamedBitField())
892 FillInEmptyInitForField(
Init, Field, Entity, ILE, RequiresSecondPass,
914 ElementType = AType->getElementType();
915 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
916 NumElements = CAType->getZExtSize();
924 ElementType = VType->getElementType();
925 NumElements = VType->getNumElements();
931 bool SkipEmptyInitChecks =
false;
944 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
949 if (SkipEmptyInitChecks)
952 Expr *Filler =
nullptr;
958 PerformEmptyInit(ILE->
getEndLoc(), ElementEntity);
969 }
else if (VerifyOnly) {
970 SkipEmptyInitChecks =
true;
971 }
else if (
Init < NumInits) {
986 if (!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
992 RequiresSecondPass =
true;
996 = dyn_cast_or_null<InitListExpr>(InitExpr)) {
997 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
998 ILE,
Init, FillWithNoInit);
1000 dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr)) {
1001 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
1002 RequiresSecondPass, ILE,
Init,
1010 if (isa_and_nonnull<DesignatedInitExpr>(
Init))
1015InitListChecker::InitListChecker(
1017 bool VerifyOnly,
bool TreatUnavailableAsInvalid,
bool InOverloadResolution,
1019 : SemaRef(S), VerifyOnly(VerifyOnly),
1020 TreatUnavailableAsInvalid(TreatUnavailableAsInvalid),
1021 InOverloadResolution(InOverloadResolution),
1022 AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes) {
1024 FullyStructuredList =
1033 CheckExplicitInitList(Entity, IL,
T, FullyStructuredList,
1036 if (!hadError && !AggrDeductionCandidateParamTypes && FullyStructuredList) {
1037 bool RequiresSecondPass =
false;
1038 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass,
1040 if (RequiresSecondPass && !hadError)
1041 FillInEmptyInitializations(Entity, FullyStructuredList,
1042 RequiresSecondPass,
nullptr, 0);
1044 if (hadError && FullyStructuredList)
1048int InitListChecker::numArrayElements(
QualType DeclType) {
1050 int maxElements = 0x7FFFFFFF;
1053 maxElements =
static_cast<int>(CAT->getZExtSize());
1058int InitListChecker::numStructUnionElements(
QualType DeclType) {
1060 int InitializableMembers = 0;
1061 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(structDecl))
1062 InitializableMembers += CXXRD->getNumBases();
1063 for (
const auto *Field : structDecl->
fields())
1064 if (!
Field->isUnnamedBitField())
1065 ++InitializableMembers;
1068 return std::min(InitializableMembers, 1);
1074 return RT->getDecl();
1076 return Inject->getDecl();
1106 if (
CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ParentRD)) {
1107 if (CXXRD->getNumBases()) {
1111 auto FieldIt = ParentRD->field_begin();
1112 assert(FieldIt != ParentRD->field_end() &&
1113 "no fields but have initializer for member?");
1114 return ++FieldIt == ParentRD->field_end();
1130 unsigned &StructuredIndex) {
1131 int maxElements = 0;
1134 maxElements = numArrayElements(
T);
1136 maxElements = numStructUnionElements(
T);
1140 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
1142 if (maxElements == 0) {
1145 diag::err_implicit_empty_initializer);
1152 InitListExpr *StructuredSubobjectInitList = getStructuredSubobjectInit(
1153 ParentIList, Index,
T, StructuredList, StructuredIndex,
1156 unsigned StructuredSubobjectInitIndex = 0;
1159 unsigned StartIndex = Index;
1160 CheckListElementTypes(Entity, ParentIList,
T,
1162 StructuredSubobjectInitList,
1163 StructuredSubobjectInitIndex);
1165 if (StructuredSubobjectInitList) {
1166 StructuredSubobjectInitList->
setType(
T);
1168 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
1171 if (EndIndex < ParentIList->getNumInits() &&
1172 ParentIList->
getInit(EndIndex)) {
1183 diag::warn_missing_braces)
1189 StructuredSubobjectInitList->
getEndLoc()),
1195 if (!VerifyOnly && CXXRD && CXXRD->hasUserDeclaredConstructor()) {
1197 diag::warn_cxx20_compat_aggregate_init_with_ctors)
1213 unsigned DiagID = 0;
1225 DiagID = diag::warn_braces_around_init;
1232 DiagID = diag::warn_braces_around_init;
1258 llvm_unreachable(
"unexpected braced scalar init");
1277 bool TopLevelObject) {
1278 unsigned Index = 0, StructuredIndex = 0;
1279 CheckListElementTypes(Entity, IList,
T,
true,
1280 Index, StructuredList, StructuredIndex, TopLevelObject);
1281 if (StructuredList) {
1287 StructuredList->
setType(ExprTy);
1295 bool ExtraInitsIsError = SemaRef.
getLangOpts().CPlusPlus ||
1297 hadError = ExtraInitsIsError;
1300 }
else if (StructuredIndex == 1 &&
1305 ? diag::err_excess_initializers_in_char_array_initializer
1306 : diag::ext_excess_initializers_in_char_array_initializer;
1310 unsigned DK = ExtraInitsIsError
1311 ? diag::err_excess_initializers_for_sizeless_type
1312 : diag::ext_excess_initializers_for_sizeless_type;
1322 unsigned DK = ExtraInitsIsError ? diag::err_excess_initializers
1323 : diag::ext_excess_initializers;
1331 !isa<InitListExpr>(IList->
getInit(0)))
1337 if (CXXRD && CXXRD->hasUserDeclaredConstructor()) {
1340 bool HasEquivCtor =
false;
1346 if (!HasEquivCtor) {
1348 diag::warn_cxx20_compat_aggregate_init_with_ctors)
1358 bool SubobjectIsDesignatorContext,
1361 unsigned &StructuredIndex,
1362 bool TopLevelObject) {
1366 CheckComplexType(Entity, IList, DeclType, Index,
1367 StructuredList, StructuredIndex);
1369 CheckScalarType(Entity, IList, DeclType, Index,
1370 StructuredList, StructuredIndex);
1372 CheckVectorType(Entity, IList, DeclType, Index,
1373 StructuredList, StructuredIndex);
1374 }
else if (
const RecordDecl *RD = getRecordDecl(DeclType)) {
1380 "non-aggregate records should be handed in CheckSubElementType");
1381 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
1382 Bases = CXXRD->bases();
1384 Bases = cast<CXXRecordDecl>(RD)->bases();
1386 CheckStructUnionTypes(Entity, IList, DeclType, Bases, RD->field_begin(),
1387 SubobjectIsDesignatorContext, Index, StructuredList,
1388 StructuredIndex, TopLevelObject);
1393 CheckArrayType(Entity, IList, DeclType, Zero,
1394 SubobjectIsDesignatorContext, Index,
1395 StructuredList, StructuredIndex);
1400 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1404 CheckReferenceType(Entity, IList, DeclType, Index,
1405 StructuredList, StructuredIndex);
1408 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_init_objc_class) << DeclType;
1413 CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1420 assert(AggrDeductionCandidateParamTypes);
1421 AggrDeductionCandidateParamTypes->push_back(DeclType);
1424 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1435 unsigned &StructuredIndex,
1436 bool DirectlyDesignated) {
1440 return CheckReferenceType(Entity, IList, ElemType, Index,
1441 StructuredList, StructuredIndex);
1444 if (SubInitList->getNumInits() == 1 &&
1449 expr = SubInitList->getInit(0);
1452 }
else if (isa<ImplicitValueInitExpr>(
expr)) {
1456 "found implicit initialization for the wrong type");
1457 UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1479 if (TmpEntity.getType()->isDependentType()) {
1484 assert(AggrDeductionCandidateParamTypes);
1498 if (isa<InitListExpr, DesignatedInitExpr>(
expr) ||
1499 !isa_and_present<ConstantArrayType>(
1502 AggrDeductionCandidateParamTypes->push_back(ElemType);
1514 if (
Seq || isa<InitListExpr>(
expr)) {
1515 if (
auto *Embed = dyn_cast<EmbedExpr>(
expr)) {
1516 expr = HandleEmbed(Embed, Entity);
1520 if (Result.isInvalid())
1523 UpdateStructuredListElement(StructuredList, StructuredIndex,
1524 Result.getAs<
Expr>());
1527 }
else if (StructuredList) {
1528 UpdateStructuredListElement(StructuredList, StructuredIndex,
1533 if (AggrDeductionCandidateParamTypes)
1534 AggrDeductionCandidateParamTypes->push_back(ElemType);
1542 return CheckScalarType(Entity, IList, ElemType, Index,
1543 StructuredList, StructuredIndex);
1557 UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1586 UpdateStructuredListElement(StructuredList, StructuredIndex,
1604 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1609 if (DirectlyDesignated && SemaRef.
getLangOpts().CPlusPlus && !hadError) {
1610 if (InOverloadResolution)
1614 diag::ext_designated_init_brace_elision)
1615 <<
expr->getSourceRange()
1630 assert(
Copy.isInvalid() &&
1631 "expected non-aggregate initialization to fail");
1643 unsigned &StructuredIndex) {
1644 assert(Index == 0 &&
"Index in explicit init list must be zero");
1654 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1659 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1668 for (
unsigned i = 0; i < 2; ++i) {
1670 CheckSubElementType(ElementEntity, IList, elementType, Index,
1671 StructuredList, StructuredIndex);
1679 unsigned &StructuredIndex) {
1686 ? diag::warn_cxx98_compat_empty_sizeless_initializer
1687 : diag::err_empty_sizeless_initializer)
1692 ? diag::warn_cxx98_compat_empty_scalar_initializer
1693 : diag::err_empty_scalar_initializer)
1709 SemaRef.
Diag(SubIList->getBeginLoc(), diag::ext_many_braces_around_init)
1712 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1715 }
else if (isa<DesignatedInitExpr>(
expr)) {
1718 diag::err_designator_for_scalar_or_sizeless_init)
1720 <<
expr->getSourceRange();
1725 }
else if (
auto *Embed = dyn_cast<EmbedExpr>(
expr)) {
1726 expr = HandleEmbed(Embed, Entity);
1732 Result = getDummyInit();
1741 Expr *ResultExpr =
nullptr;
1743 if (Result.isInvalid())
1746 ResultExpr = Result.getAs<
Expr>();
1748 if (ResultExpr !=
expr && !VerifyOnly && !CurEmbed) {
1751 IList->
setInit(Index, ResultExpr);
1755 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1758 if (AggrDeductionCandidateParamTypes)
1759 AggrDeductionCandidateParamTypes->push_back(DeclType);
1766 unsigned &StructuredIndex) {
1774 diag::err_init_reference_member_uninitialized)
1796 Result = getDummyInit();
1805 if (Result.isInvalid())
1810 if (!VerifyOnly &&
expr)
1813 UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1815 if (AggrDeductionCandidateParamTypes)
1816 AggrDeductionCandidateParamTypes->push_back(DeclType);
1823 unsigned &StructuredIndex) {
1826 unsigned numEltsInit = 0;
1831 CheckEmptyInitializable(
1841 if (!isa<InitListExpr>(
Init) &&
Init->getType()->isVectorType()) {
1845 Result = getDummyInit();
1854 Expr *ResultExpr =
nullptr;
1855 if (Result.isInvalid())
1858 ResultExpr = Result.getAs<
Expr>();
1860 if (ResultExpr !=
Init && !VerifyOnly) {
1863 IList->
setInit(Index, ResultExpr);
1866 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1868 if (AggrDeductionCandidateParamTypes)
1869 AggrDeductionCandidateParamTypes->push_back(elementType);
1876 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1879 CheckEmptyInitializable(ElementEntity, IList->
getEndLoc());
1884 CheckSubElementType(ElementEntity, IList, elementType, Index,
1885 StructuredList, StructuredIndex);
1893 if (isBigEndian && (
T->getVectorKind() == VectorKind::Neon ||
1894 T->getVectorKind() == VectorKind::NeonPoly)) {
1906 diag::warn_neon_vector_initializer_non_portable);
1908 const char *typeCode;
1918 llvm_unreachable(
"Invalid element type!");
1922 ? diag::note_neon_vector_initializer_non_portable_q
1923 : diag::note_neon_vector_initializer_non_portable)
1924 << typeCode << typeSize;
1934 for (
unsigned i = 0; i < maxElements; ++i) {
1943 CheckSubElementType(ElementEntity, IList, elementType, Index,
1944 StructuredList, StructuredIndex);
1956 CheckSubElementType(ElementEntity, IList, VecType, Index,
1957 StructuredList, StructuredIndex);
1958 numEltsInit += numIElts;
1963 if (numEltsInit != maxElements) {
1966 diag::err_vector_incorrect_num_initializers)
1967 << (numEltsInit < maxElements) << maxElements << numEltsInit;
1993 SemaRef.
PDiag(diag::err_access_dtor_temp)
2007 InitType =
Parent->getType();
2013 ExprList.size() == 1
2014 ? dyn_cast_if_present<EmbedExpr>(ExprList[0]->IgnoreParens())
2023 const bool TypesMatch =
2034 llvm::APSInt elementIndex,
2035 bool SubobjectIsDesignatorContext,
2038 unsigned &StructuredIndex) {
2056 if (Index < IList->getNumInits()) {
2069 if (StructuredList) {
2070 UpdateStructuredListElement(StructuredList, StructuredIndex,
2075 if (AggrDeductionCandidateParamTypes)
2076 AggrDeductionCandidateParamTypes->push_back(DeclType);
2097 SemaRef.
Diag(VAT->getSizeExpr()->getBeginLoc(),
2098 diag::err_variable_object_no_init)
2099 << VAT->getSizeExpr()->getSourceRange();
2108 llvm::APSInt maxElements(elementIndex.getBitWidth(),
2109 elementIndex.isUnsigned());
2110 bool maxElementsKnown =
false;
2112 maxElements = CAT->getSize();
2113 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
2114 elementIndex.setIsUnsigned(maxElements.isUnsigned());
2115 maxElementsKnown =
true;
2119 while (Index < IList->getNumInits()) {
2125 if (!SubobjectIsDesignatorContext)
2130 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
2131 DeclType,
nullptr, &elementIndex, Index,
2132 StructuredList, StructuredIndex,
true,
2138 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
2139 maxElements = maxElements.extend(elementIndex.getBitWidth());
2140 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
2141 elementIndex = elementIndex.extend(maxElements.getBitWidth());
2142 elementIndex.setIsUnsigned(maxElements.isUnsigned());
2146 if (!maxElementsKnown && elementIndex > maxElements)
2147 maxElements = elementIndex;
2154 if (maxElementsKnown && elementIndex == maxElements)
2158 SemaRef.
Context, StructuredIndex, Entity);
2160 unsigned EmbedElementIndexBeforeInit = CurEmbedIndex;
2162 CheckSubElementType(ElementEntity, IList, elementType, Index,
2163 StructuredList, StructuredIndex);
2168 elementIndex + CurEmbedIndex - EmbedElementIndexBeforeInit - 1;
2170 auto Embed = cast<EmbedExpr>(
Init);
2172 EmbedElementIndexBeforeInit - 1;
2178 if (!maxElementsKnown && elementIndex > maxElements)
2179 maxElements = elementIndex;
2184 llvm::APSInt
Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
2188 SemaRef.
Diag(IList->
getBeginLoc(), diag::ext_typecheck_zero_array_size);
2192 elementType, maxElements,
nullptr, ArraySizeModifier::Normal, 0);
2199 if ((maxElementsKnown && elementIndex < maxElements) ||
2201 CheckEmptyInitializable(
2210 bool TopLevelObject) {
2212 unsigned FlexArrayDiag;
2213 if (isa<InitListExpr>(InitExpr) &&
2214 cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
2216 FlexArrayDiag = diag::ext_flexible_array_init;
2217 }
else if (!TopLevelObject) {
2219 FlexArrayDiag = diag::err_flexible_array_init;
2222 FlexArrayDiag = diag::err_flexible_array_init;
2223 }
else if (cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
2225 FlexArrayDiag = diag::err_flexible_array_init;
2228 FlexArrayDiag = diag::ext_flexible_array_init;
2234 SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
2238 return FlexArrayDiag != diag::ext_flexible_array_init;
2241void InitListChecker::CheckStructUnionTypes(
2244 bool SubobjectIsDesignatorContext,
unsigned &Index,
2245 InitListExpr *StructuredList,
unsigned &StructuredIndex,
2246 bool TopLevelObject) {
2247 const RecordDecl *RD = getRecordDecl(DeclType);
2269 if (isa<CXXRecordDecl>(RD) &&
2270 cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
2271 if (!StructuredList)
2274 Field != FieldEnd; ++Field) {
2275 if (
Field->hasInClassInitializer() ||
2276 (
Field->isAnonymousStructOrUnion() &&
2277 Field->getType()->getAsCXXRecordDecl()->hasInClassInitializer())) {
2283 llvm_unreachable(
"Couldn't find in-class initializer");
2289 Field != FieldEnd; ++Field) {
2290 if (!
Field->isUnnamedBitField()) {
2291 CheckEmptyInitializable(
2302 bool InitializedSomething =
false;
2305 for (
auto I = Bases.begin(),
E = Bases.end(); I !=
E; ++I) {
2311 if (isa_and_nonnull<DesignatedInitExpr>(
Init))
2328 if (AggrDeductionCandidateParamTypes &&
Base.isPackExpansion()) {
2329 AggrDeductionCandidateParamTypes->push_back(
2334 if (Index < IList->getNumInits())
2346 CheckSubElementType(BaseEntity, IList,
Base.getType(), Index,
2347 StructuredList, StructuredIndex);
2348 InitializedSomething =
true;
2350 CheckEmptyInitializable(BaseEntity, InitLoc);
2365 size_t NumRecordDecls = llvm::count_if(RD->
decls(), [&](
const Decl *
D) {
2366 return isa<FieldDecl>(D) || isa<RecordDecl>(D);
2368 bool HasDesignatedInit =
false;
2372 while (Index < IList->getNumInits()) {
2380 if (!SubobjectIsDesignatorContext)
2383 HasDesignatedInit =
true;
2387 bool DesignatedInitFailed = CheckDesignatedInitializer(
2388 Entity, IList, DIE, 0, DeclType, &Field,
nullptr, Index,
2389 StructuredList, StructuredIndex,
true, TopLevelObject);
2390 if (DesignatedInitFailed)
2395 if (!VerifyOnly &&
D->isFieldDesignator()) {
2397 InitializedFields.insert(F);
2398 if (!DesignatedInitFailed) {
2407 InitializedSomething =
true;
2424 if (NumRecordDecls == 1)
2426 if (
const auto *IL = dyn_cast<IntegerLiteral>(I))
2427 return IL->getValue().isZero();
2435 SemaRef.
Diag(InitLoc, diag::err_non_designated_init_used);
2440 if (Field == FieldEnd) {
2446 if (InitializedSomething && RD->
isUnion())
2450 if (
Field->getType()->isIncompleteArrayType())
2453 if (
Field->isUnnamedBitField()) {
2462 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2483 CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
2484 StructuredList, StructuredIndex);
2485 InitializedSomething =
true;
2486 InitializedFields.insert(*Field);
2488 if (RD->
isUnion() && StructuredList) {
2499 bool IsCDesignatedInitializer =
2500 HasDesignatedInit && !SemaRef.
getLangOpts().CPlusPlus;
2501 if (!VerifyOnly && InitializedSomething && !RD->
isUnion() &&
2503 !IsCDesignatedInitializer) {
2510 if (HasDesignatedInit && InitializedFields.count(*it))
2513 if (!it->isUnnamedBitField() && !it->hasInClassInitializer() &&
2514 !it->getType()->isIncompleteArrayType()) {
2515 auto Diag = HasDesignatedInit
2516 ? diag::warn_missing_designated_field_initializers
2517 : diag::warn_missing_field_initializers;
2526 if (!StructuredList && Field != FieldEnd && !RD->
isUnion() &&
2527 !
Field->getType()->isIncompleteArrayType()) {
2528 for (;
Field != FieldEnd && !hadError; ++
Field) {
2529 if (!
Field->isUnnamedBitField() && !
Field->hasInClassInitializer())
2530 CheckEmptyInitializable(
2551 if (Field == FieldEnd || !
Field->getType()->isIncompleteArrayType() ||
2555 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
2565 if (isa<InitListExpr>(IList->
getInit(Index)) ||
2566 AggrDeductionCandidateParamTypes)
2567 CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
2568 StructuredList, StructuredIndex);
2570 CheckImplicitInitList(MemberEntity, IList,
Field->getType(), Index,
2571 StructuredList, StructuredIndex);
2573 if (RD->
isUnion() && StructuredList) {
2592 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
2600 assert(isa<FieldDecl>(*PI));
2601 Replacements.back().setFieldDecl(cast<FieldDecl>(*PI));
2608 &Replacements[0] + Replacements.size());
2615 for (
unsigned I = 0; I < NumIndexExprs; ++I)
2629 explicit FieldInitializerValidatorCCC(
const RecordDecl *RD)
2637 std::unique_ptr<CorrectionCandidateCallback>
clone()
override {
2638 return std::make_unique<FieldInitializerValidatorCCC>(*
this);
2691 llvm::APSInt *NextElementIndex,
2694 unsigned &StructuredIndex,
2695 bool FinishSubobjectInit,
2696 bool TopLevelObject) {
2697 if (DesigIdx == DIE->
size()) {
2704 assert(isa<InitListExpr>(
Init) &&
2705 "designator result in direct non-list initialization?");
2710 if (StructuredList) {
2714 UpdateStructuredListElement(StructuredList, StructuredIndex,
2718 if (AggrDeductionCandidateParamTypes)
2719 AggrDeductionCandidateParamTypes->push_back(CurrentObjectType);
2724 bool prevHadError = hadError;
2729 unsigned OldIndex = Index;
2732 CheckSubElementType(Entity, IList, CurrentObjectType, Index, StructuredList,
2733 StructuredIndex,
true);
2739 IList->
setInit(OldIndex, DIE);
2741 return hadError && !prevHadError;
2745 bool IsFirstDesignator = (DesigIdx == 0);
2746 if (IsFirstDesignator ? FullyStructuredList : StructuredList) {
2749 if (IsFirstDesignator)
2750 StructuredList = FullyStructuredList;
2752 Expr *ExistingInit = StructuredIndex < StructuredList->getNumInits() ?
2753 StructuredList->getInit(StructuredIndex) :
nullptr;
2754 if (!ExistingInit && StructuredList->hasArrayFiller())
2755 ExistingInit = StructuredList->getArrayFiller();
2758 StructuredList = getStructuredSubobjectInit(
2759 IList, Index, CurrentObjectType, StructuredList, StructuredIndex,
2761 else if (
InitListExpr *Result = dyn_cast<InitListExpr>(ExistingInit))
2762 StructuredList = Result;
2775 diagnoseInitOverride(ExistingInit,
2782 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2783 StructuredList =
E->getUpdater();
2788 StructuredList->updateInit(SemaRef.
Context, StructuredIndex, DIUE);
2797 StructuredList =
nullptr;
2803 if (
D->isFieldDesignator()) {
2813 RecordDecl *RD = getRecordDecl(CurrentObjectType);
2817 Loc =
D->getFieldLoc();
2819 SemaRef.
Diag(
Loc, diag::err_field_designator_non_aggr)
2820 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2829 if (
auto *FD = dyn_cast_if_present<FieldDecl>(VD)) {
2831 }
else if (
auto *IFD = dyn_cast_if_present<IndirectFieldDecl>(VD)) {
2837 KnownField = cast<FieldDecl>(*IFD->chain_begin());
2854 SemaRef.
Diag(
D->getFieldLoc(), diag::err_field_designator_nonfield)
2856 SemaRef.
Diag(Lookup.front()->getLocation(),
2857 diag::note_field_designator_found);
2864 FieldInitializerValidatorCCC CCC(RD);
2871 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2872 << FieldName << CurrentObjectType);
2873 KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2884 SemaRef.
Diag(
Loc, diag::err_field_designator_unknown)
2892 unsigned NumBases = 0;
2893 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
2894 NumBases = CXXRD->getNumBases();
2896 unsigned FieldIndex = NumBases;
2898 for (
auto *FI : RD->
fields()) {
2899 if (FI->isUnnamedBitField())
2915 if (StructuredList) {
2916 FieldDecl *CurrentField = StructuredList->getInitializedFieldInUnion();
2918 assert(StructuredList->getNumInits() == 1
2919 &&
"A union should never have more than one initializer!");
2921 Expr *ExistingInit = StructuredList->getInit(0);
2924 diagnoseInitOverride(
2932 StructuredList->resizeInits(SemaRef.
Context, 0);
2933 StructuredList->setInitializedFieldInUnion(
nullptr);
2936 StructuredList->setInitializedFieldInUnion(*Field);
2943 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2966 if (IsFirstDesignator && !VerifyOnly && SemaRef.
getLangOpts().CPlusPlus &&
2969 (*NextField)->getFieldIndex() >
Field->getFieldIndex() + 1)) {
2973 if (FI->isUnnamedBitField())
2984 diag::ext_designated_init_reordered)
2987 unsigned OldIndex = StructuredIndex - 1;
2988 if (StructuredList && OldIndex <= StructuredList->getNumInits()) {
2989 if (
Expr *PrevInit = StructuredList->getInit(OldIndex)) {
2990 SemaRef.
Diag(PrevInit->getBeginLoc(),
2991 diag::note_previous_field_init)
3001 D->setFieldDecl(*Field);
3005 if (StructuredList && FieldIndex >= StructuredList->getNumInits())
3006 StructuredList->resizeInits(SemaRef.
Context, FieldIndex + 1);
3009 if (
Field->getType()->isIncompleteArrayType()) {
3011 if ((DesigIdx + 1) != DIE->
size()) {
3018 diag::err_designator_into_flexible_array_member)
3020 SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
3026 if (!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
3027 !isa<StringLiteral>(DIE->
getInit())) {
3031 diag::err_flexible_array_init_needs_braces)
3033 SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
3040 if (!
Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
3050 bool prevHadError = hadError;
3051 unsigned newStructuredIndex = FieldIndex;
3052 unsigned OldIndex = Index;
3057 CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
3058 StructuredList, newStructuredIndex);
3060 IList->
setInit(OldIndex, DIE);
3061 if (hadError && !prevHadError) {
3066 StructuredIndex = FieldIndex;
3072 unsigned newStructuredIndex = FieldIndex;
3076 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
3077 FieldType,
nullptr,
nullptr, Index,
3078 StructuredList, newStructuredIndex,
3079 FinishSubobjectInit,
false))
3090 if (IsFirstDesignator) {
3097 StructuredIndex = FieldIndex;
3101 if (!FinishSubobjectInit)
3109 bool prevHadError = hadError;
3114 CheckStructUnionTypes(Entity, IList, CurrentObjectType, NoBases, Field,
3115 false, Index, StructuredList, FieldIndex);
3116 return hadError && !prevHadError;
3137 SemaRef.
Diag(
D->getLBracketLoc(), diag::err_array_designator_non_array)
3138 << CurrentObjectType;
3143 Expr *IndexExpr =
nullptr;
3144 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
3145 if (
D->isArrayDesignator()) {
3148 DesignatedEndIndex = DesignatedStartIndex;
3150 assert(
D->isArrayRangeDesignator() &&
"Need array-range designator");
3152 DesignatedStartIndex =
3154 DesignatedEndIndex =
3163 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
3168 if (isa<ConstantArrayType>(AT)) {
3169 llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
3170 DesignatedStartIndex
3171 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
3172 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
3174 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
3175 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
3176 if (DesignatedEndIndex >= MaxElements) {
3179 diag::err_array_designator_too_large)
3186 unsigned DesignatedIndexBitWidth =
3188 DesignatedStartIndex =
3189 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
3190 DesignatedEndIndex =
3191 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
3192 DesignatedStartIndex.setIsUnsigned(
true);
3193 DesignatedEndIndex.setIsUnsigned(
true);
3196 bool IsStringLiteralInitUpdate =
3197 StructuredList && StructuredList->isStringLiteralInit();
3198 if (IsStringLiteralInitUpdate && VerifyOnly) {
3201 StructuredList =
nullptr;
3202 }
else if (IsStringLiteralInitUpdate) {
3215 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
3220 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
3221 StrLen = cast<ConstantArrayType>(AT)->getZExtSize();
3222 StructuredList->resizeInits(Context, StrLen);
3226 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
3227 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
3229 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
3230 if (CharTy != PromotedCharTy)
3234 StructuredList->updateInit(Context, i,
Init);
3243 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
3244 StrLen = cast<ConstantArrayType>(AT)->getZExtSize();
3245 StructuredList->resizeInits(Context, StrLen);
3249 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
3250 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
3252 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
3253 if (CharTy != PromotedCharTy)
3257 StructuredList->updateInit(Context, i,
Init);
3264 if (StructuredList &&
3265 DesignatedEndIndex.getZExtValue() >= StructuredList->getNumInits())
3266 StructuredList->resizeInits(SemaRef.
Context,
3267 DesignatedEndIndex.getZExtValue() + 1);
3273 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
3274 unsigned OldIndex = Index;
3279 while (DesignatedStartIndex <= DesignatedEndIndex) {
3285 if (CheckDesignatedInitializer(
3286 ElementEntity, IList, DIE, DesigIdx + 1, ElementType,
nullptr,
3287 nullptr, Index, StructuredList, ElementIndex,
3288 FinishSubobjectInit && (DesignatedStartIndex == DesignatedEndIndex),
3293 ++DesignatedStartIndex;
3294 ElementIndex = DesignatedStartIndex.getZExtValue();
3299 if (IsFirstDesignator) {
3300 if (NextElementIndex)
3301 *NextElementIndex = DesignatedStartIndex;
3302 StructuredIndex = ElementIndex;
3306 if (!FinishSubobjectInit)
3310 bool prevHadError = hadError;
3311 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
3313 StructuredList, ElementIndex);
3314 return hadError && !prevHadError;
3320InitListChecker::getStructuredSubobjectInit(
InitListExpr *IList,
unsigned Index,
3323 unsigned StructuredIndex,
3325 bool IsFullyOverwritten) {
3326 if (!StructuredList)
3329 Expr *ExistingInit =
nullptr;
3330 if (StructuredIndex < StructuredList->getNumInits())
3331 ExistingInit = StructuredList->
getInit(StructuredIndex);
3333 if (
InitListExpr *Result = dyn_cast_or_null<InitListExpr>(ExistingInit))
3342 if (!IsFullyOverwritten)
3365 diagnoseInitOverride(ExistingInit, InitRange);
3368 unsigned ExpectedNumInits = 0;
3369 if (Index < IList->getNumInits()) {
3370 if (
auto *
Init = dyn_cast_or_null<InitListExpr>(IList->
getInit(Index)))
3371 ExpectedNumInits =
Init->getNumInits();
3377 createInitListExpr(CurrentObjectType, InitRange, ExpectedNumInits);
3386InitListChecker::createInitListExpr(
QualType CurrentObjectType,
3388 unsigned ExpectedNumInits) {
3392 QualType ResultType = CurrentObjectType;
3395 Result->setType(ResultType);
3398 unsigned NumElements = 0;
3403 NumElements = CAType->getZExtSize();
3406 if (NumElements > ExpectedNumInits)
3410 NumElements = VType->getNumElements();
3412 NumElements = numStructUnionElements(CurrentObjectType);
3417 Result->reserveInits(SemaRef.
Context, NumElements);
3424void InitListChecker::UpdateStructuredListElement(
InitListExpr *StructuredList,
3425 unsigned &StructuredIndex,
3428 if (!StructuredList)
3432 StructuredIndex,
expr)) {
3438 diagnoseInitOverride(PrevInit,
expr->getSourceRange());
3447 InitListChecker Check(*
this, Entity, From,
Type,
true,
3450 return !Check.HadError();
3471 return S.
Diag(
Loc, diag::err_array_designator_negative)
3474 Value.setIsUnsigned(
true);
3492 if (
D.isFieldDesignator()) {
3493 Designators.push_back(ASTDesignator::CreateFieldDesignator(
3494 D.getFieldDecl(),
D.getDotLoc(),
D.getFieldLoc()));
3495 }
else if (
D.isArrayDesignator()) {
3496 Expr *Index =
static_cast<Expr *
>(
D.getArrayIndex());
3497 llvm::APSInt IndexValue;
3498 if (!Index->isTypeDependent() && !Index->isValueDependent())
3503 Designators.push_back(ASTDesignator::CreateArrayDesignator(
3504 InitExpressions.size(),
D.getLBracketLoc(),
D.getRBracketLoc()));
3505 InitExpressions.push_back(Index);
3507 }
else if (
D.isArrayRangeDesignator()) {
3508 Expr *StartIndex =
static_cast<Expr *
>(
D.getArrayRangeStart());
3509 Expr *EndIndex =
static_cast<Expr *
>(
D.getArrayRangeEnd());
3510 llvm::APSInt StartValue;
3511 llvm::APSInt EndValue;
3516 if (!StartDependent)
3522 if (!StartIndex || !EndIndex)
3526 if (StartDependent || EndDependent) {
3528 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
3529 EndValue = EndValue.extend(StartValue.getBitWidth());
3530 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
3531 StartValue = StartValue.extend(EndValue.getBitWidth());
3533 if (!StartDependent && !EndDependent && EndValue < StartValue) {
3534 Diag(
D.getEllipsisLoc(), diag::err_array_designator_empty_range)
3539 Designators.push_back(ASTDesignator::CreateArrayRangeDesignator(
3540 InitExpressions.size(),
D.getLBracketLoc(),
D.getEllipsisLoc(),
3541 D.getRBracketLoc()));
3542 InitExpressions.push_back(StartIndex);
3543 InitExpressions.push_back(EndIndex);
3553 EqualOrColonLoc, GNUSyntax,
3561InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
3566 Kind = EK_ArrayElement;
3569 Kind = EK_VectorElement;
3573 assert(CT &&
"Unexpected type");
3574 Kind = EK_ComplexElement;
3582 bool IsInheritedVirtualBase,
3587 Result.Base = {
Base, IsInheritedVirtualBase};
3605 return Variable.VariableOrMember->getDeclName();
3627 llvm_unreachable(
"Invalid EntityKind!");
3661 llvm_unreachable(
"Invalid EntityKind!");
3696unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
3699 for (
unsigned I = 0; I != Depth; ++I)
3716 case EK_New: OS <<
"New";
break;
3720 case EK_Base: OS <<
"Base";
break;
3727 OS <<
"Block (lambda)";
3730 OS <<
"LambdaCapture ";
3737 D->printQualifiedName(OS);
3740 OS <<
" '" <<
getType() <<
"'\n";
3746 dumpImpl(llvm::errs());
3801 for (
const Step &S : llvm::reverse(Steps)) {
3861 llvm_unreachable(
"Invalid EntityKind!");
3869InitializationSequence
3872 bool HadMultipleCandidates) {
3876 S.Function.HadMultipleCandidates = HadMultipleCandidates;
3878 S.Function.FoundDecl =
Found;
3897 bool BindingTemporary) {
3922 bool HadMultipleCandidates) {
3926 S.Function.HadMultipleCandidates = HadMultipleCandidates;
3928 S.Function.FoundDecl = FoundDecl;
3967 bool TopLevelOfInitList) {
3985 bool HadMultipleCandidates,
bool FromInitList,
bool AsInitList) {
3991 S.Function.HadMultipleCandidates = HadMultipleCandidates;
3992 S.Function.Function = Constructor;
3993 S.Function.FoundDecl = FoundDecl;
4036 Steps.insert(Steps.begin(), S);
4097 "Can only rewrap trivial init lists.");
4101 Steps.insert(Steps.begin(), S);
4105 S.WrappingSyntacticList = Syntactic;
4112 this->Failure = Failure;
4113 this->FailedOverloadResult =
Result;
4134 if (!
Init.empty()) {
4154 "consuming an object of unretainable type?");
4175 bool TreatUnavailableAsInvalid);
4186 bool TreatUnavailableAsInvalid) {
4200 List->getNumInits()),
4205 List->getExprLoc(), List->getBeginLoc(), List->getEndLoc());
4207 TreatUnavailableAsInvalid);
4234 bool CopyInitializing,
bool AllowExplicit,
bool OnlyListConstructors,
4235 bool IsListInit,
bool RequireActualConstructor,
4236 bool SecondStepOfCopyInit =
false) {
4242 if (!Info.Constructor || Info.Constructor->isInvalidDecl())
4259 bool SuppressUserConversions =
4260 SecondStepOfCopyInit ||
4261 (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
4264 if (Info.ConstructorTmpl)
4266 Info.ConstructorTmpl, Info.FoundDecl,
4267 nullptr, Args, CandidateSet, SuppressUserConversions,
4268 false, AllowExplicit);
4277 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
4281 CandidateSet, SuppressUserConversions,
4282 false, AllowExplicit,
4298 if (S.
getLangOpts().CPlusPlus17 && Args.size() == 1 &&
4299 !RequireActualConstructor && !SecondStepOfCopyInit) {
4301 auto *SourceRD =
Initializer->getType()->getAsCXXRecordDecl();
4303 const auto &Conversions = SourceRD->getVisibleConversionFunctions();
4304 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
4307 D =
D->getUnderlyingDecl();
4314 Conv = cast<CXXConversionDecl>(
D);
4318 ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
4319 CandidateSet, AllowExplicit, AllowExplicit,
4323 DestType, CandidateSet, AllowExplicit,
4350 bool IsListInit =
false,
4351 bool IsInitListCopy =
false) {
4352 assert(((!IsListInit && !IsInitListCopy) ||
4353 (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
4354 "IsListInit/IsInitListCopy must come with a single initializer list "
4357 (IsListInit || IsInitListCopy) ? cast<InitListExpr>(Args[0]) :
nullptr;
4367 bool RequireActualConstructor =
4373 bool CopyElisionPossible =
false;
4374 auto ElideConstructor = [&] {
4390 if (S.
getLangOpts().CPlusPlus17 && !RequireActualConstructor &&
4391 UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isPRValue() &&
4413 assert(!IsInitListCopy &&
4414 "IsInitListCopy only possible with aggregate types");
4415 CopyElisionPossible =
true;
4423 assert(DestRecordType &&
"Constructor initialization requires record type");
4425 = cast<CXXRecordDecl>(DestRecordType->
getDecl());
4433 bool AllowExplicit = Kind.AllowExplicit() || IsListInit;
4443 bool AsInitializerList =
false;
4455 AsInitializerList =
true;
4461 S, Kind.getLocation(), Args, CandidateSet, DestType, Ctors, Best,
4462 CopyInitialization, AllowExplicit,
4463 true, IsListInit, RequireActualConstructor);
4478 AsInitializerList =
false;
4480 S, Kind.getLocation(), UnwrappedArgs, CandidateSet, DestType, Ctors,
4481 Best, CopyInitialization, AllowExplicit,
4482 false, IsListInit, RequireActualConstructor);
4494 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4498 if (
auto *CD = dyn_cast<CXXConversionDecl>(Best->Function)) {
4500 QualType ConvType = CD->getConversionType();
4502 "should not have selected this conversion function");
4504 HadMultipleCandidates);
4535 if (IsListInit && !Kind.AllowExplicit() && CtorDecl->
isExplicit()) {
4555 Best->FoundDecl, CtorDecl, DestArrayType, HadMultipleCandidates,
4556 IsListInit | IsInitListCopy, AsInitializerList);
4569 bool HadMultipleCandidates =
false;
4572 UnqualifiedTargetType,
4574 &HadMultipleCandidates)) {
4576 HadMultipleCandidates);
4577 SourceType = Fn->getType();
4596 bool TopLevelOfInitList);
4610 bool TreatUnavailableAsInvalid) {
4650 T1Quals, cv2T2, T2, T2Quals, Sequence,
4681 TreatUnavailableAsInvalid);
4713 bool TreatUnavailableAsInvalid) {
4725 TreatUnavailableAsInvalid);
4763 !IsDesignatedInit) {
4768 Expr *InitListAsExpr = InitList;
4778 if (!isa<VariableArrayType>(DestAT) &&
4788 TreatUnavailableAsInvalid);
4821 TreatUnavailableAsInvalid))
4825 Expr *InitListAsExpr = InitList;
4827 DestType, Sequence,
true);
4845 ET && ET->getDecl()->isFixed() &&
4894 if (
Init->getType()->isRecordType() ||
4905 TreatUnavailableAsInvalid);
4912 InitListChecker CheckInitList(S, Entity, InitList,
4913 DestType,
true, TreatUnavailableAsInvalid);
4914 if (CheckInitList.HadError()) {
4936 "Must have incompatible references when binding via conversion");
4947 bool AllowExplicitCtors =
false;
4948 bool AllowExplicitConvs = Kind.allowExplicitConversionFunctionsInRefBinding();
4959 if (!Info.Constructor)
4962 if (!Info.Constructor->isInvalidDecl() &&
4963 Info.Constructor->isConvertingConstructor(
true)) {
4964 if (Info.ConstructorTmpl)
4966 Info.ConstructorTmpl, Info.FoundDecl,
4969 false, AllowExplicitCtors);
4972 Info.Constructor, Info.FoundDecl,
Initializer, CandidateSet,
4974 false, AllowExplicitCtors);
4989 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
4992 if (isa<UsingShadowDecl>(
D))
4993 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
5000 Conv = cast<CXXConversionDecl>(
D);
5008 if ((AllowRValues ||
5012 ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
5014 false, AllowExplicitConvs);
5017 Conv, I.getPair(), ActingDC,
Initializer, DestType, CandidateSet,
5018 false, AllowExplicitConvs);
5040 if (isa<CXXConversionDecl>(
Function))
5053 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5055 HadMultipleCandidates);
5065 assert(!isa<CXXConstructorDecl>(
Function) &&
5066 "should not have conversion after constructor");
5070 ICS.
Standard = Best->FinalConversion;
5091 if (RefConv & Sema::ReferenceConversions::DerivedToBase)
5093 else if (RefConv & Sema::ReferenceConversions::ObjC)
5095 else if (RefConv & Sema::ReferenceConversions::Function)
5097 else if (RefConv & Sema::ReferenceConversions::Qualification) {
5114 bool TopLevelOfInitList) {
5132 T1Quals, cv2T2, T2, T2Quals, Sequence,
5133 TopLevelOfInitList);
5157 bool TopLevelOfInitList) {
5181 if (isLValueRef || T1Function) {
5184 (Kind.isCStyleOrFunctionalCast() &&
5188 if (RefConv & (Sema::ReferenceConversions::DerivedToBase |
5189 Sema::ReferenceConversions::ObjC)) {
5192 if (RefConv & (Sema::ReferenceConversions::Qualification))
5196 if (RefConv & Sema::ReferenceConversions::DerivedToBase)
5200 }
else if (RefConv & Sema::ReferenceConversions::Qualification) {
5204 }
else if (RefConv & Sema::ReferenceConversions::Function) {
5224 (isLValueRef || InitCategory.
isRValue())) {
5229 isLValueRef, Sequence);
5263 switch (RefRelationship) {
5275 llvm_unreachable(
"unexpected kind of compatible initializer");
5299 (Kind.isCStyleOrFunctionalCast() &&
5328 auto T1QualsIgnoreAS = T1Quals;
5329 auto T2QualsIgnoreAS = T2Quals;
5332 T2QualsIgnoreAS.removeAddressSpace();
5335 if (T1QualsIgnoreAS != T2QualsIgnoreAS)
5345 cv1T4 = cv1T4WithAS;
5350 if (RefConv & Sema::ReferenceConversions::DerivedToBase)
5352 else if (RefConv & Sema::ReferenceConversions::ObjC)
5354 else if (RefConv & Sema::ReferenceConversions::Qualification) {
5371 isLValueRef, Sequence);
5411 Sema::AllowedExplicit::None,
5413 Kind.isCStyleOrFunctionalCast(),
5432 TopLevelOfInitList);
5441 ((T1CVRQuals | T2CVRQuals) != T1CVRQuals ||
5486 assert((!InitList || InitList->
getNumInits() == 0) &&
5487 "Shouldn't use value-init for non-empty init lists");
5498 if (
CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
5499 bool NeedZeroInitialization =
true;
5514 NeedZeroInitialization =
false;
5522 if (NeedZeroInitialization)
5536 ClassDecl->hasUninitializedReferenceMember()) {
5544 Expr *InitListAsExpr = InitList;
5546 bool InitListSyntax = InitList;
5551 S, Entity, Kind, Args,
T, Entity.
getType(), Sequence, InitListSyntax);
5601 unsigned EntityIndexToProcess = 0;
5604 Expr *ArrayFiller =
nullptr;
5605 FieldDecl *InitializedFieldInUnion =
nullptr;
5609 Expr *Arg,
Expr **InitExpr =
nullptr) {
5611 S, SubEntity, SubKind, Arg ?
MultiExprArg(Arg) : std::nullopt);
5625 ER = IS.
Perform(S, SubEntity, SubKind,
5632 *InitExpr = ER.
get();
5634 InitExprs.push_back(ER.
get());
5642 uint64_t ArrayLength;
5650 ArrayLength = CAT->getZExtSize();
5651 ResultType = Entity.
getType();
5658 const Expr *SE = VAT->getSizeExpr();
5664 ArrayLength = Args.size();
5666 EntityIndexToProcess = ArrayLength;
5670 for (
Expr *
E : Args) {
5675 if (!HandleInitializedEntity(SubEntity, SubKind,
E))
5683 Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
true);
5684 if (!HandleInitializedEntity(SubEntity, SubKind,
nullptr, &ArrayFiller))
5688 if (ResultType.
isNull()) {
5695 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
5709 if (EntityIndexToProcess < Args.size()) {
5715 Expr *
E = Args[EntityIndexToProcess];
5718 if (!HandleInitializedEntity(SubEntity, SubKind,
E))
5726 Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
5728 if (!HandleInitializedEntity(SubEntity, SubKind,
nullptr))
5731 EntityIndexToProcess++;
5744 if (EntityIndexToProcess < Args.size()) {
5746 Expr *
E = Args[EntityIndexToProcess];
5764 if (!HandleInitializedEntity(SubEntity, SubKind,
E))
5772 InitializedFieldInUnion = FD;
5773 EntityIndexToProcess = 1;
5785 Kind.getParenOrBraceRange().getEnd(), FD);
5789 InitExprs.push_back(DIE.
get());
5799 S.
Diag(SR.
getEnd(), diag::err_init_reference_member_uninitialized)
5806 Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
true);
5807 if (!HandleInitializedEntity(SubEntity, SubKind,
nullptr))
5811 EntityIndexToProcess++;
5813 ResultType = Entity.
getType();
5818 if (EntityIndexToProcess < Args.size()) {
5823 SourceRange ExcessInitSR(Args[EntityIndexToProcess]->getBeginLoc(),
5824 Args.back()->getEndLoc());
5825 S.
Diag(Kind.getLocation(), diag::err_excess_initializers)
5826 << InitKind << ExcessInitSR;
5840 CPLIE->setArrayFiller(ArrayFiller);
5841 if (InitializedFieldInUnion)
5842 CPLIE->setInitializedFieldInUnion(InitializedFieldInUnion);
5844 S.
Diag(Kind.getLocation(),
5845 diag::warn_cxx17_compat_aggregate_init_paren_list)
5846 << Kind.getLocation() << SR << ResultType;
5858 bool TopLevelOfInitList) {
5859 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
5862 "Must have a class type to perform a user-defined conversion");
5872 bool AllowExplicit = Kind.AllowExplicit();
5878 = cast<CXXRecordDecl>(DestRecordType->getDecl());
5884 if (!Info.Constructor)
5887 if (!Info.Constructor->isInvalidDecl() &&
5888 Info.Constructor->isConvertingConstructor(
true)) {
5889 if (Info.ConstructorTmpl)
5891 Info.ConstructorTmpl, Info.FoundDecl,
5894 false, AllowExplicit);
5899 false, AllowExplicit);
5915 = cast<CXXRecordDecl>(SourceRecordType->getDecl());
5917 const auto &Conversions =
5919 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
5922 if (isa<UsingShadowDecl>(
D))
5923 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
5930 Conv = cast<CXXConversionDecl>(
D);
5934 ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
5935 CandidateSet, AllowExplicit, AllowExplicit);
5938 DestType, CandidateSet, AllowExplicit,
5964 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5966 if (isa<CXXConstructorDecl>(
Function)) {
5972 HadMultipleCandidates);
6001 HadMultipleCandidates);
6014 Function->getReturnType()->isReferenceType() ||
6024 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
6025 Best->FinalConversion.Third) {
6028 ICS.
Standard = Best->FinalConversion;
6046 isa<CXXBoolLiteralExpr>(
Init) &&
6047 !cast<CXXBoolLiteralExpr>(
Init)->getValue() &&
6056 bool isAddressOf,
bool &isWeakAccess) {
6062 if (op->getOpcode() == UO_AddrOf)
6067 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
6068 switch (ce->getCastKind()) {
6071 case CK_LValueBitCast:
6075 case CK_ArrayToPointerDecay:
6078 case CK_NullToPointer:
6086 }
else if (isa<DeclRefExpr>(e)) {
6090 isWeakAccess =
true;
6094 VarDecl *var = dyn_cast<VarDecl>(cast<DeclRefExpr>(e)->getDecl());
6108 }
else if (isa<ArraySubscriptExpr>(e)) {
6124 bool isWeakAccess =
false;
6128 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
6160 bool ArrayDecay =
false;
6165 ArgPointee = ArgArrayType->getElementType();
6177 bool ShouldCopy =
true;
6248 "cl_intel_device_side_avc_motion_estimation", S.
getLangOpts()) &&
6250 if (DestType->isOCLIntelSubgroupAVCMcePayloadType() ||
6251 DestType->isOCLIntelSubgroupAVCMceResultType())
6265 MultiExprArg Args,
bool TopLevelOfInitList,
bool TreatUnavailableAsInvalid)
6269 TreatUnavailableAsInvalid);
6275 auto *DRE = dyn_cast<DeclRefExpr>(
E);
6276 if (!DRE || !isa<FunctionDecl>(DRE->getDecl()))
6280 cast<FunctionDecl>(DRE->getDecl()));
6297 return isa<DecompositionDecl>(Entity.
getDecl());
6323 bool TopLevelOfInitList,
6324 bool TreatUnavailableAsInvalid) {
6331 for (
unsigned I = 0,
E = Args.size(); I !=
E; ++I)
6332 if (Args[I]->getType()->isNonOverloadPlaceholderType()) {
6339 Args[I] = result.
get();
6361 if (Args.size() == 1) {
6379 TreatUnavailableAsInvalid);
6391 if (Args.size() != 1)
6397 else if (isa<InitListExpr>(Args[0]))
6401 TopLevelOfInitList);
6427 if (
Initializer && isa<VariableArrayType>(DestAT)) {
6459 if (
Initializer && isa<ConstantArrayType>(DestAT) &&
6477 Expr *OVEAsExpr = &OVE;
6479 TreatUnavailableAsInvalid);
6489 isa<CompoundLiteralExpr>(
Initializer->IgnoreParens()) &&
6507 *
this, TreatUnavailableAsInvalid);
6509 }
else if (S.
getLangOpts().CPlusPlus20 && !TopLevelOfInitList &&
6525 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
6534 assert(
Initializer &&
"Initializer must be non-null");
6536 if (allowObjCWritebackConversion &&
6562 SourceType, DestType))))) {
6569 if (
const auto *RD =
6574 S.
getLangOpts().CPlusPlus20 && RD && RD->hasDefinition() &&
6575 RD->isAggregate() &&
Failed() &&
6588 S, Kind.getLocation(), Best);
6606 assert(
Initializer &&
"Initializer must be non-null");
6608 TopLevelOfInitList);
6613 assert(Args.size() >= 1 &&
"Zero-argument case handled above");
6623 for (
auto *Arg : Args) {
6624 if (Arg->getType()->isExtVectorType()) {
6627 for (
unsigned Idx = 0; Idx < Elm; ++Idx) {
6633 VTy->getElementType(), Arg->
getValueKind(), Arg->getObjectKind(),
6637 InitArgs.emplace_back(Arg);
6647 if (Args.size() > 1) {
6650 }
else if (isa<InitListExpr>(Args[0])) {
6658 assert(
Initializer &&
"Initializer must be non-null");
6661 bool NeedAtomicConversion =
false;
6665 Atomic->getValueType())) {
6666 DestType =
Atomic->getValueType();
6667 NeedAtomicConversion =
true;
6672 TopLevelOfInitList);
6674 if (!
Failed() && NeedAtomicConversion)
6701 Sema::AllowedExplicit::None,
6703 Kind.isCStyleOrFunctionalCast(),
6704 allowObjCWritebackConversion);
6712 bool ShouldCopy =
true;
6728 }
else if (ICS.
isBad()) {
6736 else if (
Initializer->getType()->isFunctionType() &&
6749 for (
auto &S : Steps)
6807 llvm_unreachable(
"Invalid EntityKind!");
6841 llvm_unreachable(
"missed an InitializedEntity kind?");
6875 llvm_unreachable(
"missed an InitializedEntity kind?");
6914 llvm_unreachable(
"missed an InitializedEntity kind?");
6941 bool IsExtraneousCopy) {
6966 S,
Loc, CurInitExpr, CandidateSet,
T, Ctors, Best,
6978 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
6979 : diag::err_temp_copy_no_viable)
6997 S.
Diag(
Loc, diag::err_temp_copy_deleted)
7004 bool HadMultipleCandidates = CandidateSet.
size() > 1;
7013 if (IsExtraneousCopy) {
7024 for (
unsigned I = 1, N = Constructor->getNumParams(); I != N; ++I) {
7027 diag::err_call_incomplete_argument))
7068 Best->Function->getParamDecl(0)->getType().getNonReferenceType(),
7073 Loc,
T, Best->FoundDecl, Constructor, Elidable, ConstructorArgs,
7074 HadMultipleCandidates,
7090 Expr *CurInitExpr) {
7109 S,
Loc, CurInitExpr, CandidateSet, CurInitExpr->
getType(), Ctors, Best,
7122 Best->FoundDecl, Entity,
Diag);
7143void InitializationSequence::PrintInitLocationNote(
Sema &S,
7158 diag::note_method_return_type_change)
7176 switch (Kind.getKind()) {
7182 return NumArgs != 1;
7194 bool &ConstructorInitRequiresZeroInit,
7195 bool IsListInitialization,
7196 bool IsStdInitListInitialization,
7199 unsigned NumArgs = Args.size();
7207 ? Kind.getEqualLoc()
7208 : Kind.getLocation();
7214 assert(Constructor->getParent() &&
"No parent class for constructor.");
7215 if (Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
7216 Constructor->isTrivial() && !Constructor->isUsed(
false)) {
7231 bool AllowExplicitConv =
7232 Kind.AllowExplicit() && !Kind.isCopyInit() && Args.size() == 1 &&
7237 if (NumArgs == 1 && !Kind.isExplicitCast())
7239 Entity.
getType(), Args.front()->getType(), Kind.getLocation());
7244 ConstructorArgs, AllowExplicitConv,
7245 IsListInitialization))
7259 : Kind.getParenOrBraceRange();
7262 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
7272 ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
7273 IsListInitialization, IsStdInitListInitialization,
7274 ConstructorInitRequiresZeroInit),
7290 if (IsListInitialization)
7291 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
7293 ParenOrBraceRange = Kind.getParenOrBraceRange();
7302 HadMultipleCandidates,
7303 IsListInitialization,
7304 IsStdInitListInitialization,
7305 ConstructorInitRequiresZeroInit,
7313 HadMultipleCandidates,
7314 IsListInitialization,
7315 IsStdInitListInitialization,
7316 ConstructorInitRequiresZeroInit,
7347 const Expr *PostInit);
7354 bool IsReturnStmt) {
7365 unsigned DiagID = 0;
7395 if (VD->
hasAttr<BlocksAttr>())
7408 if (isa<ParmVarDecl>(VD))
7409 DiagID = diag::warn_redundant_move_on_return;
7411 DiagID = diag::warn_pessimizing_move_on_return;
7413 DiagID = diag::warn_pessimizing_move_on_initialization;
7455 if (UO->getOpcode() == UO_Deref &&
7456 UO->getSubExpr()->IgnoreParenCasts()->
7459 S.
PDiag(diag::warn_binding_null_to_reference)
7460 << UO->getSubExpr()->getSourceRange());
7466 bool BoundToLvalueReference) {
7479 Record.ForRangeLifetimeExtendTemps.push_back(MTE);
7511 if (!PointeeTy.isNull() &&
7512 PointeeTy.getAddressSpace() != ExprPointeeTy.getAddressSpace())
7513 CK = CK_AddressSpaceConversion;
7515 CK = CK_AddressSpaceConversion;
7530 if (!ZeroInitializationFixit.empty()) {
7532 const auto *VD = dyn_cast_or_null<VarDecl>(
D);
7538 if (!DestType->
isRecordType() && VD && VD->isConstexpr()) {
7540 S.
Diag(Kind.getLocation(), diag::err_constexpr_var_requires_const_init)
7543 ZeroInitializationFixit);
7545 unsigned DiagID = diag::err_default_init_const;
7547 DiagID = diag::ext_default_init_const;
7549 S.
Diag(Kind.getLocation(), DiagID)
7552 ZeroInitializationFixit);
7572 if (isa<InitListExpr>((
Expr *)Args[0])) {
7576 if (
auto *DD = dyn_cast_or_null<DeclaratorDecl>(Entity.
getDecl())) {
7578 TypeLoc TL = TInfo->getTypeLoc();
7581 Brackets = ArrayLoc.getBracketsRange();
7588 ArrayT->getSizeModifier(),
7589 ArrayT->getIndexTypeCVRQualifiers(),
7596 !Kind.isExplicitCast()) {
7598 SourceRange ParenRange = Kind.getParenOrBraceRange();
7603 Kind.isExplicitCast() ||
7613 Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
7619 S.
Diag(
Init->getBeginLoc(), diag::warn_cxx98_compat_reference_list_init)
7620 <<
Init->getSourceRange();
7623 if (S.
getLangOpts().MicrosoftExt && Args.size() == 1 &&
7629 S.
Diag(
Init->getBeginLoc(), diag::ext_init_from_predefined) <<
Init;
7640 S.
Diag(Args[0]->getBeginLoc(), diag::err_opencl_atomic_init)
7660 isa<InitListExpr>(Args[0]);
7661 (void)IsHLSLVectorInit;
7666 switch (Steps.front().Kind) {
7700 assert(Args.size() == 1 || IsHLSLVectorInit);
7719 isa_and_nonnull<InitListExpr>(CurInit.
get()));
7724 auto checkAbstractType = [&](
QualType T) ->
bool {
7729 diag::err_allocation_of_abstract_type);
7734 bool ConstructorInitRequiresZeroInit =
false;
7767 bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
7779 CK_DerivedToBase, CurInit.
get(),
7795 if (
auto *DRE = dyn_cast<DeclRefExpr>(CurInit.
get()->
IgnoreParens())) {
7796 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
7809 assert(CurInit.
get()->
isPRValue() &&
"not a temporary");
7867 bool CreatedObject =
false;
7883 Loc,
Step->
Type, FoundFn, Constructor, ConstructorArgs,
7884 HadMultipleCandidates,
7896 CastKind = CK_ConstructorConversion;
7897 CreatedObject =
true;
7907 HadMultipleCandidates);
7911 CastKind = CK_UserDefinedConversion;
7915 if (CreatedObject && checkAbstractType(CurInit.
get()->
getType()))
7936 S.
PDiag(diag::err_access_dtor_temp) <<
T);
7960 "function reference should be lvalue");
7966 assert(CurInit.
get()->
isPRValue() &&
"cannot convert glvalue to atomic");
7974 if (
const auto *FromPtrType =
7977 if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
7978 !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
7981 if (!Kind.isStaticCast()) {
7983 diag::warn_noderef_to_dereferenceable_pointer)
8002 CurInit = CurInitExprRes;
8023 InitListChecker PerformInitList(S, InitEntity,
8024 InitList, Ty,
false,
8026 if (PerformInitList.HadError())
8034 if ((*ResultType)->isRValueReferenceType())
8036 else if ((*ResultType)->isLValueReferenceType())
8043 PerformInitList.getFullyStructuredList();
8047 : StructuredInitList;
8064 assert(Args.size() == 1 &&
"expected a single argument for list init");
8066 S.
Diag(InitList->
getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
8072 ConstructorInitRequiresZeroInit,
8081 CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
8110 bool IsStdInitListInit =
8114 ? Kind.getParenOrBraceRange()
8117 S, UseTemporary ? TempEntity : Entity, Kind,
8119 ConstructorInitRequiresZeroInit,
8130 if (NextStep != StepEnd &&
8135 ConstructorInitRequiresZeroInit =
true;
8138 !Kind.isImplicitValueInit()) {
8142 Kind.getRange().getBegin());
8146 Kind.getRange().getEnd());
8176 CurInit = CurInitExprRes;
8191 S.
Diag(Kind.getLocation(), diag::err_c23_constexpr_pointer_not_null);
8198 InitialCurInit.
get(),
8201 PrintInitLocationNote(S, Entity);
8203 }
else if (Complained)
8204 PrintInitLocationNote(S, Entity);
8220 CK_ObjCObjectLValueCast,
8232 BaseExpr, Kind.getLocation(), IndexExpr, Kind.getLocation());
8233 ArrayLoopCommonExprs.push_back(BaseExpr);
8238 assert(!ArrayLoopCommonExprs.empty() &&
8239 "mismatched SK_ArrayLoopIndex and SK_ArrayLoopInit");
8240 Expr *Common = ArrayLoopCommonExprs.pop_back_val();
8249 S.
Diag(Kind.getLocation(), diag::ext_array_init_copy)
8263 IncompleteDest->getElementType(), ConstantSource->getSize(),
8273 S.
Diag(Kind.getLocation(), diag::ext_array_init_parens)
8293 diag::warn_cxx98_compat_initializer_list_init)
8306 [[maybe_unused]]
bool IsStdInitializerList =
8308 assert(IsStdInitializerList &&
8309 "StdInitializerList step to non-std::initializer_list");
8313 "std::initializer_list should have already be "
8314 "complete/instantiated by this point");
8316 auto InvalidType = [&] {
8318 diag::err_std_initializer_list_malformed)
8325 return InvalidType();
8328 if (Field ==
Record->field_end())
8329 return InvalidType();
8332 if (!Field->getType()->isPointerType() ||
8335 return InvalidType();
8337 if (++Field ==
Record->field_end())
8338 return InvalidType();
8341 if (
const auto *PT = Field->getType()->getAs<
PointerType>()) {
8344 return InvalidType();
8346 if (Field->isBitField() ||
8348 return InvalidType();
8351 if (++Field !=
Record->field_end())
8352 return InvalidType();
8379 "Sampler initialization on non-sampler type.");
8385 S.
Diag(Kind.getLocation(), diag::err_sampler_argument_required)
8389 auto Var = cast<VarDecl>(DRE->getDecl());
8392 if (!Var->hasGlobalStorage()) {
8404 if (!Var->getInit() || !isa<ImplicitCastExpr>(Var->getInit()))
8406 Init = cast<ImplicitCastExpr>(
const_cast<Expr*
>(
8407 Var->getInit()))->getSubExpr();
8408 SourceType =
Init->getType();
8415 if (!
Init->isConstantInitializer(S.
Context,
false))
8420 S.
Diag(Kind.getLocation(), diag::err_sampler_initializer_not_integer)
8428 const uint64_t SamplerValue =
Result.getLimitedValue();
8435 unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
8436 unsigned FilterMode = (0x30 & SamplerValue) >> 4;
8437 if (FilterMode != 1 && FilterMode != 2 &&
8439 "cl_intel_device_side_avc_motion_estimation", S.
getLangOpts()))
8440 S.
Diag(Kind.getLocation(),
8441 diag::warn_sampler_initializer_invalid_bits)
8443 if (AddressingMode > 4)
8444 S.
Diag(Kind.getLocation(),
8445 diag::warn_sampler_initializer_invalid_bits)
8446 <<
"Addressing Mode";
8452 CK_IntToOCLSampler);
8458 "Wrong type for initialization of OpenCL opaque type.");
8461 CK_ZeroToOCLOpaqueType,
8469 if (CurInit.
get() && ResultType)
8490 cast<FieldDecl>(Entity.
getDecl())->isBitField())
8491 S.CheckBitFieldInitialization(Kind.getLocation(),
8506 S.
Diag(
Loc, diag::err_reference_without_init)
8507 <<
T.getNonReferenceType();
8515 for (
const auto *FI : RD->
fields()) {
8516 if (FI->isUnnamedBitField())
8520 S.
Diag(
Loc, diag::note_value_initialization_here) << RD;
8525 for (
const auto &BI : RD->
bases()) {
8527 S.
Diag(
Loc, diag::note_value_initialization_here) << RD;
8562 if (fromDecl && destDecl && fromDecl->getDeclKind() == Decl::CXXRecord &&
8563 destDecl->getDeclKind() == Decl::CXXRecord &&
8564 !fromDecl->isInvalidDecl() && !destDecl->isInvalidDecl() &&
8565 !fromDecl->hasDefinition() &&
8568 S.
Diag(fromDecl->getLocation(), diag::note_forward_class_conversion)
8598 S.
Diag(
Loc, diag::note_in_reference_temporary_list_initializer) <<
T;
8602 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
8605 assert(DiagnoseInitList.HadError() &&
8606 "Inconsistent init list check result.");
8621 if (Args.size() == 1) {
8622 auto *List = dyn_cast<InitListExpr>(Args[0]);
8623 if (List && List->getNumInits() == 1)
8624 OnlyArg = List->getInit(0);
8633 if (
Expr *Resolved =
8653 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
8656 S.
Diag(Kind.getLocation(), diag::err_reference_has_multiple_inits)
8657 <<
SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
8660 S.
Diag(Kind.getLocation(), diag::err_list_init_in_parens)
8661 << 1 << Entity.
getType() << Args[0]->getSourceRange();
8665 S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 0;
8668 S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 1;
8671 S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 2;
8674 S.
Diag(Kind.getLocation(), diag::err_array_init_narrow_string_into_wchar);
8677 S.
Diag(Kind.getLocation(), diag::err_array_init_wide_string_into_char);
8680 S.
Diag(Kind.getLocation(),
8681 diag::err_array_init_incompat_wide_string_into_wchar);
8684 S.
Diag(Kind.getLocation(),
8685 diag::err_array_init_plain_string_into_char8_t);
8686 S.
Diag(Args.front()->getBeginLoc(),
8687 diag::note_array_init_plain_string_into_char8_t)
8691 S.
Diag(Kind.getLocation(), diag::err_array_init_utf8_string_into_char)
8696 S.
Diag(Kind.getLocation(),
8698 ? diag::err_array_init_different_type
8699 : diag::err_array_init_non_constant_array))
8702 << Args[0]->getSourceRange();
8706 S.
Diag(Kind.getLocation(), diag::err_variable_object_no_init)
8707 << Args[0]->getSourceRange();
8720 auto *FD = cast<FunctionDecl>(cast<DeclRefExpr>(OnlyArg)->getDecl());
8728 switch (FailedOverloadResult) {
8735 ? (S.
PDiag(diag::err_typecheck_ambiguous_condition)
8736 << OnlyArg->
getType() << DestType
8737 << Args[0]->getSourceRange())
8738 : (S.
PDiag(diag::err_ref_init_ambiguous)
8739 << DestType << OnlyArg->
getType()
8740 << Args[0]->getSourceRange())),
8748 diag::err_typecheck_nonviable_condition_incomplete,
8749 OnlyArg->
getType(), Args[0]->getSourceRange()))
8750 S.
Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
8752 << OnlyArg->
getType() << Args[0]->getSourceRange()
8764 S.
Diag(Kind.getLocation(), diag::err_typecheck_deleted_function)
8766 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
8767 << Args[0]->getSourceRange();
8771 llvm_unreachable(
"Inconsistent overload resolution?");
8777 llvm_unreachable(
"Conversion did not fail!");
8782 if (isa<InitListExpr>(Args[0])) {
8783 S.
Diag(Kind.getLocation(),
8784 diag::err_lvalue_reference_bind_to_initlist)
8787 << Args[0]->getSourceRange();
8793 S.
Diag(Kind.getLocation(),
8795 ? diag::err_lvalue_reference_bind_to_temporary
8796 : diag::err_lvalue_reference_bind_to_unrelated)
8800 << Args[0]->getSourceRange();
8805 FieldDecl *BitField = Args[0]->getSourceBitField();
8806 S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_bitfield)
8809 << (BitField !=
nullptr)
8810 << Args[0]->getSourceRange();
8817 S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_vector_element)
8819 << Args[0]->getSourceRange();
8823 S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_matrix_element)
8828 S.
Diag(Kind.getLocation(), diag::err_lvalue_to_rvalue_ref)
8830 << Args[0]->getSourceRange();
8834 S.
Diag(Kind.getLocation(), diag::err_reference_bind_temporary_addrspace)
8835 << DestType << Args[0]->getSourceRange();
8846 S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
8847 << NonRefType << SourceType << 1
8848 << Args[0]->getSourceRange();
8850 S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
8851 << NonRefType << SourceType << 0
8857 S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
8858 << NonRefType << SourceType << 2
8859 << Args[0]->getSourceRange();
8864 S.
Diag(Kind.getLocation(), diag::err_reference_bind_failed)
8869 << Args[0]->getSourceRange();
8880 << Args[0]->getSourceRange();
8882 S.
Diag(Kind.getLocation(), PDiag);
8894 auto *InitList = dyn_cast<InitListExpr>(Args[0]);
8895 if (InitList && InitList->getNumInits() >= 1) {
8896 R =
SourceRange(InitList->getInit(0)->getEndLoc(), InitList->getEndLoc());
8898 assert(Args.size() > 1 &&
"Expected multiple initializers!");
8899 R =
SourceRange(Args.front()->getEndLoc(), Args.back()->getEndLoc());
8903 if (Kind.isCStyleOrFunctionalCast())
8904 S.
Diag(Kind.getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
8907 S.
Diag(Kind.getLocation(), diag::err_excess_initializers)
8913 S.
Diag(Kind.getLocation(), diag::err_list_init_in_parens)
8914 << 0 << Entity.
getType() << Args[0]->getSourceRange();
8918 S.
Diag(Kind.getLocation(), diag::err_reference_bind_init_list)
8923 S.
Diag(Kind.getLocation(), diag::err_init_list_bad_dest_type)
8924 << (DestType->
isRecordType()) << DestType << Args[0]->getSourceRange();
8932 SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
8935 assert(Args.size() == 1 &&
8936 "List construction from other than 1 argument.");
8943 switch (FailedOverloadResult) {
8947 S.
PDiag(diag::err_ovl_ambiguous_init)
8948 << DestType << ArgsRange),
8965 if (
auto Inherited = Constructor->getInheritedConstructor())
8966 InheritedFrom = Inherited.getShadowDecl()->getNominatedBaseClass();
8968 S.
Diag(Kind.getLocation(), diag::err_missing_default_ctor)
8969 << (InheritedFrom ? 2 : Constructor->isImplicit() ? 1 : 0)
8981 S.
Diag(Kind.getLocation(), diag::err_missing_default_ctor)
8982 << (InheritedFrom ? 2 : Constructor->isImplicit() ? 1 : 0)
8988 diag::note_member_declared_at);
8993 diag::note_previous_decl)
9002 S.
PDiag(diag::err_ovl_no_viable_function_in_init)
9003 << DestType << ArgsRange),
9012 S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
9013 << DestType << ArgsRange;
9014 llvm_unreachable(
"Inconsistent overload resolution?");
9022 S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_special_init)
9023 << llvm::to_underlying(
9025 << DestType << ArgsRange;
9028 S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
9029 << DestType << (Msg !=
nullptr)
9030 << (Msg ? Msg->
getString() : StringRef()) << ArgsRange;
9038 llvm_unreachable(
"Conversion did not fail!");
9050 S.
Diag(Kind.getLocation(), diag::err_uninitialized_member_in_ctor)
9051 << (Constructor->getInheritedConstructor() ? 2 :
9052 Constructor->isImplicit() ? 1 : 0)
9058 }
else if (
const auto *VD = dyn_cast_if_present<VarDecl>(Entity.
getDecl());
9059 VD && VD->isConstexpr()) {
9060 S.
Diag(Kind.getLocation(), diag::err_constexpr_var_requires_const_init)
9063 S.
Diag(Kind.getLocation(), diag::err_default_init_const)
9070 diag::err_init_incomplete_type);
9086 S.
Diag(Kind.getLocation(), diag::err_selected_explicit_constructor)
9087 << Args[0]->getSourceRange();
9092 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
9095 diag::note_explicit_ctor_deduction_guide_here) <<
false;
9106 S.
Diag(Kind.getLocation(), diag::err_designated_init_for_non_aggregate)
9111 PrintInitLocationNote(S, Entity);
9118 OS <<
"Failed sequence: ";
9121 OS <<
"too many initializers for reference";
9125 OS <<
"parenthesized list init for reference";
9129 OS <<
"array requires initializer list";
9133 OS <<
"address of unaddressable function was taken";
9137 OS <<
"array requires initializer list or string literal";
9141 OS <<
"array requires initializer list or wide string literal";
9145 OS <<
"narrow string into wide char array";
9149 OS <<
"wide string into char array";
9153 OS <<
"incompatible wide string into wide char array";
9157 OS <<
"plain string literal into char8_t array";
9161 OS <<
"u8 string literal into char array";
9165 OS <<
"array type mismatch";
9169 OS <<
"non-constant array initializer";
9173 OS <<
"address of overloaded function failed";
9177 OS <<
"overload resolution for reference initialization failed";
9181 OS <<
"non-const lvalue reference bound to temporary";
9185 OS <<
"non-const lvalue reference bound to bit-field";
9189 OS <<
"non-const lvalue reference bound to vector element";
9193 OS <<
"non-const lvalue reference bound to matrix element";
9197 OS <<
"non-const lvalue reference bound to unrelated type";
9201 OS <<
"rvalue reference bound to an lvalue";
9205 OS <<
"reference initialization drops qualifiers";
9209 OS <<
"reference with mismatching address space bound to temporary";
9213 OS <<
"reference initialization failed";
9217 OS <<
"conversion failed";
9221 OS <<
"conversion from property failed";
9225 OS <<
"too many initializers for scalar";
9229 OS <<
"parenthesized list init for reference";
9233 OS <<
"referencing binding to initializer list";
9237 OS <<
"initializer list for non-aggregate, non-scalar type";
9241 OS <<
"overloading failed for user-defined conversion";
9245 OS <<
"constructor overloading failed";
9249 OS <<
"default initialization of a const variable";
9253 OS <<
"initialization of incomplete type";
9257 OS <<
"list initialization checker failure";
9261 OS <<
"variable length array has an initializer";
9265 OS <<
"initializer expression isn't contextually valid";
9269 OS <<
"list constructor overloading failed";
9273 OS <<
"list copy initialization chose explicit constructor";
9277 OS <<
"parenthesized list initialization failed";
9281 OS <<
"designated initializer for non-aggregate type";
9289 OS <<
"Dependent sequence\n";
9293 OS <<
"Normal sequence: ";
9304 OS <<
"resolve address of overloaded function";
9308 OS <<
"derived-to-base (prvalue)";
9312 OS <<
"derived-to-base (xvalue)";
9316 OS <<
"derived-to-base (lvalue)";
9320 OS <<
"bind reference to lvalue";
9324 OS <<
"bind reference to a temporary";
9328 OS <<
"final copy in class direct-initialization";
9332 OS <<
"extraneous C++03 copy to temporary";
9336 OS <<
"user-defined conversion via " << *S->Function.Function;
9340 OS <<
"qualification conversion (prvalue)";
9344 OS <<
"qualification conversion (xvalue)";
9348 OS <<
"qualification conversion (lvalue)";
9352 OS <<
"function reference conversion";
9356 OS <<
"non-atomic-to-atomic conversion";
9360 OS <<
"implicit conversion sequence (";
9366 OS <<
"implicit conversion sequence with narrowing prohibited (";
9372 OS <<
"list aggregate initialization";
9376 OS <<
"unwrap reference initializer list";
9380 OS <<
"rewrap reference initializer list";
9384 OS <<
"constructor initialization";
9388 OS <<
"list initialization via constructor";
9392 OS <<
"zero initialization";
9396 OS <<
"C assignment";
9400 OS <<
"string initialization";
9404 OS <<
"Objective-C object conversion";
9408 OS <<
"indexing for array initialization loop";
9412 OS <<
"array initialization loop";
9416 OS <<
"array initialization";
9420 OS <<
"array initialization (GNU extension)";
9424 OS <<
"parenthesized array initialization";
9428 OS <<
"pass by indirect copy and restore";
9432 OS <<
"pass by indirect restore";
9436 OS <<
"Objective-C object retension";
9440 OS <<
"std::initializer_list from initializer list";
9444 OS <<
"list initialization from std::initializer_list";
9448 OS <<
"OpenCL sampler_t from integer constant";
9452 OS <<
"OpenCL opaque type from zero";
9455 OS <<
"initialization from a parenthesized list of values";
9459 OS <<
" [" << S->Type <<
']';
9473 const Expr *PostInit) {
9489 auto MakeDiag = [&](
bool IsConstRef,
unsigned DefaultDiagID,
9490 unsigned ConstRefDiagID,
unsigned WarnDiagID) {
9493 if (L.CPlusPlus11 &&
9495 DiagID = IsConstRef ? ConstRefDiagID : DefaultDiagID;
9497 DiagID = WarnDiagID;
9517 MakeDiag(
T != EntityType, diag::ext_init_list_type_narrowing,
9518 diag::ext_init_list_type_narrowing_const_reference,
9519 diag::warn_init_list_type_narrowing)
9521 <<
T.getLocalUnqualifiedType();
9528 diag::ext_init_list_constant_narrowing,
9529 diag::ext_init_list_constant_narrowing_const_reference,
9530 diag::warn_init_list_constant_narrowing)
9539 diag::ext_init_list_variable_narrowing,
9540 diag::ext_init_list_variable_narrowing_const_reference,
9541 diag::warn_init_list_variable_narrowing)
9549 llvm::raw_svector_ostream OS(StaticCast);
9550 OS <<
"static_cast<";
9557 OS << *TT->getDecl();
9566 S.
Diag(PostInit->
getBeginLoc(), diag::note_init_list_narrowing_silence)
9577 Init->IgnoreParenImpCasts(), ToType,
false,
9578 Sema::AllowedExplicit::None,
9594 S.
Diag(
Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
9595 <<
Value.getAsString(S.
Context, PreNarrowingType) << ToType;
9600 S.
Diag(
Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
9601 << ToType << FromType;
9611 llvm_unreachable(
"unhandled case in switch");
9623 for (
unsigned I = 0, N = SE->
getLength(); I != N; ++I) {
9628 diag::err_c23_constexpr_init_not_representable)
9642 if (
Init.isInvalid())
9646 assert(InitE &&
"No initialization expression");
9651 return !
Seq.Failed();
9658 bool TopLevelOfInitList,
9659 bool AllowExplicit) {
9660 if (
Init.isInvalid())
9664 assert(InitE &&
"No initialization expression?");
9674 const bool ShouldTrackCopy =
9676 if (ShouldTrackCopy) {
9678 Seq.SetOverloadFailure(
9684 const auto LastStep =
Seq.step_end() - 1;
9685 assert(LastStep->Kind ==
9689 llvm::find_if(
Seq.getFailedCandidateSet(),
9691 return Candidate.Viable &&
9692 Candidate.Function == Function &&
9693 Candidate.Conversions.size() > 0;
9695 if (Candidate !=
Seq.getFailedCandidateSet().end() &&
9697 Candidate->
Viable =
false;
9701 Function->getParamDecl(0)->getType());
9709 if (ShouldTrackCopy)
9718 auto NotSpecialization = [&] (
const CXXRecordDecl *Candidate) {
9719 auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Candidate);
9722 return !(NotSpecialization(RD) && RD->
forallBases(NotSpecialization));
9728 auto *DeducedTST = dyn_cast<DeducedTemplateSpecializationType>(
9730 assert(DeducedTST &&
"not a deduced template specialization type");
9741 if (
auto *
AliasTemplate = dyn_cast_or_null<TypeAliasTemplateDecl>(
9743 Diag(Kind.getLocation(),
9744 diag::warn_cxx17_compat_ctad_for_alias_templates);
9747 ->getUnderlyingType()
9748 .getCanonicalType();
9752 if (
const auto *TST =
9754 Template = dyn_cast_or_null<ClassTemplateDecl>(
9755 TST->getTemplateName().getAsTemplateDecl());
9756 }
else if (
const auto *RT = UnderlyingType->getAs<
RecordType>()) {
9760 if (
const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(
9761 RT->getAsCXXRecordDecl()))
9762 Template = CTSD->getSpecializedTemplate();
9767 Diag(Kind.getLocation(),
9768 diag::err_deduced_non_class_or_alias_template_specialization_type)
9778 diag::warn_cxx14_compat_class_template_argument_deduction)
9806 ? dyn_cast<InitListExpr>(Inits[0])
9822 bool AllowExplicit = !Kind.isCopyInit() ||
ListInit;
9828 bool OnlyListConstructors,
9829 bool AllowAggregateDeductionCandidate) {
9835 if (!AllowExplicit) {
9842 if (GD->getMinRequiredArguments() > 1 ||
9843 (GD->getNumParams() == 0 && !GD->isVariadic()))
9853 if (!AllowAggregateDeductionCandidate &&
9868 for (
Expr *
E : Inits)
9869 if (
auto *DI = dyn_cast<DesignatedInitExpr>(
E))
9870 TmpInits.push_back(DI->getInit());
9872 TmpInits.push_back(
E);
9874 TD, FoundDecl,
nullptr, TmpInits, Candidates,
9876 false, AllowExplicit, ADLCallKind::NotADL,
9877 {}, AllowAggregateDeductionCandidate);
9881 false, AllowExplicit);
9885 bool FoundDeductionGuide =
false;
9887 auto TryToResolveOverload =
9890 bool HasAnyDeductionGuide =
false;
9893 auto *Pattern = Template;
9894 while (Pattern->getInstantiatedFromMemberTemplate()) {
9895 if (Pattern->isMemberSpecialization())
9897 Pattern = Pattern->getInstantiatedFromMemberTemplate();
9900 auto *RD = cast<CXXRecordDecl>(Pattern->getTemplatedDecl());
9906 InitListChecker CheckInitList(*
this, Entity,
ListInit, Ty, ElementTypes);
9907 if (!CheckInitList.HadError()) {
9916 for (
int I = 0,
E =
ListInit->getNumInits();
9917 I <
E && !isa<PackExpansionType>(ElementTypes[I]); ++I)
9918 if (ElementTypes[I]->isArrayType()) {
9919 if (isa<InitListExpr, DesignatedInitExpr>(
ListInit->getInit(I)))
9921 else if (isa<StringLiteral>(
9922 ListInit->getInit(I)->IgnoreParenImpCasts()))
9929 LookupTemplateDecl, ElementTypes,
9933 OnlyListConstructors,
9935 HasAnyDeductionGuide =
true;
9940 for (
auto I = Guides.
begin(),
E = Guides.
end(); I !=
E; ++I) {
9945 auto *TD = dyn_cast<FunctionTemplateDecl>(
D);
9946 auto *GD = dyn_cast_if_present<CXXDeductionGuideDecl>(
9951 if (!GD->isImplicit())
9952 HasAnyDeductionGuide =
true;
9954 addDeductionCandidate(TD, GD, I.getPair(), OnlyListConstructors,
9969 }
else if (Inits.size()) {
9974 Inits, Inits.back()->getEndLoc());
9975 SynthesizeAggrGuide(&TempListInit);
9979 FoundDeductionGuide = FoundDeductionGuide || HasAnyDeductionGuide;
9989 bool TryListConstructors =
true;
9995 auto *FD = dyn_cast<FunctionDecl>(
D->getUnderlyingDecl());
9996 if (FD && FD->getMinRequiredArguments() == 0) {
9997 TryListConstructors =
false;
10001 }
else if (
ListInit->getNumInits() == 1) {
10009 if (!isa<InitListExpr>(
E) && RD &&
10012 TryListConstructors =
false;
10015 if (TryListConstructors)
10016 Result = TryToResolveOverload(
true);
10025 Result = TryToResolveOverload(
false);
10034 Kind.getLocation(),
10035 PDiag(diag::err_deduced_class_template_ctor_ambiguous)
10042 cast<ClassTemplateDecl>(Template)->getTemplatedDecl();
10047 Kind.getLocation(),
10048 PDiag(
Complete ? diag::err_deduced_class_template_ctor_no_viable
10049 : diag::err_deduced_class_template_incomplete)
10059 Diag(Kind.getLocation(), diag::err_deduced_class_template_deleted)
10069 if (Kind.isCopyInit() &&
ListInit &&
10070 cast<CXXDeductionGuideDecl>(Best->Function)->isExplicit()) {
10071 bool IsDeductionGuide = !Best->Function->isImplicit();
10072 Diag(Kind.getLocation(), diag::err_deduced_class_template_explicit)
10074 Diag(Best->Function->getLocation(),
10075 diag::note_explicit_ctor_deduction_guide_here)
10076 << IsDeductionGuide;
10093 diag::warn_cxx14_compat_class_template_argument_deduction)
10098 if (!FoundDeductionGuide) {
10100 diag::warn_ctad_maybe_unsupported)
10102 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 Sema::AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
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...
@ 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 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.
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.
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
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 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 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 a value-initialized rvalue of type T, which is a non-class type.
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.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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 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 hasAddressSpace() const
Qualifiers withoutAddressSpace() const
void removeAddressSpace()
static Qualifiers fromCVRMask(unsigned CVR)
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
bool hasObjCLifetime() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
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.
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)
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 ...
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
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...
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()
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
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.
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=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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)
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...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
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() 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
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 checkExprLifetime(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.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
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.
@ 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).
bool Viable
Viable - True to indicate that this overload candidate is viable.
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.
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.