24 #include "llvm/ADT/APInt.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/Support/ErrorHandling.h"
27 #include "llvm/Support/raw_ostream.h"
29 using namespace clang;
61 if (!isa<ConstantArrayType>(AT) && !isa<IncompleteArrayType>(AT))
120 llvm_unreachable(
"missed a StringLiteral kind?");
136 if (isa<StringLiteral>(E) || isa<ObjCEncodeExpr>(E))
138 else if (
ParenExpr *PE = dyn_cast<ParenExpr>(E))
139 E = PE->getSubExpr();
141 E = UO->getSubExpr();
143 E = GSE->getResultExpr();
145 llvm_unreachable(
"unexpected expr in string literal init");
152 auto *ConstantArrayTy =
154 uint64_t StrLength = ConstantArrayTy->getSize().getZExtValue();
159 llvm::APInt ConstVal(32, StrLength);
184 if (StrLength > CAT->
getSize().getZExtValue())
186 diag::err_initializer_string_for_char_array_too_long)
190 if (StrLength-1 > CAT->
getSize().getZExtValue())
192 diag::ext_initializer_string_for_char_array_too_long)
236 class InitListChecker {
240 bool TreatUnavailableAsInvalid;
241 llvm::DenseMap<InitListExpr *, InitListExpr *> SyntacticToSemantic;
247 unsigned &StructuredIndex);
251 bool TopLevelObject =
false);
254 bool SubobjectIsDesignatorContext,
257 unsigned &StructuredIndex,
258 bool TopLevelObject =
false);
263 unsigned &StructuredIndex);
268 unsigned &StructuredIndex);
273 unsigned &StructuredIndex);
278 unsigned &StructuredIndex);
282 unsigned &StructuredIndex);
287 bool SubobjectIsDesignatorContext,
unsigned &Index,
289 unsigned &StructuredIndex,
290 bool TopLevelObject =
false);
293 llvm::APSInt elementIndex,
294 bool SubobjectIsDesignatorContext,
unsigned &Index,
296 unsigned &StructuredIndex);
302 llvm::APSInt *NextElementIndex,
305 unsigned &StructuredIndex,
306 bool FinishSubobjectInit,
307 bool TopLevelObject);
311 unsigned StructuredIndex,
313 bool IsFullyOverwritten =
false);
314 void UpdateStructuredListElement(
InitListExpr *StructuredList,
315 unsigned &StructuredIndex,
317 int numArrayElements(
QualType DeclType);
318 int numStructUnionElements(
QualType DeclType);
324 bool TreatUnavailableAsInvalid);
348 bool FillWithNoInit);
349 void FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
352 bool FillWithNoInit =
false);
355 bool FillWithNoInit =
false);
358 bool TopLevelObject);
365 bool TreatUnavailableAsInvalid);
366 bool HadError() {
return hadError; }
370 InitListExpr *getFullyStructuredList()
const {
return FullyStructuredList; }
379 bool TreatUnavailableAsInvalid) {
390 bool EmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
403 InitExpr = VerifyOnly ? &DummyInitList :
new (SemaRef.
Context)
419 if (!InitSeq && EmptyInitList && InitSeq.getFailureKind() ==
423 InitSeq.getFailedCandidateSet()
424 .BestViableFunction(SemaRef, Kind.
getLocation(), Best);
426 assert(O ==
OR_Success &&
"Inconsistent overload resolution");
433 bool IsInStd =
false;
434 for (
NamespaceDecl *ND = dyn_cast<NamespaceDecl>(R->getDeclContext());
435 ND && !IsInStd; ND = dyn_cast<
NamespaceDecl>(ND->getParent())) {
440 if (IsInStd && llvm::StringSwitch<bool>(R->getName())
441 .Cases(
"basic_string",
"deque",
"forward_list",
true)
442 .Cases(
"list",
"map",
"multimap",
"multiset",
true)
443 .Cases(
"priority_queue",
"queue",
"set",
"stack",
true)
444 .Cases(
"unordered_map",
"unordered_set",
"vector",
true)
446 InitSeq.InitializeFrom(
450 TreatUnavailableAsInvalid);
455 diag::warn_invalid_initializer_from_system_header);
458 diag::note_used_in_initialization_here);
460 SemaRef.
Diag(Loc, diag::note_used_in_initialization_here);
467 InitSeq.Diagnose(SemaRef, Entity, Kind, SubInit);
470 diag::note_in_omitted_aggregate_initializer)
473 bool IsTrailingArrayNewMember =
476 SemaRef.
Diag(Loc, diag::note_in_omitted_aggregate_initializer)
477 << (IsTrailingArrayNewMember ? 2 : 0)
484 return VerifyOnly ?
ExprResult(static_cast<Expr *>(
nullptr))
485 : InitSeq.Perform(SemaRef, Entity, Kind, SubInit);
491 "CheckEmptyInitializable is only inteded for verification mode.");
492 if (PerformEmptyInit(SemaRef, Loc, Entity,
true,
497 void InitListChecker::FillInEmptyInitForBase(
500 bool &RequiresSecondPass,
bool FillWithNoInit) {
501 assert(Init < ILE->getNumInits() &&
"should have been expanded");
504 SemaRef.
Context, &Base,
false, &ParentEntity);
509 : PerformEmptyInit(SemaRef, ILE->
getLocEnd(), BaseEntity,
511 TreatUnavailableAsInvalid);
519 dyn_cast<InitListExpr>(ILE->
getInit(Init))) {
520 FillInEmptyInitializations(BaseEntity, InnerILE,
521 RequiresSecondPass, FillWithNoInit);
523 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init))) {
524 FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
525 RequiresSecondPass,
true);
529 void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
532 bool &RequiresSecondPass,
533 bool FillWithNoInit) {
540 if (!RType->getDecl()->isUnion())
541 assert(Init < NumInits &&
"This ILE should have been expanded");
543 if (Init >= NumInits || !ILE->
getInit(Init)) {
544 if (FillWithNoInit) {
566 RequiresSecondPass =
true;
576 SemaRef.
Diag(Loc, diag::err_init_reference_member_uninitialized)
580 diag::note_uninit_reference_member);
585 ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
587 TreatUnavailableAsInvalid);
595 }
else if (Init < NumInits) {
597 }
else if (!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
603 RequiresSecondPass =
true;
606 = dyn_cast<InitListExpr>(ILE->
getInit(Init)))
607 FillInEmptyInitializations(MemberEntity, InnerILE,
608 RequiresSecondPass, FillWithNoInit);
610 = dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init)))
611 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
612 RequiresSecondPass,
true);
621 bool &RequiresSecondPass,
622 bool FillWithNoInit) {
624 "Should not have void type");
635 Entity, ILE, RequiresSecondPass, FillWithNoInit);
636 else if (RDecl->
isUnion() && isa<CXXRecordDecl>(RDecl) &&
637 cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) {
638 for (
auto *Field : RDecl->
fields()) {
640 FillInEmptyInitForField(0, Field, Entity, ILE, RequiresSecondPass,
649 unsigned NumElems = numStructUnionElements(ILE->getType());
652 if (ILE->getNumInits() < NumElems)
653 ILE->resizeInits(SemaRef.
Context, NumElems);
657 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RDecl)) {
658 for (
auto &Base : CXXRD->bases()) {
662 FillInEmptyInitForBase(Init, Base, Entity, ILE, RequiresSecondPass,
668 for (
auto *Field : RDecl->
fields()) {
675 FillInEmptyInitForField(Init, Field, Entity, ILE, RequiresSecondPass,
694 unsigned NumInits = ILE->getNumInits();
695 unsigned NumElements = NumInits;
697 ElementType = AType->getElementType();
698 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
699 NumElements = CAType->getSize().getZExtValue();
707 ElementType = VType->getElementType();
708 NumElements = VType->getNumElements();
712 ElementType = ILE->getType();
714 for (
unsigned Init = 0; Init != NumElements; ++Init) {
722 Expr *InitExpr = (Init < NumInits ? ILE->getInit(Init) :
nullptr);
723 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
724 ILE->setInit(Init, ILE->getArrayFiller());
725 else if (!InitExpr && !ILE->hasArrayFiller()) {
726 Expr *Filler =
nullptr;
731 ExprResult ElementInit = PerformEmptyInit(SemaRef, ILE->getLocEnd(),
734 TreatUnavailableAsInvalid);
745 }
else if (Init < NumInits) {
749 ILE->setArrayFiller(Filler);
751 ILE->setInit(Init, Filler);
756 ILE->setArrayFiller(Filler);
760 if (!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
765 ILE->updateInit(SemaRef.
Context, Init, Filler);
766 RequiresSecondPass =
true;
770 = dyn_cast_or_null<InitListExpr>(InitExpr))
771 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
774 = dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr))
775 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
776 RequiresSecondPass,
true);
783 bool TreatUnavailableAsInvalid)
784 : SemaRef(S), VerifyOnly(VerifyOnly),
785 TreatUnavailableAsInvalid(TreatUnavailableAsInvalid) {
791 FullyStructuredList =
792 getStructuredSubobjectInit(IL, 0, T,
nullptr, 0, IL->
getSourceRange());
793 CheckExplicitInitList(Entity, IL, T, FullyStructuredList,
796 if (!hadError && !VerifyOnly) {
797 bool RequiresSecondPass =
false;
798 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass);
799 if (RequiresSecondPass && !hadError)
800 FillInEmptyInitializations(Entity, FullyStructuredList,
805 int InitListChecker::numArrayElements(
QualType DeclType) {
807 int maxElements = 0x7FFFFFFF;
810 maxElements =
static_cast<int>(CAT->getSize().getZExtValue());
815 int InitListChecker::numStructUnionElements(
QualType DeclType) {
817 int InitializableMembers = 0;
818 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(structDecl))
819 InitializableMembers += CXXRD->getNumBases();
820 for (
const auto *Field : structDecl->
fields())
822 ++InitializableMembers;
825 return std::min(InitializableMembers, 1);
839 unsigned &StructuredIndex) {
843 maxElements = numArrayElements(T);
845 maxElements = numStructUnionElements(T);
849 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
851 if (maxElements == 0) {
854 diag::err_implicit_empty_initializer);
862 = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList,
866 unsigned StructuredSubobjectInitIndex = 0;
869 unsigned StartIndex = Index;
870 CheckListElementTypes(Entity, ParentIList, T,
872 StructuredSubobjectInitList,
873 StructuredSubobjectInitIndex);
876 StructuredSubobjectInitList->
setType(T);
878 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
881 if (EndIndex < ParentIList->getNumInits() &&
882 ParentIList->
getInit(EndIndex)) {
891 diag::warn_missing_braces)
893 << FixItHint::CreateInsertion(
895 << FixItHint::CreateInsertion(
897 StructuredSubobjectInitList->
getLocEnd()),
916 case InitializedEntity::EK_VectorElement:
917 case InitializedEntity::EK_ComplexElement:
918 case InitializedEntity::EK_ArrayElement:
919 case InitializedEntity::EK_Parameter:
920 case InitializedEntity::EK_Parameter_CF_Audited:
921 case InitializedEntity::EK_Result:
923 DiagID = diag::warn_braces_around_scalar_init;
926 case InitializedEntity::EK_Member:
930 DiagID = diag::warn_braces_around_scalar_init;
933 case InitializedEntity::EK_Variable:
934 case InitializedEntity::EK_LambdaCapture:
939 case InitializedEntity::EK_New:
940 case InitializedEntity::EK_Temporary:
941 case InitializedEntity::EK_CompoundLiteralInit:
945 case InitializedEntity::EK_RelatedResult:
949 case InitializedEntity::EK_Exception:
950 case InitializedEntity::EK_Base:
951 case InitializedEntity::EK_Delegating:
952 case InitializedEntity::EK_BlockElement:
953 case InitializedEntity::EK_LambdaToBlockConversionBlockElement:
954 case InitializedEntity::EK_Binding:
955 llvm_unreachable(
"unexpected braced scalar init");
961 << FixItHint::CreateRemoval(Braces.
getBegin())
962 << FixItHint::CreateRemoval(Braces.
getEnd());
974 bool TopLevelObject) {
976 SyntacticToSemantic[IList] = StructuredList;
980 unsigned Index = 0, StructuredIndex = 0;
981 CheckListElementTypes(Entity, IList, T,
true,
982 Index, StructuredList, StructuredIndex, TopLevelObject);
988 StructuredList->
setType(ExprTy);
993 if (Index < IList->getNumInits()) {
1004 if (StructuredIndex == 1 &&
1007 unsigned DK = diag::ext_excess_initializers_in_char_array_initializer;
1009 DK = diag::err_excess_initializers_in_char_array_initializer;
1026 unsigned DK = diag::ext_excess_initializers;
1028 DK = diag::err_excess_initializers;
1031 if (SemaRef.
getLangOpts().OpenCL && initKind == 1) {
1032 DK = diag::err_excess_initializers;
1049 bool SubobjectIsDesignatorContext,
1052 unsigned &StructuredIndex,
1053 bool TopLevelObject) {
1057 CheckComplexType(Entity, IList, DeclType, Index,
1058 StructuredList, StructuredIndex);
1060 CheckScalarType(Entity, IList, DeclType, Index,
1061 StructuredList, StructuredIndex);
1063 CheckVectorType(Entity, IList, DeclType, Index,
1064 StructuredList, StructuredIndex);
1067 "non-aggregate records should be handed in CheckSubElementType");
1072 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
1073 Bases = CXXRD->bases();
1074 CheckStructUnionTypes(Entity, IList, DeclType, Bases, RD->field_begin(),
1075 SubobjectIsDesignatorContext, Index, StructuredList,
1076 StructuredIndex, TopLevelObject);
1081 CheckArrayType(Entity, IList, DeclType, Zero,
1082 SubobjectIsDesignatorContext, Index,
1083 StructuredList, StructuredIndex);
1088 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1092 CheckReferenceType(Entity, IList, DeclType, Index,
1093 StructuredList, StructuredIndex);
1101 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1112 unsigned &StructuredIndex) {
1116 return CheckReferenceType(Entity, IList, ElemType, Index,
1117 StructuredList, StructuredIndex);
1119 if (
InitListExpr *SubInitList = dyn_cast<InitListExpr>(expr)) {
1120 if (SubInitList->getNumInits() == 1 &&
1123 expr = SubInitList->getInit(0);
1126 = getStructuredSubobjectInit(IList, Index, ElemType,
1127 StructuredList, StructuredIndex,
1128 SubInitList->getSourceRange(),
true);
1129 CheckExplicitInitList(Entity, SubInitList, ElemType,
1130 InnerStructuredList);
1132 if (!hadError && !VerifyOnly) {
1133 bool RequiresSecondPass =
false;
1134 FillInEmptyInitializations(Entity, InnerStructuredList,
1135 RequiresSecondPass);
1136 if (RequiresSecondPass && !hadError)
1137 FillInEmptyInitializations(Entity, InnerStructuredList,
1138 RequiresSecondPass);
1145 }
else if (isa<ImplicitValueInitExpr>(expr)) {
1149 "found implicit initialization for the wrong type");
1151 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1173 if (Seq || isa<InitListExpr>(expr)) {
1176 Seq.Perform(SemaRef, Entity, Kind, expr);
1180 UpdateStructuredListElement(StructuredList, StructuredIndex,
1191 return CheckScalarType(Entity, IList, ElemType, Index,
1192 StructuredList, StructuredIndex);
1202 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1224 ElemType, ExprRes, !VerifyOnly) != Sema::Incompatible) {
1232 UpdateStructuredListElement(StructuredList, StructuredIndex,
1250 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1270 unsigned &StructuredIndex) {
1271 assert(Index == 0 &&
"Index in explicit init list must be zero");
1281 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1286 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1293 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1295 for (
unsigned i = 0; i < 2; ++i) {
1297 CheckSubElementType(ElementEntity, IList, elementType, Index,
1298 StructuredList, StructuredIndex);
1306 unsigned &StructuredIndex) {
1311 diag::warn_cxx98_compat_empty_scalar_initializer :
1312 diag::err_empty_scalar_initializer)
1321 if (
InitListExpr *SubIList = dyn_cast<InitListExpr>(expr)) {
1325 SemaRef.
Diag(SubIList->getLocStart(),
1326 diag::ext_many_braces_around_scalar_init)
1327 << SubIList->getSourceRange();
1329 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1332 }
else if (isa<DesignatedInitExpr>(expr)) {
1335 diag::err_designator_for_scalar_init)
1354 Expr *ResultExpr =
nullptr;
1361 if (ResultExpr != expr) {
1363 IList->
setInit(Index, ResultExpr);
1369 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1377 unsigned &StructuredIndex) {
1385 diag::err_init_reference_member_uninitialized)
1395 if (isa<InitListExpr>(expr) && !SemaRef.
getLangOpts().CPlusPlus11) {
1425 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1433 unsigned &StructuredIndex) {
1436 unsigned numEltsInit = 0;
1442 CheckEmptyInitializable(
1443 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity),
1464 Expr *ResultExpr =
nullptr;
1470 if (ResultExpr != Init) {
1472 IList->
setInit(Index, ResultExpr);
1478 UpdateStructuredListElement(StructuredList, StructuredIndex,
1485 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1487 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1491 CheckEmptyInitializable(ElementEntity, IList->
getLocEnd());
1496 CheckSubElementType(ElementEntity, IList, elementType, Index,
1497 StructuredList, StructuredIndex);
1505 if (isBigEndian && (T->
getVectorKind() == VectorType::NeonVector ||
1518 diag::warn_neon_vector_initializer_non_portable);
1520 const char *typeCode;
1530 llvm_unreachable(
"Invalid element type!");
1534 diag::note_neon_vector_initializer_non_portable_q :
1535 diag::note_neon_vector_initializer_non_portable)
1536 << typeCode << typeSize;
1543 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1546 for (
unsigned i = 0; i < maxElements; ++i) {
1555 CheckSubElementType(ElementEntity, IList, elementType, Index,
1556 StructuredList, StructuredIndex);
1568 CheckSubElementType(ElementEntity, IList, VecType, Index,
1569 StructuredList, StructuredIndex);
1570 numEltsInit += numIElts;
1575 if (numEltsInit != maxElements) {
1578 diag::err_vector_incorrect_num_initializers)
1579 << (numEltsInit < maxElements) << maxElements << numEltsInit;
1586 llvm::APSInt elementIndex,
1587 bool SubobjectIsDesignatorContext,
1590 unsigned &StructuredIndex) {
1594 if (Index < IList->getNumInits()) {
1604 UpdateStructuredListElement(StructuredList, StructuredIndex,
1617 SemaRef.
Diag(VAT->getSizeExpr()->getLocStart(),
1618 diag::err_variable_object_no_init)
1619 << VAT->getSizeExpr()->getSourceRange();
1627 llvm::APSInt maxElements(elementIndex.getBitWidth(),
1628 elementIndex.isUnsigned());
1629 bool maxElementsKnown =
false;
1631 maxElements = CAT->getSize();
1632 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
1633 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1634 maxElementsKnown =
true;
1638 while (Index < IList->getNumInits()) {
1644 if (!SubobjectIsDesignatorContext)
1649 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1650 DeclType,
nullptr, &elementIndex, Index,
1651 StructuredList, StructuredIndex,
true,
1657 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
1658 maxElements = maxElements.extend(elementIndex.getBitWidth());
1659 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
1660 elementIndex = elementIndex.extend(maxElements.getBitWidth());
1661 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1665 if (!maxElementsKnown && elementIndex > maxElements)
1666 maxElements = elementIndex;
1673 if (maxElementsKnown && elementIndex == maxElements)
1677 InitializedEntity::InitializeElement(SemaRef.
Context, StructuredIndex,
1680 CheckSubElementType(ElementEntity, IList, elementType, Index,
1681 StructuredList, StructuredIndex);
1686 if (!maxElementsKnown && elementIndex > maxElements)
1687 maxElements = elementIndex;
1692 llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
1697 diag::ext_typecheck_zero_array_size);
1701 ArrayType::Normal, 0);
1703 if (!hadError && VerifyOnly) {
1709 if ((maxElementsKnown && elementIndex < maxElements) ||
1711 CheckEmptyInitializable(InitializedEntity::InitializeElement(
1720 bool TopLevelObject) {
1722 unsigned FlexArrayDiag;
1723 if (isa<InitListExpr>(InitExpr) &&
1724 cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
1726 FlexArrayDiag = diag::ext_flexible_array_init;
1730 FlexArrayDiag = diag::err_flexible_array_init;
1731 }
else if (!TopLevelObject) {
1733 FlexArrayDiag = diag::err_flexible_array_init;
1734 }
else if (Entity.
getKind() != InitializedEntity::EK_Variable) {
1736 FlexArrayDiag = diag::err_flexible_array_init;
1737 }
else if (cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
1739 FlexArrayDiag = diag::err_flexible_array_init;
1742 FlexArrayDiag = diag::ext_flexible_array_init;
1753 return FlexArrayDiag != diag::ext_flexible_array_init;
1756 void InitListChecker::CheckStructUnionTypes(
1759 bool SubobjectIsDesignatorContext,
unsigned &Index,
1760 InitListExpr *StructuredList,
unsigned &StructuredIndex,
1761 bool TopLevelObject) {
1777 if (isa<CXXRecordDecl>(RD) && cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
1781 Field != FieldEnd; ++Field) {
1782 if (Field->hasInClassInitializer()) {
1793 Field != FieldEnd; ++Field) {
1794 if (!Field->isUnnamedBitfield()) {
1796 CheckEmptyInitializable(
1797 InitializedEntity::InitializeMember(*Field, &Entity),
1807 bool InitializedSomething =
false;
1810 for (
auto &Base : Bases) {
1816 if (Init && isa<DesignatedInitExpr>(Init))
1820 SemaRef.
Context, &Base,
false, &Entity);
1822 CheckSubElementType(BaseEntity, IList, Base.
getType(), Index,
1823 StructuredList, StructuredIndex);
1824 InitializedSomething =
true;
1825 }
else if (VerifyOnly) {
1826 CheckEmptyInitializable(BaseEntity, InitLoc);
1836 bool CheckForMissingFields =
true;
1837 while (Index < IList->getNumInits()) {
1844 if (!SubobjectIsDesignatorContext)
1849 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1850 DeclType, &Field,
nullptr, Index,
1851 StructuredList, StructuredIndex,
1852 true, TopLevelObject))
1855 InitializedSomething =
true;
1859 CheckForMissingFields =
false;
1863 if (Field == FieldEnd) {
1869 if (InitializedSomething && DeclType->
isUnionType())
1873 if (Field->getType()->isIncompleteArrayType())
1876 if (Field->isUnnamedBitfield()) {
1885 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
1897 InitializedEntity::InitializeMember(*Field, &Entity);
1898 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1899 StructuredList, StructuredIndex);
1900 InitializedSomething =
true;
1904 StructuredList->setInitializedFieldInUnion(*Field);
1911 if (!VerifyOnly && InitializedSomething && CheckForMissingFields &&
1912 Field != FieldEnd && !Field->getType()->isIncompleteArrayType() &&
1918 if (!it->isUnnamedBitfield() && !it->hasInClassInitializer()) {
1920 diag::warn_missing_field_initializers) << *it;
1927 if (VerifyOnly && Field != FieldEnd && !DeclType->
isUnionType() &&
1928 !Field->getType()->isIncompleteArrayType()) {
1930 for (; Field != FieldEnd && !hadError; ++Field) {
1931 if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
1932 CheckEmptyInitializable(
1933 InitializedEntity::InitializeMember(*Field, &Entity),
1938 if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
1942 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
1950 InitializedEntity::InitializeMember(*Field, &Entity);
1952 if (isa<InitListExpr>(IList->
getInit(Index)))
1953 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1954 StructuredList, StructuredIndex);
1956 CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index,
1957 StructuredList, StructuredIndex);
1973 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
1981 assert(isa<FieldDecl>(*PI));
1982 Replacements.back().setField(cast<FieldDecl>(*PI));
1989 &Replacements[0] + Replacements.size());
1996 for (
unsigned I = 0;
I < NumIndexExprs; ++
I)
2010 explicit FieldInitializerValidatorCCC(
RecordDecl *RD)
2066 llvm::APSInt *NextElementIndex,
2069 unsigned &StructuredIndex,
2070 bool FinishSubobjectInit,
2071 bool TopLevelObject) {
2072 if (DesigIdx == DIE->
size()) {
2074 bool prevHadError = hadError;
2079 unsigned OldIndex = Index;
2082 CheckSubElementType(Entity, IList, CurrentObjectType, Index,
2083 StructuredList, StructuredIndex);
2089 IList->
setInit(OldIndex, DIE);
2091 return hadError && !prevHadError;
2095 bool IsFirstDesignator = (DesigIdx == 0);
2097 assert((IsFirstDesignator || StructuredList) &&
2098 "Need a non-designated initializer list to start from");
2102 if (IsFirstDesignator)
2103 StructuredList = SyntacticToSemantic.lookup(IList);
2105 Expr *ExistingInit = StructuredIndex < StructuredList->
getNumInits() ?
2106 StructuredList->
getInit(StructuredIndex) :
nullptr;
2112 getStructuredSubobjectInit(IList, Index, CurrentObjectType,
2113 StructuredList, StructuredIndex,
2116 else if (
InitListExpr *Result = dyn_cast<InitListExpr>(ExistingInit))
2120 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2121 StructuredList =
E->getUpdater();
2152 diag::warn_subobject_initializer_overrides)
2156 diag::note_previous_initializer)
2162 assert(StructuredList &&
"Expected a structured initializer list");
2181 SemaRef.
Diag(Loc, diag::err_field_designator_non_aggr)
2182 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2192 if (
auto *FD = dyn_cast<FieldDecl>(ND)) {
2196 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND)) {
2202 KnownField = cast<FieldDecl>(*IFD->chain_begin());
2213 if (!Lookup.empty()) {
2216 SemaRef.
Diag(Lookup.front()->getLocation(),
2217 diag::note_field_designator_found);
2226 Sema::LookupMemberName,
nullptr,
nullptr,
2227 llvm::make_unique<FieldInitializerValidatorCCC>(RT->
getDecl()),
2228 Sema::CTK_ErrorRecovery, RT->
getDecl())) {
2231 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2232 << FieldName << CurrentObjectType);
2233 KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2238 << FieldName << CurrentObjectType;
2245 unsigned FieldIndex = 0;
2247 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RT->
getDecl()))
2248 FieldIndex = CXXRD->getNumBases();
2251 if (FI->isUnnamedBitfield())
2271 &&
"A union should never have more than one initializer!");
2277 diag::warn_initializer_overrides)
2279 SemaRef.
Diag(ExistingInit->getLocStart(),
2280 diag::note_previous_initializer)
2282 << ExistingInit->getSourceRange();
2297 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2316 if (Field->getType()->isIncompleteArrayType()) {
2318 if ((DesigIdx + 1) != DIE->
size()) {
2325 diag::err_designator_into_flexible_array_member)
2328 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2334 if (!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
2335 !isa<StringLiteral>(DIE->
getInit())) {
2339 diag::err_flexible_array_init_needs_braces)
2341 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2348 if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
2358 bool prevHadError = hadError;
2359 unsigned newStructuredIndex = FieldIndex;
2360 unsigned OldIndex = Index;
2364 InitializedEntity::InitializeMember(*Field, &Entity);
2365 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2366 StructuredList, newStructuredIndex);
2368 IList->
setInit(OldIndex, DIE);
2369 if (hadError && !prevHadError) {
2374 StructuredIndex = FieldIndex;
2379 QualType FieldType = Field->getType();
2380 unsigned newStructuredIndex = FieldIndex;
2383 InitializedEntity::InitializeMember(*Field, &Entity);
2384 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
2385 FieldType,
nullptr,
nullptr, Index,
2386 StructuredList, newStructuredIndex,
2387 FinishSubobjectInit,
false))
2398 if (IsFirstDesignator) {
2401 StructuredIndex = FieldIndex;
2405 if (!FinishSubobjectInit)
2413 bool prevHadError = hadError;
2418 CheckStructUnionTypes(Entity, IList, CurrentObjectType, NoBases, Field,
2419 false, Index, StructuredList, FieldIndex);
2420 return hadError && !prevHadError;
2442 << CurrentObjectType;
2447 Expr *IndexExpr =
nullptr;
2448 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
2452 DesignatedEndIndex = DesignatedStartIndex;
2456 DesignatedStartIndex =
2458 DesignatedEndIndex =
2467 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
2469 FullyStructuredList->sawArrayRangeDesignator();
2472 if (isa<ConstantArrayType>(AT)) {
2473 llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
2474 DesignatedStartIndex
2475 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
2476 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
2478 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
2479 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
2480 if (DesignatedEndIndex >= MaxElements) {
2483 diag::err_array_designator_too_large)
2484 << DesignatedEndIndex.toString(10) << MaxElements.toString(10)
2490 unsigned DesignatedIndexBitWidth =
2491 ConstantArrayType::getMaxSizeBits(SemaRef.
Context);
2492 DesignatedStartIndex =
2493 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
2494 DesignatedEndIndex =
2495 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
2496 DesignatedStartIndex.setIsUnsigned(
true);
2497 DesignatedEndIndex.setIsUnsigned(
true);
2500 if (!VerifyOnly && StructuredList->isStringLiteralInit()) {
2513 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
2517 uint64_t StrLen = SL->getLength();
2518 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2519 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2520 StructuredList->resizeInits(Context, StrLen);
2524 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2525 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
2527 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2528 if (CharTy != PromotedCharTy)
2531 StructuredList->updateInit(Context, i, Init);
2539 uint64_t StrLen = Str.size();
2540 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2541 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2542 StructuredList->resizeInits(Context, StrLen);
2546 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2547 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
2549 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2550 if (CharTy != PromotedCharTy)
2553 StructuredList->updateInit(Context, i, Init);
2561 DesignatedEndIndex.getZExtValue() >= StructuredList->getNumInits())
2562 StructuredList->resizeInits(SemaRef.
Context,
2563 DesignatedEndIndex.getZExtValue() + 1);
2569 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
2570 unsigned OldIndex = Index;
2573 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
2575 while (DesignatedStartIndex <= DesignatedEndIndex) {
2581 if (CheckDesignatedInitializer(
2582 ElementEntity, IList, DIE, DesigIdx + 1, ElementType,
nullptr,
2583 nullptr, Index, StructuredList, ElementIndex,
2584 FinishSubobjectInit && (DesignatedStartIndex == DesignatedEndIndex),
2589 ++DesignatedStartIndex;
2590 ElementIndex = DesignatedStartIndex.getZExtValue();
2595 if (IsFirstDesignator) {
2596 if (NextElementIndex)
2597 *NextElementIndex = DesignatedStartIndex;
2598 StructuredIndex = ElementIndex;
2602 if (!FinishSubobjectInit)
2606 bool prevHadError = hadError;
2607 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
2609 StructuredList, ElementIndex);
2610 return hadError && !prevHadError;
2616 InitListChecker::getStructuredSubobjectInit(
InitListExpr *IList,
unsigned Index,
2619 unsigned StructuredIndex,
2621 bool IsFullyOverwritten) {
2624 Expr *ExistingInit =
nullptr;
2625 if (!StructuredList)
2626 ExistingInit = SyntacticToSemantic.lookup(IList);
2627 else if (StructuredIndex < StructuredList->getNumInits())
2628 ExistingInit = StructuredList->
getInit(StructuredIndex);
2630 if (
InitListExpr *Result = dyn_cast_or_null<InitListExpr>(ExistingInit))
2639 if (!IsFullyOverwritten)
2655 diag::warn_subobject_initializer_overrides)
2658 diag::note_previous_initializer)
2668 QualType ResultType = CurrentObjectType;
2674 unsigned NumElements = 0;
2675 unsigned NumInits = 0;
2676 bool GotNumInits =
false;
2677 if (!StructuredList) {
2680 }
else if (Index < IList->getNumInits()) {
2682 NumInits = SubList->getNumInits();
2690 NumElements = CAType->getSize().getZExtValue();
2693 if (GotNumInits && NumElements > NumInits)
2697 NumElements = VType->getNumElements();
2714 SyntacticToSemantic[IList] =
Result;
2722 void InitListChecker::UpdateStructuredListElement(
InitListExpr *StructuredList,
2723 unsigned &StructuredIndex,
2726 if (!StructuredList)
2730 StructuredIndex, expr)) {
2738 if (PrevInit->getSourceRange().isValid()) {
2740 diag::warn_initializer_overrides)
2743 SemaRef.
Diag(PrevInit->getLocStart(),
2744 diag::note_previous_initializer)
2746 << PrevInit->getSourceRange();
2769 if (Value.isSigned() && Value.isNegative())
2770 return S.
Diag(Loc, diag::err_array_designator_negative)
2773 Value.setIsUnsigned(
true);
2783 bool Invalid =
false;
2798 llvm::APSInt IndexValue;
2804 Designators.push_back(ASTDesignator(InitExpressions.size(),
2807 InitExpressions.push_back(Index);
2815 llvm::APSInt StartValue;
2816 llvm::APSInt EndValue;
2821 if (!StartDependent)
2827 if (!StartIndex || !EndIndex)
2831 if (StartDependent || EndDependent) {
2833 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
2834 EndValue = EndValue.extend(StartValue.getBitWidth());
2835 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
2836 StartValue = StartValue.extend(EndValue.getBitWidth());
2838 if (!StartDependent && !EndDependent && EndValue < StartValue) {
2840 << StartValue.toString(10) << EndValue.toString(10)
2844 Designators.push_back(ASTDesignator(InitExpressions.size(),
2848 InitExpressions.push_back(StartIndex);
2849 InitExpressions.push_back(EndIndex);
2866 InitExpressions, Loc, GNUSyntax,
2880 InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
2882 : Parent(&Parent), Index(Index)
2885 Kind = EK_ArrayElement;
2888 Kind = EK_VectorElement;
2892 assert(CT &&
"Unexpected type");
2893 Kind = EK_ComplexElement;
2901 bool IsInheritedVirtualBase,
2905 Result.Parent = Parent;
2907 if (IsInheritedVirtualBase)
2908 Result.
Base |= 0x01;
2910 Result.Type = Base->
getType();
2925 return Variable.VariableOrMember->getDeclName();
2946 llvm_unreachable(
"Invalid EntityKind!");
2977 llvm_unreachable(
"Invalid EntityKind!");
3009 unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
3012 for (
unsigned I = 0;
I !=
Depth; ++
I)
3024 case EK_New: OS <<
"New";
break;
3028 case EK_Base: OS <<
"Base";
break;
3035 OS <<
"Block (lambda)";
3038 OS <<
"LambdaCapture ";
3045 D->printQualifiedName(OS);
3054 dumpImpl(llvm::errs());
3109 for (
auto I = Steps.rbegin();
I != Steps.rend(); ++
I) {
3163 llvm_unreachable(
"Invalid EntityKind!");
3174 bool HadMultipleCandidates) {
3197 bool BindingTemporary) {
3222 bool HadMultipleCandidates) {
3259 assert(!Ty.
hasQualifiers() &&
"rvalues may not have qualifiers");
3269 bool TopLevelOfInitList) {
3287 bool HadMultipleCandidates,
bool FromInitList,
bool AsInitList) {
3338 Steps.insert(Steps.begin(),
S);
3399 "Can only rewrap trivial init lists.");
3403 Steps.insert(Steps.begin(),
S);
3407 S.WrappingSyntacticList = Syntactic;
3414 this->Failure = Failure;
3415 this->FailedOverloadResult =
Result;
3436 if (!Init.empty()) {
3456 "consuming an object of unretainable type?");
3476 bool TreatUnavailableAsInvalid);
3487 bool TreatUnavailableAsInvalid) {
3507 TreatUnavailableAsInvalid);
3536 bool CopyInitializing,
bool AllowExplicit,
3537 bool OnlyListConstructors,
bool IsListInit,
3538 bool SecondStepOfCopyInit =
false) {
3539 CandidateSet.
clear();
3543 if (!Info.Constructor || Info.Constructor->isInvalidDecl())
3546 if (!AllowExplicit && Info.Constructor->isExplicit())
3563 bool SuppressUserConversions =
3564 SecondStepOfCopyInit ||
3565 (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
3568 if (Info.ConstructorTmpl)
3571 CandidateSet, SuppressUserConversions);
3580 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
3584 CandidateSet, SuppressUserConversions,
3610 bool IsListInit =
false,
3611 bool IsInitListCopy =
false) {
3612 assert(((!IsListInit && !IsInitListCopy) ||
3613 (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3614 "IsListInit/IsInitListCopy must come with a single initializer list "
3617 (IsListInit || IsInitListCopy) ? cast<InitListExpr>(Args[0]) :
nullptr;
3641 UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isRValue() &&
3651 assert(DestRecordType &&
"Constructor initialization requires record type");
3653 = cast<CXXRecordDecl>(DestRecordType->
getDecl());
3671 bool AsInitializerList =
false;
3683 AsInitializerList =
true;
3689 CandidateSet, Ctors, Best,
3690 CopyInitialization, AllowExplicit,
3701 AsInitializerList =
false;
3703 CandidateSet, Ctors, Best,
3704 CopyInitialization, AllowExplicit,
3744 bool HadMultipleCandidates = (CandidateSet.size() > 1);
3746 Best->FoundDecl, CtorDecl, DestArrayType, HadMultipleCandidates,
3747 IsListInit | IsInitListCopy, AsInitializerList);
3760 bool HadMultipleCandidates =
false;
3763 UnqualifiedTargetType,
3765 &HadMultipleCandidates)) {
3767 HadMultipleCandidates);
3768 SourceType = Fn->getType();
3800 bool TreatUnavailableAsInvalid) {
3835 bool dummy1, dummy2, dummy3;
3842 T1Quals, cv2T2, T2, T2Quals, Sequence);
3857 TreatUnavailableAsInvalid);
3874 bool TreatUnavailableAsInvalid) {
3886 TreatUnavailableAsInvalid);
3912 Expr *InitListAsExpr = InitList;
3922 if (!isa<VariableArrayType>(DestAT) &&
3932 TreatUnavailableAsInvalid);
3965 TreatUnavailableAsInvalid))
3969 Expr *InitListAsExpr = InitList;
3971 DestType, Sequence,
true);
3989 ET && ET->getDecl()->isFixed() &&
4045 TreatUnavailableAsInvalid);
4052 InitListChecker CheckInitList(S, Entity, InitList,
4053 DestType,
true, TreatUnavailableAsInvalid);
4054 if (CheckInitList.HadError()) {
4067 Expr *Initializer,
bool AllowRValues,
bool IsLValueRef,
4076 bool ObjCConversion;
4077 bool ObjCLifetimeConversion;
4079 T1, T2, DerivedToBase,
4081 ObjCLifetimeConversion) &&
4082 "Must have incompatible references when binding via conversion");
4083 (void)DerivedToBase;
4084 (void)ObjCConversion;
4085 (void)ObjCLifetimeConversion;
4090 CandidateSet.
clear();
4106 if (!Info.Constructor)
4109 if (!Info.Constructor->isInvalidDecl() &&
4110 Info.Constructor->isConvertingConstructor(AllowExplicit)) {
4111 if (Info.ConstructorTmpl)
4114 Initializer, CandidateSet,
4118 Initializer, CandidateSet,
4134 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
4137 if (isa<UsingShadowDecl>(D))
4138 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4145 Conv = cast<CXXConversionDecl>(D);
4153 if ((AllowExplicitConvs || !Conv->isExplicit()) &&
4154 (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){
4157 ActingDC, Initializer,
4158 DestType, CandidateSet,
4163 Initializer, DestType, CandidateSet,
4186 if (isa<CXXConversionDecl>(Function))
4199 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4201 HadMultipleCandidates);
4205 bool NewDerivedToBase =
false;
4206 bool NewObjCConversion =
false;
4207 bool NewObjCLifetimeConversion =
false;
4210 NewDerivedToBase, NewObjCConversion,
4211 NewObjCLifetimeConversion);
4215 assert(!isa<CXXConstructorDecl>(Function) &&
4216 "should not have conversion after constructor");
4220 ICS.
Standard = Best->FinalConversion;
4241 if (NewDerivedToBase)
4243 else if (NewObjCConversion)
4276 T1Quals, cv2T2, T2, T2Quals, Sequence);
4301 bool DerivedToBase =
false;
4302 bool ObjCConversion =
false;
4303 bool ObjCLifetimeConversion =
false;
4307 ObjCConversion, ObjCLifetimeConversion);
4320 if (isLValueRef || T1Function) {
4327 if (T1Quals != T2Quals)
4336 else if (ObjCConversion)
4355 (isLValueRef || InitCategory.
isRValue())) {
4357 S, Entity, Kind, Initializer, isRValueRef,
4358 isLValueRef, Sequence);
4383 switch (RefRelationship) {
4392 llvm_unreachable(
"unexpected kind of compatible initializer");
4444 if (T1Quals != T2Quals)
4453 else if (ObjCConversion)
4467 S, Entity, Kind, Initializer,
true,
4468 isLValueRef, Sequence);
4478 isRValueRef && InitCategory.
isLValue()) {
4529 (T1CVRQuals | T2CVRQuals) != T1CVRQuals) {
4562 assert((!InitList || InitList->
getNumInits() == 0) &&
4563 "Shouldn't use value-init for non-empty init lists");
4575 bool NeedZeroInitialization =
true;
4590 NeedZeroInitialization =
false;
4598 if (NeedZeroInitialization)
4612 ClassDecl->hasUninitializedReferenceMember()) {
4620 Expr *InitListAsExpr = InitList;
4622 bool InitListSyntax = InitList;
4627 S, Entity, Kind, Args, T, Entity.
getType(), Sequence, InitListSyntax);
4649 if (DestType->isRecordType() && S.
getLangOpts().CPlusPlus) {
4660 if (DestType.isConstQualified() && S.
getLangOpts().CPlusPlus) {
4667 if (DestType.getQualifiers().hasObjCLifetime()) {
4681 bool TopLevelOfInitList) {
4682 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
4684 assert((DestType->
isRecordType() || SourceType->isRecordType()) &&
4685 "Must have a class type to perform a user-defined conversion");
4690 CandidateSet.
clear();
4700 = cast<CXXRecordDecl>(DestRecordType->getDecl());
4706 if (!Info.Constructor)
4709 if (!Info.Constructor->isInvalidDecl() &&
4710 Info.Constructor->isConvertingConstructor(AllowExplicit)) {
4711 if (Info.ConstructorTmpl)
4714 Initializer, CandidateSet,
4718 Initializer, CandidateSet,
4735 = cast<CXXRecordDecl>(SourceRecordType->getDecl());
4737 const auto &Conversions =
4739 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
4742 if (isa<UsingShadowDecl>(D))
4743 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4750 Conv = cast<CXXConversionDecl>(D);
4752 if (AllowExplicit || !Conv->isExplicit()) {
4755 ActingDC, Initializer, DestType,
4756 CandidateSet, AllowExplicit);
4759 Initializer, DestType, CandidateSet,
4778 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4780 if (isa<CXXConstructorDecl>(Function)) {
4786 HadMultipleCandidates);
4815 HadMultipleCandidates);
4838 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
4839 Best->FinalConversion.Third) {
4842 ICS.
Standard = Best->FinalConversion;
4860 isa<CXXBoolLiteralExpr>(Init) &&
4861 !cast<CXXBoolLiteralExpr>(Init)->getValue() &&
4870 bool isAddressOf,
bool &isWeakAccess) {
4876 if (op->getOpcode() == UO_AddrOf)
4881 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
4882 switch (ce->getCastKind()) {
4885 case CK_LValueBitCast:
4889 case CK_ArrayToPointerDecay:
4892 case CK_NullToPointer:
4900 }
else if (isa<DeclRefExpr>(e)) {
4904 isWeakAccess =
true;
4908 VarDecl *var = dyn_cast<
VarDecl>(cast<DeclRefExpr>(e)->getDecl());
4922 }
else if (isa<ArraySubscriptExpr>(e)) {
4938 bool isWeakAccess =
false;
4942 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
4948 << ((
unsigned) iik - 1)
4973 Expr *Initializer) {
4974 bool ArrayDecay =
false;
4979 ArgPointee = ArgArrayType->getElementType();
4991 bool ShouldCopy =
true;
4996 if (ArrayDecay || Initializer->
isGLValue()) {
5020 Expr *Initializer) {
5041 Expr *Initializer) {
5054 Expr *Initializer) {
5069 bool TopLevelOfInitList,
5070 bool TreatUnavailableAsInvalid)
5073 TreatUnavailableAsInvalid);
5080 if (!DRE || !isa<FunctionDecl>(DRE->getDecl()))
5084 cast<FunctionDecl>(DRE->getDecl()));
5101 return isa<DecompositionDecl>(Entity.
getDecl());
5127 bool TopLevelOfInitList,
5128 bool TreatUnavailableAsInvalid) {
5135 for (
unsigned I = 0, E = Args.size();
I !=
E; ++
I)
5136 if (Args[
I]->getType()->isNonOverloadPlaceholderType()) {
5143 Args[
I] = result.
get();
5164 Expr *Initializer =
nullptr;
5165 if (Args.size() == 1) {
5166 Initializer = Args[0];
5169 DestType, Initializer->
getType(),
5172 Args[0] = Initializer;
5174 if (!isa<InitListExpr>(Initializer))
5175 SourceType = Initializer->
getType();
5181 if (
InitListExpr *InitList = dyn_cast_or_null<InitListExpr>(Initializer)) {
5183 TreatUnavailableAsInvalid);
5195 if (Args.size() != 1)
5201 else if (isa<InitListExpr>(Args[0]))
5227 if (Initializer && isa<VariableArrayType>(DestAT)) {
5253 if (Initializer && isa<ConstantArrayType>(DestAT) &&
5271 Expr *OVEAsExpr = &OVE;
5273 TreatUnavailableAsInvalid);
5283 isa<CompoundLiteralExpr>(Initializer->
IgnoreParens()) &&
5299 Initializer && isa<InitListExpr>(Initializer)) {
5301 *
this, TreatUnavailableAsInvalid);
5303 }
else if (DestAT->getElementType()->isCharType())
5315 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
5322 if (allowObjCWritebackConversion &&
5355 DestType, DestType, *
this);
5364 TopLevelOfInitList);
5368 assert(Args.size() >= 1 &&
"Zero-argument case handled above");
5371 if (Args.size() > 1) {
5374 }
else if (isa<InitListExpr>(Args[0])) {
5384 bool NeedAtomicConversion =
false;
5388 Atomic->getValueType())) {
5389 DestType = Atomic->getValueType();
5390 NeedAtomicConversion =
true;
5395 TopLevelOfInitList);
5397 if (!
Failed() && NeedAtomicConversion)
5414 allowObjCWritebackConversion);
5422 bool ShouldCopy =
true;
5438 }
else if (ICS.
isBad()) {
5459 for (
auto &S : Steps)
5510 llvm_unreachable(
"Invalid EntityKind!");
5541 llvm_unreachable(
"missed an InitializedEntity kind?");
5572 llvm_unreachable(
"missed an InitializedEntity kind?");
5577 Expr *Initializer) {
5608 llvm_unreachable(
"missed an InitializedEntity kind?");
5635 bool IsExtraneousCopy) {
5642 Class = cast<CXXRecordDecl>(Record->getDecl());
5660 S, Loc, CurInitExpr, CandidateSet, Ctors, Best,
5669 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
5670 : diag::err_temp_copy_no_viable)
5679 S.
Diag(Loc, diag::err_temp_copy_ambiguous)
5686 S.
Diag(Loc, diag::err_temp_copy_deleted)
5693 bool HadMultipleCandidates = CandidateSet.
size() > 1;
5702 if (IsExtraneousCopy) {
5716 diag::err_call_incomplete_argument))
5756 Best->Function->getParamDecl(0)->getType().getNonReferenceType(),
5763 HadMultipleCandidates,
5781 Expr *CurInitExpr) {
5800 S, Loc, CurInitExpr, CandidateSet, Ctors, Best,
5812 Best->FoundDecl, Entity, Diag);
5833 void InitializationSequence::PrintInitLocationNote(
Sema &S,
5848 diag::note_method_return_type_change)
5872 return NumArgs != 1;
5884 bool &ConstructorInitRequiresZeroInit,
5885 bool IsListInitialization,
5886 bool IsStdInitListInitialization,
5889 unsigned NumArgs = Args.size();
5904 assert(Constructor->
getParent() &&
"No parent class for constructor.");
5918 bool AllowExplicitConv =
5926 Loc, ConstructorArgs,
5928 IsListInitialization))
5945 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
5956 ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
5957 IsListInitialization, IsStdInitListInitialization,
5958 ConstructorInitRequiresZeroInit);
5974 if (IsListInitialization)
5975 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
5986 HadMultipleCandidates,
5987 IsListInitialization,
5988 IsStdInitListInitialization,
5989 ConstructorInitRequiresZeroInit,
5997 HadMultipleCandidates,
5998 IsListInitialization,
5999 IsStdInitListInitialization,
6000 ConstructorInitRequiresZeroInit,
6057 llvm_unreachable(
"unknown entity kind");
6127 return FallbackDecl;
6137 llvm_unreachable(
"unknown entity kind");
6154 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6155 if (ILE->getNumInits() == 1 && ILE->isGLValue()) {
6157 Init = ILE->getInit(0);
6167 if (
CastExpr *CE = dyn_cast<CastExpr>(Init))
6168 if (CE->getSubExpr()->isGLValue())
6169 Init = CE->getSubExpr();
6173 if (
auto *ASE = dyn_cast<ArraySubscriptExpr>(Init))
6174 Init = ASE->getBase();
6175 }
while (Init != Old);
6180 ME->setExtendingDecl(ExtendingEntity->
getDecl(),
6197 Init = BTE->getSubExpr();
6200 dyn_cast<CXXStdInitializerListExpr>(Init)) {
6205 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6206 if (ILE->getType()->isArrayType()) {
6207 for (
unsigned I = 0, N = ILE->getNumInits();
I != N; ++
I)
6212 if (
CXXRecordDecl *RD = ILE->getType()->getAsCXXRecordDecl()) {
6213 assert(RD->isAggregate() &&
"aggregate init on non-aggregate");
6218 if (RD->
isUnion() && ILE->getInitializedFieldInUnion() &&
6219 ILE->getInitializedFieldInUnion()->getType()->isReferenceType())
6223 for (
const auto *
I : RD->
fields()) {
6224 if (Index >= ILE->getNumInits())
6226 if (
I->isUnnamedBitfield())
6228 Expr *SubInit = ILE->getInit(Index);
6229 if (
I->getType()->isReferenceType())
6231 else if (isa<InitListExpr>(SubInit) ||
6232 isa<CXXStdInitializerListExpr>(SubInit))
6245 const Expr *Init,
bool IsInitializerList,
6248 if (isa<FieldDecl>(ExtendingDecl)) {
6249 if (IsInitializerList) {
6250 S.
Diag(Init->
getExprLoc(), diag::warn_dangling_std_initializer_list)
6255 bool IsSubobjectMember =
false;
6259 IsSubobjectMember =
true;
6264 diag::warn_bind_ref_member_to_temporary)
6266 << IsSubobjectMember << IsInitializerList;
6267 if (IsSubobjectMember)
6269 diag::note_ref_subobject_of_member_declared_here);
6272 diag::note_ref_or_ptr_member_declared_here)
6281 const Expr *PostInit);
6285 bool IsReturnStmt) {
6296 unsigned DiagID = 0;
6341 if (isa<ParmVarDecl>(VD))
6342 DiagID = diag::warn_redundant_move_on_return;
6344 DiagID = diag::warn_pessimizing_move_on_return;
6346 DiagID = diag::warn_pessimizing_move_on_initialization;
6388 if (UO->getOpcode() == UO_Deref &&
6389 UO->getSubExpr()->IgnoreParenCasts()->
6392 S.
PDiag(diag::warn_binding_null_to_reference)
6393 << UO->getSubExpr()->getSourceRange());
6399 bool BoundToLvalueReference) {
6441 if (!ZeroInitializationFixit.empty()) {
6442 unsigned DiagID = diag::err_default_init_const;
6444 if (S.
getLangOpts().MSVCCompat && D->hasAttr<SelectAnyAttr>())
6445 DiagID = diag::ext_default_init_const;
6454 ZeroInitializationFixit);
6473 if (isa<InitListExpr>((
Expr *)Args[0])) {
6477 if (
auto *DD = dyn_cast_or_null<DeclaratorDecl>(Entity.
getDecl())) {
6479 TypeLoc TL = TInfo->getTypeLoc();
6482 Brackets = ArrayLoc.getBracketsRange();
6489 ArrayT->getSizeModifier(),
6490 ArrayT->getIndexTypeCVRQualifiers(),
6514 Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
6519 Expr *Init = Args[0];
6520 S.
Diag(Init->
getLocStart(), diag::warn_cxx98_compat_reference_list_init)
6533 S.
Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << 1 <<
6540 if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
6543 const Expr *Init = Args[0]->skipRValueSubobjectAdjustments();
6544 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
6545 Init = MTE->GetTemporaryExpr();
6548 S.
Diag(Init->
getLocStart(), diag::warn_temporary_array_to_pointer_decay)
6566 switch (Steps.front().Kind) {
6601 assert(Args.size() == 1);
6619 CurInit.
get() && isa<InitListExpr>(CurInit.
get()));
6624 auto checkAbstractType = [&](
QualType T) ->
bool {
6629 diag::err_allocation_of_abstract_type);
6634 bool ConstructorInitRequiresZeroInit =
false;
6667 &BasePath, IgnoreBaseAccess))
6678 CurInit.
get(), &BasePath, VK);
6693 if (
auto *DRE = dyn_cast<DeclRefExpr>(CurInit.
get()->
IgnoreParens())) {
6694 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
6710 ExtendingEntity->getDecl());
6717 assert(CurInit.
get()->
isRValue() &&
"not a temporary");
6734 ExtendingEntity->getDecl());
6773 bool CreatedObject =
false;
6784 Loc, ConstructorArgs))
6789 FoundFn, Constructor,
6791 HadMultipleCandidates,
6805 CastKind = CK_ConstructorConversion;
6806 CreatedObject =
true;
6820 FoundFn, Conversion);
6826 HadMultipleCandidates);
6830 CastKind = CK_UserDefinedConversion;
6831 CreatedObject = Conversion->getReturnType()->isRecordType();
6834 if (CreatedObject && checkAbstractType(CurInit.
get()->
getType()))
6855 S.
PDiag(diag::err_access_dtor_temp) << T);
6879 assert(CurInit.
get()->
isRValue() &&
"cannot convert glvalue to atomic");
6886 assert(CurInit.
get()->
isGLValue() &&
"cannot load from a prvalue");
6888 CK_LValueToRValue, CurInit.get(),
6908 CurInit = CurInitExprRes;
6929 InitListChecker PerformInitList(S, InitEntity,
6930 InitList, Ty,
false,
6932 if (PerformInitList.HadError())
6940 if ((*ResultType)->isRValueReferenceType())
6942 else if ((*ResultType)->isLValueReferenceType())
6949 PerformInitList.getFullyStructuredList();
6953 : StructuredInitList;
6970 assert(Args.size() == 1 &&
"expected a single argument for list init");
6972 S.
Diag(InitList->getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
6973 << InitList->getSourceRange();
6974 MultiExprArg Arg(InitList->getInits(), InitList->getNumInits());
6978 ConstructorInitRequiresZeroInit,
6981 InitList->getLBraceLoc(),
6982 InitList->getRBraceLoc());
6987 CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
7016 bool IsStdInitListInit =
7020 S, UseTemporary ? TempEntity : Entity, Kind,
7022 ConstructorInitRequiresZeroInit,
7033 if (NextStep != StepEnd &&
7038 ConstructorInitRequiresZeroInit =
true;
7077 CurInit = CurInitExprRes;
7082 InitialCurInit.
get(),
7085 PrintInitLocationNote(S, Entity);
7087 }
else if (Complained)
7088 PrintInitLocationNote(S, Entity);
7101 CK_ObjCObjectLValueCast,
7114 ArrayLoopCommonExprs.push_back(BaseExpr);
7119 assert(!ArrayLoopCommonExprs.empty() &&
7120 "mismatched SK_ArrayLoopIndex and SK_ArrayLoopInit");
7121 Expr *Common = ArrayLoopCommonExprs.pop_back_val();
7143 IncompleteDest->getElementType(),
7144 ConstantSource->getSize(),
7173 S.
Diag(CurInit.get()->getExprLoc(),
7174 diag::warn_cxx98_compat_initializer_list_init)
7175 << CurInit.get()->getSourceRange();
7179 CurInit.get()->getType(), CurInit.get(),
7218 "Sampler initialization on non-sampler type.");
7219 Expr *Init = CurInit.get();
7220 QualType SourceType = Init->getType();
7227 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Init)) {
7228 auto Var = cast<VarDecl>(DRE->getDecl());
7231 if (!Var->hasGlobalStorage()) {
7233 CK_LValueToRValue, Init,
7243 if (!Var->getInit() || !isa<ImplicitCastExpr>(Var->getInit()))
7245 Init = cast<ImplicitCastExpr>(
const_cast<Expr*
>(
7246 Var->getInit()))->getSubExpr();
7247 SourceType = Init->getType();
7254 if (!Init->isConstantInitializer(S.
Context,
false))
7265 Init->EvaluateAsInt(Result, S.
Context);
7266 const uint64_t SamplerValue = Result.getLimitedValue();
7273 unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
7274 unsigned FilterMode = (0x30 & SamplerValue) >> 4;
7275 if (FilterMode != 1 && FilterMode != 2)
7277 diag::warn_sampler_initializer_invalid_bits)
7279 if (AddressingMode > 4)
7281 diag::warn_sampler_initializer_invalid_bits)
7282 <<
"Addressing Mode";
7288 CK_IntToOCLSampler);
7293 "Event initialization on non-event type.");
7297 CurInit.get()->getValueKind());
7302 "Event initialization on non queue type.");
7306 CurInit.get()->getValueKind());
7314 cast<FieldDecl>(Entity.
getDecl())->isBitField())
7316 cast<FieldDecl>(Entity.
getDecl()),
7320 if (
const Expr *E = CurInit.
get()) {
7333 S.
Diag(Loc, diag::err_reference_without_init)
7342 for (
const auto *FI : RD->
fields()) {
7343 if (FI->isUnnamedBitfield())
7347 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
7352 for (
const auto &BI : RD->
bases()) {
7354 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
7409 if (
auto *D = Entity.
getDecl())
7410 Loc = D->getLocation();
7411 S.
Diag(Loc, diag::note_in_reference_temporary_list_initializer) << T;
7415 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
7418 assert(DiagnoseInitList.HadError() &&
7419 "Inconsistent init list check result.");
7441 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
7445 <<
SourceRange(Args.front()->getLocStart(), Args.back()->getLocEnd());
7449 << 1 << Entity.
getType() << Args[0]->getSourceRange();
7462 S.
Diag(Kind.
getLocation(), diag::err_array_init_narrow_string_into_wchar);
7465 S.
Diag(Kind.
getLocation(), diag::err_array_init_wide_string_into_char);
7469 diag::err_array_init_incompat_wide_string_into_wchar);
7475 ? diag::err_array_init_different_type
7476 : diag::err_array_init_non_constant_array))
7478 << Args[0]->getType()
7479 << Args[0]->getSourceRange();
7497 auto *FD = cast<FunctionDecl>(cast<DeclRefExpr>(Args[0])->getDecl());
7499 Args[0]->getLocStart());
7505 switch (FailedOverloadResult) {
7509 << Args[0]->getType() << DestType
7510 << Args[0]->getSourceRange();
7513 << DestType << Args[0]->getType()
7514 << Args[0]->getSourceRange();
7522 diag::err_typecheck_nonviable_condition_incomplete,
7523 Args[0]->getType(), Args[0]->getSourceRange()))
7526 << Args[0]->getType() << Args[0]->getSourceRange()
7535 << Args[0]->getSourceRange();
7543 llvm_unreachable(
"Inconsistent overload resolution?");
7549 llvm_unreachable(
"Conversion did not fail!");
7554 if (isa<InitListExpr>(Args[0])) {
7556 diag::err_lvalue_reference_bind_to_initlist)
7559 << Args[0]->getSourceRange();
7567 ? diag::err_lvalue_reference_bind_to_temporary
7568 : diag::err_lvalue_reference_bind_to_unrelated)
7571 << Args[0]->getType()
7572 << Args[0]->getSourceRange();
7577 FieldDecl *BitField = Args[0]->getSourceBitField();
7581 << (BitField !=
nullptr)
7582 << Args[0]->getSourceRange();
7589 S.
Diag(Kind.
getLocation(), diag::err_reference_bind_to_vector_element)
7591 << Args[0]->getSourceRange();
7597 << Args[0]->getSourceRange();
7601 QualType SourceType = Args[0]->getType();
7610 << Args[0]->getSourceRange();
7617 << Args[0]->isLValue()
7618 << Args[0]->getType()
7619 << Args[0]->getSourceRange();
7624 QualType FromType = Args[0]->getType();
7628 << Args[0]->isLValue()
7630 << Args[0]->getSourceRange();
7645 if (InitList && InitList->getNumInits() >= 1) {
7646 R =
SourceRange(InitList->getInit(0)->getLocEnd(), InitList->getLocEnd());
7648 assert(Args.size() > 1 &&
"Expected multiple initializers!");
7649 R =
SourceRange(Args.front()->getLocEnd(), Args.back()->getLocEnd());
7654 S.
Diag(Kind.
getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
7664 << 0 << Entity.
getType() << Args[0]->getSourceRange();
7681 ArgsRange =
SourceRange(Args.front()->getLocStart(),
7682 Args.back()->getLocEnd());
7685 assert(Args.size() == 1 &&
7686 "List construction from other than 1 argument.");
7688 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
7693 switch (FailedOverloadResult) {
7696 << DestType << ArgsRange;
7713 InheritedFrom = Inherited.getShadowDecl()->getNominatedBaseClass();
7716 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
7729 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
7735 diag::note_member_declared_at);
7739 S.
Diag(Record->getDecl()->getLocation(),
7740 diag::note_previous_decl)
7747 << DestType << ArgsRange;
7757 <<
true << DestType << ArgsRange;
7758 llvm_unreachable(
"Inconsistent overload resolution?");
7768 << DestType << ArgsRange;
7771 <<
true << DestType << ArgsRange;
7778 llvm_unreachable(
"Conversion did not fail!");
7806 diag::err_init_incomplete_type);
7828 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
7831 diag::note_explicit_ctor_deduction_guide_here) <<
false;
7836 PrintInitLocationNote(S, Entity);
7843 OS <<
"Failed sequence: ";
7846 OS <<
"too many initializers for reference";
7850 OS <<
"parenthesized list init for reference";
7854 OS <<
"array requires initializer list";
7858 OS <<
"address of unaddressable function was taken";
7862 OS <<
"array requires initializer list or string literal";
7866 OS <<
"array requires initializer list or wide string literal";
7870 OS <<
"narrow string into wide char array";
7874 OS <<
"wide string into char array";
7878 OS <<
"incompatible wide string into wide char array";
7882 OS <<
"array type mismatch";
7886 OS <<
"non-constant array initializer";
7890 OS <<
"address of overloaded function failed";
7894 OS <<
"overload resolution for reference initialization failed";
7898 OS <<
"non-const lvalue reference bound to temporary";
7902 OS <<
"non-const lvalue reference bound to bit-field";
7906 OS <<
"non-const lvalue reference bound to vector element";
7910 OS <<
"non-const lvalue reference bound to unrelated type";
7914 OS <<
"rvalue reference bound to an lvalue";
7918 OS <<
"reference initialization drops qualifiers";
7922 OS <<
"reference initialization failed";
7926 OS <<
"conversion failed";
7930 OS <<
"conversion from property failed";
7934 OS <<
"too many initializers for scalar";
7938 OS <<
"parenthesized list init for reference";
7942 OS <<
"referencing binding to initializer list";
7946 OS <<
"initializer list for non-aggregate, non-scalar type";
7950 OS <<
"overloading failed for user-defined conversion";
7954 OS <<
"constructor overloading failed";
7958 OS <<
"default initialization of a const variable";
7962 OS <<
"initialization of incomplete type";
7966 OS <<
"list initialization checker failure";
7970 OS <<
"variable length array has an initializer";
7974 OS <<
"initializer expression isn't contextually valid";
7978 OS <<
"list constructor overloading failed";
7982 OS <<
"list copy initialization chose explicit constructor";
7990 OS <<
"Dependent sequence\n";
7994 OS <<
"Normal sequence: ";
8005 OS <<
"resolve address of overloaded function";
8009 OS <<
"derived-to-base (rvalue)";
8013 OS <<
"derived-to-base (xvalue)";
8017 OS <<
"derived-to-base (lvalue)";
8021 OS <<
"bind reference to lvalue";
8025 OS <<
"bind reference to a temporary";
8029 OS <<
"final copy in class direct-initialization";
8033 OS <<
"extraneous C++03 copy to temporary";
8037 OS <<
"user-defined conversion via " << *S->Function.Function;
8041 OS <<
"qualification conversion (rvalue)";
8045 OS <<
"qualification conversion (xvalue)";
8049 OS <<
"qualification conversion (lvalue)";
8053 OS <<
"non-atomic-to-atomic conversion";
8057 OS <<
"load (lvalue to rvalue)";
8061 OS <<
"implicit conversion sequence (";
8067 OS <<
"implicit conversion sequence with narrowing prohibited (";
8073 OS <<
"list aggregate initialization";
8077 OS <<
"unwrap reference initializer list";
8081 OS <<
"rewrap reference initializer list";
8085 OS <<
"constructor initialization";
8089 OS <<
"list initialization via constructor";
8093 OS <<
"zero initialization";
8097 OS <<
"C assignment";
8101 OS <<
"string initialization";
8105 OS <<
"Objective-C object conversion";
8109 OS <<
"indexing for array initialization loop";
8113 OS <<
"array initialization loop";
8117 OS <<
"array initialization";
8121 OS <<
"array initialization (GNU extension)";
8125 OS <<
"parenthesized array initialization";
8129 OS <<
"pass by indirect copy and restore";
8133 OS <<
"pass by indirect restore";
8137 OS <<
"Objective-C object retension";
8141 OS <<
"std::initializer_list from initializer list";
8145 OS <<
"list initialization from std::initializer_list";
8149 OS <<
"OpenCL sampler_t from integer constant";
8153 OS <<
"OpenCL event_t from zero";
8157 OS <<
"OpenCL queue_t from zero";
8161 OS <<
" [" << S->Type.getAsString() <<
']';
8175 const Expr *PostInit) {
8206 ? diag::warn_init_list_type_narrowing
8207 : diag::ext_init_list_type_narrowing)
8217 ? diag::warn_init_list_constant_narrowing
8218 : diag::ext_init_list_constant_narrowing)
8228 ? diag::warn_init_list_variable_narrowing
8229 : diag::ext_init_list_variable_narrowing)
8237 llvm::raw_svector_ostream OS(StaticCast);
8238 OS <<
"static_cast<";
8245 OS << *TT->getDecl();
8254 S.
Diag(PostInit->
getLocStart(), diag::note_init_list_narrowing_silence)
8271 assert(InitE &&
"No initialization expression");
8276 return !Seq.Failed();
8283 bool TopLevelOfInitList,
8284 bool AllowExplicit) {
8289 assert(InitE &&
"No initialization expression?");
8300 const bool ShouldTrackCopy =
8302 if (ShouldTrackCopy) {
8305 Seq.SetOverloadFailure(
8311 const auto LastStep = Seq.step_end() - 1;
8312 assert(LastStep->Kind ==
8314 const FunctionDecl *Function = LastStep->Function.Function;
8316 llvm::find_if(Seq.getFailedCandidateSet(),
8318 return Candidate.Viable &&
8319 Candidate.Function == Function &&
8320 Candidate.Conversions.size() > 0;
8322 if (Candidate != Seq.getFailedCandidateSet().end() &&
8324 Candidate->Viable =
false;
8334 ExprResult Result = Seq.Perform(*
this, Entity, Kind, InitE);
8336 if (ShouldTrackCopy)
8347 assert(DeducedTST &&
"not a deduced template specialization type");
8355 diag::err_deduced_non_class_template_specialization_type)
8358 Diag(TD->getLocation(), diag::note_template_decl_here);
8386 Guides.suppressDiagnostics();
8391 ? dyn_cast<InitListExpr>(Inits[0])
8406 auto tryToResolveOverload =
8409 for (
auto I = Guides.begin(), E = Guides.end();
I !=
E; ++
I) {
8410 NamedDecl *D = (*I)->getUnderlyingDecl();
8415 auto *GD = dyn_cast_or_null<CXXDeductionGuideDecl>(
8416 TD ? TD->getTemplatedDecl() : dyn_cast<
FunctionDecl>(D));
8427 if (GD->isExplicit())
8433 if (GD->getMinRequiredArguments() > 1 ||
8434 (GD->getNumParams() == 0 && !GD->isVariadic()))
8456 bool SuppressUserConversions = Kind.
isCopyInit();
8461 SuppressUserConversions);
8464 SuppressUserConversions);
8466 return Candidates.BestViableFunction(*
this, Kind.
getLocation(), Best);
8474 bool TryListConstructors =
true;
8480 auto *FD = dyn_cast<
FunctionDecl>(D->getUnderlyingDecl());
8481 if (FD && FD->getMinRequiredArguments() == 0) {
8482 TryListConstructors =
false;
8488 if (TryListConstructors)
8489 Result = tryToResolveOverload(
true);
8498 Result = tryToResolveOverload(
false);
8502 Diag(Kind.
getLocation(), diag::err_deduced_class_template_ctor_ambiguous)
8512 cast<ClassTemplateDecl>(Template)->getTemplatedDecl();
8516 Complete ? diag::err_deduced_class_template_ctor_no_viable
8517 : diag::err_deduced_class_template_incomplete)
8535 cast<CXXDeductionGuideDecl>(Best->Function)->isExplicit()) {
8536 bool IsDeductionGuide = !Best->Function->isImplicit();
8539 Diag(Best->Function->getLocation(),
8540 diag::note_explicit_ctor_deduction_guide_here)
8541 << IsDeductionGuide;
unsigned getNumElements() const
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
llvm::iterator_range< base_class_iterator > base_class_range
Represents a single C99 designator.
Perform a derived-to-base cast, producing an lvalue.
Defines the clang::ASTContext interface.
unsigned getNumInits() const
SourceLocation getEnd() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
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)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
InitListExpr * WrappingSyntacticList
When Kind = SK_RewrapInitList, the syntactic form of the wrapping list.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
ArrayRef< NamedDecl * >::const_iterator chain_iterator
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 isConstantArrayType() const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
DesignatorKind getKind() const
Simple class containing the result of Sema::CorrectTypo.
unsigned Index
When Kind == EK_ArrayElement, EK_VectorElement, or EK_ComplexElement, the index of the array or vecto...
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
step_iterator step_end() const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
void setFromType(QualType T)
Produce an Objective-C object pointer.
A cast other than a C-style cast.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
QualType getCallResultType() const
Determine the type of an expression that calls this function.
void AddOCLZeroEventStep(QualType T)
Add a step to initialize an OpenCL event_t from a NULL constant.
Initializing char array with wide string literal.
QualType getType() const
Retrieves the type of the base class.
Perform an implicit conversion sequence without narrowing.
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
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.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
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...
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.
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
SmallVectorImpl< Step >::const_iterator step_iterator
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Expr * getInit() const
Retrieve the initializer value.
unsigned getIntWidth(QualType T) const
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)
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
bool isRecordType() const
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
ConstructorInfo getConstructorInfo(NamedDecl *ND)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
unsigned size() const
Returns the number of designators in this initializer.
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.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Not a narrowing conversion.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
bool hasFlexibleArrayMember() const
ParenExpr - This represents a parethesized expression, e.g.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
std::string getAsString() const
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
The base class of the type hierarchy.
bool isInStdNamespace() const
SourceLocation getEqualLoc() const
Retrieve the location of the equal sign for copy initialization (if present).
static bool tryObjCWritebackConversion(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity, Expr *Initializer)
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
The entity being initialized is a variable.
QualType getRecordType(const RecordDecl *Decl) const
InitListExpr * getSyntacticForm() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getInit() const
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.
Ambiguous candidates found.
A container of type source information.
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.
The entity being initialized is a base member subobject.
bool isFunctionalCast() const
Determine whether this is a functional-style cast.
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.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
bool isSpelledAsLValue() const
SourceLocation getDotLoc() const
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 isVariableLengthArrayNew() const
Determine whether this is an array new with an unknown bound.
const llvm::APInt & getSize() 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...
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...
Initialize an OpenCL sampler from an integer.
EntityKind getKind() const
Determine the kind of initialization.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
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)?
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.
Array initialization by elementwise copy.
DiagnosticsEngine & Diags
const Expr * getCallee() const
static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT, ASTContext &Context)
Check whether the array of type AT can be initialized by the Init expression by means of string initi...
static void 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())
SourceRange getParenRange() const
Retrieve the source range containing the locations of the open and closing parentheses for value and ...
SourceLocation getLBracketLoc() const
field_iterator field_begin() const
Represents a C++17 deduced template specialization type.
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void setInit(unsigned Init, Expr *expr)
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
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...
step_iterator step_begin() const
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
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)
bool allowsNRVO() const
Determine whether this initialization allows the named return value optimization, which also applies ...
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.
bool isImplicitMemberInitializer() const
Is this the implicit initialization of a member of a class from a defaulted constructor?
The entity being initialized is a temporary object.
bool isObjCRetainableType() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * getArrayIndex(const Designator &D) const
bool allowExplicitConversionFunctionsInRefBinding() const
Retrieve whether this initialization allows the use of explicit conversion functions when binding a r...
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...
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...
RecordDecl - Represents a struct/union/class.
Represents a C99 designated initializer expression.
bool isOpenCLSpecificType() const
Construct a std::initializer_list from an initializer list.
Trying to take the address of a function that doesn't support having its address taken.
One of these records is kept for each identifier that is lexed.
static void CheckForNullPointerDereference(Sema &S, const Expr *E)
bool isScalarType() const
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
Expr * getSubExpr(unsigned Idx) const
static bool isExprAnUnaddressableFunction(Sema &S, const Expr *E)
Tries to get a FunctionDecl out of E.
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic)
Add steps to unwrap a initializer list for a reference around a single element and rewrap it at the e...
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
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 isReferenceType() const
QualType getReturnType() const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a place-holder for an object not to be initialized by anything.
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call...
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 r...
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.
unsigned getCVRQualifiers() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible...
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceLocation getRParenLoc() const
~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.
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized...
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.
static OverloadingResult ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, MultiExprArg Args, OverloadCandidateSet &CandidateSet, DeclContext::lookup_result Ctors, OverloadCandidateSet::iterator &Best, bool CopyInitializing, bool AllowExplicit, bool OnlyListConstructors, bool IsListInit, bool SecondStepOfCopyInit=false)
const TargetInfo & getTargetInfo() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
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...
const LangOptions & getLangOpts() const
StepKind Kind
The kind of conversion or initialization step we are taking.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceRange getRange() const
Retrieve the source range that covers the initialization.
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.
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isDefaulted() const
Whether this function is defaulted per C++0x.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
field_range fields() 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...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
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...
SourceLocation getRBraceLoc() const
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Variable-length array must not have an initializer.
RecordDecl * getDecl() const
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.
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.
CheckedConversionKind
The kind of conversion being performed.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
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.
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...
chain_iterator chain_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.
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
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.
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...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
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.
bool isExtVectorType() const
Implicit conversion failed.
detail::InMemoryDirectory::const_iterator I
The entity being initialized is a function parameter.
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, InitListExpr *InitList)
field_iterator field_end() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
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.
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
IdentifierInfo * getFieldName() const
Reference binding drops qualifiers.
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.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
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
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.
NamedDecl * getDecl() const
A narrowing conversion by virtue of the source and destination types.
The entity being initialized is a field of block descriptor for the copied-in c++ object...
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
SourceLocation getEllipsisLoc() const
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
Initializing wide char array with incompatible wide string literal.
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
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...
bool isDeleted() const
Whether this function has been deleted.
SourceLocation getLocStart() const LLVM_READONLY
Implicit conversion failed.
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.
void setRBraceLoc(SourceLocation Loc)
SourceLocation getLocStart() const LLVM_READONLY
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isAnyComplexType() const
Scalar initialized from a parenthesized initializer list.
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
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 ...
uintptr_t Parameter
When Kind == EK_Parameter, the ParmVarDecl, with the low bit indicating whether the parameter is "con...
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)
Represents a C++ functional cast expression that builds a temporary object.
SourceLocation getLBraceLoc() const
static void performLifetimeExtension(Expr *Init, const InitializedEntity *ExtendingEntity)
Update a prvalue expression that is going to be materialized as a lifetime-extended temporary...
bool isAtomicType() const
Represents a C++ destructor within a class.
Initializing a wide char array with narrow string literal.
void ClearExprs(Sema &Actions)
ClearExprs - Null out any expression references, which prevents them from being 'delete'd later...
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.
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
const ParmVarDecl * getParamDecl(unsigned i) const
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
Resolve the address of an overloaded function to a specific function declaration. ...
Expr * getArrayRangeStart(const Designator &D) const
DeclContext * getDeclContext()
Overload resolution succeeded.
The entity being initialized is an exception object that is being thrown.
bool isFloatingType() const
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...
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...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
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 isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
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)
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isExplicit() const
Whether this function is explicit.
ObjCMethodDecl * getMethodDecl() const
Retrieve the ObjectiveC method being initialized.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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...
static void TryDefaultInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence)
Attempt default initialization (C++ [dcl.init]p6).
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...
Initializer has a placeholder type which cannot be resolved by initialization.
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])
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
const IdentifierInfo * getField() const
FailureKind getFailureKind() const
Determine why initialization failed.
QualType getElementType() const
Represents a C++ conversion function within a class.
void AddStringInitStep(QualType T)
Add a string init step.
The result type of a method or function.
Pass an object by indirect restore.
InitKind getKind() const
Determine the initialization kind.
__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...
QualType getWideCharType() const
Return the type of wide characters.
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
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.
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.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
InitListExpr * getUpdater() const
FailureKind
Describes why initialization failed.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
Too many initializers for scalar.
bool isArrayRangeDesignator() const
Lvalue-to-rvalue conversion (C++ 4.1)
List initialization failed at some point.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getLocStart() const LLVM_READONLY
Initialize queue_t from 0.
Perform a conversion adding _Atomic to a type.
void AddListInitializationStep(QualType T)
Add a list-initialization step.
SourceLocation getDotLoc() 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...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
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...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Expr * getArrayRangeEnd(const Designator &D) const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
SequenceKind
Describes the kind of initialization sequence computed.
Array indexing for initialization by elementwise copy.
Encodes a location in the source.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Reference initialization from an initializer list.
QualType getElementType() const
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...
static bool shouldBindAsTemporary(const InitializedEntity &Entity)
Whether we should bind a created object as a temporary when initializing the given entity...
SourceLocation getLocation() const
Retrieve the location at which initialization is occurring.
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda...
bool isValid() const
Return true if this is a valid SourceLocation object.
Expr * getArrayRangeStart() const
FieldDecl * getField() const
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
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.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
ASTContext & getASTContext() 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 refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setReferenced(bool R=true)
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
VD Variable
When Kind == EK_Variable, EK_Member or EK_Binding, the variable.
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
QualType withConst() const
static InvalidICRKind isInvalidICRSource(ASTContext &C, Expr *e, bool isAddressOf, bool &isWeakAccess)
Determines whether this expression is an acceptable ICR source.
bool isExplicitCast() const
Determine whether this initialization is an explicit cast.
const Designator & getDesignator(unsigned Idx) const
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
Adds a conversion function template specialization candidate to the overload set, using template argu...
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
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)
SourceLocation getLBracketLoc() const
Objective-C ARC writeback conversion.
The entity being implicitly initialized back to the formal result type.
SourceLocation getRBracketLoc() const
Zero-initialize the object.
The entity being initialized is the initializer for a compound literal.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
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...
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...
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...
Describes the kind of initialization being performed, along with location information for tokens rela...
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.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Reference initialized from a parenthesized initializer list.
bool isCStyleOrFunctionalCast() const
Determine whether this initialization is a C-style cast.
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.
Expr ** getInits()
Retrieve the set of initializers.
Overloading for initialization by constructor failed.
QualType getToType(unsigned Idx) const
static bool ResolveOverloadedFunctionForReferenceBinding(Sema &S, Expr *Initializer, QualType &SourceType, QualType &UnqualifiedSourceType, QualType UnqualifiedTargetType, InitializationSequence &Sequence)
SourceLocation getBegin() const
Requests that all candidates be shown.
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.
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void AddOCLZeroQueueStep(QualType T)
Add a step to initialize an OpenCL queue_t from 0.
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
bool isVectorType() const
void AddAtomicConversionStep(QualType Ty)
Add a new step that performs conversion from non-atomic to atomic type.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
bool HadMultipleCandidates
void AddArrayInitStep(QualType T, bool IsGNUExtension)
Add an array initialization step.
void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy)
Add a step to pass an object by indirect copy-restore.
SourceLocation getLocStart() const LLVM_READONLY
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
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 isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, Sema &S)
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
MutableArrayRef< Expr * > MultiExprArg
QualType getType() const
Return the type wrapped by this type source info.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool isFunctionProtoType() const
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.
bool isCStyleCast() const
Determine whether this is a C-style cast.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
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)
Non-constant array initializer.
void setIncompleteTypeFailure(QualType IncompleteType)
Note that this initialization sequence failed due to an incomplete type.
A single step in the initialization sequence.
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
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.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
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.
bool isInvalidDecl() const
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...
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
bool isAtStartOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the beginning of the immediate macro expansion...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
Array-to-pointer conversion (C++ 4.2)
std::pair< SourceLocation, SourceLocation > getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
DeclarationName - The name of a declaration.
chain_iterator chain_end() const
static bool IsWideCharCompatible(QualType T, ASTContext &Context)
Check whether T is compatible with a wide character type (wchar_t, char16_t or char32_t).
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
std::string getAsString(ASTContext &Ctx, QualType Ty) const
SourceLocation getLocStart() const LLVM_READONLY
StringKind getKind() const
Requests that only viable candidates be shown.
Array initialization (from an array rvalue) as a GNU extension.
detail::InMemoryDirectory::const_iterator E
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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 isLValueReferenceType() const
Overloading due to reference initialization failed.
Expr * getArrayIndex() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
unsigned getNumArgs() const
bool isParameterKind() const
void setInitializedFieldInUnion(FieldDecl *FD)
DeclClass * getCorrectionDeclAs() const
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).
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
bool isRValueReferenceType() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static bool isRValueRef(QualType ParamType)
bool isObjCObjectType() const
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
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)
SourceManager & getSourceManager() const
const T * getAs() const
Member-template getAs<specific type>'.
SourceLocation getLocEnd() const LLVM_READONLY
QualType getCanonicalType() const
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.
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...
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
ObjCEncodeExpr, used for @encode in Objective-C.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
SourceLocation getFieldLoc() const
Reference binding failed.
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() 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 ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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.
unsigned getAddressSpace() const
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
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.
void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category)
Add a new step in the initialization that performs a derived-to- base cast.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
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)
QualType getType() const
Retrieve type being initialized.
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 isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
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...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
bool AllowExplicit() const
Retrieve whether this initialization allows the use of explicit constructors.
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...
bool hasAddressSpace() 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).
void dump() const
Dump a representation of the initialized entity to standard error, for debugging purposes.
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.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
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.
Represents a loop initializing the elements of an array.
bool isObjCObjectPointerType() const
Represents a C array with an unspecified size.
QualType getEncodedType() const
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Expr * getArrayRangeEnd() const
The entity being initialized is a field of block descriptor for the copied-in lambda object that's us...
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...
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.
This class is used for builtin types like 'int'.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isImplicitValueInit() const
Determine whether this initialization is an implicit value-initialization, e.g., as occurs during agg...
unsigned allocateManglingNumber() const
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
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]).
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Designator * getDesignator(unsigned Idx)
Reference binding to a temporary.
DeclarationName getName() const
Retrieve the name of the entity being initialized.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
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...
bool isIncompleteArrayType() const
void AddConstructorInitializationStep(DeclAccessPair FoundDecl, CXXConstructorDecl *Constructor, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
Add a constructor-initialization step.
Designation - Represent a full designation, which is a sequence of designators.
static Sema::AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Designator - A designator in a C99 designated initializer.
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...
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
QualType getElementType() 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...
bool hasQualifiers() const
Determine whether this type has any qualifiers.
SourceManager & SourceMgr
void clear()
Clear out all of the candidates.
bool hasDefaultConstructor() const
Determine whether this class has any default constructors.
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
const Expr * getInit(unsigned Init) const
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
No viable function found.
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
A failed initialization sequence.
bool isFieldDesignator() const
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.
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.
SourceLocation getLocation() const
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 ...
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.
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes...
Represents a C array with a specified size that is not an integer-constant-expression.
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
Automatic storage duration (most local variables).
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 isConstQualified() const
Determine whether this type is const-qualified.
static void DiagnoseNarrowingInInitList(Sema &S, const ImplicitConversionSequence &ICS, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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...
Describes an entity that is being initialized.
void setToType(unsigned Idx, QualType T)
NamespaceDecl * getStdNamespace() const
unsigned getNumDesignators() const
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getFieldLoc() const
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.
Array initialization from a parenthesized initializer list.
Represents the canonical version of C arrays with a specified constant size.
bool isArrayDesignator() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
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...
static bool TryOCLZeroQueueInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
static bool maybeRecoverWithZeroInitialization(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Tries to add a zero initializer. Returns true if that worked.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
Non-const lvalue reference binding to a temporary.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool hasInClassInitializer() const
hasInClassInitializer - Determine whether this member has a C++11 in-class initializer.
bool isPointerType() const
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).