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);
356 bool FillWithNoInit =
false);
359 bool TopLevelObject);
366 bool TreatUnavailableAsInvalid);
367 bool HadError() {
return hadError; }
371 InitListExpr *getFullyStructuredList()
const {
return FullyStructuredList; }
380 bool TreatUnavailableAsInvalid) {
391 bool EmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
404 InitExpr = VerifyOnly ? &DummyInitList :
new (SemaRef.
Context)
427 assert(O ==
OR_Success &&
"Inconsistent overload resolution");
434 bool IsInStd =
false;
435 for (
NamespaceDecl *ND = dyn_cast<NamespaceDecl>(R->getDeclContext());
436 ND && !IsInStd; ND = dyn_cast<
NamespaceDecl>(ND->getParent())) {
441 if (IsInStd && llvm::StringSwitch<bool>(R->getName())
442 .Cases(
"basic_string",
"deque",
"forward_list",
true)
443 .Cases(
"list",
"map",
"multimap",
"multiset",
true)
444 .Cases(
"priority_queue",
"queue",
"set",
"stack",
true)
445 .Cases(
"unordered_map",
"unordered_set",
"vector",
true)
451 TreatUnavailableAsInvalid);
456 diag::warn_invalid_initializer_from_system_header);
459 diag::note_used_in_initialization_here);
461 SemaRef.
Diag(Loc, diag::note_used_in_initialization_here);
468 InitSeq.
Diagnose(SemaRef, Entity, Kind, SubInit);
471 diag::note_in_omitted_aggregate_initializer)
474 bool IsTrailingArrayNewMember =
477 SemaRef.
Diag(Loc, diag::note_in_omitted_aggregate_initializer)
478 << (IsTrailingArrayNewMember ? 2 : 0)
485 return VerifyOnly ?
ExprResult(static_cast<Expr *>(
nullptr))
486 : InitSeq.
Perform(SemaRef, Entity, Kind, SubInit);
492 "CheckEmptyInitializable is only inteded for verification mode.");
493 if (PerformEmptyInit(SemaRef, Loc, Entity,
true,
498 void InitListChecker::FillInEmptyInitForBase(
501 bool &RequiresSecondPass,
bool FillWithNoInit) {
502 assert(Init < ILE->getNumInits() &&
"should have been expanded");
505 SemaRef.
Context, &Base,
false, &ParentEntity);
510 : PerformEmptyInit(SemaRef, ILE->
getLocEnd(), BaseEntity,
512 TreatUnavailableAsInvalid);
520 dyn_cast<InitListExpr>(ILE->
getInit(Init))) {
521 FillInEmptyInitializations(BaseEntity, InnerILE, RequiresSecondPass,
522 ILE, Init, FillWithNoInit);
524 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init))) {
525 FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
526 RequiresSecondPass, ILE, Init,
531 void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
534 bool &RequiresSecondPass,
535 bool FillWithNoInit) {
542 if (!RType->getDecl()->isUnion())
543 assert(Init < NumInits &&
"This ILE should have been expanded");
545 if (Init >= NumInits || !ILE->
getInit(Init)) {
546 if (FillWithNoInit) {
568 RequiresSecondPass =
true;
578 SemaRef.
Diag(Loc, diag::err_init_reference_member_uninitialized)
582 diag::note_uninit_reference_member);
587 ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
589 TreatUnavailableAsInvalid);
597 }
else if (Init < NumInits) {
599 }
else if (!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
605 RequiresSecondPass =
true;
608 = dyn_cast<InitListExpr>(ILE->
getInit(Init)))
609 FillInEmptyInitializations(MemberEntity, InnerILE,
610 RequiresSecondPass, ILE, Init, FillWithNoInit);
612 = dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init)))
613 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
614 RequiresSecondPass, ILE, Init,
624 bool &RequiresSecondPass,
627 bool FillWithNoInit) {
629 "Should not have void type");
638 struct UpdateOuterILEWithUpdatedInit {
641 ~UpdateOuterILEWithUpdatedInit() {
645 } UpdateOuterRAII = {OuterILE, OuterIndex};
656 Entity, ILE, RequiresSecondPass, FillWithNoInit);
657 else if (RDecl->
isUnion() && isa<CXXRecordDecl>(RDecl) &&
658 cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) {
659 for (
auto *Field : RDecl->
fields()) {
661 FillInEmptyInitForField(0, Field, Entity, ILE, RequiresSecondPass,
670 unsigned NumElems = numStructUnionElements(ILE->getType());
673 if (ILE->getNumInits() < NumElems)
674 ILE->resizeInits(SemaRef.
Context, NumElems);
678 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RDecl)) {
679 for (
auto &Base : CXXRD->bases()) {
683 FillInEmptyInitForBase(Init, Base, Entity, ILE, RequiresSecondPass,
689 for (
auto *Field : RDecl->
fields()) {
696 FillInEmptyInitForField(Init, Field, Entity, ILE, RequiresSecondPass,
716 unsigned NumElements = NumInits;
718 ElementType = AType->getElementType();
719 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
720 NumElements = CAType->getSize().getZExtValue();
728 ElementType = VType->getElementType();
729 NumElements = VType->getNumElements();
735 for (
unsigned Init = 0; Init != NumElements; ++Init) {
743 Expr *InitExpr = (Init < NumInits ? ILE->
getInit(Init) :
nullptr);
744 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
747 Expr *Filler =
nullptr;
755 TreatUnavailableAsInvalid);
766 }
else if (Init < NumInits) {
781 if (!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
787 RequiresSecondPass =
true;
791 = dyn_cast_or_null<InitListExpr>(InitExpr))
792 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
793 ILE, Init, FillWithNoInit);
795 = dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr))
796 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
797 RequiresSecondPass, ILE, Init,
805 bool TreatUnavailableAsInvalid)
806 : SemaRef(S), VerifyOnly(VerifyOnly),
807 TreatUnavailableAsInvalid(TreatUnavailableAsInvalid) {
813 FullyStructuredList =
814 getStructuredSubobjectInit(IL, 0, T,
nullptr, 0, IL->
getSourceRange());
815 CheckExplicitInitList(Entity, IL, T, FullyStructuredList,
818 if (!hadError && !VerifyOnly) {
819 bool RequiresSecondPass =
false;
820 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass,
822 if (RequiresSecondPass && !hadError)
823 FillInEmptyInitializations(Entity, FullyStructuredList,
824 RequiresSecondPass,
nullptr, 0);
828 int InitListChecker::numArrayElements(
QualType DeclType) {
830 int maxElements = 0x7FFFFFFF;
833 maxElements =
static_cast<int>(CAT->getSize().getZExtValue());
838 int InitListChecker::numStructUnionElements(
QualType DeclType) {
840 int InitializableMembers = 0;
841 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(structDecl))
842 InitializableMembers += CXXRD->getNumBases();
843 for (
const auto *Field : structDecl->
fields())
845 ++InitializableMembers;
848 return std::min(InitializableMembers, 1);
870 if (
CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ParentRD))
871 if (CXXRD->getNumBases())
874 auto FieldIt = ParentRD->field_begin();
875 assert(FieldIt != ParentRD->field_end() &&
876 "no fields but have initializer for member?");
877 return ++FieldIt == ParentRD->field_end();
890 unsigned &StructuredIndex) {
894 maxElements = numArrayElements(T);
896 maxElements = numStructUnionElements(T);
900 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
902 if (maxElements == 0) {
905 diag::err_implicit_empty_initializer);
913 = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList,
917 unsigned StructuredSubobjectInitIndex = 0;
920 unsigned StartIndex = Index;
921 CheckListElementTypes(Entity, ParentIList, T,
923 StructuredSubobjectInitList,
924 StructuredSubobjectInitIndex);
927 StructuredSubobjectInitList->
setType(T);
929 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
932 if (EndIndex < ParentIList->getNumInits() &&
933 ParentIList->
getInit(EndIndex)) {
944 diag::warn_missing_braces)
950 StructuredSubobjectInitList->
getLocEnd()),
976 DiagID = diag::warn_braces_around_scalar_init;
983 DiagID = diag::warn_braces_around_scalar_init;
1008 llvm_unreachable(
"unexpected braced scalar init");
1027 bool TopLevelObject) {
1029 SyntacticToSemantic[IList] = StructuredList;
1033 unsigned Index = 0, StructuredIndex = 0;
1034 CheckListElementTypes(Entity, IList, T,
true,
1035 Index, StructuredList, StructuredIndex, TopLevelObject);
1041 StructuredList->
setType(ExprTy);
1046 if (Index < IList->getNumInits()) {
1057 if (StructuredIndex == 1 &&
1060 unsigned DK = diag::ext_excess_initializers_in_char_array_initializer;
1062 DK = diag::err_excess_initializers_in_char_array_initializer;
1079 unsigned DK = diag::ext_excess_initializers;
1081 DK = diag::err_excess_initializers;
1084 if (SemaRef.
getLangOpts().OpenCL && initKind == 1) {
1085 DK = diag::err_excess_initializers;
1102 bool SubobjectIsDesignatorContext,
1105 unsigned &StructuredIndex,
1106 bool TopLevelObject) {
1110 CheckComplexType(Entity, IList, DeclType, Index,
1111 StructuredList, StructuredIndex);
1113 CheckScalarType(Entity, IList, DeclType, Index,
1114 StructuredList, StructuredIndex);
1116 CheckVectorType(Entity, IList, DeclType, Index,
1117 StructuredList, StructuredIndex);
1120 "non-aggregate records should be handed in CheckSubElementType");
1125 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
1126 Bases = CXXRD->bases();
1127 CheckStructUnionTypes(Entity, IList, DeclType, Bases, RD->field_begin(),
1128 SubobjectIsDesignatorContext, Index, StructuredList,
1129 StructuredIndex, TopLevelObject);
1134 CheckArrayType(Entity, IList, DeclType, Zero,
1135 SubobjectIsDesignatorContext, Index,
1136 StructuredList, StructuredIndex);
1141 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1145 CheckReferenceType(Entity, IList, DeclType, Index,
1146 StructuredList, StructuredIndex);
1154 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1165 unsigned &StructuredIndex) {
1169 return CheckReferenceType(Entity, IList, ElemType, Index,
1170 StructuredList, StructuredIndex);
1172 if (
InitListExpr *SubInitList = dyn_cast<InitListExpr>(expr)) {
1173 if (SubInitList->getNumInits() == 1 &&
1176 expr = SubInitList->getInit(0);
1179 = getStructuredSubobjectInit(IList, Index, ElemType,
1180 StructuredList, StructuredIndex,
1182 CheckExplicitInitList(Entity, SubInitList, ElemType,
1183 InnerStructuredList);
1185 if (!hadError && !VerifyOnly) {
1186 bool RequiresSecondPass =
false;
1187 FillInEmptyInitializations(Entity, InnerStructuredList,
1188 RequiresSecondPass, StructuredList,
1190 if (RequiresSecondPass && !hadError)
1191 FillInEmptyInitializations(Entity, InnerStructuredList,
1192 RequiresSecondPass, StructuredList,
1200 }
else if (isa<ImplicitValueInitExpr>(expr)) {
1204 "found implicit initialization for the wrong type");
1206 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1228 if (Seq || isa<InitListExpr>(expr)) {
1231 Seq.Perform(SemaRef, Entity, Kind, expr);
1235 UpdateStructuredListElement(StructuredList, StructuredIndex,
1246 return CheckScalarType(Entity, IList, ElemType, Index,
1247 StructuredList, StructuredIndex);
1257 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1287 UpdateStructuredListElement(StructuredList, StructuredIndex,
1305 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1325 unsigned &StructuredIndex) {
1326 assert(Index == 0 &&
"Index in explicit init list must be zero");
1336 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1341 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1350 for (
unsigned i = 0; i < 2; ++i) {
1352 CheckSubElementType(ElementEntity, IList, elementType, Index,
1353 StructuredList, StructuredIndex);
1361 unsigned &StructuredIndex) {
1366 diag::warn_cxx98_compat_empty_scalar_initializer :
1367 diag::err_empty_scalar_initializer)
1376 if (
InitListExpr *SubIList = dyn_cast<InitListExpr>(expr)) {
1380 SemaRef.
Diag(SubIList->getLocStart(),
1381 diag::ext_many_braces_around_scalar_init)
1382 << SubIList->getSourceRange();
1384 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1387 }
else if (isa<DesignatedInitExpr>(expr)) {
1390 diag::err_designator_for_scalar_init)
1409 Expr *ResultExpr =
nullptr;
1416 if (ResultExpr != expr) {
1418 IList->
setInit(Index, ResultExpr);
1424 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1432 unsigned &StructuredIndex) {
1440 diag::err_init_reference_member_uninitialized)
1450 if (isa<InitListExpr>(expr) && !SemaRef.
getLangOpts().CPlusPlus11) {
1480 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1488 unsigned &StructuredIndex) {
1491 unsigned numEltsInit = 0;
1497 CheckEmptyInitializable(
1519 Expr *ResultExpr =
nullptr;
1525 if (ResultExpr != Init) {
1527 IList->
setInit(Index, ResultExpr);
1533 UpdateStructuredListElement(StructuredList, StructuredIndex,
1542 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1546 CheckEmptyInitializable(ElementEntity, IList->
getLocEnd());
1551 CheckSubElementType(ElementEntity, IList, elementType, Index,
1552 StructuredList, StructuredIndex);
1573 diag::warn_neon_vector_initializer_non_portable);
1575 const char *typeCode;
1585 llvm_unreachable(
"Invalid element type!");
1589 diag::note_neon_vector_initializer_non_portable_q :
1590 diag::note_neon_vector_initializer_non_portable)
1591 << typeCode << typeSize;
1601 for (
unsigned i = 0; i < maxElements; ++i) {
1610 CheckSubElementType(ElementEntity, IList, elementType, Index,
1611 StructuredList, StructuredIndex);
1623 CheckSubElementType(ElementEntity, IList, VecType, Index,
1624 StructuredList, StructuredIndex);
1625 numEltsInit += numIElts;
1630 if (numEltsInit != maxElements) {
1633 diag::err_vector_incorrect_num_initializers)
1634 << (numEltsInit < maxElements) << maxElements << numEltsInit;
1641 llvm::APSInt elementIndex,
1642 bool SubobjectIsDesignatorContext,
1645 unsigned &StructuredIndex) {
1649 if (Index < IList->getNumInits()) {
1659 UpdateStructuredListElement(StructuredList, StructuredIndex,
1672 SemaRef.
Diag(VAT->getSizeExpr()->getLocStart(),
1673 diag::err_variable_object_no_init)
1674 << VAT->getSizeExpr()->getSourceRange();
1682 llvm::APSInt maxElements(elementIndex.getBitWidth(),
1683 elementIndex.isUnsigned());
1684 bool maxElementsKnown =
false;
1686 maxElements = CAT->getSize();
1687 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
1688 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1689 maxElementsKnown =
true;
1693 while (Index < IList->getNumInits()) {
1699 if (!SubobjectIsDesignatorContext)
1704 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1705 DeclType,
nullptr, &elementIndex, Index,
1706 StructuredList, StructuredIndex,
true,
1712 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
1713 maxElements = maxElements.extend(elementIndex.getBitWidth());
1714 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
1715 elementIndex = elementIndex.extend(maxElements.getBitWidth());
1716 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1720 if (!maxElementsKnown && elementIndex > maxElements)
1721 maxElements = elementIndex;
1728 if (maxElementsKnown && elementIndex == maxElements)
1735 CheckSubElementType(ElementEntity, IList, elementType, Index,
1736 StructuredList, StructuredIndex);
1741 if (!maxElementsKnown && elementIndex > maxElements)
1742 maxElements = elementIndex;
1747 llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
1752 diag::ext_typecheck_zero_array_size);
1758 if (!hadError && VerifyOnly) {
1764 if ((maxElementsKnown && elementIndex < maxElements) ||
1775 bool TopLevelObject) {
1777 unsigned FlexArrayDiag;
1778 if (isa<InitListExpr>(InitExpr) &&
1779 cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
1781 FlexArrayDiag = diag::ext_flexible_array_init;
1785 FlexArrayDiag = diag::err_flexible_array_init;
1786 }
else if (!TopLevelObject) {
1788 FlexArrayDiag = diag::err_flexible_array_init;
1791 FlexArrayDiag = diag::err_flexible_array_init;
1792 }
else if (cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
1794 FlexArrayDiag = diag::err_flexible_array_init;
1797 FlexArrayDiag = diag::ext_flexible_array_init;
1808 return FlexArrayDiag != diag::ext_flexible_array_init;
1811 void InitListChecker::CheckStructUnionTypes(
1814 bool SubobjectIsDesignatorContext,
unsigned &Index,
1815 InitListExpr *StructuredList,
unsigned &StructuredIndex,
1816 bool TopLevelObject) {
1832 if (isa<CXXRecordDecl>(RD) && cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
1836 Field != FieldEnd; ++Field) {
1837 if (Field->hasInClassInitializer()) {
1848 Field != FieldEnd; ++Field) {
1849 if (!Field->isUnnamedBitfield()) {
1851 CheckEmptyInitializable(
1862 bool InitializedSomething =
false;
1865 for (
auto &Base : Bases) {
1871 if (Init && isa<DesignatedInitExpr>(Init))
1875 SemaRef.
Context, &Base,
false, &Entity);
1877 CheckSubElementType(BaseEntity, IList, Base.
getType(), Index,
1878 StructuredList, StructuredIndex);
1879 InitializedSomething =
true;
1880 }
else if (VerifyOnly) {
1881 CheckEmptyInitializable(BaseEntity, InitLoc);
1891 bool CheckForMissingFields =
1894 while (Index < IList->getNumInits()) {
1901 if (!SubobjectIsDesignatorContext)
1906 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1907 DeclType, &Field,
nullptr, Index,
1908 StructuredList, StructuredIndex,
1909 true, TopLevelObject))
1912 InitializedSomething =
true;
1916 CheckForMissingFields =
false;
1920 if (Field == FieldEnd) {
1926 if (InitializedSomething && DeclType->
isUnionType())
1930 if (Field->getType()->isIncompleteArrayType())
1933 if (Field->isUnnamedBitfield()) {
1942 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
1955 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1956 StructuredList, StructuredIndex);
1957 InitializedSomething =
true;
1961 StructuredList->setInitializedFieldInUnion(*Field);
1968 if (!VerifyOnly && InitializedSomething && CheckForMissingFields &&
1969 Field != FieldEnd && !Field->getType()->isIncompleteArrayType() &&
1975 if (!it->isUnnamedBitfield() && !it->hasInClassInitializer()) {
1977 diag::warn_missing_field_initializers) << *it;
1984 if (VerifyOnly && Field != FieldEnd && !DeclType->
isUnionType() &&
1985 !Field->getType()->isIncompleteArrayType()) {
1987 for (; Field != FieldEnd && !hadError; ++Field) {
1988 if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
1989 CheckEmptyInitializable(
1995 if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
1999 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
2009 if (isa<InitListExpr>(IList->
getInit(Index)))
2010 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2011 StructuredList, StructuredIndex);
2013 CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index,
2014 StructuredList, StructuredIndex);
2030 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
2038 assert(isa<FieldDecl>(*PI));
2039 Replacements.back().setField(cast<FieldDecl>(*PI));
2046 &Replacements[0] + Replacements.size());
2053 for (
unsigned I = 0; I < NumIndexExprs; ++I)
2067 explicit FieldInitializerValidatorCCC(
RecordDecl *RD)
2070 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2123 llvm::APSInt *NextElementIndex,
2126 unsigned &StructuredIndex,
2127 bool FinishSubobjectInit,
2128 bool TopLevelObject) {
2129 if (DesigIdx == DIE->
size()) {
2131 bool prevHadError = hadError;
2136 unsigned OldIndex = Index;
2139 CheckSubElementType(Entity, IList, CurrentObjectType, Index,
2140 StructuredList, StructuredIndex);
2146 IList->
setInit(OldIndex, DIE);
2148 return hadError && !prevHadError;
2152 bool IsFirstDesignator = (DesigIdx == 0);
2154 assert((IsFirstDesignator || StructuredList) &&
2155 "Need a non-designated initializer list to start from");
2159 if (IsFirstDesignator)
2160 StructuredList = SyntacticToSemantic.lookup(IList);
2162 Expr *ExistingInit = StructuredIndex < StructuredList->
getNumInits() ?
2163 StructuredList->
getInit(StructuredIndex) :
nullptr;
2169 getStructuredSubobjectInit(IList, Index, CurrentObjectType,
2170 StructuredList, StructuredIndex,
2177 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2178 StructuredList = E->getUpdater();
2209 diag::warn_subobject_initializer_overrides)
2213 diag::note_previous_initializer)
2219 assert(StructuredList &&
"Expected a structured initializer list");
2238 SemaRef.
Diag(Loc, diag::err_field_designator_non_aggr)
2239 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2249 if (
auto *FD = dyn_cast<FieldDecl>(ND)) {
2253 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND)) {
2259 KnownField = cast<FieldDecl>(*IFD->chain_begin());
2270 if (!Lookup.empty()) {
2273 SemaRef.
Diag(Lookup.front()->getLocation(),
2274 diag::note_field_designator_found);
2284 llvm::make_unique<FieldInitializerValidatorCCC>(RT->
getDecl()),
2288 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2289 << FieldName << CurrentObjectType);
2290 KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2295 << FieldName << CurrentObjectType;
2302 unsigned FieldIndex = 0;
2304 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RT->
getDecl()))
2305 FieldIndex = CXXRD->getNumBases();
2308 if (FI->isUnnamedBitfield())
2328 &&
"A union should never have more than one initializer!");
2334 diag::warn_initializer_overrides)
2336 SemaRef.
Diag(ExistingInit->getLocStart(),
2337 diag::note_previous_initializer)
2339 << ExistingInit->getSourceRange();
2354 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2373 if (Field->getType()->isIncompleteArrayType()) {
2374 bool Invalid =
false;
2375 if ((DesigIdx + 1) != DIE->
size()) {
2382 diag::err_designator_into_flexible_array_member)
2385 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2391 if (!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
2392 !isa<StringLiteral>(DIE->
getInit())) {
2396 diag::err_flexible_array_init_needs_braces)
2398 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2405 if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
2415 bool prevHadError = hadError;
2416 unsigned newStructuredIndex = FieldIndex;
2417 unsigned OldIndex = Index;
2422 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2423 StructuredList, newStructuredIndex);
2425 IList->
setInit(OldIndex, DIE);
2426 if (hadError && !prevHadError) {
2431 StructuredIndex = FieldIndex;
2436 QualType FieldType = Field->getType();
2437 unsigned newStructuredIndex = FieldIndex;
2441 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
2442 FieldType,
nullptr,
nullptr, Index,
2443 StructuredList, newStructuredIndex,
2444 FinishSubobjectInit,
false))
2455 if (IsFirstDesignator) {
2458 StructuredIndex = FieldIndex;
2462 if (!FinishSubobjectInit)
2470 bool prevHadError = hadError;
2475 CheckStructUnionTypes(Entity, IList, CurrentObjectType, NoBases, Field,
2476 false, Index, StructuredList, FieldIndex);
2477 return hadError && !prevHadError;
2499 << CurrentObjectType;
2504 Expr *IndexExpr =
nullptr;
2505 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
2509 DesignatedEndIndex = DesignatedStartIndex;
2513 DesignatedStartIndex =
2515 DesignatedEndIndex =
2524 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
2526 FullyStructuredList->sawArrayRangeDesignator();
2529 if (isa<ConstantArrayType>(AT)) {
2530 llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
2531 DesignatedStartIndex
2532 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
2533 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
2535 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
2536 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
2537 if (DesignatedEndIndex >= MaxElements) {
2540 diag::err_array_designator_too_large)
2541 << DesignatedEndIndex.toString(10) << MaxElements.toString(10)
2547 unsigned DesignatedIndexBitWidth =
2549 DesignatedStartIndex =
2550 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
2551 DesignatedEndIndex =
2552 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
2553 DesignatedStartIndex.setIsUnsigned(
true);
2554 DesignatedEndIndex.setIsUnsigned(
true);
2570 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
2574 uint64_t StrLen = SL->getLength();
2575 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2576 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2581 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2582 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
2584 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2585 if (CharTy != PromotedCharTy)
2588 StructuredList->
updateInit(Context, i, Init);
2596 uint64_t StrLen = Str.size();
2597 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2598 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2603 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2604 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
2606 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2607 if (CharTy != PromotedCharTy)
2610 StructuredList->
updateInit(Context, i, Init);
2618 DesignatedEndIndex.getZExtValue() >= StructuredList->
getNumInits())
2620 DesignatedEndIndex.getZExtValue() + 1);
2626 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
2627 unsigned OldIndex = Index;
2632 while (DesignatedStartIndex <= DesignatedEndIndex) {
2638 if (CheckDesignatedInitializer(
2639 ElementEntity, IList, DIE, DesigIdx + 1, ElementType,
nullptr,
2640 nullptr, Index, StructuredList, ElementIndex,
2641 FinishSubobjectInit && (DesignatedStartIndex == DesignatedEndIndex),
2646 ++DesignatedStartIndex;
2647 ElementIndex = DesignatedStartIndex.getZExtValue();
2652 if (IsFirstDesignator) {
2653 if (NextElementIndex)
2654 *NextElementIndex = DesignatedStartIndex;
2655 StructuredIndex = ElementIndex;
2659 if (!FinishSubobjectInit)
2663 bool prevHadError = hadError;
2664 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
2666 StructuredList, ElementIndex);
2667 return hadError && !prevHadError;
2673 InitListChecker::getStructuredSubobjectInit(
InitListExpr *IList,
unsigned Index,
2676 unsigned StructuredIndex,
2678 bool IsFullyOverwritten) {
2681 Expr *ExistingInit =
nullptr;
2682 if (!StructuredList)
2683 ExistingInit = SyntacticToSemantic.lookup(IList);
2684 else if (StructuredIndex < StructuredList->getNumInits())
2685 ExistingInit = StructuredList->
getInit(StructuredIndex);
2696 if (!IsFullyOverwritten)
2712 diag::warn_subobject_initializer_overrides)
2715 diag::note_previous_initializer)
2725 QualType ResultType = CurrentObjectType;
2731 unsigned NumElements = 0;
2732 unsigned NumInits = 0;
2733 bool GotNumInits =
false;
2734 if (!StructuredList) {
2737 }
else if (Index < IList->getNumInits()) {
2739 NumInits = SubList->getNumInits();
2747 NumElements = CAType->getSize().getZExtValue();
2750 if (GotNumInits && NumElements > NumInits)
2754 NumElements = VType->getNumElements();
2771 SyntacticToSemantic[IList] =
Result;
2779 void InitListChecker::UpdateStructuredListElement(
InitListExpr *StructuredList,
2780 unsigned &StructuredIndex,
2783 if (!StructuredList)
2787 StructuredIndex, expr)) {
2795 if (PrevInit->getSourceRange().isValid()) {
2797 diag::warn_initializer_overrides)
2800 SemaRef.
Diag(PrevInit->getLocStart(),
2801 diag::note_previous_initializer)
2803 << PrevInit->getSourceRange();
2826 if (Value.isSigned() && Value.isNegative())
2827 return S.
Diag(Loc, diag::err_array_designator_negative)
2830 Value.setIsUnsigned(
true);
2840 bool Invalid =
false;
2855 llvm::APSInt IndexValue;
2861 Designators.push_back(ASTDesignator(InitExpressions.size(),
2864 InitExpressions.push_back(Index);
2872 llvm::APSInt StartValue;
2873 llvm::APSInt EndValue;
2878 if (!StartDependent)
2884 if (!StartIndex || !EndIndex)
2888 if (StartDependent || EndDependent) {
2890 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
2891 EndValue = EndValue.extend(StartValue.getBitWidth());
2892 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
2893 StartValue = StartValue.extend(EndValue.getBitWidth());
2895 if (!StartDependent && !EndDependent && EndValue < StartValue) {
2897 << StartValue.toString(10) << EndValue.toString(10)
2901 Designators.push_back(ASTDesignator(InitExpressions.size(),
2905 InitExpressions.push_back(StartIndex);
2906 InitExpressions.push_back(EndIndex);
2923 InitExpressions, Loc, GNUSyntax,
2926 if (!getLangOpts().
C99)
2937 InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
2939 :
Parent(&Parent), Index(Index)
2942 Kind = EK_ArrayElement;
2943 Type = AT->getElementType();
2945 Kind = EK_VectorElement;
2946 Type = VT->getElementType();
2949 assert(CT &&
"Unexpected type");
2950 Kind = EK_ComplexElement;
2958 bool IsInheritedVirtualBase,
2961 Result.Kind = EK_Base;
2964 if (IsInheritedVirtualBase)
2965 Result.
Base |= 0x01;
2967 Result.Type = Base->
getType();
2974 case EK_Parameter_CF_Audited: {
2982 return Variable.VariableOrMember->getDeclName();
2984 case EK_LambdaCapture:
2993 case EK_ArrayElement:
2994 case EK_VectorElement:
2995 case EK_ComplexElement:
2996 case EK_BlockElement:
2997 case EK_LambdaToBlockConversionBlockElement:
2998 case EK_CompoundLiteralInit:
2999 case EK_RelatedResult:
3003 llvm_unreachable(
"Invalid EntityKind!");
3011 return Variable.VariableOrMember;
3014 case EK_Parameter_CF_Audited:
3023 case EK_ArrayElement:
3024 case EK_VectorElement:
3025 case EK_ComplexElement:
3026 case EK_BlockElement:
3027 case EK_LambdaToBlockConversionBlockElement:
3028 case EK_LambdaCapture:
3029 case EK_CompoundLiteralInit:
3030 case EK_RelatedResult:
3034 llvm_unreachable(
"Invalid EntityKind!");
3041 return LocAndNRVO.NRVO;
3045 case EK_Parameter_CF_Audited:
3050 case EK_CompoundLiteralInit:
3053 case EK_ArrayElement:
3054 case EK_VectorElement:
3055 case EK_ComplexElement:
3056 case EK_BlockElement:
3057 case EK_LambdaToBlockConversionBlockElement:
3058 case EK_LambdaCapture:
3059 case EK_RelatedResult:
3066 unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
3067 assert(getParent() !=
this);
3068 unsigned Depth = getParent() ? getParent()->dumpImpl(OS) : 0;
3069 for (
unsigned I = 0; I !=
Depth; ++I)
3073 case EK_Variable: OS <<
"Variable";
break;
3074 case EK_Parameter: OS <<
"Parameter";
break;
3075 case EK_Parameter_CF_Audited: OS <<
"CF audited function Parameter";
3077 case EK_Result: OS <<
"Result";
break;
3078 case EK_Exception: OS <<
"Exception";
break;
3079 case EK_Member: OS <<
"Member";
break;
3080 case EK_Binding: OS <<
"Binding";
break;
3081 case EK_New: OS <<
"New";
break;
3082 case EK_Temporary: OS <<
"Temporary";
break;
3083 case EK_CompoundLiteralInit: OS <<
"CompoundLiteral";
break;
3084 case EK_RelatedResult: OS <<
"RelatedResult";
break;
3085 case EK_Base: OS <<
"Base";
break;
3086 case EK_Delegating: OS <<
"Delegating";
break;
3087 case EK_ArrayElement: OS <<
"ArrayElement " << Index;
break;
3088 case EK_VectorElement: OS <<
"VectorElement " << Index;
break;
3089 case EK_ComplexElement: OS <<
"ComplexElement " << Index;
break;
3090 case EK_BlockElement: OS <<
"Block";
break;
3091 case EK_LambdaToBlockConversionBlockElement:
3092 OS <<
"Block (lambda)";
3094 case EK_LambdaCapture:
3095 OS <<
"LambdaCapture ";
3100 if (
auto *D = getDecl()) {
3102 D->printQualifiedName(OS);
3105 OS <<
" '" << getType().getAsString() <<
"'\n";
3111 dumpImpl(llvm::errs());
3120 case SK_ResolveAddressOfOverloadedFunction:
3121 case SK_CastDerivedToBaseRValue:
3122 case SK_CastDerivedToBaseXValue:
3123 case SK_CastDerivedToBaseLValue:
3124 case SK_BindReference:
3125 case SK_BindReferenceToTemporary:
3127 case SK_ExtraneousCopyToTemporary:
3128 case SK_UserConversion:
3129 case SK_QualificationConversionRValue:
3130 case SK_QualificationConversionXValue:
3131 case SK_QualificationConversionLValue:
3132 case SK_AtomicConversion:
3133 case SK_LValueToRValue:
3134 case SK_ListInitialization:
3135 case SK_UnwrapInitList:
3136 case SK_RewrapInitList:
3137 case SK_ConstructorInitialization:
3138 case SK_ConstructorInitializationFromList:
3139 case SK_ZeroInitialization:
3140 case SK_CAssignment:
3142 case SK_ObjCObjectConversion:
3143 case SK_ArrayLoopIndex:
3144 case SK_ArrayLoopInit:
3146 case SK_GNUArrayInit:
3147 case SK_ParenthesizedArrayInit:
3148 case SK_PassByIndirectCopyRestore:
3149 case SK_PassByIndirectRestore:
3150 case SK_ProduceObjCObject:
3151 case SK_StdInitializerList:
3152 case SK_StdInitializerListConstructorCall:
3153 case SK_OCLSamplerInit:
3154 case SK_OCLZeroEvent:
3155 case SK_OCLZeroQueue:
3158 case SK_ConversionSequence:
3159 case SK_ConversionSequenceNoNarrowing:
3166 for (
auto I = Steps.rbegin(); I != Steps.rend(); ++I) {
3167 if (I->Kind == SK_BindReference)
3169 if (I->Kind == SK_BindReferenceToTemporary)
3179 switch (getFailureKind()) {
3180 case FK_TooManyInitsForReference:
3181 case FK_ParenthesizedListInitForReference:
3182 case FK_ArrayNeedsInitList:
3183 case FK_ArrayNeedsInitListOrStringLiteral:
3184 case FK_ArrayNeedsInitListOrWideStringLiteral:
3185 case FK_NarrowStringIntoWideCharArray:
3186 case FK_WideStringIntoCharArray:
3187 case FK_IncompatWideStringIntoWideChar:
3188 case FK_AddressOfOverloadFailed:
3189 case FK_NonConstLValueReferenceBindingToTemporary:
3190 case FK_NonConstLValueReferenceBindingToBitfield:
3191 case FK_NonConstLValueReferenceBindingToVectorElement:
3192 case FK_NonConstLValueReferenceBindingToUnrelated:
3193 case FK_RValueReferenceBindingToLValue:
3194 case FK_ReferenceInitDropsQualifiers:
3195 case FK_ReferenceInitFailed:
3196 case FK_ConversionFailed:
3197 case FK_ConversionFromPropertyFailed:
3198 case FK_TooManyInitsForScalar:
3199 case FK_ParenthesizedListInitForScalar:
3200 case FK_ReferenceBindingToInitList:
3201 case FK_InitListBadDestinationType:
3202 case FK_DefaultInitOfConst:
3204 case FK_ArrayTypeMismatch:
3205 case FK_NonConstantArrayInit:
3206 case FK_ListInitializationFailed:
3207 case FK_VariableLengthArrayHasInitializer:
3208 case FK_PlaceholderType:
3209 case FK_ExplicitConstructor:
3210 case FK_AddressOfUnaddressableFunction:
3213 case FK_ReferenceInitOverloadFailed:
3214 case FK_UserConversionOverloadFailed:
3215 case FK_ConstructorOverloadFailed:
3216 case FK_ListConstructorOverloadFailed:
3220 llvm_unreachable(
"Invalid EntityKind!");
3224 return !Steps.empty() && Steps.back().Kind == SK_ConstructorInitialization;
3231 bool HadMultipleCandidates) {
3233 S.
Kind = SK_ResolveAddressOfOverloadedFunction;
3254 bool BindingTemporary) {
3256 S.
Kind = BindingTemporary? SK_BindReferenceToTemporary : SK_BindReference;
3263 S.
Kind = SK_FinalCopy;
3270 S.
Kind = SK_ExtraneousCopyToTemporary;
3279 bool HadMultipleCandidates) {
3281 S.
Kind = SK_UserConversion;
3292 S.
Kind = SK_QualificationConversionRValue;
3295 S.
Kind = SK_QualificationConversionRValue;
3298 S.
Kind = SK_QualificationConversionXValue;
3301 S.
Kind = SK_QualificationConversionLValue;
3310 S.
Kind = SK_AtomicConversion;
3316 assert(!Ty.
hasQualifiers() &&
"rvalues may not have qualifiers");
3319 S.Kind = SK_LValueToRValue;
3326 bool TopLevelOfInitList) {
3328 S.
Kind = TopLevelOfInitList ? SK_ConversionSequenceNoNarrowing
3329 : SK_ConversionSequence;
3337 S.
Kind = SK_ListInitialization;
3344 bool HadMultipleCandidates,
bool FromInitList,
bool AsInitList) {
3346 S.
Kind = FromInitList ? AsInitList ? SK_StdInitializerListConstructorCall
3347 : SK_ConstructorInitializationFromList
3348 : SK_ConstructorInitialization;
3358 S.
Kind = SK_ZeroInitialization;
3365 S.
Kind = SK_CAssignment;
3372 S.
Kind = SK_StringInit;
3379 S.
Kind = SK_ObjCObjectConversion;
3386 S.
Kind = IsGNUExtension ? SK_GNUArrayInit : SK_ArrayInit;
3393 S.
Kind = SK_ArrayLoopIndex;
3395 Steps.insert(Steps.begin(), S);
3397 S.
Kind = SK_ArrayLoopInit;
3404 S.
Kind = SK_ParenthesizedArrayInit;
3412 s.
Kind = (shouldCopy ? SK_PassByIndirectCopyRestore
3413 : SK_PassByIndirectRestore);
3420 S.
Kind = SK_ProduceObjCObject;
3427 S.
Kind = SK_StdInitializerList;
3434 S.
Kind = SK_OCLSamplerInit;
3441 S.
Kind = SK_OCLZeroEvent;
3448 S.
Kind = SK_OCLZeroQueue;
3456 "Can only rewrap trivial init lists.");
3458 S.Kind = SK_UnwrapInitList;
3460 Steps.insert(Steps.begin(), S);
3462 S.Kind = SK_RewrapInitList;
3464 S.WrappingSyntacticList = Syntactic;
3470 setSequenceKind(FailedSequence);
3471 this->Failure = Failure;
3472 this->FailedOverloadResult =
Result;
3493 if (!Init.empty()) {
3513 "consuming an object of unretainable type?");
3533 bool TreatUnavailableAsInvalid);
3544 bool TreatUnavailableAsInvalid) {
3564 TreatUnavailableAsInvalid);
3594 bool CopyInitializing,
bool AllowExplicit,
3595 bool OnlyListConstructors,
bool IsListInit,
3596 bool SecondStepOfCopyInit =
false) {
3601 if (!Info.Constructor || Info.Constructor->isInvalidDecl())
3604 if (!AllowExplicit && Info.Constructor->isExplicit())
3621 bool SuppressUserConversions =
3622 SecondStepOfCopyInit ||
3623 (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
3626 if (Info.ConstructorTmpl)
3629 CandidateSet, SuppressUserConversions);
3638 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
3642 CandidateSet, SuppressUserConversions,
3659 if (S.
getLangOpts().CPlusPlus17 && Args.size() == 1 &&
3660 !SecondStepOfCopyInit) {
3661 Expr *Initializer = Args[0];
3665 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
3675 Conv = cast<CXXConversionDecl>(D);
3677 if ((AllowExplicit && !CopyInitializing) || !Conv->isExplicit()) {
3680 ActingDC, Initializer, DestType,
3681 CandidateSet, AllowExplicit,
3685 DestType, CandidateSet, AllowExplicit,
3712 bool IsListInit =
false,
3713 bool IsInitListCopy =
false) {
3714 assert(((!IsListInit && !IsInitListCopy) ||
3715 (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3716 "IsListInit/IsInitListCopy must come with a single initializer list " 3719 (IsListInit || IsInitListCopy) ? cast<InitListExpr>(Args[0]) :
nullptr;
3743 UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isRValue() &&
3753 assert(DestRecordType &&
"Constructor initialization requires record type");
3755 = cast<CXXRecordDecl>(DestRecordType->
getDecl());
3773 bool AsInitializerList =
false;
3785 AsInitializerList =
true;
3791 CandidateSet, DestType, Ctors, Best,
3792 CopyInitialization, AllowExplicit,
3803 AsInitializerList =
false;
3805 CandidateSet, DestType, Ctors, Best,
3806 CopyInitialization, AllowExplicit,
3818 bool HadMultipleCandidates = (CandidateSet.size() > 1);
3822 if (
auto *CD = dyn_cast<CXXConversionDecl>(Best->Function)) {
3824 QualType ConvType = CD->getConversionType();
3826 "should not have selected this conversion function");
3828 HadMultipleCandidates);
3865 Best->FoundDecl, CtorDecl, DestArrayType, HadMultipleCandidates,
3866 IsListInit | IsInitListCopy, AsInitializerList);
3879 bool HadMultipleCandidates =
false;
3882 UnqualifiedTargetType,
3884 &HadMultipleCandidates)) {
3886 HadMultipleCandidates);
3887 SourceType = Fn->getType();
3919 bool TreatUnavailableAsInvalid) {
3954 bool dummy1, dummy2, dummy3;
3961 T1Quals, cv2T2, T2, T2Quals, Sequence);
3976 TreatUnavailableAsInvalid);
3993 bool TreatUnavailableAsInvalid) {
4005 TreatUnavailableAsInvalid);
4031 Expr *InitListAsExpr = InitList;
4041 if (!isa<VariableArrayType>(DestAT) &&
4051 TreatUnavailableAsInvalid);
4084 TreatUnavailableAsInvalid))
4088 Expr *InitListAsExpr = InitList;
4090 DestType, Sequence,
true);
4108 ET && ET->getDecl()->isFixed() &&
4164 TreatUnavailableAsInvalid);
4171 InitListChecker CheckInitList(S, Entity, InitList,
4172 DestType,
true, TreatUnavailableAsInvalid);
4173 if (CheckInitList.HadError()) {
4186 Expr *Initializer,
bool AllowRValues,
bool IsLValueRef,
4195 bool ObjCConversion;
4196 bool ObjCLifetimeConversion;
4198 T1, T2, DerivedToBase,
4200 ObjCLifetimeConversion) &&
4201 "Must have incompatible references when binding via conversion");
4202 (void)DerivedToBase;
4203 (void)ObjCConversion;
4204 (void)ObjCLifetimeConversion;
4225 if (!Info.Constructor)
4228 if (!Info.Constructor->isInvalidDecl() &&
4229 Info.Constructor->isConvertingConstructor(AllowExplicit)) {
4230 if (Info.ConstructorTmpl)
4233 Initializer, CandidateSet,
4237 Initializer, CandidateSet,
4253 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4256 if (isa<UsingShadowDecl>(D))
4257 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4264 Conv = cast<CXXConversionDecl>(D);
4272 if ((AllowExplicitConvs || !Conv->isExplicit()) &&
4273 (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){
4276 ActingDC, Initializer,
4277 DestType, CandidateSet,
4282 Initializer, DestType, CandidateSet,
4305 if (isa<CXXConversionDecl>(Function))
4318 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4320 HadMultipleCandidates);
4324 bool NewDerivedToBase =
false;
4325 bool NewObjCConversion =
false;
4326 bool NewObjCLifetimeConversion =
false;
4329 NewDerivedToBase, NewObjCConversion,
4330 NewObjCLifetimeConversion);
4334 assert(!isa<CXXConstructorDecl>(Function) &&
4335 "should not have conversion after constructor");
4339 ICS.
Standard = Best->FinalConversion;
4360 if (NewDerivedToBase)
4362 else if (NewObjCConversion)
4395 T1Quals, cv2T2, T2, T2Quals, Sequence);
4420 bool DerivedToBase =
false;
4421 bool ObjCConversion =
false;
4422 bool ObjCLifetimeConversion =
false;
4426 ObjCConversion, ObjCLifetimeConversion);
4439 if (isLValueRef || T1Function) {
4446 if (T1Quals != T2Quals)
4455 else if (ObjCConversion)
4474 (isLValueRef || InitCategory.
isRValue())) {
4476 S, Entity, Kind, Initializer, isRValueRef,
4477 isLValueRef, Sequence);
4502 switch (RefRelationship) {
4506 FK_NonConstLValueReferenceBindingToBitfield;
4509 FK_NonConstLValueReferenceBindingToVectorElement;
4511 llvm_unreachable(
"unexpected kind of compatible initializer");
4563 if (T1Quals != T2Quals)
4572 else if (ObjCConversion)
4586 S, Entity, Kind, Initializer,
true,
4587 isLValueRef, Sequence);
4597 isRValueRef && InitCategory.
isLValue()) {
4648 (T1CVRQuals | T2CVRQuals) != T1CVRQuals) {
4681 assert((!InitList || InitList->
getNumInits() == 0) &&
4682 "Shouldn't use value-init for non-empty init lists");
4693 if (
CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
4694 bool NeedZeroInitialization =
true;
4709 NeedZeroInitialization =
false;
4717 if (NeedZeroInitialization)
4731 ClassDecl->hasUninitializedReferenceMember()) {
4739 Expr *InitListAsExpr = InitList;
4741 bool InitListSyntax = InitList;
4746 S, Entity, Kind, Args, T, Entity.
getType(), Sequence, InitListSyntax);
4768 if (DestType->isRecordType() && S.
getLangOpts().CPlusPlus) {
4779 if (DestType.isConstQualified() && S.
getLangOpts().CPlusPlus) {
4786 if (DestType.getQualifiers().hasObjCLifetime()) {
4800 bool TopLevelOfInitList) {
4801 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
4803 assert((DestType->
isRecordType() || SourceType->isRecordType()) &&
4804 "Must have a class type to perform a user-defined conversion");
4819 = cast<CXXRecordDecl>(DestRecordType->getDecl());
4825 if (!Info.Constructor)
4828 if (!Info.Constructor->isInvalidDecl() &&
4829 Info.Constructor->isConvertingConstructor(AllowExplicit)) {
4830 if (Info.ConstructorTmpl)
4833 Initializer, CandidateSet,
4837 Initializer, CandidateSet,
4854 = cast<CXXRecordDecl>(SourceRecordType->getDecl());
4856 const auto &Conversions =
4858 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4861 if (isa<UsingShadowDecl>(D))
4862 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4869 Conv = cast<CXXConversionDecl>(D);
4871 if (AllowExplicit || !Conv->isExplicit()) {
4874 ActingDC, Initializer, DestType,
4875 CandidateSet, AllowExplicit);
4878 Initializer, DestType, CandidateSet,
4897 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4899 if (isa<CXXConstructorDecl>(Function)) {
4905 HadMultipleCandidates);
4934 HadMultipleCandidates);
4957 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
4958 Best->FinalConversion.Third) {
4961 ICS.
Standard = Best->FinalConversion;
4979 isa<CXXBoolLiteralExpr>(Init) &&
4980 !cast<CXXBoolLiteralExpr>(Init)->getValue() &&
4989 bool isAddressOf,
bool &isWeakAccess) {
4995 if (op->getOpcode() == UO_AddrOf)
5000 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
5001 switch (ce->getCastKind()) {
5004 case CK_LValueBitCast:
5008 case CK_ArrayToPointerDecay:
5011 case CK_NullToPointer:
5019 }
else if (isa<DeclRefExpr>(e)) {
5023 isWeakAccess =
true;
5027 VarDecl *var = dyn_cast<
VarDecl>(cast<DeclRefExpr>(e)->getDecl());
5041 }
else if (isa<ArraySubscriptExpr>(e)) {
5057 bool isWeakAccess =
false;
5061 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
5067 << ((
unsigned) iik - 1)
5092 Expr *Initializer) {
5093 bool ArrayDecay =
false;
5098 ArgPointee = ArgArrayType->getElementType();
5110 bool ShouldCopy =
true;
5115 if (ArrayDecay || Initializer->
isGLValue()) {
5139 Expr *Initializer) {
5160 Expr *Initializer) {
5173 Expr *Initializer) {
5188 bool TopLevelOfInitList,
5189 bool TreatUnavailableAsInvalid)
5192 TreatUnavailableAsInvalid);
5199 if (!DRE || !isa<FunctionDecl>(DRE->getDecl()))
5203 cast<FunctionDecl>(DRE->getDecl()));
5220 return isa<DecompositionDecl>(Entity.
getDecl());
5246 bool TopLevelOfInitList,
5247 bool TreatUnavailableAsInvalid) {
5254 for (
unsigned I = 0, E = Args.size(); I != E; ++I)
5255 if (Args[I]->getType()->isNonOverloadPlaceholderType()) {
5262 Args[I] = result.
get();
5283 Expr *Initializer =
nullptr;
5284 if (Args.size() == 1) {
5285 Initializer = Args[0];
5288 DestType, Initializer->
getType(),
5291 Args[0] = Initializer;
5293 if (!isa<InitListExpr>(Initializer))
5294 SourceType = Initializer->
getType();
5300 if (
InitListExpr *InitList = dyn_cast_or_null<InitListExpr>(Initializer)) {
5302 TreatUnavailableAsInvalid);
5314 if (Args.size() != 1)
5320 else if (isa<InitListExpr>(Args[0]))
5346 if (Initializer && isa<VariableArrayType>(DestAT)) {
5372 if (Initializer && isa<ConstantArrayType>(DestAT) &&
5390 Expr *OVEAsExpr = &OVE;
5392 TreatUnavailableAsInvalid);
5402 isa<CompoundLiteralExpr>(Initializer->
IgnoreParens()) &&
5418 Initializer && isa<InitListExpr>(Initializer)) {
5420 *
this, TreatUnavailableAsInvalid);
5422 }
else if (DestAT->getElementType()->isCharType())
5434 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
5441 if (allowObjCWritebackConversion &&
5474 DestType, DestType, *
this);
5483 TopLevelOfInitList);
5487 assert(Args.size() >= 1 &&
"Zero-argument case handled above");
5490 if (Args.size() > 1) {
5493 }
else if (isa<InitListExpr>(Args[0])) {
5503 bool NeedAtomicConversion =
false;
5507 Atomic->getValueType())) {
5508 DestType = Atomic->getValueType();
5509 NeedAtomicConversion =
true;
5514 TopLevelOfInitList);
5516 if (!
Failed() && NeedAtomicConversion)
5533 allowObjCWritebackConversion);
5541 bool ShouldCopy =
true;
5557 }
else if (ICS.
isBad()) {
5578 for (
auto &S : Steps)
5629 llvm_unreachable(
"Invalid EntityKind!");
5660 llvm_unreachable(
"missed an InitializedEntity kind?");
5691 llvm_unreachable(
"missed an InitializedEntity kind?");
5696 Expr *Initializer) {
5727 llvm_unreachable(
"missed an InitializedEntity kind?");
5754 bool IsExtraneousCopy) {
5761 Class = cast<CXXRecordDecl>(Record->getDecl());
5779 S, Loc, CurInitExpr, CandidateSet, T, Ctors, Best,
5788 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
5789 : diag::err_temp_copy_no_viable)
5798 S.
Diag(Loc, diag::err_temp_copy_ambiguous)
5805 S.
Diag(Loc, diag::err_temp_copy_deleted)
5812 bool HadMultipleCandidates = CandidateSet.
size() > 1;
5821 if (IsExtraneousCopy) {
5832 for (
unsigned I = 1, N = Constructor->
getNumParams(); I != N; ++I) {
5835 diag::err_call_incomplete_argument))
5875 Best->Function->getParamDecl(0)->getType().getNonReferenceType(),
5882 HadMultipleCandidates,
5900 Expr *CurInitExpr) {
5919 S, Loc, CurInitExpr, CandidateSet, CurInitExpr->
getType(), Ctors, Best,
5931 Best->FoundDecl, Entity, Diag);
5952 void InitializationSequence::PrintInitLocationNote(
Sema &S,
5967 diag::note_method_return_type_change)
5991 return NumArgs != 1;
6003 bool &ConstructorInitRequiresZeroInit,
6004 bool IsListInitialization,
6005 bool IsStdInitListInitialization,
6008 unsigned NumArgs = Args.size();
6023 assert(Constructor->
getParent() &&
"No parent class for constructor.");
6037 bool AllowExplicitConv =
6045 Loc, ConstructorArgs,
6047 IsListInitialization))
6064 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
6075 ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
6076 IsListInitialization, IsStdInitListInitialization,
6077 ConstructorInitRequiresZeroInit);
6093 if (IsListInitialization)
6094 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
6105 HadMultipleCandidates,
6106 IsListInitialization,
6107 IsStdInitListInitialization,
6108 ConstructorInitRequiresZeroInit,
6116 HadMultipleCandidates,
6117 IsListInitialization,
6118 IsStdInitListInitialization,
6119 ConstructorInitRequiresZeroInit,
6176 llvm_unreachable(
"unknown entity kind");
6246 return FallbackDecl;
6256 llvm_unreachable(
"unknown entity kind");
6273 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6286 if (
CastExpr *CE = dyn_cast<CastExpr>(Init))
6287 if (CE->getSubExpr()->isGLValue())
6288 Init = CE->getSubExpr();
6292 if (
auto *ASE = dyn_cast<ArraySubscriptExpr>(Init))
6293 Init = ASE->getBase();
6294 }
while (Init != Old);
6299 ME->setExtendingDecl(ExtendingEntity->
getDecl(),
6316 Init = BTE->getSubExpr();
6319 dyn_cast<CXXStdInitializerListExpr>(Init)) {
6324 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6326 for (
unsigned I = 0, N = ILE->
getNumInits(); I != N; ++I)
6332 assert(RD->isAggregate() &&
"aggregate init on non-aggregate");
6342 for (
const auto *I : RD->fields()) {
6345 if (I->isUnnamedBitfield())
6348 if (I->getType()->isReferenceType())
6350 else if (isa<InitListExpr>(SubInit) ||
6351 isa<CXXStdInitializerListExpr>(SubInit))
6364 const Expr *Init,
bool IsInitializerList,
6367 if (isa<FieldDecl>(ExtendingDecl)) {
6368 if (IsInitializerList) {
6369 S.
Diag(Init->
getExprLoc(), diag::warn_dangling_std_initializer_list)
6374 bool IsSubobjectMember =
false;
6378 IsSubobjectMember =
true;
6383 diag::warn_bind_ref_member_to_temporary)
6385 << IsSubobjectMember << IsInitializerList;
6386 if (IsSubobjectMember)
6388 diag::note_ref_subobject_of_member_declared_here);
6391 diag::note_ref_or_ptr_member_declared_here)
6400 const Expr *PostInit);
6404 bool IsReturnStmt) {
6415 unsigned DiagID = 0;
6451 if (VD->
hasAttr<BlocksAttr>())
6464 if (isa<ParmVarDecl>(VD))
6465 DiagID = diag::warn_redundant_move_on_return;
6467 DiagID = diag::warn_pessimizing_move_on_return;
6469 DiagID = diag::warn_pessimizing_move_on_initialization;
6511 if (UO->getOpcode() == UO_Deref &&
6512 UO->getSubExpr()->IgnoreParenCasts()->
6515 S.
PDiag(diag::warn_binding_null_to_reference)
6516 << UO->getSubExpr()->getSourceRange());
6522 bool BoundToLvalueReference) {
6523 auto MTE =
new (Context)
6532 Cleanup.setExprNeedsCleanups(
false);
6541 if (!E->
isRValue() || !getLangOpts().CPlusPlus11)
6548 if (RequireCompleteType(E->
getExprLoc(),
T, diag::err_incomplete_type))
6551 return CreateMaterializeTemporaryExpr(E->
getType(), E,
false);
6564 if (!ZeroInitializationFixit.empty()) {
6565 unsigned DiagID = diag::err_default_init_const;
6567 if (S.
getLangOpts().MSVCCompat && D->hasAttr<SelectAnyAttr>())
6568 DiagID = diag::ext_default_init_const;
6577 ZeroInitializationFixit);
6596 if (isa<InitListExpr>((
Expr *)Args[0])) {
6600 if (
auto *DD = dyn_cast_or_null<DeclaratorDecl>(Entity.
getDecl())) {
6602 TypeLoc TL = TInfo->getTypeLoc();
6605 Brackets = ArrayLoc.getBracketsRange();
6612 ArrayT->getSizeModifier(),
6613 ArrayT->getIndexTypeCVRQualifiers(),
6637 Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
6642 Expr *Init = Args[0];
6643 S.
Diag(Init->
getLocStart(), diag::warn_cxx98_compat_reference_list_init)
6656 S.
Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << 1 <<
6663 if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
6666 const Expr *Init = Args[0]->skipRValueSubobjectAdjustments();
6667 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
6668 Init = MTE->GetTemporaryExpr();
6671 S.
Diag(Init->
getLocStart(), diag::warn_temporary_array_to_pointer_decay)
6689 switch (Steps.front().Kind) {
6724 assert(Args.size() == 1);
6742 CurInit.
get() && isa<InitListExpr>(CurInit.
get()));
6747 auto checkAbstractType = [&](
QualType T) ->
bool {
6752 diag::err_allocation_of_abstract_type);
6757 bool ConstructorInitRequiresZeroInit =
false;
6788 CurInit.
get()->getLocStart(),
6789 CurInit.
get()->getSourceRange(),
6790 &BasePath, IgnoreBaseAccess))
6801 CurInit.
get(), &BasePath, VK);
6815 if (CurInit.
get()->getType()->isFunctionProtoType()) {
6816 if (
auto *DRE = dyn_cast<DeclRefExpr>(CurInit.
get()->IgnoreParens())) {
6817 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
6819 DRE->getLocStart()))
6840 assert(CurInit.
get()->isRValue() &&
"not a temporary");
6896 bool CreatedObject =
false;
6907 Loc, ConstructorArgs))
6912 FoundFn, Constructor,
6914 HadMultipleCandidates,
6928 CastKind = CK_ConstructorConversion;
6929 CreatedObject =
true;
6943 FoundFn, Conversion);
6949 HadMultipleCandidates);
6953 CastKind = CK_UserDefinedConversion;
6954 CreatedObject = Conversion->getReturnType()->isRecordType();
6957 if (CreatedObject && checkAbstractType(CurInit.
get()->getType()))
6962 CurInit.
get()->getValueKind());
6978 S.
PDiag(diag::err_access_dtor_temp) <<
T);
7002 assert(CurInit.
get()->isRValue() &&
"cannot convert glvalue to atomic");
7009 assert(CurInit.
get()->isGLValue() &&
"cannot load from a prvalue");
7011 CK_LValueToRValue, CurInit.get(),
7031 CurInit = CurInitExprRes;
7052 InitListChecker PerformInitList(S, InitEntity,
7053 InitList, Ty,
false,
7055 if (PerformInitList.HadError())
7063 if ((*ResultType)->isRValueReferenceType())
7065 else if ((*ResultType)->isLValueReferenceType())
7072 PerformInitList.getFullyStructuredList();
7076 : StructuredInitList;
7093 assert(Args.size() == 1 &&
"expected a single argument for list init");
7095 S.
Diag(InitList->getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
7096 << InitList->getSourceRange();
7097 MultiExprArg Arg(InitList->getInits(), InitList->getNumInits());
7101 ConstructorInitRequiresZeroInit,
7104 InitList->getLBraceLoc(),
7105 InitList->getRBraceLoc());
7110 CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
7139 bool IsStdInitListInit =
7143 S, UseTemporary ? TempEntity : Entity, Kind,
7145 ConstructorInitRequiresZeroInit,
7156 if (NextStep != StepEnd &&
7161 ConstructorInitRequiresZeroInit =
true;
7200 CurInit = CurInitExprRes;
7205 InitialCurInit.
get(),
7208 PrintInitLocationNote(S, Entity);
7210 }
else if (Complained)
7211 PrintInitLocationNote(S, Entity);
7224 CK_ObjCObjectLValueCast,
7225 CurInit.
get()->getValueKind());
7237 ArrayLoopCommonExprs.push_back(BaseExpr);
7242 assert(!ArrayLoopCommonExprs.empty() &&
7243 "mismatched SK_ArrayLoopIndex and SK_ArrayLoopInit");
7244 Expr *Common = ArrayLoopCommonExprs.pop_back_val();
7255 << CurInit.
get()->getSourceRange();
7266 IncompleteDest->getElementType(),
7267 ConstantSource->getSize(),
7278 << CurInit.
get()->getSourceRange();
7296 S.
Diag(CurInit.get()->getExprLoc(),
7297 diag::warn_cxx98_compat_initializer_list_init)
7298 << CurInit.get()->getSourceRange();
7302 CurInit.get()->getType(), CurInit.get(),
7341 "Sampler initialization on non-sampler type.");
7342 Expr *Init = CurInit.get();
7343 QualType SourceType = Init->getType();
7350 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Init)) {
7351 auto Var = cast<VarDecl>(DRE->getDecl());
7354 if (!Var->hasGlobalStorage()) {
7356 CK_LValueToRValue, Init,
7366 if (!Var->getInit() || !isa<ImplicitCastExpr>(Var->getInit()))
7368 Init = cast<ImplicitCastExpr>(
const_cast<Expr*
>(
7369 Var->getInit()))->getSubExpr();
7370 SourceType = Init->getType();
7377 if (!Init->isConstantInitializer(S.
Context,
false))
7388 Init->EvaluateAsInt(Result, S.
Context);
7389 const uint64_t SamplerValue = Result.getLimitedValue();
7396 unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
7397 unsigned FilterMode = (0x30 & SamplerValue) >> 4;
7398 if (FilterMode != 1 && FilterMode != 2)
7400 diag::warn_sampler_initializer_invalid_bits)
7402 if (AddressingMode > 4)
7404 diag::warn_sampler_initializer_invalid_bits)
7405 <<
"Addressing Mode";
7411 CK_IntToOCLSampler);
7416 "Event initialization on non-event type.");
7420 CurInit.get()->getValueKind());
7425 "Event initialization on non queue type.");
7429 CurInit.get()->getValueKind());
7437 cast<FieldDecl>(Entity.
getDecl())->isBitField())
7439 cast<FieldDecl>(Entity.
getDecl()),
7443 if (
const Expr *E = CurInit.
get()) {
7456 S.
Diag(Loc, diag::err_reference_without_init)
7465 for (
const auto *FI : RD->
fields()) {
7466 if (FI->isUnnamedBitfield())
7470 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
7475 for (
const auto &BI : RD->
bases()) {
7477 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
7532 if (
auto *D = Entity.
getDecl())
7533 Loc = D->getLocation();
7534 S.
Diag(Loc, diag::note_in_reference_temporary_list_initializer) <<
T;
7538 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
7541 assert(DiagnoseInitList.HadError() &&
7542 "Inconsistent init list check result.");
7564 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
7568 <<
SourceRange(Args.front()->getLocStart(), Args.back()->getLocEnd());
7572 << 1 << Entity.
getType() << Args[0]->getSourceRange();
7585 S.
Diag(Kind.
getLocation(), diag::err_array_init_narrow_string_into_wchar);
7588 S.
Diag(Kind.
getLocation(), diag::err_array_init_wide_string_into_char);
7592 diag::err_array_init_incompat_wide_string_into_wchar);
7598 ? diag::err_array_init_different_type
7599 : diag::err_array_init_non_constant_array))
7601 << Args[0]->getType()
7602 << Args[0]->getSourceRange();
7620 auto *FD = cast<FunctionDecl>(cast<DeclRefExpr>(Args[0])->getDecl());
7622 Args[0]->getLocStart());
7628 switch (FailedOverloadResult) {
7632 << Args[0]->getType() << DestType
7633 << Args[0]->getSourceRange();
7636 << DestType << Args[0]->getType()
7637 << Args[0]->getSourceRange();
7645 diag::err_typecheck_nonviable_condition_incomplete,
7646 Args[0]->getType(), Args[0]->getSourceRange()))
7649 << Args[0]->getType() << Args[0]->getSourceRange()
7658 << Args[0]->getSourceRange();
7665 llvm_unreachable(
"Inconsistent overload resolution?");
7671 llvm_unreachable(
"Conversion did not fail!");
7676 if (isa<InitListExpr>(Args[0])) {
7678 diag::err_lvalue_reference_bind_to_initlist)
7681 << Args[0]->getSourceRange();
7689 ? diag::err_lvalue_reference_bind_to_temporary
7690 : diag::err_lvalue_reference_bind_to_unrelated)
7693 << Args[0]->getType()
7694 << Args[0]->getSourceRange();
7699 FieldDecl *BitField = Args[0]->getSourceBitField();
7703 << (BitField !=
nullptr)
7704 << Args[0]->getSourceRange();
7711 S.
Diag(Kind.
getLocation(), diag::err_reference_bind_to_vector_element)
7713 << Args[0]->getSourceRange();
7719 << Args[0]->getSourceRange();
7723 QualType SourceType = Args[0]->getType();
7732 << Args[0]->getSourceRange();
7739 << Args[0]->isLValue()
7740 << Args[0]->getType()
7741 << Args[0]->getSourceRange();
7746 QualType FromType = Args[0]->getType();
7750 << Args[0]->isLValue()
7752 << Args[0]->getSourceRange();
7770 assert(Args.size() > 1 &&
"Expected multiple initializers!");
7771 R =
SourceRange(Args.front()->getLocEnd(), Args.back()->getLocEnd());
7776 S.
Diag(Kind.
getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
7786 << 0 << Entity.
getType() << Args[0]->getSourceRange();
7803 ArgsRange =
SourceRange(Args.front()->getLocStart(),
7804 Args.back()->getLocEnd());
7807 assert(Args.size() == 1 &&
7808 "List construction from other than 1 argument.");
7810 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
7815 switch (FailedOverloadResult) {
7818 << DestType << ArgsRange;
7835 InheritedFrom = Inherited.getShadowDecl()->getNominatedBaseClass();
7838 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
7851 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
7857 diag::note_member_declared_at);
7861 S.
Diag(Record->getDecl()->getLocation(),
7862 diag::note_previous_decl)
7869 << DestType << ArgsRange;
7879 <<
true << DestType << ArgsRange;
7880 llvm_unreachable(
"Inconsistent overload resolution?");
7890 << DestType << ArgsRange;
7893 <<
true << DestType << ArgsRange;
7900 llvm_unreachable(
"Conversion did not fail!");
7928 diag::err_init_incomplete_type);
7950 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
7953 diag::note_explicit_ctor_deduction_guide_here) <<
false;
7958 PrintInitLocationNote(S, Entity);
7965 OS <<
"Failed sequence: ";
7968 OS <<
"too many initializers for reference";
7972 OS <<
"parenthesized list init for reference";
7976 OS <<
"array requires initializer list";
7980 OS <<
"address of unaddressable function was taken";
7984 OS <<
"array requires initializer list or string literal";
7988 OS <<
"array requires initializer list or wide string literal";
7992 OS <<
"narrow string into wide char array";
7996 OS <<
"wide string into char array";
8000 OS <<
"incompatible wide string into wide char array";
8004 OS <<
"array type mismatch";
8008 OS <<
"non-constant array initializer";
8012 OS <<
"address of overloaded function failed";
8016 OS <<
"overload resolution for reference initialization failed";
8020 OS <<
"non-const lvalue reference bound to temporary";
8024 OS <<
"non-const lvalue reference bound to bit-field";
8028 OS <<
"non-const lvalue reference bound to vector element";
8032 OS <<
"non-const lvalue reference bound to unrelated type";
8036 OS <<
"rvalue reference bound to an lvalue";
8040 OS <<
"reference initialization drops qualifiers";
8044 OS <<
"reference initialization failed";
8048 OS <<
"conversion failed";
8052 OS <<
"conversion from property failed";
8056 OS <<
"too many initializers for scalar";
8060 OS <<
"parenthesized list init for reference";
8064 OS <<
"referencing binding to initializer list";
8068 OS <<
"initializer list for non-aggregate, non-scalar type";
8072 OS <<
"overloading failed for user-defined conversion";
8076 OS <<
"constructor overloading failed";
8080 OS <<
"default initialization of a const variable";
8084 OS <<
"initialization of incomplete type";
8088 OS <<
"list initialization checker failure";
8092 OS <<
"variable length array has an initializer";
8096 OS <<
"initializer expression isn't contextually valid";
8100 OS <<
"list constructor overloading failed";
8104 OS <<
"list copy initialization chose explicit constructor";
8112 OS <<
"Dependent sequence\n";
8116 OS <<
"Normal sequence: ";
8127 OS <<
"resolve address of overloaded function";
8131 OS <<
"derived-to-base (rvalue)";
8135 OS <<
"derived-to-base (xvalue)";
8139 OS <<
"derived-to-base (lvalue)";
8143 OS <<
"bind reference to lvalue";
8147 OS <<
"bind reference to a temporary";
8151 OS <<
"final copy in class direct-initialization";
8155 OS <<
"extraneous C++03 copy to temporary";
8159 OS <<
"user-defined conversion via " << *S->Function.Function;
8163 OS <<
"qualification conversion (rvalue)";
8167 OS <<
"qualification conversion (xvalue)";
8171 OS <<
"qualification conversion (lvalue)";
8175 OS <<
"non-atomic-to-atomic conversion";
8179 OS <<
"load (lvalue to rvalue)";
8183 OS <<
"implicit conversion sequence (";
8189 OS <<
"implicit conversion sequence with narrowing prohibited (";
8195 OS <<
"list aggregate initialization";
8199 OS <<
"unwrap reference initializer list";
8203 OS <<
"rewrap reference initializer list";
8207 OS <<
"constructor initialization";
8211 OS <<
"list initialization via constructor";
8215 OS <<
"zero initialization";
8219 OS <<
"C assignment";
8223 OS <<
"string initialization";
8227 OS <<
"Objective-C object conversion";
8231 OS <<
"indexing for array initialization loop";
8235 OS <<
"array initialization loop";
8239 OS <<
"array initialization";
8243 OS <<
"array initialization (GNU extension)";
8247 OS <<
"parenthesized array initialization";
8251 OS <<
"pass by indirect copy and restore";
8255 OS <<
"pass by indirect restore";
8259 OS <<
"Objective-C object retension";
8263 OS <<
"std::initializer_list from initializer list";
8267 OS <<
"list initialization from std::initializer_list";
8271 OS <<
"OpenCL sampler_t from integer constant";
8275 OS <<
"OpenCL event_t from zero";
8279 OS <<
"OpenCL queue_t from zero";
8283 OS <<
" [" << S->Type.getAsString() <<
']';
8297 const Expr *PostInit) {
8328 ? diag::warn_init_list_type_narrowing
8329 : diag::ext_init_list_type_narrowing)
8339 ? diag::warn_init_list_constant_narrowing
8340 : diag::ext_init_list_constant_narrowing)
8350 ? diag::warn_init_list_variable_narrowing
8351 : diag::ext_init_list_variable_narrowing)
8359 llvm::raw_svector_ostream OS(StaticCast);
8360 OS <<
"static_cast<";
8367 OS << *TT->getDecl();
8376 S.
Diag(PostInit->
getLocStart(), diag::note_init_list_narrowing_silence)
8393 assert(InitE &&
"No initialization expression");
8398 return !Seq.Failed();
8405 bool TopLevelOfInitList,
8406 bool AllowExplicit) {
8411 assert(InitE &&
"No initialization expression?");
8422 const bool ShouldTrackCopy =
8424 if (ShouldTrackCopy) {
8425 if (llvm::find(CurrentParameterCopyTypes, Entity.
getType()) !=
8426 CurrentParameterCopyTypes.end()) {
8427 Seq.SetOverloadFailure(
8433 const auto LastStep = Seq.step_end() - 1;
8434 assert(LastStep->Kind ==
8436 const FunctionDecl *Function = LastStep->Function.Function;
8438 llvm::find_if(Seq.getFailedCandidateSet(),
8440 return Candidate.Viable &&
8441 Candidate.Function == Function &&
8442 Candidate.Conversions.size() > 0;
8444 if (Candidate != Seq.getFailedCandidateSet().end() &&
8446 Candidate->Viable =
false;
8453 CurrentParameterCopyTypes.push_back(Entity.
getType());
8458 if (ShouldTrackCopy)
8459 CurrentParameterCopyTypes.pop_back();
8467 auto NotSpecialization = [&] (
const CXXRecordDecl *Candidate) {
8471 return !(NotSpecialization(RD) && RD->
forallBases(NotSpecialization));
8479 assert(DeducedTST &&
"not a deduced template specialization type");
8487 diag::err_deduced_non_class_template_specialization_type)
8490 Diag(TD->getLocation(), diag::note_template_decl_here);
8513 LookupResult Guides(*
this, NameInfo, LookupOrdinaryName);
8514 LookupQualifiedName(Guides, Template->getDeclContext());
8518 Guides.suppressDiagnostics();
8523 ? dyn_cast<InitListExpr>(Inits[0])
8538 auto tryToResolveOverload =
8541 for (
auto I = Guides.begin(), E = Guides.end(); I != E; ++I) {
8547 auto *GD = dyn_cast_or_null<CXXDeductionGuideDecl>(
8548 TD ? TD->getTemplatedDecl() : dyn_cast<
FunctionDecl>(D));
8559 if (GD->isExplicit())
8565 if (GD->getMinRequiredArguments() > 1 ||
8566 (GD->getNumParams() == 0 && !GD->isVariadic()))
8573 if (OnlyListConstructors && !isInitListConstructor(GD))
8588 bool SuppressUserConversions = Kind.
isCopyInit();
8591 AddTemplateOverloadCandidate(TD, I.getPair(),
nullptr,
8593 SuppressUserConversions);
8595 AddOverloadCandidate(GD, I.getPair(),
Inits, Candidates,
8596 SuppressUserConversions);
8598 return Candidates.BestViableFunction(*
this, Kind.
getLocation(), Best);
8606 bool TryListConstructors =
true;
8612 auto *FD = dyn_cast<
FunctionDecl>(D->getUnderlyingDecl());
8613 if (FD && FD->getMinRequiredArguments() == 0) {
8614 TryListConstructors =
false;
8626 if (!isa<InitListExpr>(E) && RD &&
8628 TryListConstructors =
false;
8631 if (TryListConstructors)
8632 Result = tryToResolveOverload(
true);
8641 Result = tryToResolveOverload(
false);
8645 Diag(Kind.
getLocation(), diag::err_deduced_class_template_ctor_ambiguous)
8655 cast<ClassTemplateDecl>(Template)->getTemplatedDecl();
8659 Complete ? diag::err_deduced_class_template_ctor_no_viable
8660 : diag::err_deduced_class_template_incomplete)
8669 NoteDeletedFunction(Best->Function);
8678 cast<CXXDeductionGuideDecl>(Best->Function)->isExplicit()) {
8679 bool IsDeductionGuide = !Best->Function->isImplicit();
8682 Diag(Best->Function->getLocation(),
8683 diag::note_explicit_ctor_deduction_guide_here)
8684 << IsDeductionGuide;
8690 DiagnoseUseOfDecl(Best->Function, Kind.
getLocation());
8691 MarkFunctionReferenced(Kind.
getLocation(), Best->Function);
8698 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.