24 #include "llvm/ADT/APInt.h" 25 #include "llvm/ADT/SmallString.h" 26 #include "llvm/Support/ErrorHandling.h" 27 #include "llvm/Support/raw_ostream.h" 29 using namespace clang;
61 if (!isa<ConstantArrayType>(AT) && !isa<IncompleteArrayType>(AT))
120 llvm_unreachable(
"missed a StringLiteral kind?");
136 if (isa<StringLiteral>(E) || isa<ObjCEncodeExpr>(E))
138 else if (
ParenExpr *PE = dyn_cast<ParenExpr>(E))
139 E = PE->getSubExpr();
141 E = UO->getSubExpr();
143 E = GSE->getResultExpr();
145 llvm_unreachable(
"unexpected expr in string literal init");
152 auto *ConstantArrayTy =
154 uint64_t StrLength = ConstantArrayTy->getSize().getZExtValue();
159 llvm::APInt ConstVal(32, StrLength);
184 if (StrLength > CAT->
getSize().getZExtValue())
186 diag::err_initializer_string_for_char_array_too_long)
190 if (StrLength-1 > CAT->
getSize().getZExtValue())
192 diag::ext_initializer_string_for_char_array_too_long)
236 class InitListChecker {
240 bool TreatUnavailableAsInvalid;
241 llvm::DenseMap<InitListExpr *, InitListExpr *> SyntacticToSemantic;
247 unsigned &StructuredIndex);
251 bool TopLevelObject =
false);
254 bool SubobjectIsDesignatorContext,
257 unsigned &StructuredIndex,
258 bool TopLevelObject =
false);
263 unsigned &StructuredIndex);
268 unsigned &StructuredIndex);
273 unsigned &StructuredIndex);
278 unsigned &StructuredIndex);
282 unsigned &StructuredIndex);
287 bool SubobjectIsDesignatorContext,
unsigned &Index,
289 unsigned &StructuredIndex,
290 bool TopLevelObject =
false);
293 llvm::APSInt elementIndex,
294 bool SubobjectIsDesignatorContext,
unsigned &Index,
296 unsigned &StructuredIndex);
302 llvm::APSInt *NextElementIndex,
305 unsigned &StructuredIndex,
306 bool FinishSubobjectInit,
307 bool TopLevelObject);
311 unsigned StructuredIndex,
313 bool IsFullyOverwritten =
false);
314 void UpdateStructuredListElement(
InitListExpr *StructuredList,
315 unsigned &StructuredIndex,
317 int numArrayElements(
QualType DeclType);
318 int numStructUnionElements(
QualType DeclType);
324 bool TreatUnavailableAsInvalid);
348 bool FillWithNoInit);
349 void FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
352 bool FillWithNoInit =
false);
355 bool FillWithNoInit =
false);
358 bool TopLevelObject);
365 bool TreatUnavailableAsInvalid);
366 bool HadError() {
return hadError; }
370 InitListExpr *getFullyStructuredList()
const {
return FullyStructuredList; }
379 bool TreatUnavailableAsInvalid) {
390 bool EmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
403 InitExpr = VerifyOnly ? &DummyInitList :
new (SemaRef.
Context)
426 assert(O ==
OR_Success &&
"Inconsistent overload resolution");
433 bool IsInStd =
false;
434 for (
NamespaceDecl *ND = dyn_cast<NamespaceDecl>(R->getDeclContext());
435 ND && !IsInStd; ND = dyn_cast<
NamespaceDecl>(ND->getParent())) {
440 if (IsInStd && llvm::StringSwitch<bool>(R->getName())
441 .Cases(
"basic_string",
"deque",
"forward_list",
true)
442 .Cases(
"list",
"map",
"multimap",
"multiset",
true)
443 .Cases(
"priority_queue",
"queue",
"set",
"stack",
true)
444 .Cases(
"unordered_map",
"unordered_set",
"vector",
true)
450 TreatUnavailableAsInvalid);
455 diag::warn_invalid_initializer_from_system_header);
458 diag::note_used_in_initialization_here);
460 SemaRef.
Diag(Loc, diag::note_used_in_initialization_here);
467 InitSeq.
Diagnose(SemaRef, Entity, Kind, SubInit);
470 diag::note_in_omitted_aggregate_initializer)
473 bool IsTrailingArrayNewMember =
476 SemaRef.
Diag(Loc, diag::note_in_omitted_aggregate_initializer)
477 << (IsTrailingArrayNewMember ? 2 : 0)
484 return VerifyOnly ?
ExprResult(static_cast<Expr *>(
nullptr))
485 : InitSeq.
Perform(SemaRef, Entity, Kind, SubInit);
491 "CheckEmptyInitializable is only inteded for verification mode.");
492 if (PerformEmptyInit(SemaRef, Loc, Entity,
true,
497 void InitListChecker::FillInEmptyInitForBase(
500 bool &RequiresSecondPass,
bool FillWithNoInit) {
501 assert(Init < ILE->getNumInits() &&
"should have been expanded");
504 SemaRef.
Context, &Base,
false, &ParentEntity);
509 : PerformEmptyInit(SemaRef, ILE->
getLocEnd(), BaseEntity,
511 TreatUnavailableAsInvalid);
519 dyn_cast<InitListExpr>(ILE->
getInit(Init))) {
520 FillInEmptyInitializations(BaseEntity, InnerILE,
521 RequiresSecondPass, FillWithNoInit);
523 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init))) {
524 FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
525 RequiresSecondPass,
true);
529 void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
532 bool &RequiresSecondPass,
533 bool FillWithNoInit) {
540 if (!RType->getDecl()->isUnion())
541 assert(Init < NumInits &&
"This ILE should have been expanded");
543 if (Init >= NumInits || !ILE->
getInit(Init)) {
544 if (FillWithNoInit) {
566 RequiresSecondPass =
true;
576 SemaRef.
Diag(Loc, diag::err_init_reference_member_uninitialized)
580 diag::note_uninit_reference_member);
585 ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
587 TreatUnavailableAsInvalid);
595 }
else if (Init < NumInits) {
597 }
else if (!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
603 RequiresSecondPass =
true;
606 = dyn_cast<InitListExpr>(ILE->
getInit(Init)))
607 FillInEmptyInitializations(MemberEntity, InnerILE,
608 RequiresSecondPass, FillWithNoInit);
610 = dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init)))
611 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
612 RequiresSecondPass,
true);
621 bool &RequiresSecondPass,
622 bool FillWithNoInit) {
624 "Should not have void type");
635 Entity, ILE, RequiresSecondPass, FillWithNoInit);
636 else if (RDecl->
isUnion() && isa<CXXRecordDecl>(RDecl) &&
637 cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) {
638 for (
auto *Field : RDecl->
fields()) {
640 FillInEmptyInitForField(0, Field, Entity, ILE, RequiresSecondPass,
649 unsigned NumElems = numStructUnionElements(ILE->getType());
652 if (ILE->getNumInits() < NumElems)
653 ILE->resizeInits(SemaRef.
Context, NumElems);
657 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RDecl)) {
658 for (
auto &Base : CXXRD->bases()) {
662 FillInEmptyInitForBase(Init, Base, Entity, ILE, RequiresSecondPass,
668 for (
auto *Field : RDecl->
fields()) {
675 FillInEmptyInitForField(Init, Field, Entity, ILE, RequiresSecondPass,
695 unsigned NumElements = NumInits;
697 ElementType = AType->getElementType();
698 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
699 NumElements = CAType->getSize().getZExtValue();
707 ElementType = VType->getElementType();
708 NumElements = VType->getNumElements();
714 for (
unsigned Init = 0; Init != NumElements; ++Init) {
722 Expr *InitExpr = (Init < NumInits ? ILE->
getInit(Init) :
nullptr);
723 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
726 Expr *Filler =
nullptr;
734 TreatUnavailableAsInvalid);
745 }
else if (Init < NumInits) {
760 if (!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
766 RequiresSecondPass =
true;
770 = dyn_cast_or_null<InitListExpr>(InitExpr))
771 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
774 = dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr))
775 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
776 RequiresSecondPass,
true);
783 bool TreatUnavailableAsInvalid)
784 : SemaRef(S), VerifyOnly(VerifyOnly),
785 TreatUnavailableAsInvalid(TreatUnavailableAsInvalid) {
791 FullyStructuredList =
792 getStructuredSubobjectInit(IL, 0, T,
nullptr, 0, IL->
getSourceRange());
793 CheckExplicitInitList(Entity, IL, T, FullyStructuredList,
796 if (!hadError && !VerifyOnly) {
797 bool RequiresSecondPass =
false;
798 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass);
799 if (RequiresSecondPass && !hadError)
800 FillInEmptyInitializations(Entity, FullyStructuredList,
805 int InitListChecker::numArrayElements(
QualType DeclType) {
807 int maxElements = 0x7FFFFFFF;
810 maxElements =
static_cast<int>(CAT->getSize().getZExtValue());
815 int InitListChecker::numStructUnionElements(
QualType DeclType) {
817 int InitializableMembers = 0;
818 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(structDecl))
819 InitializableMembers += CXXRD->getNumBases();
820 for (
const auto *Field : structDecl->
fields())
822 ++InitializableMembers;
825 return std::min(InitializableMembers, 1);
847 if (
CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ParentRD))
848 if (CXXRD->getNumBases())
851 auto FieldIt = ParentRD->field_begin();
852 assert(FieldIt != ParentRD->field_end() &&
853 "no fields but have initializer for member?");
854 return ++FieldIt == ParentRD->field_end();
867 unsigned &StructuredIndex) {
871 maxElements = numArrayElements(T);
873 maxElements = numStructUnionElements(T);
877 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
879 if (maxElements == 0) {
882 diag::err_implicit_empty_initializer);
890 = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList,
894 unsigned StructuredSubobjectInitIndex = 0;
897 unsigned StartIndex = Index;
898 CheckListElementTypes(Entity, ParentIList, T,
900 StructuredSubobjectInitList,
901 StructuredSubobjectInitIndex);
904 StructuredSubobjectInitList->
setType(T);
906 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
909 if (EndIndex < ParentIList->getNumInits() &&
910 ParentIList->
getInit(EndIndex)) {
921 diag::warn_missing_braces)
927 StructuredSubobjectInitList->
getLocEnd()),
953 DiagID = diag::warn_braces_around_scalar_init;
960 DiagID = diag::warn_braces_around_scalar_init;
985 llvm_unreachable(
"unexpected braced scalar init");
1004 bool TopLevelObject) {
1006 SyntacticToSemantic[IList] = StructuredList;
1010 unsigned Index = 0, StructuredIndex = 0;
1011 CheckListElementTypes(Entity, IList, T,
true,
1012 Index, StructuredList, StructuredIndex, TopLevelObject);
1018 StructuredList->
setType(ExprTy);
1023 if (Index < IList->getNumInits()) {
1034 if (StructuredIndex == 1 &&
1037 unsigned DK = diag::ext_excess_initializers_in_char_array_initializer;
1039 DK = diag::err_excess_initializers_in_char_array_initializer;
1056 unsigned DK = diag::ext_excess_initializers;
1058 DK = diag::err_excess_initializers;
1061 if (SemaRef.
getLangOpts().OpenCL && initKind == 1) {
1062 DK = diag::err_excess_initializers;
1079 bool SubobjectIsDesignatorContext,
1082 unsigned &StructuredIndex,
1083 bool TopLevelObject) {
1087 CheckComplexType(Entity, IList, DeclType, Index,
1088 StructuredList, StructuredIndex);
1090 CheckScalarType(Entity, IList, DeclType, Index,
1091 StructuredList, StructuredIndex);
1093 CheckVectorType(Entity, IList, DeclType, Index,
1094 StructuredList, StructuredIndex);
1097 "non-aggregate records should be handed in CheckSubElementType");
1102 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
1103 Bases = CXXRD->bases();
1104 CheckStructUnionTypes(Entity, IList, DeclType, Bases, RD->field_begin(),
1105 SubobjectIsDesignatorContext, Index, StructuredList,
1106 StructuredIndex, TopLevelObject);
1111 CheckArrayType(Entity, IList, DeclType, Zero,
1112 SubobjectIsDesignatorContext, Index,
1113 StructuredList, StructuredIndex);
1118 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1122 CheckReferenceType(Entity, IList, DeclType, Index,
1123 StructuredList, StructuredIndex);
1131 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1142 unsigned &StructuredIndex) {
1146 return CheckReferenceType(Entity, IList, ElemType, Index,
1147 StructuredList, StructuredIndex);
1149 if (
InitListExpr *SubInitList = dyn_cast<InitListExpr>(expr)) {
1150 if (SubInitList->getNumInits() == 1 &&
1153 expr = SubInitList->getInit(0);
1156 = getStructuredSubobjectInit(IList, Index, ElemType,
1157 StructuredList, StructuredIndex,
1159 CheckExplicitInitList(Entity, SubInitList, ElemType,
1160 InnerStructuredList);
1162 if (!hadError && !VerifyOnly) {
1163 bool RequiresSecondPass =
false;
1164 FillInEmptyInitializations(Entity, InnerStructuredList,
1165 RequiresSecondPass);
1166 if (RequiresSecondPass && !hadError)
1167 FillInEmptyInitializations(Entity, InnerStructuredList,
1168 RequiresSecondPass);
1175 }
else if (isa<ImplicitValueInitExpr>(expr)) {
1179 "found implicit initialization for the wrong type");
1181 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1203 if (Seq || isa<InitListExpr>(expr)) {
1206 Seq.Perform(SemaRef, Entity, Kind, expr);
1210 UpdateStructuredListElement(StructuredList, StructuredIndex,
1221 return CheckScalarType(Entity, IList, ElemType, Index,
1222 StructuredList, StructuredIndex);
1232 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1262 UpdateStructuredListElement(StructuredList, StructuredIndex,
1280 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1300 unsigned &StructuredIndex) {
1301 assert(Index == 0 &&
"Index in explicit init list must be zero");
1311 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1316 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1325 for (
unsigned i = 0; i < 2; ++i) {
1327 CheckSubElementType(ElementEntity, IList, elementType, Index,
1328 StructuredList, StructuredIndex);
1336 unsigned &StructuredIndex) {
1341 diag::warn_cxx98_compat_empty_scalar_initializer :
1342 diag::err_empty_scalar_initializer)
1351 if (
InitListExpr *SubIList = dyn_cast<InitListExpr>(expr)) {
1355 SemaRef.
Diag(SubIList->getLocStart(),
1356 diag::ext_many_braces_around_scalar_init)
1357 << SubIList->getSourceRange();
1359 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1362 }
else if (isa<DesignatedInitExpr>(expr)) {
1365 diag::err_designator_for_scalar_init)
1384 Expr *ResultExpr =
nullptr;
1391 if (ResultExpr != expr) {
1393 IList->
setInit(Index, ResultExpr);
1399 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1407 unsigned &StructuredIndex) {
1415 diag::err_init_reference_member_uninitialized)
1425 if (isa<InitListExpr>(expr) && !SemaRef.
getLangOpts().CPlusPlus11) {
1455 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1463 unsigned &StructuredIndex) {
1466 unsigned numEltsInit = 0;
1472 CheckEmptyInitializable(
1494 Expr *ResultExpr =
nullptr;
1500 if (ResultExpr != Init) {
1502 IList->
setInit(Index, ResultExpr);
1508 UpdateStructuredListElement(StructuredList, StructuredIndex,
1517 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1521 CheckEmptyInitializable(ElementEntity, IList->
getLocEnd());
1526 CheckSubElementType(ElementEntity, IList, elementType, Index,
1527 StructuredList, StructuredIndex);
1548 diag::warn_neon_vector_initializer_non_portable);
1550 const char *typeCode;
1560 llvm_unreachable(
"Invalid element type!");
1564 diag::note_neon_vector_initializer_non_portable_q :
1565 diag::note_neon_vector_initializer_non_portable)
1566 << typeCode << typeSize;
1576 for (
unsigned i = 0; i < maxElements; ++i) {
1585 CheckSubElementType(ElementEntity, IList, elementType, Index,
1586 StructuredList, StructuredIndex);
1598 CheckSubElementType(ElementEntity, IList, VecType, Index,
1599 StructuredList, StructuredIndex);
1600 numEltsInit += numIElts;
1605 if (numEltsInit != maxElements) {
1608 diag::err_vector_incorrect_num_initializers)
1609 << (numEltsInit < maxElements) << maxElements << numEltsInit;
1616 llvm::APSInt elementIndex,
1617 bool SubobjectIsDesignatorContext,
1620 unsigned &StructuredIndex) {
1624 if (Index < IList->getNumInits()) {
1634 UpdateStructuredListElement(StructuredList, StructuredIndex,
1647 SemaRef.
Diag(VAT->getSizeExpr()->getLocStart(),
1648 diag::err_variable_object_no_init)
1649 << VAT->getSizeExpr()->getSourceRange();
1657 llvm::APSInt maxElements(elementIndex.getBitWidth(),
1658 elementIndex.isUnsigned());
1659 bool maxElementsKnown =
false;
1661 maxElements = CAT->getSize();
1662 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
1663 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1664 maxElementsKnown =
true;
1668 while (Index < IList->getNumInits()) {
1674 if (!SubobjectIsDesignatorContext)
1679 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1680 DeclType,
nullptr, &elementIndex, Index,
1681 StructuredList, StructuredIndex,
true,
1687 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
1688 maxElements = maxElements.extend(elementIndex.getBitWidth());
1689 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
1690 elementIndex = elementIndex.extend(maxElements.getBitWidth());
1691 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1695 if (!maxElementsKnown && elementIndex > maxElements)
1696 maxElements = elementIndex;
1703 if (maxElementsKnown && elementIndex == maxElements)
1710 CheckSubElementType(ElementEntity, IList, elementType, Index,
1711 StructuredList, StructuredIndex);
1716 if (!maxElementsKnown && elementIndex > maxElements)
1717 maxElements = elementIndex;
1722 llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
1727 diag::ext_typecheck_zero_array_size);
1733 if (!hadError && VerifyOnly) {
1739 if ((maxElementsKnown && elementIndex < maxElements) ||
1750 bool TopLevelObject) {
1752 unsigned FlexArrayDiag;
1753 if (isa<InitListExpr>(InitExpr) &&
1754 cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
1756 FlexArrayDiag = diag::ext_flexible_array_init;
1760 FlexArrayDiag = diag::err_flexible_array_init;
1761 }
else if (!TopLevelObject) {
1763 FlexArrayDiag = diag::err_flexible_array_init;
1766 FlexArrayDiag = diag::err_flexible_array_init;
1767 }
else if (cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
1769 FlexArrayDiag = diag::err_flexible_array_init;
1772 FlexArrayDiag = diag::ext_flexible_array_init;
1783 return FlexArrayDiag != diag::ext_flexible_array_init;
1786 void InitListChecker::CheckStructUnionTypes(
1789 bool SubobjectIsDesignatorContext,
unsigned &Index,
1790 InitListExpr *StructuredList,
unsigned &StructuredIndex,
1791 bool TopLevelObject) {
1807 if (isa<CXXRecordDecl>(RD) && cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
1811 Field != FieldEnd; ++Field) {
1812 if (Field->hasInClassInitializer()) {
1823 Field != FieldEnd; ++Field) {
1824 if (!Field->isUnnamedBitfield()) {
1826 CheckEmptyInitializable(
1837 bool InitializedSomething =
false;
1840 for (
auto &Base : Bases) {
1846 if (Init && isa<DesignatedInitExpr>(Init))
1850 SemaRef.
Context, &Base,
false, &Entity);
1852 CheckSubElementType(BaseEntity, IList, Base.
getType(), Index,
1853 StructuredList, StructuredIndex);
1854 InitializedSomething =
true;
1855 }
else if (VerifyOnly) {
1856 CheckEmptyInitializable(BaseEntity, InitLoc);
1866 bool CheckForMissingFields =
1869 while (Index < IList->getNumInits()) {
1876 if (!SubobjectIsDesignatorContext)
1881 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1882 DeclType, &Field,
nullptr, Index,
1883 StructuredList, StructuredIndex,
1884 true, TopLevelObject))
1887 InitializedSomething =
true;
1891 CheckForMissingFields =
false;
1895 if (Field == FieldEnd) {
1901 if (InitializedSomething && DeclType->
isUnionType())
1905 if (Field->getType()->isIncompleteArrayType())
1908 if (Field->isUnnamedBitfield()) {
1917 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
1930 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1931 StructuredList, StructuredIndex);
1932 InitializedSomething =
true;
1936 StructuredList->setInitializedFieldInUnion(*Field);
1943 if (!VerifyOnly && InitializedSomething && CheckForMissingFields &&
1944 Field != FieldEnd && !Field->getType()->isIncompleteArrayType() &&
1950 if (!it->isUnnamedBitfield() && !it->hasInClassInitializer()) {
1952 diag::warn_missing_field_initializers) << *it;
1959 if (VerifyOnly && Field != FieldEnd && !DeclType->
isUnionType() &&
1960 !Field->getType()->isIncompleteArrayType()) {
1962 for (; Field != FieldEnd && !hadError; ++Field) {
1963 if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
1964 CheckEmptyInitializable(
1970 if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
1974 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
1984 if (isa<InitListExpr>(IList->
getInit(Index)))
1985 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1986 StructuredList, StructuredIndex);
1988 CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index,
1989 StructuredList, StructuredIndex);
2005 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
2013 assert(isa<FieldDecl>(*PI));
2014 Replacements.back().setField(cast<FieldDecl>(*PI));
2021 &Replacements[0] + Replacements.size());
2028 for (
unsigned I = 0; I < NumIndexExprs; ++I)
2042 explicit FieldInitializerValidatorCCC(
RecordDecl *RD)
2045 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2098 llvm::APSInt *NextElementIndex,
2101 unsigned &StructuredIndex,
2102 bool FinishSubobjectInit,
2103 bool TopLevelObject) {
2104 if (DesigIdx == DIE->
size()) {
2106 bool prevHadError = hadError;
2111 unsigned OldIndex = Index;
2114 CheckSubElementType(Entity, IList, CurrentObjectType, Index,
2115 StructuredList, StructuredIndex);
2121 IList->
setInit(OldIndex, DIE);
2123 return hadError && !prevHadError;
2127 bool IsFirstDesignator = (DesigIdx == 0);
2129 assert((IsFirstDesignator || StructuredList) &&
2130 "Need a non-designated initializer list to start from");
2134 if (IsFirstDesignator)
2135 StructuredList = SyntacticToSemantic.lookup(IList);
2137 Expr *ExistingInit = StructuredIndex < StructuredList->
getNumInits() ?
2138 StructuredList->
getInit(StructuredIndex) :
nullptr;
2144 getStructuredSubobjectInit(IList, Index, CurrentObjectType,
2145 StructuredList, StructuredIndex,
2152 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2153 StructuredList = E->getUpdater();
2184 diag::warn_subobject_initializer_overrides)
2188 diag::note_previous_initializer)
2194 assert(StructuredList &&
"Expected a structured initializer list");
2213 SemaRef.
Diag(Loc, diag::err_field_designator_non_aggr)
2214 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2224 if (
auto *FD = dyn_cast<FieldDecl>(ND)) {
2228 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND)) {
2234 KnownField = cast<FieldDecl>(*IFD->chain_begin());
2245 if (!Lookup.empty()) {
2248 SemaRef.
Diag(Lookup.front()->getLocation(),
2249 diag::note_field_designator_found);
2259 llvm::make_unique<FieldInitializerValidatorCCC>(RT->
getDecl()),
2263 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2264 << FieldName << CurrentObjectType);
2265 KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2270 << FieldName << CurrentObjectType;
2277 unsigned FieldIndex = 0;
2279 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RT->
getDecl()))
2280 FieldIndex = CXXRD->getNumBases();
2283 if (FI->isUnnamedBitfield())
2303 &&
"A union should never have more than one initializer!");
2309 diag::warn_initializer_overrides)
2311 SemaRef.
Diag(ExistingInit->getLocStart(),
2312 diag::note_previous_initializer)
2314 << ExistingInit->getSourceRange();
2329 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2348 if (Field->getType()->isIncompleteArrayType()) {
2349 bool Invalid =
false;
2350 if ((DesigIdx + 1) != DIE->
size()) {
2357 diag::err_designator_into_flexible_array_member)
2360 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2366 if (!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
2367 !isa<StringLiteral>(DIE->
getInit())) {
2371 diag::err_flexible_array_init_needs_braces)
2373 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2380 if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
2390 bool prevHadError = hadError;
2391 unsigned newStructuredIndex = FieldIndex;
2392 unsigned OldIndex = Index;
2397 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2398 StructuredList, newStructuredIndex);
2400 IList->
setInit(OldIndex, DIE);
2401 if (hadError && !prevHadError) {
2406 StructuredIndex = FieldIndex;
2411 QualType FieldType = Field->getType();
2412 unsigned newStructuredIndex = FieldIndex;
2416 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
2417 FieldType,
nullptr,
nullptr, Index,
2418 StructuredList, newStructuredIndex,
2419 FinishSubobjectInit,
false))
2430 if (IsFirstDesignator) {
2433 StructuredIndex = FieldIndex;
2437 if (!FinishSubobjectInit)
2445 bool prevHadError = hadError;
2450 CheckStructUnionTypes(Entity, IList, CurrentObjectType, NoBases, Field,
2451 false, Index, StructuredList, FieldIndex);
2452 return hadError && !prevHadError;
2474 << CurrentObjectType;
2479 Expr *IndexExpr =
nullptr;
2480 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
2484 DesignatedEndIndex = DesignatedStartIndex;
2488 DesignatedStartIndex =
2490 DesignatedEndIndex =
2499 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
2501 FullyStructuredList->sawArrayRangeDesignator();
2504 if (isa<ConstantArrayType>(AT)) {
2505 llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
2506 DesignatedStartIndex
2507 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
2508 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
2510 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
2511 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
2512 if (DesignatedEndIndex >= MaxElements) {
2515 diag::err_array_designator_too_large)
2516 << DesignatedEndIndex.toString(10) << MaxElements.toString(10)
2522 unsigned DesignatedIndexBitWidth =
2524 DesignatedStartIndex =
2525 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
2526 DesignatedEndIndex =
2527 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
2528 DesignatedStartIndex.setIsUnsigned(
true);
2529 DesignatedEndIndex.setIsUnsigned(
true);
2545 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
2549 uint64_t StrLen = SL->getLength();
2550 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2551 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2556 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2557 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
2559 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2560 if (CharTy != PromotedCharTy)
2563 StructuredList->
updateInit(Context, i, Init);
2571 uint64_t StrLen = Str.size();
2572 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2573 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2578 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2579 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
2581 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2582 if (CharTy != PromotedCharTy)
2585 StructuredList->
updateInit(Context, i, Init);
2593 DesignatedEndIndex.getZExtValue() >= StructuredList->
getNumInits())
2595 DesignatedEndIndex.getZExtValue() + 1);
2601 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
2602 unsigned OldIndex = Index;
2607 while (DesignatedStartIndex <= DesignatedEndIndex) {
2613 if (CheckDesignatedInitializer(
2614 ElementEntity, IList, DIE, DesigIdx + 1, ElementType,
nullptr,
2615 nullptr, Index, StructuredList, ElementIndex,
2616 FinishSubobjectInit && (DesignatedStartIndex == DesignatedEndIndex),
2621 ++DesignatedStartIndex;
2622 ElementIndex = DesignatedStartIndex.getZExtValue();
2627 if (IsFirstDesignator) {
2628 if (NextElementIndex)
2629 *NextElementIndex = DesignatedStartIndex;
2630 StructuredIndex = ElementIndex;
2634 if (!FinishSubobjectInit)
2638 bool prevHadError = hadError;
2639 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
2641 StructuredList, ElementIndex);
2642 return hadError && !prevHadError;
2648 InitListChecker::getStructuredSubobjectInit(
InitListExpr *IList,
unsigned Index,
2651 unsigned StructuredIndex,
2653 bool IsFullyOverwritten) {
2656 Expr *ExistingInit =
nullptr;
2657 if (!StructuredList)
2658 ExistingInit = SyntacticToSemantic.lookup(IList);
2659 else if (StructuredIndex < StructuredList->getNumInits())
2660 ExistingInit = StructuredList->
getInit(StructuredIndex);
2671 if (!IsFullyOverwritten)
2687 diag::warn_subobject_initializer_overrides)
2690 diag::note_previous_initializer)
2700 QualType ResultType = CurrentObjectType;
2706 unsigned NumElements = 0;
2707 unsigned NumInits = 0;
2708 bool GotNumInits =
false;
2709 if (!StructuredList) {
2712 }
else if (Index < IList->getNumInits()) {
2714 NumInits = SubList->getNumInits();
2722 NumElements = CAType->getSize().getZExtValue();
2725 if (GotNumInits && NumElements > NumInits)
2729 NumElements = VType->getNumElements();
2746 SyntacticToSemantic[IList] =
Result;
2754 void InitListChecker::UpdateStructuredListElement(
InitListExpr *StructuredList,
2755 unsigned &StructuredIndex,
2758 if (!StructuredList)
2762 StructuredIndex, expr)) {
2770 if (PrevInit->getSourceRange().isValid()) {
2772 diag::warn_initializer_overrides)
2775 SemaRef.
Diag(PrevInit->getLocStart(),
2776 diag::note_previous_initializer)
2778 << PrevInit->getSourceRange();
2801 if (Value.isSigned() && Value.isNegative())
2802 return S.
Diag(Loc, diag::err_array_designator_negative)
2805 Value.setIsUnsigned(
true);
2815 bool Invalid =
false;
2830 llvm::APSInt IndexValue;
2836 Designators.push_back(ASTDesignator(InitExpressions.size(),
2839 InitExpressions.push_back(Index);
2847 llvm::APSInt StartValue;
2848 llvm::APSInt EndValue;
2853 if (!StartDependent)
2859 if (!StartIndex || !EndIndex)
2863 if (StartDependent || EndDependent) {
2865 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
2866 EndValue = EndValue.extend(StartValue.getBitWidth());
2867 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
2868 StartValue = StartValue.extend(EndValue.getBitWidth());
2870 if (!StartDependent && !EndDependent && EndValue < StartValue) {
2872 << StartValue.toString(10) << EndValue.toString(10)
2876 Designators.push_back(ASTDesignator(InitExpressions.size(),
2880 InitExpressions.push_back(StartIndex);
2881 InitExpressions.push_back(EndIndex);
2898 InitExpressions, Loc, GNUSyntax,
2901 if (!getLangOpts().
C99)
2912 InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
2914 :
Parent(&Parent), Index(Index)
2917 Kind = EK_ArrayElement;
2918 Type = AT->getElementType();
2920 Kind = EK_VectorElement;
2921 Type = VT->getElementType();
2924 assert(CT &&
"Unexpected type");
2925 Kind = EK_ComplexElement;
2933 bool IsInheritedVirtualBase,
2936 Result.Kind = EK_Base;
2939 if (IsInheritedVirtualBase)
2940 Result.
Base |= 0x01;
2942 Result.Type = Base->
getType();
2949 case EK_Parameter_CF_Audited: {
2957 return Variable.VariableOrMember->getDeclName();
2959 case EK_LambdaCapture:
2968 case EK_ArrayElement:
2969 case EK_VectorElement:
2970 case EK_ComplexElement:
2971 case EK_BlockElement:
2972 case EK_LambdaToBlockConversionBlockElement:
2973 case EK_CompoundLiteralInit:
2974 case EK_RelatedResult:
2978 llvm_unreachable(
"Invalid EntityKind!");
2986 return Variable.VariableOrMember;
2989 case EK_Parameter_CF_Audited:
2998 case EK_ArrayElement:
2999 case EK_VectorElement:
3000 case EK_ComplexElement:
3001 case EK_BlockElement:
3002 case EK_LambdaToBlockConversionBlockElement:
3003 case EK_LambdaCapture:
3004 case EK_CompoundLiteralInit:
3005 case EK_RelatedResult:
3009 llvm_unreachable(
"Invalid EntityKind!");
3016 return LocAndNRVO.NRVO;
3020 case EK_Parameter_CF_Audited:
3025 case EK_CompoundLiteralInit:
3028 case EK_ArrayElement:
3029 case EK_VectorElement:
3030 case EK_ComplexElement:
3031 case EK_BlockElement:
3032 case EK_LambdaToBlockConversionBlockElement:
3033 case EK_LambdaCapture:
3034 case EK_RelatedResult:
3041 unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
3042 assert(getParent() !=
this);
3043 unsigned Depth = getParent() ? getParent()->dumpImpl(OS) : 0;
3044 for (
unsigned I = 0; I !=
Depth; ++I)
3048 case EK_Variable: OS <<
"Variable";
break;
3049 case EK_Parameter: OS <<
"Parameter";
break;
3050 case EK_Parameter_CF_Audited: OS <<
"CF audited function Parameter";
3052 case EK_Result: OS <<
"Result";
break;
3053 case EK_Exception: OS <<
"Exception";
break;
3054 case EK_Member: OS <<
"Member";
break;
3055 case EK_Binding: OS <<
"Binding";
break;
3056 case EK_New: OS <<
"New";
break;
3057 case EK_Temporary: OS <<
"Temporary";
break;
3058 case EK_CompoundLiteralInit: OS <<
"CompoundLiteral";
break;
3059 case EK_RelatedResult: OS <<
"RelatedResult";
break;
3060 case EK_Base: OS <<
"Base";
break;
3061 case EK_Delegating: OS <<
"Delegating";
break;
3062 case EK_ArrayElement: OS <<
"ArrayElement " << Index;
break;
3063 case EK_VectorElement: OS <<
"VectorElement " << Index;
break;
3064 case EK_ComplexElement: OS <<
"ComplexElement " << Index;
break;
3065 case EK_BlockElement: OS <<
"Block";
break;
3066 case EK_LambdaToBlockConversionBlockElement:
3067 OS <<
"Block (lambda)";
3069 case EK_LambdaCapture:
3070 OS <<
"LambdaCapture ";
3075 if (
auto *D = getDecl()) {
3077 D->printQualifiedName(OS);
3080 OS <<
" '" << getType().getAsString() <<
"'\n";
3086 dumpImpl(llvm::errs());
3095 case SK_ResolveAddressOfOverloadedFunction:
3096 case SK_CastDerivedToBaseRValue:
3097 case SK_CastDerivedToBaseXValue:
3098 case SK_CastDerivedToBaseLValue:
3099 case SK_BindReference:
3100 case SK_BindReferenceToTemporary:
3102 case SK_ExtraneousCopyToTemporary:
3103 case SK_UserConversion:
3104 case SK_QualificationConversionRValue:
3105 case SK_QualificationConversionXValue:
3106 case SK_QualificationConversionLValue:
3107 case SK_AtomicConversion:
3108 case SK_LValueToRValue:
3109 case SK_ListInitialization:
3110 case SK_UnwrapInitList:
3111 case SK_RewrapInitList:
3112 case SK_ConstructorInitialization:
3113 case SK_ConstructorInitializationFromList:
3114 case SK_ZeroInitialization:
3115 case SK_CAssignment:
3117 case SK_ObjCObjectConversion:
3118 case SK_ArrayLoopIndex:
3119 case SK_ArrayLoopInit:
3121 case SK_GNUArrayInit:
3122 case SK_ParenthesizedArrayInit:
3123 case SK_PassByIndirectCopyRestore:
3124 case SK_PassByIndirectRestore:
3125 case SK_ProduceObjCObject:
3126 case SK_StdInitializerList:
3127 case SK_StdInitializerListConstructorCall:
3128 case SK_OCLSamplerInit:
3129 case SK_OCLZeroEvent:
3130 case SK_OCLZeroQueue:
3133 case SK_ConversionSequence:
3134 case SK_ConversionSequenceNoNarrowing:
3141 for (
auto I = Steps.rbegin(); I != Steps.rend(); ++I) {
3142 if (I->Kind == SK_BindReference)
3144 if (I->Kind == SK_BindReferenceToTemporary)
3154 switch (getFailureKind()) {
3155 case FK_TooManyInitsForReference:
3156 case FK_ParenthesizedListInitForReference:
3157 case FK_ArrayNeedsInitList:
3158 case FK_ArrayNeedsInitListOrStringLiteral:
3159 case FK_ArrayNeedsInitListOrWideStringLiteral:
3160 case FK_NarrowStringIntoWideCharArray:
3161 case FK_WideStringIntoCharArray:
3162 case FK_IncompatWideStringIntoWideChar:
3163 case FK_AddressOfOverloadFailed:
3164 case FK_NonConstLValueReferenceBindingToTemporary:
3165 case FK_NonConstLValueReferenceBindingToBitfield:
3166 case FK_NonConstLValueReferenceBindingToVectorElement:
3167 case FK_NonConstLValueReferenceBindingToUnrelated:
3168 case FK_RValueReferenceBindingToLValue:
3169 case FK_ReferenceInitDropsQualifiers:
3170 case FK_ReferenceInitFailed:
3171 case FK_ConversionFailed:
3172 case FK_ConversionFromPropertyFailed:
3173 case FK_TooManyInitsForScalar:
3174 case FK_ParenthesizedListInitForScalar:
3175 case FK_ReferenceBindingToInitList:
3176 case FK_InitListBadDestinationType:
3177 case FK_DefaultInitOfConst:
3179 case FK_ArrayTypeMismatch:
3180 case FK_NonConstantArrayInit:
3181 case FK_ListInitializationFailed:
3182 case FK_VariableLengthArrayHasInitializer:
3183 case FK_PlaceholderType:
3184 case FK_ExplicitConstructor:
3185 case FK_AddressOfUnaddressableFunction:
3188 case FK_ReferenceInitOverloadFailed:
3189 case FK_UserConversionOverloadFailed:
3190 case FK_ConstructorOverloadFailed:
3191 case FK_ListConstructorOverloadFailed:
3195 llvm_unreachable(
"Invalid EntityKind!");
3199 return !Steps.empty() && Steps.back().Kind == SK_ConstructorInitialization;
3206 bool HadMultipleCandidates) {
3208 S.
Kind = SK_ResolveAddressOfOverloadedFunction;
3229 bool BindingTemporary) {
3231 S.
Kind = BindingTemporary? SK_BindReferenceToTemporary : SK_BindReference;
3238 S.
Kind = SK_FinalCopy;
3245 S.
Kind = SK_ExtraneousCopyToTemporary;
3254 bool HadMultipleCandidates) {
3256 S.
Kind = SK_UserConversion;
3267 S.
Kind = SK_QualificationConversionRValue;
3270 S.
Kind = SK_QualificationConversionRValue;
3273 S.
Kind = SK_QualificationConversionXValue;
3276 S.
Kind = SK_QualificationConversionLValue;
3285 S.
Kind = SK_AtomicConversion;
3291 assert(!Ty.
hasQualifiers() &&
"rvalues may not have qualifiers");
3294 S.Kind = SK_LValueToRValue;
3301 bool TopLevelOfInitList) {
3303 S.
Kind = TopLevelOfInitList ? SK_ConversionSequenceNoNarrowing
3304 : SK_ConversionSequence;
3312 S.
Kind = SK_ListInitialization;
3319 bool HadMultipleCandidates,
bool FromInitList,
bool AsInitList) {
3321 S.
Kind = FromInitList ? AsInitList ? SK_StdInitializerListConstructorCall
3322 : SK_ConstructorInitializationFromList
3323 : SK_ConstructorInitialization;
3333 S.
Kind = SK_ZeroInitialization;
3340 S.
Kind = SK_CAssignment;
3347 S.
Kind = SK_StringInit;
3354 S.
Kind = SK_ObjCObjectConversion;
3361 S.
Kind = IsGNUExtension ? SK_GNUArrayInit : SK_ArrayInit;
3368 S.
Kind = SK_ArrayLoopIndex;
3370 Steps.insert(Steps.begin(), S);
3372 S.
Kind = SK_ArrayLoopInit;
3379 S.
Kind = SK_ParenthesizedArrayInit;
3387 s.
Kind = (shouldCopy ? SK_PassByIndirectCopyRestore
3388 : SK_PassByIndirectRestore);
3395 S.
Kind = SK_ProduceObjCObject;
3402 S.
Kind = SK_StdInitializerList;
3409 S.
Kind = SK_OCLSamplerInit;
3416 S.
Kind = SK_OCLZeroEvent;
3423 S.
Kind = SK_OCLZeroQueue;
3431 "Can only rewrap trivial init lists.");
3433 S.Kind = SK_UnwrapInitList;
3435 Steps.insert(Steps.begin(), S);
3437 S.Kind = SK_RewrapInitList;
3439 S.WrappingSyntacticList = Syntactic;
3445 setSequenceKind(FailedSequence);
3446 this->Failure = Failure;
3447 this->FailedOverloadResult =
Result;
3468 if (!Init.empty()) {
3488 "consuming an object of unretainable type?");
3508 bool TreatUnavailableAsInvalid);
3519 bool TreatUnavailableAsInvalid) {
3539 TreatUnavailableAsInvalid);
3569 bool CopyInitializing,
bool AllowExplicit,
3570 bool OnlyListConstructors,
bool IsListInit,
3571 bool SecondStepOfCopyInit =
false) {
3576 if (!Info.Constructor || Info.Constructor->isInvalidDecl())
3579 if (!AllowExplicit && Info.Constructor->isExplicit())
3596 bool SuppressUserConversions =
3597 SecondStepOfCopyInit ||
3598 (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
3601 if (Info.ConstructorTmpl)
3604 CandidateSet, SuppressUserConversions);
3613 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
3617 CandidateSet, SuppressUserConversions,
3634 if (S.
getLangOpts().CPlusPlus17 && Args.size() == 1 &&
3635 !SecondStepOfCopyInit) {
3636 Expr *Initializer = Args[0];
3640 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
3650 Conv = cast<CXXConversionDecl>(D);
3652 if ((AllowExplicit && !CopyInitializing) || !Conv->isExplicit()) {
3655 ActingDC, Initializer, DestType,
3656 CandidateSet, AllowExplicit,
3660 DestType, CandidateSet, AllowExplicit,
3687 bool IsListInit =
false,
3688 bool IsInitListCopy =
false) {
3689 assert(((!IsListInit && !IsInitListCopy) ||
3690 (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3691 "IsListInit/IsInitListCopy must come with a single initializer list " 3694 (IsListInit || IsInitListCopy) ? cast<InitListExpr>(Args[0]) :
nullptr;
3718 UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isRValue() &&
3728 assert(DestRecordType &&
"Constructor initialization requires record type");
3730 = cast<CXXRecordDecl>(DestRecordType->
getDecl());
3748 bool AsInitializerList =
false;
3760 AsInitializerList =
true;
3766 CandidateSet, DestType, Ctors, Best,
3767 CopyInitialization, AllowExplicit,
3778 AsInitializerList =
false;
3780 CandidateSet, DestType, Ctors, Best,
3781 CopyInitialization, AllowExplicit,
3793 bool HadMultipleCandidates = (CandidateSet.size() > 1);
3797 if (
auto *CD = dyn_cast<CXXConversionDecl>(Best->Function)) {
3799 QualType ConvType = CD->getConversionType();
3801 "should not have selected this conversion function");
3803 HadMultipleCandidates);
3840 Best->FoundDecl, CtorDecl, DestArrayType, HadMultipleCandidates,
3841 IsListInit | IsInitListCopy, AsInitializerList);
3854 bool HadMultipleCandidates =
false;
3857 UnqualifiedTargetType,
3859 &HadMultipleCandidates)) {
3861 HadMultipleCandidates);
3862 SourceType = Fn->getType();
3894 bool TreatUnavailableAsInvalid) {
3929 bool dummy1, dummy2, dummy3;
3936 T1Quals, cv2T2, T2, T2Quals, Sequence);
3951 TreatUnavailableAsInvalid);
3968 bool TreatUnavailableAsInvalid) {
3980 TreatUnavailableAsInvalid);
4006 Expr *InitListAsExpr = InitList;
4016 if (!isa<VariableArrayType>(DestAT) &&
4026 TreatUnavailableAsInvalid);
4059 TreatUnavailableAsInvalid))
4063 Expr *InitListAsExpr = InitList;
4065 DestType, Sequence,
true);
4083 ET && ET->getDecl()->isFixed() &&
4139 TreatUnavailableAsInvalid);
4146 InitListChecker CheckInitList(S, Entity, InitList,
4147 DestType,
true, TreatUnavailableAsInvalid);
4148 if (CheckInitList.HadError()) {
4161 Expr *Initializer,
bool AllowRValues,
bool IsLValueRef,
4170 bool ObjCConversion;
4171 bool ObjCLifetimeConversion;
4173 T1, T2, DerivedToBase,
4175 ObjCLifetimeConversion) &&
4176 "Must have incompatible references when binding via conversion");
4177 (void)DerivedToBase;
4178 (void)ObjCConversion;
4179 (void)ObjCLifetimeConversion;
4200 if (!Info.Constructor)
4203 if (!Info.Constructor->isInvalidDecl() &&
4204 Info.Constructor->isConvertingConstructor(AllowExplicit)) {
4205 if (Info.ConstructorTmpl)
4208 Initializer, CandidateSet,
4212 Initializer, CandidateSet,
4228 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4231 if (isa<UsingShadowDecl>(D))
4232 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4239 Conv = cast<CXXConversionDecl>(D);
4247 if ((AllowExplicitConvs || !Conv->isExplicit()) &&
4248 (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){
4251 ActingDC, Initializer,
4252 DestType, CandidateSet,
4257 Initializer, DestType, CandidateSet,
4280 if (isa<CXXConversionDecl>(Function))
4293 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4295 HadMultipleCandidates);
4299 bool NewDerivedToBase =
false;
4300 bool NewObjCConversion =
false;
4301 bool NewObjCLifetimeConversion =
false;
4304 NewDerivedToBase, NewObjCConversion,
4305 NewObjCLifetimeConversion);
4309 assert(!isa<CXXConstructorDecl>(Function) &&
4310 "should not have conversion after constructor");
4314 ICS.
Standard = Best->FinalConversion;
4335 if (NewDerivedToBase)
4337 else if (NewObjCConversion)
4370 T1Quals, cv2T2, T2, T2Quals, Sequence);
4395 bool DerivedToBase =
false;
4396 bool ObjCConversion =
false;
4397 bool ObjCLifetimeConversion =
false;
4401 ObjCConversion, ObjCLifetimeConversion);
4414 if (isLValueRef || T1Function) {
4421 if (T1Quals != T2Quals)
4430 else if (ObjCConversion)
4449 (isLValueRef || InitCategory.
isRValue())) {
4451 S, Entity, Kind, Initializer, isRValueRef,
4452 isLValueRef, Sequence);
4477 switch (RefRelationship) {
4481 FK_NonConstLValueReferenceBindingToBitfield;
4484 FK_NonConstLValueReferenceBindingToVectorElement;
4486 llvm_unreachable(
"unexpected kind of compatible initializer");
4538 if (T1Quals != T2Quals)
4547 else if (ObjCConversion)
4561 S, Entity, Kind, Initializer,
true,
4562 isLValueRef, Sequence);
4572 isRValueRef && InitCategory.
isLValue()) {
4623 (T1CVRQuals | T2CVRQuals) != T1CVRQuals) {
4656 assert((!InitList || InitList->
getNumInits() == 0) &&
4657 "Shouldn't use value-init for non-empty init lists");
4668 if (
CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
4669 bool NeedZeroInitialization =
true;
4684 NeedZeroInitialization =
false;
4692 if (NeedZeroInitialization)
4706 ClassDecl->hasUninitializedReferenceMember()) {
4714 Expr *InitListAsExpr = InitList;
4716 bool InitListSyntax = InitList;
4721 S, Entity, Kind, Args, T, Entity.
getType(), Sequence, InitListSyntax);
4743 if (DestType->isRecordType() && S.
getLangOpts().CPlusPlus) {
4754 if (DestType.isConstQualified() && S.
getLangOpts().CPlusPlus) {
4761 if (DestType.getQualifiers().hasObjCLifetime()) {
4775 bool TopLevelOfInitList) {
4776 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
4778 assert((DestType->
isRecordType() || SourceType->isRecordType()) &&
4779 "Must have a class type to perform a user-defined conversion");
4794 = cast<CXXRecordDecl>(DestRecordType->getDecl());
4800 if (!Info.Constructor)
4803 if (!Info.Constructor->isInvalidDecl() &&
4804 Info.Constructor->isConvertingConstructor(AllowExplicit)) {
4805 if (Info.ConstructorTmpl)
4808 Initializer, CandidateSet,
4812 Initializer, CandidateSet,
4829 = cast<CXXRecordDecl>(SourceRecordType->getDecl());
4831 const auto &Conversions =
4833 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4836 if (isa<UsingShadowDecl>(D))
4837 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4844 Conv = cast<CXXConversionDecl>(D);
4846 if (AllowExplicit || !Conv->isExplicit()) {
4849 ActingDC, Initializer, DestType,
4850 CandidateSet, AllowExplicit);
4853 Initializer, DestType, CandidateSet,
4872 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4874 if (isa<CXXConstructorDecl>(Function)) {
4880 HadMultipleCandidates);
4909 HadMultipleCandidates);
4932 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
4933 Best->FinalConversion.Third) {
4936 ICS.
Standard = Best->FinalConversion;
4954 isa<CXXBoolLiteralExpr>(Init) &&
4955 !cast<CXXBoolLiteralExpr>(Init)->getValue() &&
4964 bool isAddressOf,
bool &isWeakAccess) {
4970 if (op->getOpcode() == UO_AddrOf)
4975 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
4976 switch (ce->getCastKind()) {
4979 case CK_LValueBitCast:
4983 case CK_ArrayToPointerDecay:
4986 case CK_NullToPointer:
4994 }
else if (isa<DeclRefExpr>(e)) {
4998 isWeakAccess =
true;
5002 VarDecl *var = dyn_cast<
VarDecl>(cast<DeclRefExpr>(e)->getDecl());
5016 }
else if (isa<ArraySubscriptExpr>(e)) {
5032 bool isWeakAccess =
false;
5036 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
5042 << ((
unsigned) iik - 1)
5067 Expr *Initializer) {
5068 bool ArrayDecay =
false;
5073 ArgPointee = ArgArrayType->getElementType();
5085 bool ShouldCopy =
true;
5090 if (ArrayDecay || Initializer->
isGLValue()) {
5114 Expr *Initializer) {
5135 Expr *Initializer) {
5148 Expr *Initializer) {
5163 bool TopLevelOfInitList,
5164 bool TreatUnavailableAsInvalid)
5167 TreatUnavailableAsInvalid);
5174 if (!DRE || !isa<FunctionDecl>(DRE->getDecl()))
5178 cast<FunctionDecl>(DRE->getDecl()));
5195 return isa<DecompositionDecl>(Entity.
getDecl());
5221 bool TopLevelOfInitList,
5222 bool TreatUnavailableAsInvalid) {
5229 for (
unsigned I = 0, E = Args.size(); I != E; ++I)
5230 if (Args[I]->getType()->isNonOverloadPlaceholderType()) {
5237 Args[I] = result.
get();
5258 Expr *Initializer =
nullptr;
5259 if (Args.size() == 1) {
5260 Initializer = Args[0];
5263 DestType, Initializer->
getType(),
5266 Args[0] = Initializer;
5268 if (!isa<InitListExpr>(Initializer))
5269 SourceType = Initializer->
getType();
5275 if (
InitListExpr *InitList = dyn_cast_or_null<InitListExpr>(Initializer)) {
5277 TreatUnavailableAsInvalid);
5289 if (Args.size() != 1)
5295 else if (isa<InitListExpr>(Args[0]))
5321 if (Initializer && isa<VariableArrayType>(DestAT)) {
5347 if (Initializer && isa<ConstantArrayType>(DestAT) &&
5365 Expr *OVEAsExpr = &OVE;
5367 TreatUnavailableAsInvalid);
5377 isa<CompoundLiteralExpr>(Initializer->
IgnoreParens()) &&
5393 Initializer && isa<InitListExpr>(Initializer)) {
5395 *
this, TreatUnavailableAsInvalid);
5397 }
else if (DestAT->getElementType()->isCharType())
5409 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
5416 if (allowObjCWritebackConversion &&
5449 DestType, DestType, *
this);
5458 TopLevelOfInitList);
5462 assert(Args.size() >= 1 &&
"Zero-argument case handled above");
5465 if (Args.size() > 1) {
5468 }
else if (isa<InitListExpr>(Args[0])) {
5478 bool NeedAtomicConversion =
false;
5482 Atomic->getValueType())) {
5483 DestType = Atomic->getValueType();
5484 NeedAtomicConversion =
true;
5489 TopLevelOfInitList);
5491 if (!
Failed() && NeedAtomicConversion)
5508 allowObjCWritebackConversion);
5516 bool ShouldCopy =
true;
5532 }
else if (ICS.
isBad()) {
5553 for (
auto &S : Steps)
5604 llvm_unreachable(
"Invalid EntityKind!");
5635 llvm_unreachable(
"missed an InitializedEntity kind?");
5666 llvm_unreachable(
"missed an InitializedEntity kind?");
5671 Expr *Initializer) {
5702 llvm_unreachable(
"missed an InitializedEntity kind?");
5729 bool IsExtraneousCopy) {
5736 Class = cast<CXXRecordDecl>(Record->getDecl());
5754 S, Loc, CurInitExpr, CandidateSet, T, Ctors, Best,
5763 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
5764 : diag::err_temp_copy_no_viable)
5773 S.
Diag(Loc, diag::err_temp_copy_ambiguous)
5780 S.
Diag(Loc, diag::err_temp_copy_deleted)
5787 bool HadMultipleCandidates = CandidateSet.
size() > 1;
5796 if (IsExtraneousCopy) {
5807 for (
unsigned I = 1, N = Constructor->
getNumParams(); I != N; ++I) {
5810 diag::err_call_incomplete_argument))
5850 Best->Function->getParamDecl(0)->getType().getNonReferenceType(),
5857 HadMultipleCandidates,
5875 Expr *CurInitExpr) {
5894 S, Loc, CurInitExpr, CandidateSet, CurInitExpr->
getType(), Ctors, Best,
5906 Best->FoundDecl, Entity, Diag);
5927 void InitializationSequence::PrintInitLocationNote(
Sema &S,
5942 diag::note_method_return_type_change)
5966 return NumArgs != 1;
5978 bool &ConstructorInitRequiresZeroInit,
5979 bool IsListInitialization,
5980 bool IsStdInitListInitialization,
5983 unsigned NumArgs = Args.size();
5998 assert(Constructor->
getParent() &&
"No parent class for constructor.");
6012 bool AllowExplicitConv =
6020 Loc, ConstructorArgs,
6022 IsListInitialization))
6039 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
6050 ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
6051 IsListInitialization, IsStdInitListInitialization,
6052 ConstructorInitRequiresZeroInit);
6068 if (IsListInitialization)
6069 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
6080 HadMultipleCandidates,
6081 IsListInitialization,
6082 IsStdInitListInitialization,
6083 ConstructorInitRequiresZeroInit,
6091 HadMultipleCandidates,
6092 IsListInitialization,
6093 IsStdInitListInitialization,
6094 ConstructorInitRequiresZeroInit,
6151 llvm_unreachable(
"unknown entity kind");
6221 return FallbackDecl;
6231 llvm_unreachable(
"unknown entity kind");
6248 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6261 if (
CastExpr *CE = dyn_cast<CastExpr>(Init))
6262 if (CE->getSubExpr()->isGLValue())
6263 Init = CE->getSubExpr();
6267 if (
auto *ASE = dyn_cast<ArraySubscriptExpr>(Init))
6268 Init = ASE->getBase();
6269 }
while (Init != Old);
6274 ME->setExtendingDecl(ExtendingEntity->
getDecl(),
6291 Init = BTE->getSubExpr();
6294 dyn_cast<CXXStdInitializerListExpr>(Init)) {
6299 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6301 for (
unsigned I = 0, N = ILE->
getNumInits(); I != N; ++I)
6307 assert(RD->isAggregate() &&
"aggregate init on non-aggregate");
6317 for (
const auto *I : RD->fields()) {
6320 if (I->isUnnamedBitfield())
6323 if (I->getType()->isReferenceType())
6325 else if (isa<InitListExpr>(SubInit) ||
6326 isa<CXXStdInitializerListExpr>(SubInit))
6339 const Expr *Init,
bool IsInitializerList,
6342 if (isa<FieldDecl>(ExtendingDecl)) {
6343 if (IsInitializerList) {
6344 S.
Diag(Init->
getExprLoc(), diag::warn_dangling_std_initializer_list)
6349 bool IsSubobjectMember =
false;
6353 IsSubobjectMember =
true;
6358 diag::warn_bind_ref_member_to_temporary)
6360 << IsSubobjectMember << IsInitializerList;
6361 if (IsSubobjectMember)
6363 diag::note_ref_subobject_of_member_declared_here);
6366 diag::note_ref_or_ptr_member_declared_here)
6375 const Expr *PostInit);
6379 bool IsReturnStmt) {
6390 unsigned DiagID = 0;
6426 if (VD->
hasAttr<BlocksAttr>())
6439 if (isa<ParmVarDecl>(VD))
6440 DiagID = diag::warn_redundant_move_on_return;
6442 DiagID = diag::warn_pessimizing_move_on_return;
6444 DiagID = diag::warn_pessimizing_move_on_initialization;
6486 if (UO->getOpcode() == UO_Deref &&
6487 UO->getSubExpr()->IgnoreParenCasts()->
6490 S.
PDiag(diag::warn_binding_null_to_reference)
6491 << UO->getSubExpr()->getSourceRange());
6497 bool BoundToLvalueReference) {
6498 auto MTE =
new (Context)
6507 Cleanup.setExprNeedsCleanups(
false);
6516 if (!E->
isRValue() || !getLangOpts().CPlusPlus11)
6523 if (RequireCompleteType(E->
getExprLoc(),
T, diag::err_incomplete_type))
6526 return CreateMaterializeTemporaryExpr(E->
getType(), E,
false);
6539 if (!ZeroInitializationFixit.empty()) {
6540 unsigned DiagID = diag::err_default_init_const;
6542 if (S.
getLangOpts().MSVCCompat && D->hasAttr<SelectAnyAttr>())
6543 DiagID = diag::ext_default_init_const;
6552 ZeroInitializationFixit);
6571 if (isa<InitListExpr>((
Expr *)Args[0])) {
6575 if (
auto *DD = dyn_cast_or_null<DeclaratorDecl>(Entity.
getDecl())) {
6577 TypeLoc TL = TInfo->getTypeLoc();
6580 Brackets = ArrayLoc.getBracketsRange();
6587 ArrayT->getSizeModifier(),
6588 ArrayT->getIndexTypeCVRQualifiers(),
6612 Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
6617 Expr *Init = Args[0];
6618 S.
Diag(Init->
getLocStart(), diag::warn_cxx98_compat_reference_list_init)
6631 S.
Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << 1 <<
6638 if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
6641 const Expr *Init = Args[0]->skipRValueSubobjectAdjustments();
6642 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
6643 Init = MTE->GetTemporaryExpr();
6646 S.
Diag(Init->
getLocStart(), diag::warn_temporary_array_to_pointer_decay)
6664 switch (Steps.front().Kind) {
6699 assert(Args.size() == 1);
6717 CurInit.
get() && isa<InitListExpr>(CurInit.
get()));
6722 auto checkAbstractType = [&](
QualType T) ->
bool {
6727 diag::err_allocation_of_abstract_type);
6732 bool ConstructorInitRequiresZeroInit =
false;
6763 CurInit.
get()->getLocStart(),
6764 CurInit.
get()->getSourceRange(),
6765 &BasePath, IgnoreBaseAccess))
6776 CurInit.
get(), &BasePath, VK);
6790 if (CurInit.
get()->getType()->isFunctionProtoType()) {
6791 if (
auto *DRE = dyn_cast<DeclRefExpr>(CurInit.
get()->IgnoreParens())) {
6792 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
6794 DRE->getLocStart()))
6815 assert(CurInit.
get()->isRValue() &&
"not a temporary");
6871 bool CreatedObject =
false;
6882 Loc, ConstructorArgs))
6887 FoundFn, Constructor,
6889 HadMultipleCandidates,
6903 CastKind = CK_ConstructorConversion;
6904 CreatedObject =
true;
6918 FoundFn, Conversion);
6924 HadMultipleCandidates);
6928 CastKind = CK_UserDefinedConversion;
6929 CreatedObject = Conversion->getReturnType()->isRecordType();
6932 if (CreatedObject && checkAbstractType(CurInit.
get()->getType()))
6937 CurInit.
get()->getValueKind());
6953 S.
PDiag(diag::err_access_dtor_temp) <<
T);
6977 assert(CurInit.
get()->isRValue() &&
"cannot convert glvalue to atomic");
6984 assert(CurInit.
get()->isGLValue() &&
"cannot load from a prvalue");
6986 CK_LValueToRValue, CurInit.get(),
7006 CurInit = CurInitExprRes;
7027 InitListChecker PerformInitList(S, InitEntity,
7028 InitList, Ty,
false,
7030 if (PerformInitList.HadError())
7038 if ((*ResultType)->isRValueReferenceType())
7040 else if ((*ResultType)->isLValueReferenceType())
7047 PerformInitList.getFullyStructuredList();
7051 : StructuredInitList;
7068 assert(Args.size() == 1 &&
"expected a single argument for list init");
7070 S.
Diag(InitList->getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
7071 << InitList->getSourceRange();
7072 MultiExprArg Arg(InitList->getInits(), InitList->getNumInits());
7076 ConstructorInitRequiresZeroInit,
7079 InitList->getLBraceLoc(),
7080 InitList->getRBraceLoc());
7085 CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
7114 bool IsStdInitListInit =
7118 S, UseTemporary ? TempEntity : Entity, Kind,
7120 ConstructorInitRequiresZeroInit,
7131 if (NextStep != StepEnd &&
7136 ConstructorInitRequiresZeroInit =
true;
7175 CurInit = CurInitExprRes;
7180 InitialCurInit.
get(),
7183 PrintInitLocationNote(S, Entity);
7185 }
else if (Complained)
7186 PrintInitLocationNote(S, Entity);
7199 CK_ObjCObjectLValueCast,
7200 CurInit.
get()->getValueKind());
7212 ArrayLoopCommonExprs.push_back(BaseExpr);
7217 assert(!ArrayLoopCommonExprs.empty() &&
7218 "mismatched SK_ArrayLoopIndex and SK_ArrayLoopInit");
7219 Expr *Common = ArrayLoopCommonExprs.pop_back_val();
7230 << CurInit.
get()->getSourceRange();
7241 IncompleteDest->getElementType(),
7242 ConstantSource->getSize(),
7253 << CurInit.
get()->getSourceRange();
7271 S.
Diag(CurInit.get()->getExprLoc(),
7272 diag::warn_cxx98_compat_initializer_list_init)
7273 << CurInit.get()->getSourceRange();
7277 CurInit.get()->getType(), CurInit.get(),
7316 "Sampler initialization on non-sampler type.");
7317 Expr *Init = CurInit.get();
7318 QualType SourceType = Init->getType();
7325 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Init)) {
7326 auto Var = cast<VarDecl>(DRE->getDecl());
7329 if (!Var->hasGlobalStorage()) {
7331 CK_LValueToRValue, Init,
7341 if (!Var->getInit() || !isa<ImplicitCastExpr>(Var->getInit()))
7343 Init = cast<ImplicitCastExpr>(
const_cast<Expr*
>(
7344 Var->getInit()))->getSubExpr();
7345 SourceType = Init->getType();
7352 if (!Init->isConstantInitializer(S.
Context,
false))
7363 Init->EvaluateAsInt(Result, S.
Context);
7364 const uint64_t SamplerValue = Result.getLimitedValue();
7371 unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
7372 unsigned FilterMode = (0x30 & SamplerValue) >> 4;
7373 if (FilterMode != 1 && FilterMode != 2)
7375 diag::warn_sampler_initializer_invalid_bits)
7377 if (AddressingMode > 4)
7379 diag::warn_sampler_initializer_invalid_bits)
7380 <<
"Addressing Mode";
7386 CK_IntToOCLSampler);
7391 "Event initialization on non-event type.");
7395 CurInit.get()->getValueKind());
7400 "Event initialization on non queue type.");
7404 CurInit.get()->getValueKind());
7412 cast<FieldDecl>(Entity.
getDecl())->isBitField())
7414 cast<FieldDecl>(Entity.
getDecl()),
7418 if (
const Expr *E = CurInit.
get()) {
7431 S.
Diag(Loc, diag::err_reference_without_init)
7440 for (
const auto *FI : RD->
fields()) {
7441 if (FI->isUnnamedBitfield())
7445 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
7450 for (
const auto &BI : RD->
bases()) {
7452 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
7507 if (
auto *D = Entity.
getDecl())
7508 Loc = D->getLocation();
7509 S.
Diag(Loc, diag::note_in_reference_temporary_list_initializer) <<
T;
7513 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
7516 assert(DiagnoseInitList.HadError() &&
7517 "Inconsistent init list check result.");
7539 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
7543 <<
SourceRange(Args.front()->getLocStart(), Args.back()->getLocEnd());
7547 << 1 << Entity.
getType() << Args[0]->getSourceRange();
7560 S.
Diag(Kind.
getLocation(), diag::err_array_init_narrow_string_into_wchar);
7563 S.
Diag(Kind.
getLocation(), diag::err_array_init_wide_string_into_char);
7567 diag::err_array_init_incompat_wide_string_into_wchar);
7573 ? diag::err_array_init_different_type
7574 : diag::err_array_init_non_constant_array))
7576 << Args[0]->getType()
7577 << Args[0]->getSourceRange();
7595 auto *FD = cast<FunctionDecl>(cast<DeclRefExpr>(Args[0])->getDecl());
7597 Args[0]->getLocStart());
7603 switch (FailedOverloadResult) {
7607 << Args[0]->getType() << DestType
7608 << Args[0]->getSourceRange();
7611 << DestType << Args[0]->getType()
7612 << Args[0]->getSourceRange();
7620 diag::err_typecheck_nonviable_condition_incomplete,
7621 Args[0]->getType(), Args[0]->getSourceRange()))
7624 << Args[0]->getType() << Args[0]->getSourceRange()
7633 << Args[0]->getSourceRange();
7640 llvm_unreachable(
"Inconsistent overload resolution?");
7646 llvm_unreachable(
"Conversion did not fail!");
7651 if (isa<InitListExpr>(Args[0])) {
7653 diag::err_lvalue_reference_bind_to_initlist)
7656 << Args[0]->getSourceRange();
7664 ? diag::err_lvalue_reference_bind_to_temporary
7665 : diag::err_lvalue_reference_bind_to_unrelated)
7668 << Args[0]->getType()
7669 << Args[0]->getSourceRange();
7674 FieldDecl *BitField = Args[0]->getSourceBitField();
7678 << (BitField !=
nullptr)
7679 << Args[0]->getSourceRange();
7686 S.
Diag(Kind.
getLocation(), diag::err_reference_bind_to_vector_element)
7688 << Args[0]->getSourceRange();
7694 << Args[0]->getSourceRange();
7698 QualType SourceType = Args[0]->getType();
7707 << Args[0]->getSourceRange();
7714 << Args[0]->isLValue()
7715 << Args[0]->getType()
7716 << Args[0]->getSourceRange();
7721 QualType FromType = Args[0]->getType();
7725 << Args[0]->isLValue()
7727 << Args[0]->getSourceRange();
7745 assert(Args.size() > 1 &&
"Expected multiple initializers!");
7746 R =
SourceRange(Args.front()->getLocEnd(), Args.back()->getLocEnd());
7751 S.
Diag(Kind.
getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
7761 << 0 << Entity.
getType() << Args[0]->getSourceRange();
7778 ArgsRange =
SourceRange(Args.front()->getLocStart(),
7779 Args.back()->getLocEnd());
7782 assert(Args.size() == 1 &&
7783 "List construction from other than 1 argument.");
7785 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
7790 switch (FailedOverloadResult) {
7793 << DestType << ArgsRange;
7810 InheritedFrom = Inherited.getShadowDecl()->getNominatedBaseClass();
7813 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
7826 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
7832 diag::note_member_declared_at);
7836 S.
Diag(Record->getDecl()->getLocation(),
7837 diag::note_previous_decl)
7844 << DestType << ArgsRange;
7854 <<
true << DestType << ArgsRange;
7855 llvm_unreachable(
"Inconsistent overload resolution?");
7865 << DestType << ArgsRange;
7868 <<
true << DestType << ArgsRange;
7875 llvm_unreachable(
"Conversion did not fail!");
7903 diag::err_init_incomplete_type);
7925 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
7928 diag::note_explicit_ctor_deduction_guide_here) <<
false;
7933 PrintInitLocationNote(S, Entity);
7940 OS <<
"Failed sequence: ";
7943 OS <<
"too many initializers for reference";
7947 OS <<
"parenthesized list init for reference";
7951 OS <<
"array requires initializer list";
7955 OS <<
"address of unaddressable function was taken";
7959 OS <<
"array requires initializer list or string literal";
7963 OS <<
"array requires initializer list or wide string literal";
7967 OS <<
"narrow string into wide char array";
7971 OS <<
"wide string into char array";
7975 OS <<
"incompatible wide string into wide char array";
7979 OS <<
"array type mismatch";
7983 OS <<
"non-constant array initializer";
7987 OS <<
"address of overloaded function failed";
7991 OS <<
"overload resolution for reference initialization failed";
7995 OS <<
"non-const lvalue reference bound to temporary";
7999 OS <<
"non-const lvalue reference bound to bit-field";
8003 OS <<
"non-const lvalue reference bound to vector element";
8007 OS <<
"non-const lvalue reference bound to unrelated type";
8011 OS <<
"rvalue reference bound to an lvalue";
8015 OS <<
"reference initialization drops qualifiers";
8019 OS <<
"reference initialization failed";
8023 OS <<
"conversion failed";
8027 OS <<
"conversion from property failed";
8031 OS <<
"too many initializers for scalar";
8035 OS <<
"parenthesized list init for reference";
8039 OS <<
"referencing binding to initializer list";
8043 OS <<
"initializer list for non-aggregate, non-scalar type";
8047 OS <<
"overloading failed for user-defined conversion";
8051 OS <<
"constructor overloading failed";
8055 OS <<
"default initialization of a const variable";
8059 OS <<
"initialization of incomplete type";
8063 OS <<
"list initialization checker failure";
8067 OS <<
"variable length array has an initializer";
8071 OS <<
"initializer expression isn't contextually valid";
8075 OS <<
"list constructor overloading failed";
8079 OS <<
"list copy initialization chose explicit constructor";
8087 OS <<
"Dependent sequence\n";
8091 OS <<
"Normal sequence: ";
8102 OS <<
"resolve address of overloaded function";
8106 OS <<
"derived-to-base (rvalue)";
8110 OS <<
"derived-to-base (xvalue)";
8114 OS <<
"derived-to-base (lvalue)";
8118 OS <<
"bind reference to lvalue";
8122 OS <<
"bind reference to a temporary";
8126 OS <<
"final copy in class direct-initialization";
8130 OS <<
"extraneous C++03 copy to temporary";
8134 OS <<
"user-defined conversion via " << *S->Function.Function;
8138 OS <<
"qualification conversion (rvalue)";
8142 OS <<
"qualification conversion (xvalue)";
8146 OS <<
"qualification conversion (lvalue)";
8150 OS <<
"non-atomic-to-atomic conversion";
8154 OS <<
"load (lvalue to rvalue)";
8158 OS <<
"implicit conversion sequence (";
8164 OS <<
"implicit conversion sequence with narrowing prohibited (";
8170 OS <<
"list aggregate initialization";
8174 OS <<
"unwrap reference initializer list";
8178 OS <<
"rewrap reference initializer list";
8182 OS <<
"constructor initialization";
8186 OS <<
"list initialization via constructor";
8190 OS <<
"zero initialization";
8194 OS <<
"C assignment";
8198 OS <<
"string initialization";
8202 OS <<
"Objective-C object conversion";
8206 OS <<
"indexing for array initialization loop";
8210 OS <<
"array initialization loop";
8214 OS <<
"array initialization";
8218 OS <<
"array initialization (GNU extension)";
8222 OS <<
"parenthesized array initialization";
8226 OS <<
"pass by indirect copy and restore";
8230 OS <<
"pass by indirect restore";
8234 OS <<
"Objective-C object retension";
8238 OS <<
"std::initializer_list from initializer list";
8242 OS <<
"list initialization from std::initializer_list";
8246 OS <<
"OpenCL sampler_t from integer constant";
8250 OS <<
"OpenCL event_t from zero";
8254 OS <<
"OpenCL queue_t from zero";
8258 OS <<
" [" << S->Type.getAsString() <<
']';
8272 const Expr *PostInit) {
8303 ? diag::warn_init_list_type_narrowing
8304 : diag::ext_init_list_type_narrowing)
8314 ? diag::warn_init_list_constant_narrowing
8315 : diag::ext_init_list_constant_narrowing)
8325 ? diag::warn_init_list_variable_narrowing
8326 : diag::ext_init_list_variable_narrowing)
8334 llvm::raw_svector_ostream OS(StaticCast);
8335 OS <<
"static_cast<";
8342 OS << *TT->getDecl();
8351 S.
Diag(PostInit->
getLocStart(), diag::note_init_list_narrowing_silence)
8368 assert(InitE &&
"No initialization expression");
8373 return !Seq.Failed();
8380 bool TopLevelOfInitList,
8381 bool AllowExplicit) {
8386 assert(InitE &&
"No initialization expression?");
8397 const bool ShouldTrackCopy =
8399 if (ShouldTrackCopy) {
8400 if (llvm::find(CurrentParameterCopyTypes, Entity.
getType()) !=
8401 CurrentParameterCopyTypes.end()) {
8402 Seq.SetOverloadFailure(
8408 const auto LastStep = Seq.step_end() - 1;
8409 assert(LastStep->Kind ==
8411 const FunctionDecl *Function = LastStep->Function.Function;
8413 llvm::find_if(Seq.getFailedCandidateSet(),
8415 return Candidate.Viable &&
8416 Candidate.Function == Function &&
8417 Candidate.Conversions.size() > 0;
8419 if (Candidate != Seq.getFailedCandidateSet().end() &&
8421 Candidate->Viable =
false;
8428 CurrentParameterCopyTypes.push_back(Entity.
getType());
8433 if (ShouldTrackCopy)
8434 CurrentParameterCopyTypes.pop_back();
8442 auto NotSpecialization = [&] (
const CXXRecordDecl *Candidate) {
8446 return !(NotSpecialization(RD) && RD->
forallBases(NotSpecialization));
8454 assert(DeducedTST &&
"not a deduced template specialization type");
8462 diag::err_deduced_non_class_template_specialization_type)
8465 Diag(TD->getLocation(), diag::note_template_decl_here);
8488 LookupResult Guides(*
this, NameInfo, LookupOrdinaryName);
8489 LookupQualifiedName(Guides, Template->getDeclContext());
8493 Guides.suppressDiagnostics();
8498 ? dyn_cast<InitListExpr>(Inits[0])
8513 auto tryToResolveOverload =
8516 for (
auto I = Guides.begin(), E = Guides.end(); I != E; ++I) {
8522 auto *GD = dyn_cast_or_null<CXXDeductionGuideDecl>(
8523 TD ? TD->getTemplatedDecl() : dyn_cast<
FunctionDecl>(D));
8534 if (GD->isExplicit())
8540 if (GD->getMinRequiredArguments() > 1 ||
8541 (GD->getNumParams() == 0 && !GD->isVariadic()))
8548 if (OnlyListConstructors && !isInitListConstructor(GD))
8563 bool SuppressUserConversions = Kind.
isCopyInit();
8566 AddTemplateOverloadCandidate(TD, I.getPair(),
nullptr,
8568 SuppressUserConversions);
8570 AddOverloadCandidate(GD, I.getPair(),
Inits, Candidates,
8571 SuppressUserConversions);
8573 return Candidates.BestViableFunction(*
this, Kind.
getLocation(), Best);
8581 bool TryListConstructors =
true;
8587 auto *FD = dyn_cast<
FunctionDecl>(D->getUnderlyingDecl());
8588 if (FD && FD->getMinRequiredArguments() == 0) {
8589 TryListConstructors =
false;
8601 if (!isa<InitListExpr>(E) && RD &&
8603 TryListConstructors =
false;
8606 if (TryListConstructors)
8607 Result = tryToResolveOverload(
true);
8616 Result = tryToResolveOverload(
false);
8620 Diag(Kind.
getLocation(), diag::err_deduced_class_template_ctor_ambiguous)
8630 cast<ClassTemplateDecl>(Template)->getTemplatedDecl();
8634 Complete ? diag::err_deduced_class_template_ctor_no_viable
8635 : diag::err_deduced_class_template_incomplete)
8644 NoteDeletedFunction(Best->Function);
8653 cast<CXXDeductionGuideDecl>(Best->Function)->isExplicit()) {
8654 bool IsDeductionGuide = !Best->Function->isImplicit();
8657 Diag(Best->Function->getLocation(),
8658 diag::note_explicit_ctor_deduction_guide_here)
8659 << IsDeductionGuide;
8665 DiagnoseUseOfDecl(Best->Function, Kind.
getLocation());
8666 MarkFunctionReferenced(Kind.
getLocation(), Best->Function);
8673 return SubstAutoType(TSInfo->
getType(), Best->Function->getReturnType());
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Represents a single C99 designator.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Perform a derived-to-base cast, producing an lvalue.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
static bool performReferenceExtension(Expr *Init, const InitializedEntity *ExtendingEntity)
Update a glvalue expression that is used as the initializer of a reference to note that its lifetime ...
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
An instance of this class is created to represent a function declaration or definition.
Expr * getArrayIndex(const Designator &D) const
InitListExpr * WrappingSyntacticList
When Kind = SK_RewrapInitList, the syntactic form of the wrapping list.
NamespaceDecl * getStdNamespace() const
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.
step_iterator step_begin() const
SourceLocation getRParenLoc() const
SourceLocation getEllipsisLoc() const
void setArrayFiller(Expr *filler)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
void SetZeroInitializationFixit(const std::string &Fixit, SourceLocation L)
Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied...
A (possibly-)qualified type.
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
Simple class containing the result of Sema::CorrectTypo.
StringKind getKind() const
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
DeclarationName getName() const
Retrieve the name of the entity being initialized.
void setFromType(QualType T)
Produce an Objective-C object pointer.
A cast other than a C-style cast.
void AddOCLZeroEventStep(QualType T)
Add a step to initialize an OpenCL event_t from a NULL constant.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr *> &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
Initializing char array with wide string literal.
Perform an implicit conversion sequence without narrowing.
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
const Expr * getInit(unsigned Init) const
InvalidICRKind
The non-zero enum values here are indexes into diagnostic alternatives.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static ExprResult CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value)
Check that the given Index expression is a valid array designator value.
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)
Reference initialization without resolving overloaded functions.
Perform a qualification conversion, producing an rvalue.
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
SmallVectorImpl< Step >::const_iterator step_iterator
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
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 SecondStepOfCopyInit=false)
ActionResult< Expr * > ExprResult
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
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 DesignatedInitExpr * CloneDesignatedInitExpr(Sema &SemaRef, DesignatedInitExpr *DIE)
bool isRecordType() const
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
ConstructorInfo getConstructorInfo(NamedDecl *ND)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
uintptr_t Base
When Kind == EK_Base, the base specifier that provides the base class.
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
static bool canPerformArrayCopy(const InitializedEntity &Entity)
Determine whether we can perform an elementwise array copy for this kind of entity.
bool isExtVectorType() const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic, and whose semantics are that of the sole contained initializer)?
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators.
FailureKind getFailureKind() const
Determine why initialization failed.
Not a narrowing conversion.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
ParenExpr - This represents a parethesized expression, e.g.
NamedDecl * getDecl() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
The base class of the type hierarchy.
static bool tryObjCWritebackConversion(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity, Expr *Initializer)
The entity being initialized is a variable.
const IdentifierInfo * getField() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
NamespaceDecl - Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
Overloading for a user-defined conversion failed.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
Ambiguous candidates found.
QualType withConst() const
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST...
const TargetInfo & getTargetInfo() const
A container of type source information.
QualType getCallResultType() const
Determine the type of an expression that calls this function.
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...
Perform a derived-to-base cast, producing an xvalue.
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda...
The entity being initialized is a base member subobject.
List-copy-initialization chose an explicit constructor.
SourceLocation getLocEnd() const LLVM_READONLY
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...
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
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, C99 6.9p3)
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
SourceLocation getEndLoc() const
Get the end source location.
QualType getElementType() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
The entity being initialized is a function parameter; function is member of group of audited CF APIs...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Initialize an OpenCL sampler from an integer.
static const InitializedEntity * getEntityForTemporaryLifetimeExtension(const InitializedEntity *Entity, const InitializedEntity *FallbackDecl=nullptr)
Determine the declaration which an initialized entity ultimately refers to, for the purpose of lifeti...
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
RAII object that enters a new expression evaluation context.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ExprResult PerformObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
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...
void AddCAssignmentStep(QualType T)
Add a C assignment step.
Initialization by string.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
QualType getReturnType() const
Array initialization by elementwise copy.
DiagnosticsEngine & Diags
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).
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...
SourceLocation getEqualLoc() const
Retrieve the location of the equal sign for copy initialization (if present).
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false, ConversionSequenceList EarlyConversions=None)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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...
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
Represents a C++17 deduced template specialization type.
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
void setInit(unsigned Init, Expr *expr)
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
DeclClass * getCorrectionDeclAs() const
Non-const lvalue reference binding to an lvalue of unrelated type.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
bool isInvalidDecl() const
void setBegin(SourceLocation b)
Perform a derived-to-base cast, producing an rvalue.
void AddReferenceBindingStep(QualType T, bool BindingTemporary)
Add a new step binding a reference to an object.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
EntityKind getKind() const
Determine the kind of initialization.
void setElementIndex(unsigned Index)
If this is already the initializer for an array or vector element, sets the element index...
ParmVarDecl - Represents a parameter to a function.
The entity being initialized is a temporary object.
Expr * getArrayRangeStart() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, bool IsReturnStmt)
Provide warnings when std::move is used on construction.
Non-const lvalue reference binding to a vector element.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
bool isImplicitMemberInitializer() const
Is this the implicit initialization of a member of a class from a defaulted constructor?
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
SourceLocation getDotLoc() const
RecordDecl - Represents a struct/union/class.
Represents a C99 designated initializer expression.
Construct a std::initializer_list from an initializer list.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Trying to take the address of a function that doesn't support having its address taken.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
static void CheckForNullPointerDereference(Sema &S, const Expr *E)
static bool isExprAnUnaddressableFunction(Sema &S, const Expr *E)
Tries to get a FunctionDecl out of E.
bool isArrayRangeDesignator() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
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...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Expr * getInit() const
Retrieve the initializer value.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
The results of name lookup within a DeclContext.
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion...
ImplicitConversionSequence * ICS
When Kind = SK_ConversionSequence, the implicit conversion sequence.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
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...
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 isSpelledAsLValue() const
field_range fields() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Represents a place-holder for an object not to be initialized by anything.
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr *> IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
bool isArrayDesignator() const
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
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...
SourceLocation getRBraceLoc() const
static void warnOnLifetimeExtension(Sema &S, const InitializedEntity &Entity, const Expr *Init, bool IsInitializerList, const ValueDecl *ExtendingDecl)
Rewrap the single-element initializer list for a reference.
bool isReferenceType() const
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible...
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
specific_decl_iterator< FieldDecl > field_iterator
~InitializationSequence()
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Perform initialization via a constructor taking a single std::initializer_list argument.
Describes an C or C++ initializer list.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
Represents the results of name lookup.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
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...
StepKind Kind
The kind of conversion or initialization step we are taking.
bool isImplicitValueInit() const
Determine whether this initialization is an implicit value-initialization, e.g., as occurs during agg...
Succeeded, but refers to a deleted function.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, bool &DerivedToBase, bool &ObjCConversion, bool &ObjCLifetimeConversion)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
Ref_Compatible - The two types are reference-compatible.
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation Loc, bool GNUSyntax, ExprResult Init)
bool hasAddressSpace() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
QualType getToType(unsigned Idx) const
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...
std::string getAsString(ASTContext &Ctx, QualType Ty) const
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
LangAS getAddressSpace() const
Variable-length array must not have an initializer.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
Initialization of an incomplete type.
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes...
The entity being initialized is a non-static data member subobject.
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
bool isRValueReferenceType() const
CheckedConversionKind
The kind of conversion being performed.
A narrowing conversion, because a constant expression got narrowed.
Unwrap the single-element initializer list for a reference.
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...
void AddParenthesizedArrayInitStep(QualType T)
Add a parenthesized array initialization step.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
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...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
field_iterator field_begin() const
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
The entity being initialized is an element of a vector.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents binding an expression to a temporary.
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
const LangOptions & getLangOpts() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
bool isScalarType() const
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.
Perform initialization via a constructor.
Perform a user-defined conversion, either via a conversion function or via a constructor.
Implicit conversion failed.
Member name lookup, which finds the names of class/struct/union members.
is ARM Neon polynomial vector
The entity being initialized is a function parameter.
static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, InitListExpr *InitList)
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
Perform an implicit conversion sequence.
ConditionalOperator - The ?: ternary operator.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Sema - This implements semantic analysis and AST building for C.
void setField(FieldDecl *FD)
Overloading for list-initialization by constructor failed.
Perform list-initialization without a constructor.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Reference binding drops qualifiers.
unsigned getNumDesignators() const
void AddObjCObjectConversionStep(QualType T)
Add an Objective-C object conversion step, which is always a no-op.
Non-const lvalue reference binding to a bit-field.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Cannot resolve the address of an overloaded function.
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...
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify().
void AddStdInitializerListConstructionStep(QualType T)
Add a step to construct a std::initializer_list object from an initializer list.
SourceLocation getLocEnd() const LLVM_READONLY
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
bool hasQualifiers() const
Determine whether this type has any qualifiers.
InitListExpr * getUpdater() const
A narrowing conversion by virtue of the source and destination types.
bool isFunctionalCast() const
Determine whether this is a functional-style cast.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
unsigned allocateManglingNumber() const
The entity being initialized is a field of block descriptor for the copied-in c++ object...
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
Initializing wide char array with incompatible wide string literal.
The entity being initialized is the real or imaginary part of a complex number.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
QualType getElementType() const
SourceLocation getLocStart() const LLVM_READONLY
Implicit conversion failed.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
llvm::MutableArrayRef< Designator > designators()
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
void setRBraceLoc(SourceLocation Loc)
SourceLocation getLocStart() const LLVM_READONLY
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
const FunctionProtoType * T
void dump() const
Dump a representation of the initialized entity to standard error, for debugging purposes.
Scalar initialized from a parenthesized initializer list.
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
static void updateStringLiteralType(Expr *E, QualType Ty)
Update the type of a string literal, including any surrounding parentheses, to match the type of the ...
The entity being initialized is an object (or array of objects) allocated via new.
Perform a qualification conversion, producing an xvalue.
void setSyntacticForm(InitListExpr *Init)
const T * castAs() const
Member-template castAs<specific type>.
Represents a C++ functional cast expression that builds a temporary object.
static void performLifetimeExtension(Expr *Init, const InitializedEntity *ExtendingEntity)
Update a prvalue expression that is going to be materialized as a lifetime-extended temporary...
bool isObjCRetainableType() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
Initializing a wide char array with narrow string literal.
bool isFieldDesignator() const
unsigned getNumInits() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void ClearExprs(Sema &Actions)
ClearExprs - Null out any expression references, which prevents them from being 'delete'd later...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
const Expr * getCallee() const
void AddProduceObjCObjectStep(QualType T)
Add a step to "produce" an Objective-C object (by retaining it).
SmallVectorImpl< OverloadCandidate >::iterator iterator
Passing zero to a function where OpenCL event_t is expected.
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...
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
SourceLocation getLocEnd() const LLVM_READONLY
field_iterator field_end() const
Resolve the address of an overloaded function to a specific function declaration. ...
DeclContext * getDeclContext()
Overload resolution succeeded.
bool isAnyComplexType() const
The entity being initialized is an exception object that is being thrown.
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...
unsigned size() const
Returns the number of designators in this initializer.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
struct F Function
When Kind == SK_ResolvedOverloadedFunction or Kind == SK_UserConversion, the function that the expres...
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
Represents a C++ template name within the type system.
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
Floating-integral conversions (C++ 4.9)
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
QualType getEncodedType() const
bool isExplicitCast() const
Determine whether this initialization is an explicit cast.
Expr * getArrayRangeEnd() const
static void TryDefaultInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence)
Attempt default initialization (C++ [dcl.init]p6).
QualType getRecordType(const RecordDecl *Decl) const
Initializer has a placeholder type which cannot be resolved by initialization.
SourceLocation getLBracketLoc() const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
static void TryReferenceInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence)
Attempt reference initialization (C++0x [dcl.init.ref])
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
An lvalue reference type, per C++11 [dcl.ref].
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
SourceLocation getLocation() const
Retrieve the location at which initialization is occurring.
bool AllowExplicit() const
Retrieve whether this initialization allows the use of explicit constructors.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
Represents a C++ conversion function within a class.
void AddStringInitStep(QualType T)
Add a string init step.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call...
The result type of a method or function.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Pass an object by indirect restore.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Expr * getArrayIndex() const
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
InitKind getKind() const
Determine the initialization kind.
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
static void TryReferenceListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Attempt list initialization of a reference.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
FailureKind
Describes why initialization failed.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
Too many initializers for scalar.
Lvalue-to-rvalue conversion (C++ 4.1)
bool isConstQualified() const
Determine whether this type is const-qualified.
List initialization failed at some point.
RecordDecl * getDecl() const
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr *> Args)
Diagnose an potentially-invalid initialization sequence.
bool isAtStartOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the beginning of the immediate macro expansion...
SourceLocation getLocStart() const LLVM_READONLY
QualType getWideCharType() const
Return the type of wide characters.
Initialize queue_t from 0.
Perform a conversion adding _Atomic to a type.
void AddListInitializationStep(QualType T)
Add a list-initialization step.
chain_iterator chain_end() const
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool allowExplicitConversionFunctionsInRefBinding() const
Retrieve whether this initialization allows the use of explicit conversion functions when binding a r...
CXXConstructorDecl * Constructor
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).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Perform a qualification conversion, producing an lvalue.
Integral conversions (C++ 4.7)
void AddLValueToRValueStep(QualType Ty)
Add a new step that performs a load of the given type.
Reference binding to an lvalue.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
bool isParameterKind() const
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
const Designator & getDesignator(unsigned Idx) const
QualType getCanonicalType() const
ArrayRef< NamedDecl * >::const_iterator chain_iterator
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
bool allowsNRVO() const
Determine whether this initialization allows the named return value optimization, which also applies ...
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
SequenceKind
Describes the kind of initialization sequence computed.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
Array indexing for initialization by elementwise copy.
ASTContext & getASTContext() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor...
SourceLocation getFieldLoc() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Reference initialization from an initializer list.
std::pair< SourceLocation, SourceLocation > getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
static bool shouldBindAsTemporary(const InitializedEntity &Entity)
Whether we should bind a created object as a temporary when initializing the given entity...
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
Expr * getSubExpr(unsigned Idx) const
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
bool isCStyleOrFunctionalCast() const
Determine whether this initialization is a C-style cast.
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
QualType getElementType() const
void setReferenced(bool R=true)
llvm::iterator_range< base_class_iterator > base_class_range
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
static InvalidICRKind isInvalidICRSource(ASTContext &C, Expr *e, bool isAddressOf, bool &isWeakAccess)
Determines whether this expression is an acceptable ICR source.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
const ConstantArrayType * getAsConstantArrayType(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...
Initialization of some unused destination type with an initializer list.
The entity being initialized is the result of a function call.
void InitializeFrom(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList, bool TreatUnavailableAsInvalid)
Objective-C ARC writeback conversion.
The entity being implicitly initialized back to the formal result type.
const ParmVarDecl * getParamDecl(unsigned i) const
Zero-initialize the object.
The entity being initialized is the initializer for a compound literal.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
void AddExtraneousCopyToTemporary(QualType T)
Add a new step that makes an extraneous copy of the input to a temporary of the same class type...
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
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...
SourceLocation getLBracketLoc() const
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool forallBases(ForallBasesCallback BaseMatches, bool AllowShortCircuit=true) const
Determines if the given callback holds for all the direct or indirect base classes of this type...
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
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...
The entity being initialized is an element of an array.
bool isObjCObjectPointerType() const
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Reference initialized from a parenthesized initializer list.
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 bool DiagnoseUninitializedReference(Sema &S, SourceLocation Loc, QualType T)
Somewhere within T there is an uninitialized reference subobject.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
Expr ** getInits()
Retrieve the set of initializers.
Overloading for initialization by constructor failed.
static bool ResolveOverloadedFunctionForReferenceBinding(Sema &S, Expr *Initializer, QualType &SourceType, QualType &UnqualifiedSourceType, QualType UnqualifiedTargetType, InitializationSequence &Sequence)
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
Requests that all candidates be shown.
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
void AddOCLZeroQueueStep(QualType T)
Add a step to initialize an OpenCL queue_t from 0.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Expr * getArrayRangeStart(const Designator &D) const
void AddAtomicConversionStep(QualType Ty)
Add a new step that performs conversion from non-atomic to atomic type.
bool HadMultipleCandidates
void AddArrayInitStep(QualType T, bool IsGNUExtension)
Add an array initialization step.
bool isVectorType() const
void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy)
Add a step to pass an object by indirect copy-restore.
SourceLocation getLocStart() const LLVM_READONLY
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
bool hasFlexibleArrayMember() const
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, Sema &S)
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
MutableArrayRef< Expr * > MultiExprArg
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
Pass an object by indirect copy-and-restore.
A POD class for pairing a NamedDecl* with an access specifier.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
Represents a C11 generic selection.
Rvalue reference binding to an lvalue.
void SetFailed(FailureKind Failure)
Note that this initialization sequence failed.
decl_iterator - Iterates through the declarations stored within this context.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Array must be initialized with an initializer list or a string literal.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
static bool isInvalid(LocType Loc, bool *Invalid)
QualType getType() const
Retrieve type being initialized.
Dataflow Directional Tag Classes.
bool isExplicit() const
Whether this function is explicit.
bool isValid() const
Return true if this is a valid SourceLocation object.
Non-constant array initializer.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
void setIncompleteTypeFailure(QualType IncompleteType)
Note that this initialization sequence failed due to an incomplete type.
A single step in the initialization sequence.
Array must be initialized with an initializer list or a wide string literal.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Too many initializers provided for a reference.
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 bool isNonReferenceableGLValue(Expr *E)
Determine whether an expression is a non-referenceable glvalue (one to which a reference can never bi...
Perform a load from a glvalue, producing an rvalue.
static void checkIndirectCopyRestoreSource(Sema &S, Expr *src)
Check whether the given expression is a valid operand for an indirect copy/restore.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
static bool InitializedEntityOutlivesFullExpression(const InitializedEntity &Entity)
Determine whether the specified InitializedEntity definitely has a lifetime longer than the current f...
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const Expr * getInit() const
Array-to-pointer conversion (C++ 4.2)
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
SourceLocation getLBraceLoc() const
DeclarationName - The name of a declaration.
VectorKind getVectorKind() const
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
static bool IsWideCharCompatible(QualType T, ASTContext &Context)
Check whether T is compatible with a wide character type (wchar_t, char16_t or char32_t).
Requests that only viable candidates be shown.
Array initialization (from an array rvalue) as a GNU extension.
SourceRange getParenRange() const
Retrieve the source range containing the locations of the open and closing parentheses for value and ...
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
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...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
Overloading due to reference initialization failed.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
static bool isIdiomaticBraceElisionEntity(const InitializedEntity &Entity)
Determine whether Entity is an entity for which it is idiomatic to elide the braces in aggregate init...
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
Expr * getArrayRangeEnd(const Designator &D) const
static bool isRValueRef(QualType ParamType)
bool isStringLiteralInit() const
SourceLocation getFieldLoc() const
unsigned getIntWidth(QualType T) const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::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 isIncompleteArrayType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setAllToTypes(QualType T)
Complex values, per C99 6.2.5p11.
static bool TryOCLZeroEventInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
SourceLocation getLocEnd() const LLVM_READONLY
Array must be initialized with an initializer list.
static bool shouldDestroyEntity(const InitializedEntity &Entity)
Whether the given entity, when initialized with an object created for that initialization, requires destruction.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
The entity being initialized is a structured binding of a decomposition declaration.
static void emitBadConversionNotes(Sema &S, const InitializedEntity &entity, Expr *op)
Emit notes associated with an initialization that failed due to a "simple" conversion failure...
chain_iterator chain_begin() const
ObjCEncodeExpr, used for @encode in Objective-C.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
const llvm::APInt & getSize() const
Reference binding failed.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
bool isAtomicType() 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.
bool isFunctionType() const
SourceLocation getLocStart() const LLVM_READONLY
FieldDecl * getField() const
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void AddArrayInitLoopStep(QualType T, QualType EltTy)
Add an array initialization loop step.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
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.
step_iterator step_end() const
void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category)
Add a new step in the initialization that performs a derived-to- base cast.
bool isConstantArrayType() const
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
void setExprNeedsCleanups(bool SideEffects)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
static bool TryOCLSamplerInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
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...
static SourceLocation getInitializationLoc(const InitializedEntity &Entity, Expr *Initializer)
Get the location at which initialization diagnostics should appear.
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
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...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isLValueReferenceType() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Reading or writing from this object requires a barrier call.
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...
Direct-initialization from a reference-related object in the final stage of class copy-initialization...
DesignatorKind getKind() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
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])
bool Failed() const
Determine whether the initialization sequence is invalid.
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], C99 6.7.8).
Describes the sequence of initializations required to initialize a given object or reference with a s...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
Perform initialization via a constructor, taking arguments from a single InitListExpr.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, 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 ...
Represents a loop initializing the elements of an array.
SourceRange getRange() const
Retrieve the source range that covers the initialization.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
Represents a C array with an unspecified size.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
The entity being initialized is a field of block descriptor for the copied-in lambda object that's us...
The parameter type of a method or function.
The entity being initialized is the field that captures a variable in a lambda.
void setSequenceKind(enum SequenceKind SK)
Set the kind of sequence computed.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
static void TryValueInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence, InitListExpr *InitList=nullptr)
Attempt value initialization (C++ [dcl.init]p7).
A dependent initialization, which could not be type-checked due to the presence of dependent types or...
Declaration of a class template.
bool isCStyleCast() const
Determine whether this is a C-style cast.
SourceLocation getRBracketLoc() const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
This class is used for builtin types like 'int'.
SourceManager & getSourceManager() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static bool isOrIsDerivedFromSpecializationOf(CXXRecordDecl *RD, ClassTemplateDecl *CTD)
Determine whether RD is, or is derived from, a specialization of CTD.
Designator * getDesignator(unsigned Idx)
unsigned getCVRQualifiers() const
Reference binding to a temporary.
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
static Decl::Kind getKind(const Decl *D)
void AddConstructorInitializationStep(DeclAccessPair FoundDecl, CXXConstructorDecl *Constructor, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
Add a constructor-initialization step.
unsigned getNumElements() const
Designation - Represent a full designation, which is a sequence of designators.
static Sema::AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Designator - A designator in a C99 designated initializer.
bool isDeleted() const
Whether this function has been deleted.
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
bool isPointerType() const
The initialization is being done by a delegating constructor.
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
void AddQualificationConversionStep(QualType Ty, ExprValueKind Category)
Add a new step that performs a qualification conversion to the given type.
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...
SourceManager & SourceMgr
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
No viable function found.
A failed initialization sequence.
Array initialization (from an array rvalue).
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
An l-value expression is a reference to an object with independent storage.
Default-initialization of a 'const' object.
unsigned getNumArgs() const
bool isFloatingType() const
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
Add a new step that applies an implicit conversion sequence.
A trivial tuple used to represent a source range.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< 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...
NamedDecl - This represents a decl with a name.
bool isOpenCLSpecificType() const
SourceLocation getDotLoc() const
Represents a C array with a specified size that is not an integer-constant-expression.
Automatic storage duration (most local variables).
static void DiagnoseNarrowingInInitList(Sema &S, const ImplicitConversionSequence &ICS, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit)
Describes an entity that is being initialized.
bool isInStdNamespace() const
void setToType(unsigned Idx, QualType T)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
ObjCMethodDecl * getMethodDecl() const
Retrieve the ObjectiveC method being initialized.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
bool hasDefaultConstructor() const
Determine whether this class has any default constructors.
bool isVariableLengthArrayNew() const
Determine whether this is an array new with an unknown bound.
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 ...
Direct list-initialization.
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr *> Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
Array initialization from a parenthesized initializer list.
IdentifierInfo * getFieldName() const
Represents the canonical version of C arrays with a specified constant size.
InitListExpr * getSyntacticForm() const
static void MaybeProduceObjCObject(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Declaration of a template function.
Represents an implicitly-generated value initialization of an object of a given type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
SourceLocation getLocation() const
QualType getType() const
Return the type wrapped by this type source info.
static bool TryOCLZeroQueueInitialization(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.
Non-const lvalue reference binding to a temporary.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
SourceRange getSourceRange() const LLVM_READONLY
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...
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
QualType getType() const
Retrieves the type of the base class.