25 #include "llvm/ADT/APInt.h" 26 #include "llvm/ADT/SmallString.h" 27 #include "llvm/Support/ErrorHandling.h" 28 #include "llvm/Support/raw_ostream.h" 30 using namespace clang;
64 if (!isa<ConstantArrayType>(AT) && !isa<IncompleteArrayType>(AT))
132 llvm_unreachable(
"missed a StringLiteral kind?");
148 if (isa<StringLiteral>(E) || isa<ObjCEncodeExpr>(E))
150 else if (
ParenExpr *PE = dyn_cast<ParenExpr>(E))
151 E = PE->getSubExpr();
153 E = UO->getSubExpr();
155 E = GSE->getResultExpr();
157 llvm_unreachable(
"unexpected expr in string literal init");
164 auto *ConstantArrayTy =
166 uint64_t StrLength = ConstantArrayTy->getSize().getZExtValue();
171 llvm::APInt ConstVal(32, StrLength);
196 if (StrLength > CAT->
getSize().getZExtValue())
198 diag::err_initializer_string_for_char_array_too_long)
202 if (StrLength-1 > CAT->
getSize().getZExtValue())
204 diag::ext_initializer_string_for_char_array_too_long)
248 class InitListChecker {
252 bool TreatUnavailableAsInvalid;
253 llvm::DenseMap<InitListExpr *, InitListExpr *> SyntacticToSemantic;
259 unsigned &StructuredIndex);
263 bool TopLevelObject =
false);
266 bool SubobjectIsDesignatorContext,
269 unsigned &StructuredIndex,
270 bool TopLevelObject =
false);
275 unsigned &StructuredIndex);
280 unsigned &StructuredIndex);
285 unsigned &StructuredIndex);
290 unsigned &StructuredIndex);
294 unsigned &StructuredIndex);
299 bool SubobjectIsDesignatorContext,
unsigned &Index,
301 unsigned &StructuredIndex,
302 bool TopLevelObject =
false);
305 llvm::APSInt elementIndex,
306 bool SubobjectIsDesignatorContext,
unsigned &Index,
308 unsigned &StructuredIndex);
314 llvm::APSInt *NextElementIndex,
317 unsigned &StructuredIndex,
318 bool FinishSubobjectInit,
319 bool TopLevelObject);
323 unsigned StructuredIndex,
325 bool IsFullyOverwritten =
false);
326 void UpdateStructuredListElement(
InitListExpr *StructuredList,
327 unsigned &StructuredIndex,
329 int numArrayElements(
QualType DeclType);
330 int numStructUnionElements(
QualType DeclType);
336 bool TreatUnavailableAsInvalid);
360 bool FillWithNoInit);
361 void FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
364 bool FillWithNoInit =
false);
368 bool FillWithNoInit =
false);
371 bool TopLevelObject);
378 bool TreatUnavailableAsInvalid);
379 bool HadError() {
return hadError; }
383 InitListExpr *getFullyStructuredList()
const {
return FullyStructuredList; }
392 bool TreatUnavailableAsInvalid) {
403 bool EmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
416 InitExpr = VerifyOnly ? &DummyInitList :
new (SemaRef.
Context)
439 assert(O ==
OR_Success &&
"Inconsistent overload resolution");
446 bool IsInStd =
false;
447 for (
NamespaceDecl *ND = dyn_cast<NamespaceDecl>(R->getDeclContext());
448 ND && !IsInStd; ND = dyn_cast<
NamespaceDecl>(ND->getParent())) {
453 if (IsInStd && llvm::StringSwitch<bool>(R->getName())
454 .Cases(
"basic_string",
"deque",
"forward_list",
true)
455 .Cases(
"list",
"map",
"multimap",
"multiset",
true)
456 .Cases(
"priority_queue",
"queue",
"set",
"stack",
true)
457 .Cases(
"unordered_map",
"unordered_set",
"vector",
true)
463 TreatUnavailableAsInvalid);
468 diag::warn_invalid_initializer_from_system_header);
471 diag::note_used_in_initialization_here);
473 SemaRef.
Diag(Loc, diag::note_used_in_initialization_here);
480 InitSeq.
Diagnose(SemaRef, Entity, Kind, SubInit);
483 diag::note_in_omitted_aggregate_initializer)
486 bool IsTrailingArrayNewMember =
489 SemaRef.
Diag(Loc, diag::note_in_omitted_aggregate_initializer)
490 << (IsTrailingArrayNewMember ? 2 : 0)
497 return VerifyOnly ?
ExprResult(static_cast<Expr *>(
nullptr))
498 : InitSeq.
Perform(SemaRef, Entity, Kind, SubInit);
504 "CheckEmptyInitializable is only inteded for verification mode.");
505 if (PerformEmptyInit(SemaRef, Loc, Entity,
true,
510 void InitListChecker::FillInEmptyInitForBase(
513 bool &RequiresSecondPass,
bool FillWithNoInit) {
514 assert(Init < ILE->getNumInits() &&
"should have been expanded");
517 SemaRef.
Context, &Base,
false, &ParentEntity);
523 : PerformEmptyInit(SemaRef, ILE->
getEndLoc(), BaseEntity,
524 false, TreatUnavailableAsInvalid);
532 dyn_cast<InitListExpr>(ILE->
getInit(Init))) {
533 FillInEmptyInitializations(BaseEntity, InnerILE, RequiresSecondPass,
534 ILE, Init, FillWithNoInit);
536 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init))) {
537 FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
538 RequiresSecondPass, ILE, Init,
543 void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
546 bool &RequiresSecondPass,
547 bool FillWithNoInit) {
554 if (!RType->getDecl()->isUnion())
555 assert(Init < NumInits &&
"This ILE should have been expanded");
557 if (Init >= NumInits || !ILE->
getInit(Init)) {
558 if (FillWithNoInit) {
581 RequiresSecondPass =
true;
591 SemaRef.
Diag(Loc, diag::err_init_reference_member_uninitialized)
595 diag::note_uninit_reference_member);
600 ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
602 TreatUnavailableAsInvalid);
610 }
else if (Init < NumInits) {
612 }
else if (!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
618 RequiresSecondPass =
true;
621 = dyn_cast<InitListExpr>(ILE->
getInit(Init)))
622 FillInEmptyInitializations(MemberEntity, InnerILE,
623 RequiresSecondPass, ILE, Init, FillWithNoInit);
625 = dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init)))
626 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
627 RequiresSecondPass, ILE, Init,
637 bool &RequiresSecondPass,
640 bool FillWithNoInit) {
642 "Should not have void type");
651 struct UpdateOuterILEWithUpdatedInit {
654 ~UpdateOuterILEWithUpdatedInit() {
658 } UpdateOuterRAII = {OuterILE, OuterIndex};
669 Entity, ILE, RequiresSecondPass, FillWithNoInit);
670 else if (RDecl->
isUnion() && isa<CXXRecordDecl>(RDecl) &&
671 cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) {
672 for (
auto *Field : RDecl->
fields()) {
674 FillInEmptyInitForField(0, Field, Entity, ILE, RequiresSecondPass,
683 unsigned NumElems = numStructUnionElements(ILE->getType());
686 if (ILE->getNumInits() < NumElems)
687 ILE->resizeInits(SemaRef.
Context, NumElems);
691 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RDecl)) {
692 for (
auto &Base : CXXRD->bases()) {
696 FillInEmptyInitForBase(Init, Base, Entity, ILE, RequiresSecondPass,
702 for (
auto *Field : RDecl->
fields()) {
709 FillInEmptyInitForField(Init, Field, Entity, ILE, RequiresSecondPass,
729 unsigned NumElements = NumInits;
731 ElementType = AType->getElementType();
732 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
733 NumElements = CAType->getSize().getZExtValue();
741 ElementType = VType->getElementType();
742 NumElements = VType->getNumElements();
748 for (
unsigned Init = 0; Init != NumElements; ++Init) {
759 Expr *InitExpr = (Init < NumInits ? ILE->
getInit(Init) :
nullptr);
760 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
763 Expr *Filler =
nullptr;
769 PerformEmptyInit(SemaRef, ILE->
getEndLoc(), ElementEntity,
770 false, TreatUnavailableAsInvalid);
781 }
else if (Init < NumInits) {
796 if (!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
802 RequiresSecondPass =
true;
806 = dyn_cast_or_null<InitListExpr>(InitExpr))
807 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
808 ILE, Init, FillWithNoInit);
810 = dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr))
811 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
812 RequiresSecondPass, ILE, Init,
820 bool TreatUnavailableAsInvalid)
821 : SemaRef(S), VerifyOnly(VerifyOnly),
822 TreatUnavailableAsInvalid(TreatUnavailableAsInvalid) {
828 FullyStructuredList =
829 getStructuredSubobjectInit(IL, 0, T,
nullptr, 0, IL->
getSourceRange());
830 CheckExplicitInitList(Entity, IL, T, FullyStructuredList,
833 if (!hadError && !VerifyOnly) {
834 bool RequiresSecondPass =
false;
835 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass,
837 if (RequiresSecondPass && !hadError)
838 FillInEmptyInitializations(Entity, FullyStructuredList,
839 RequiresSecondPass,
nullptr, 0);
843 int InitListChecker::numArrayElements(
QualType DeclType) {
845 int maxElements = 0x7FFFFFFF;
848 maxElements =
static_cast<int>(CAT->getSize().getZExtValue());
853 int InitListChecker::numStructUnionElements(
QualType DeclType) {
855 int InitializableMembers = 0;
856 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(structDecl))
857 InitializableMembers += CXXRD->getNumBases();
858 for (
const auto *Field : structDecl->
fields())
860 ++InitializableMembers;
863 return std::min(InitializableMembers, 1);
885 if (
CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ParentRD))
886 if (CXXRD->getNumBases())
889 auto FieldIt = ParentRD->field_begin();
890 assert(FieldIt != ParentRD->field_end() &&
891 "no fields but have initializer for member?");
892 return ++FieldIt == ParentRD->field_end();
905 unsigned &StructuredIndex) {
909 maxElements = numArrayElements(T);
911 maxElements = numStructUnionElements(T);
915 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
917 if (maxElements == 0) {
920 diag::err_implicit_empty_initializer);
927 InitListExpr *StructuredSubobjectInitList = getStructuredSubobjectInit(
928 ParentIList, Index, T, StructuredList, StructuredIndex,
931 unsigned StructuredSubobjectInitIndex = 0;
934 unsigned StartIndex = Index;
935 CheckListElementTypes(Entity, ParentIList, T,
937 StructuredSubobjectInitList,
938 StructuredSubobjectInitIndex);
941 StructuredSubobjectInitList->
setType(T);
943 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
946 if (EndIndex < ParentIList->getNumInits() &&
947 ParentIList->
getInit(EndIndex)) {
958 diag::warn_missing_braces)
964 StructuredSubobjectInitList->
getEndLoc()),
970 if (CXXRD && CXXRD->hasUserDeclaredConstructor()) {
972 diag::warn_cxx2a_compat_aggregate_init_with_ctors)
998 DiagID = diag::warn_braces_around_scalar_init;
1005 DiagID = diag::warn_braces_around_scalar_init;
1031 llvm_unreachable(
"unexpected braced scalar init");
1050 bool TopLevelObject) {
1052 SyntacticToSemantic[IList] = StructuredList;
1056 unsigned Index = 0, StructuredIndex = 0;
1057 CheckListElementTypes(Entity, IList, T,
true,
1058 Index, StructuredList, StructuredIndex, TopLevelObject);
1064 StructuredList->
setType(ExprTy);
1069 if (Index < IList->getNumInits()) {
1080 if (StructuredIndex == 1 &&
1083 unsigned DK = diag::ext_excess_initializers_in_char_array_initializer;
1085 DK = diag::err_excess_initializers_in_char_array_initializer;
1102 unsigned DK = diag::ext_excess_initializers;
1104 DK = diag::err_excess_initializers;
1107 if (SemaRef.
getLangOpts().OpenCL && initKind == 1) {
1108 DK = diag::err_excess_initializers;
1119 !isa<InitListExpr>(IList->
getInit(0)))
1125 if (CXXRD && CXXRD->hasUserDeclaredConstructor()) {
1128 bool HasEquivCtor =
false;
1134 if (!HasEquivCtor) {
1136 diag::warn_cxx2a_compat_aggregate_init_with_ctors)
1146 bool SubobjectIsDesignatorContext,
1149 unsigned &StructuredIndex,
1150 bool TopLevelObject) {
1154 CheckComplexType(Entity, IList, DeclType, Index,
1155 StructuredList, StructuredIndex);
1157 CheckScalarType(Entity, IList, DeclType, Index,
1158 StructuredList, StructuredIndex);
1160 CheckVectorType(Entity, IList, DeclType, Index,
1161 StructuredList, StructuredIndex);
1164 "non-aggregate records should be handed in CheckSubElementType");
1169 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
1170 Bases = CXXRD->bases();
1171 CheckStructUnionTypes(Entity, IList, DeclType, Bases, RD->field_begin(),
1172 SubobjectIsDesignatorContext, Index, StructuredList,
1173 StructuredIndex, TopLevelObject);
1178 CheckArrayType(Entity, IList, DeclType, Zero,
1179 SubobjectIsDesignatorContext, Index,
1180 StructuredList, StructuredIndex);
1185 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1189 CheckReferenceType(Entity, IList, DeclType, Index,
1190 StructuredList, StructuredIndex);
1193 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_init_objc_class) << DeclType;
1197 CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1201 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1212 unsigned &StructuredIndex) {
1216 return CheckReferenceType(Entity, IList, ElemType, Index,
1217 StructuredList, StructuredIndex);
1219 if (
InitListExpr *SubInitList = dyn_cast<InitListExpr>(expr)) {
1220 if (SubInitList->getNumInits() == 1 &&
1223 expr = SubInitList->getInit(0);
1226 = getStructuredSubobjectInit(IList, Index, ElemType,
1227 StructuredList, StructuredIndex,
1229 CheckExplicitInitList(Entity, SubInitList, ElemType,
1230 InnerStructuredList);
1232 if (!hadError && !VerifyOnly) {
1233 bool RequiresSecondPass =
false;
1234 FillInEmptyInitializations(Entity, InnerStructuredList,
1235 RequiresSecondPass, StructuredList,
1237 if (RequiresSecondPass && !hadError)
1238 FillInEmptyInitializations(Entity, InnerStructuredList,
1239 RequiresSecondPass, StructuredList,
1247 }
else if (isa<ImplicitValueInitExpr>(expr)) {
1251 "found implicit initialization for the wrong type");
1253 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1275 if (Seq || isa<InitListExpr>(expr)) {
1278 Seq.Perform(SemaRef, Entity, Kind, expr);
1282 UpdateStructuredListElement(StructuredList, StructuredIndex,
1293 return CheckScalarType(Entity, IList, ElemType, Index,
1294 StructuredList, StructuredIndex);
1304 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1334 UpdateStructuredListElement(StructuredList, StructuredIndex,
1352 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1372 unsigned &StructuredIndex) {
1373 assert(Index == 0 &&
"Index in explicit init list must be zero");
1383 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1388 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1397 for (
unsigned i = 0; i < 2; ++i) {
1399 CheckSubElementType(ElementEntity, IList, elementType, Index,
1400 StructuredList, StructuredIndex);
1408 unsigned &StructuredIndex) {
1413 ? diag::warn_cxx98_compat_empty_scalar_initializer
1414 : diag::err_empty_scalar_initializer)
1423 if (
InitListExpr *SubIList = dyn_cast<InitListExpr>(expr)) {
1427 SemaRef.
Diag(SubIList->getBeginLoc(),
1428 diag::ext_many_braces_around_scalar_init)
1429 << SubIList->getSourceRange();
1431 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1434 }
else if (isa<DesignatedInitExpr>(expr)) {
1436 SemaRef.
Diag(expr->
getBeginLoc(), diag::err_designator_for_scalar_init)
1455 Expr *ResultExpr =
nullptr;
1462 if (ResultExpr != expr) {
1464 IList->
setInit(Index, ResultExpr);
1470 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1478 unsigned &StructuredIndex) {
1486 diag::err_init_reference_member_uninitialized)
1495 if (isa<InitListExpr>(expr) && !SemaRef.
getLangOpts().CPlusPlus11) {
1525 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1533 unsigned &StructuredIndex) {
1536 unsigned numEltsInit = 0;
1542 CheckEmptyInitializable(
1564 Expr *ResultExpr =
nullptr;
1570 if (ResultExpr != Init) {
1572 IList->
setInit(Index, ResultExpr);
1578 UpdateStructuredListElement(StructuredList, StructuredIndex,
1587 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1591 CheckEmptyInitializable(ElementEntity, IList->
getEndLoc());
1596 CheckSubElementType(ElementEntity, IList, elementType, Index,
1597 StructuredList, StructuredIndex);
1618 diag::warn_neon_vector_initializer_non_portable);
1620 const char *typeCode;
1630 llvm_unreachable(
"Invalid element type!");
1634 ? diag::note_neon_vector_initializer_non_portable_q
1635 : diag::note_neon_vector_initializer_non_portable)
1636 << typeCode << typeSize;
1646 for (
unsigned i = 0; i < maxElements; ++i) {
1655 CheckSubElementType(ElementEntity, IList, elementType, Index,
1656 StructuredList, StructuredIndex);
1668 CheckSubElementType(ElementEntity, IList, VecType, Index,
1669 StructuredList, StructuredIndex);
1670 numEltsInit += numIElts;
1675 if (numEltsInit != maxElements) {
1678 diag::err_vector_incorrect_num_initializers)
1679 << (numEltsInit < maxElements) << maxElements << numEltsInit;
1686 llvm::APSInt elementIndex,
1687 bool SubobjectIsDesignatorContext,
1690 unsigned &StructuredIndex) {
1694 if (Index < IList->getNumInits()) {
1704 UpdateStructuredListElement(StructuredList, StructuredIndex,
1717 SemaRef.
Diag(VAT->getSizeExpr()->getBeginLoc(),
1718 diag::err_variable_object_no_init)
1719 << VAT->getSizeExpr()->getSourceRange();
1727 llvm::APSInt maxElements(elementIndex.getBitWidth(),
1728 elementIndex.isUnsigned());
1729 bool maxElementsKnown =
false;
1731 maxElements = CAT->getSize();
1732 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
1733 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1734 maxElementsKnown =
true;
1738 while (Index < IList->getNumInits()) {
1744 if (!SubobjectIsDesignatorContext)
1749 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1750 DeclType,
nullptr, &elementIndex, Index,
1751 StructuredList, StructuredIndex,
true,
1757 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
1758 maxElements = maxElements.extend(elementIndex.getBitWidth());
1759 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
1760 elementIndex = elementIndex.extend(maxElements.getBitWidth());
1761 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1765 if (!maxElementsKnown && elementIndex > maxElements)
1766 maxElements = elementIndex;
1773 if (maxElementsKnown && elementIndex == maxElements)
1780 CheckSubElementType(ElementEntity, IList, elementType, Index,
1781 StructuredList, StructuredIndex);
1786 if (!maxElementsKnown && elementIndex > maxElements)
1787 maxElements = elementIndex;
1792 llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
1796 SemaRef.
Diag(IList->
getBeginLoc(), diag::ext_typecheck_zero_array_size);
1802 if (!hadError && VerifyOnly) {
1808 if ((maxElementsKnown && elementIndex < maxElements) ||
1810 CheckEmptyInitializable(
1819 bool TopLevelObject) {
1821 unsigned FlexArrayDiag;
1822 if (isa<InitListExpr>(InitExpr) &&
1823 cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
1825 FlexArrayDiag = diag::ext_flexible_array_init;
1829 FlexArrayDiag = diag::err_flexible_array_init;
1830 }
else if (!TopLevelObject) {
1832 FlexArrayDiag = diag::err_flexible_array_init;
1835 FlexArrayDiag = diag::err_flexible_array_init;
1836 }
else if (cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
1838 FlexArrayDiag = diag::err_flexible_array_init;
1841 FlexArrayDiag = diag::ext_flexible_array_init;
1851 return FlexArrayDiag != diag::ext_flexible_array_init;
1870 SemaRef.
PDiag(diag::err_access_dtor_temp)
1878 void InitListChecker::CheckStructUnionTypes(
1881 bool SubobjectIsDesignatorContext,
unsigned &Index,
1882 InitListExpr *StructuredList,
unsigned &StructuredIndex,
1883 bool TopLevelObject) {
1908 if (isa<CXXRecordDecl>(RD) && cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
1912 Field != FieldEnd; ++Field) {
1913 if (Field->hasInClassInitializer()) {
1924 Field != FieldEnd; ++Field) {
1925 if (!Field->isUnnamedBitfield()) {
1927 CheckEmptyInitializable(
1938 bool InitializedSomething =
false;
1941 for (
auto &Base : Bases) {
1946 if (Init && isa<DesignatedInitExpr>(Init))
1951 SemaRef.
Context, &Base,
false, &Entity);
1953 CheckSubElementType(BaseEntity, IList, Base.
getType(), Index,
1954 StructuredList, StructuredIndex);
1955 InitializedSomething =
true;
1956 }
else if (VerifyOnly) {
1957 CheckEmptyInitializable(BaseEntity, InitLoc);
1973 bool CheckForMissingFields =
1975 bool HasDesignatedInit =
false;
1977 while (Index < IList->getNumInits()) {
1985 if (!SubobjectIsDesignatorContext)
1988 HasDesignatedInit =
true;
1992 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1993 DeclType, &Field,
nullptr, Index,
1994 StructuredList, StructuredIndex,
1995 true, TopLevelObject))
1997 else if (!VerifyOnly) {
2000 while (std::next(F) != Field)
2009 InitializedSomething =
true;
2013 CheckForMissingFields =
false;
2017 if (Field == FieldEnd) {
2023 if (InitializedSomething && DeclType->
isUnionType())
2027 if (Field->getType()->isIncompleteArrayType())
2030 if (Field->isUnnamedBitfield()) {
2039 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2060 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2061 StructuredList, StructuredIndex);
2062 InitializedSomething =
true;
2066 StructuredList->setInitializedFieldInUnion(*Field);
2073 if (!VerifyOnly && InitializedSomething && CheckForMissingFields &&
2074 Field != FieldEnd && !Field->getType()->isIncompleteArrayType() &&
2080 if (!it->isUnnamedBitfield() && !it->hasInClassInitializer()) {
2082 diag::warn_missing_field_initializers) << *it;
2089 if (VerifyOnly && Field != FieldEnd && !DeclType->
isUnionType() &&
2090 !Field->getType()->isIncompleteArrayType()) {
2092 for (; Field != FieldEnd && !hadError; ++Field) {
2093 if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
2094 CheckEmptyInitializable(
2115 if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
2119 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
2129 if (isa<InitListExpr>(IList->
getInit(Index)))
2130 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2131 StructuredList, StructuredIndex);
2133 CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index,
2134 StructuredList, StructuredIndex);
2150 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
2158 assert(isa<FieldDecl>(*PI));
2159 Replacements.back().setField(cast<FieldDecl>(*PI));
2166 &Replacements[0] + Replacements.size());
2173 for (
unsigned I = 0; I < NumIndexExprs; ++I)
2187 explicit FieldInitializerValidatorCCC(
RecordDecl *RD)
2190 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2243 llvm::APSInt *NextElementIndex,
2246 unsigned &StructuredIndex,
2247 bool FinishSubobjectInit,
2248 bool TopLevelObject) {
2249 if (DesigIdx == DIE->
size()) {
2251 bool prevHadError = hadError;
2256 unsigned OldIndex = Index;
2259 CheckSubElementType(Entity, IList, CurrentObjectType, Index,
2260 StructuredList, StructuredIndex);
2266 IList->
setInit(OldIndex, DIE);
2268 return hadError && !prevHadError;
2272 bool IsFirstDesignator = (DesigIdx == 0);
2274 assert((IsFirstDesignator || StructuredList) &&
2275 "Need a non-designated initializer list to start from");
2279 if (IsFirstDesignator)
2280 StructuredList = SyntacticToSemantic.lookup(IList);
2282 Expr *ExistingInit = StructuredIndex < StructuredList->
getNumInits() ?
2283 StructuredList->
getInit(StructuredIndex) :
nullptr;
2288 StructuredList = getStructuredSubobjectInit(
2289 IList, Index, CurrentObjectType, StructuredList, StructuredIndex,
2295 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2296 StructuredList = E->getUpdater();
2326 diag::warn_subobject_initializer_overrides)
2330 diag::note_previous_initializer)
2335 assert(StructuredList &&
"Expected a structured initializer list");
2354 SemaRef.
Diag(Loc, diag::err_field_designator_non_aggr)
2355 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2365 if (
auto *FD = dyn_cast<FieldDecl>(ND)) {
2369 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND)) {
2375 KnownField = cast<FieldDecl>(*IFD->chain_begin());
2386 if (!Lookup.empty()) {
2389 SemaRef.
Diag(Lookup.front()->getLocation(),
2390 diag::note_field_designator_found);
2400 llvm::make_unique<FieldInitializerValidatorCCC>(RT->
getDecl()),
2404 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2405 << FieldName << CurrentObjectType);
2406 KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2411 << FieldName << CurrentObjectType;
2418 unsigned FieldIndex = 0;
2420 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RT->
getDecl()))
2421 FieldIndex = CXXRD->getNumBases();
2424 if (FI->isUnnamedBitfield())
2444 &&
"A union should never have more than one initializer!");
2450 diag::warn_initializer_overrides)
2452 SemaRef.
Diag(ExistingInit->getBeginLoc(),
2453 diag::note_previous_initializer)
2455 << ExistingInit->getSourceRange();
2470 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2489 if (Field->getType()->isIncompleteArrayType()) {
2490 bool Invalid =
false;
2491 if ((DesigIdx + 1) != DIE->
size()) {
2498 diag::err_designator_into_flexible_array_member)
2500 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2506 if (!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
2507 !isa<StringLiteral>(DIE->
getInit())) {
2511 diag::err_flexible_array_init_needs_braces)
2513 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2520 if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
2530 bool prevHadError = hadError;
2531 unsigned newStructuredIndex = FieldIndex;
2532 unsigned OldIndex = Index;
2537 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2538 StructuredList, newStructuredIndex);
2540 IList->
setInit(OldIndex, DIE);
2541 if (hadError && !prevHadError) {
2546 StructuredIndex = FieldIndex;
2551 QualType FieldType = Field->getType();
2552 unsigned newStructuredIndex = FieldIndex;
2556 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
2557 FieldType,
nullptr,
nullptr, Index,
2558 StructuredList, newStructuredIndex,
2559 FinishSubobjectInit,
false))
2570 if (IsFirstDesignator) {
2573 StructuredIndex = FieldIndex;
2577 if (!FinishSubobjectInit)
2585 bool prevHadError = hadError;
2590 CheckStructUnionTypes(Entity, IList, CurrentObjectType, NoBases, Field,
2591 false, Index, StructuredList, FieldIndex);
2592 return hadError && !prevHadError;
2614 << CurrentObjectType;
2619 Expr *IndexExpr =
nullptr;
2620 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
2624 DesignatedEndIndex = DesignatedStartIndex;
2628 DesignatedStartIndex =
2630 DesignatedEndIndex =
2639 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
2641 FullyStructuredList->sawArrayRangeDesignator();
2644 if (isa<ConstantArrayType>(AT)) {
2645 llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
2646 DesignatedStartIndex
2647 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
2648 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
2650 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
2651 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
2652 if (DesignatedEndIndex >= MaxElements) {
2655 diag::err_array_designator_too_large)
2656 << DesignatedEndIndex.toString(10) << MaxElements.toString(10)
2662 unsigned DesignatedIndexBitWidth =
2664 DesignatedStartIndex =
2665 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
2666 DesignatedEndIndex =
2667 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
2668 DesignatedStartIndex.setIsUnsigned(
true);
2669 DesignatedEndIndex.setIsUnsigned(
true);
2685 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
2689 uint64_t StrLen = SL->getLength();
2690 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2691 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2696 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2697 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
2699 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2700 if (CharTy != PromotedCharTy)
2703 StructuredList->
updateInit(Context, i, Init);
2711 uint64_t StrLen = Str.size();
2712 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2713 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2718 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2719 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
2721 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2722 if (CharTy != PromotedCharTy)
2725 StructuredList->
updateInit(Context, i, Init);
2733 DesignatedEndIndex.getZExtValue() >= StructuredList->
getNumInits())
2735 DesignatedEndIndex.getZExtValue() + 1);
2741 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
2742 unsigned OldIndex = Index;
2747 while (DesignatedStartIndex <= DesignatedEndIndex) {
2753 if (CheckDesignatedInitializer(
2754 ElementEntity, IList, DIE, DesigIdx + 1, ElementType,
nullptr,
2755 nullptr, Index, StructuredList, ElementIndex,
2756 FinishSubobjectInit && (DesignatedStartIndex == DesignatedEndIndex),
2761 ++DesignatedStartIndex;
2762 ElementIndex = DesignatedStartIndex.getZExtValue();
2767 if (IsFirstDesignator) {
2768 if (NextElementIndex)
2769 *NextElementIndex = DesignatedStartIndex;
2770 StructuredIndex = ElementIndex;
2774 if (!FinishSubobjectInit)
2778 bool prevHadError = hadError;
2779 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
2781 StructuredList, ElementIndex);
2782 return hadError && !prevHadError;
2788 InitListChecker::getStructuredSubobjectInit(
InitListExpr *IList,
unsigned Index,
2791 unsigned StructuredIndex,
2793 bool IsFullyOverwritten) {
2796 Expr *ExistingInit =
nullptr;
2797 if (!StructuredList)
2798 ExistingInit = SyntacticToSemantic.lookup(IList);
2799 else if (StructuredIndex < StructuredList->getNumInits())
2800 ExistingInit = StructuredList->
getInit(StructuredIndex);
2811 if (!IsFullyOverwritten)
2827 diag::warn_subobject_initializer_overrides)
2829 SemaRef.
Diag(ExistingInit->
getBeginLoc(), diag::note_previous_initializer)
2838 QualType ResultType = CurrentObjectType;
2844 unsigned NumElements = 0;
2845 unsigned NumInits = 0;
2846 bool GotNumInits =
false;
2847 if (!StructuredList) {
2850 }
else if (Index < IList->getNumInits()) {
2852 NumInits = SubList->getNumInits();
2860 NumElements = CAType->getSize().getZExtValue();
2863 if (GotNumInits && NumElements > NumInits)
2867 NumElements = VType->getNumElements();
2884 SyntacticToSemantic[IList] =
Result;
2892 void InitListChecker::UpdateStructuredListElement(
InitListExpr *StructuredList,
2893 unsigned &StructuredIndex,
2896 if (!StructuredList)
2900 StructuredIndex, expr)) {
2908 if (PrevInit->getSourceRange().isValid()) {
2912 SemaRef.
Diag(PrevInit->getBeginLoc(), diag::note_previous_initializer)
2913 << 0 << PrevInit->getSourceRange();
2936 if (Value.isSigned() && Value.isNegative())
2937 return S.
Diag(Loc, diag::err_array_designator_negative)
2940 Value.setIsUnsigned(
true);
2950 bool Invalid =
false;
2965 llvm::APSInt IndexValue;
2971 Designators.push_back(ASTDesignator(InitExpressions.size(),
2974 InitExpressions.push_back(Index);
2982 llvm::APSInt StartValue;
2983 llvm::APSInt EndValue;
2988 if (!StartDependent)
2994 if (!StartIndex || !EndIndex)
2998 if (StartDependent || EndDependent) {
3000 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
3001 EndValue = EndValue.extend(StartValue.getBitWidth());
3002 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
3003 StartValue = StartValue.extend(EndValue.getBitWidth());
3005 if (!StartDependent && !EndDependent && EndValue < StartValue) {
3007 << StartValue.toString(10) << EndValue.toString(10)
3011 Designators.push_back(ASTDesignator(InitExpressions.size(),
3015 InitExpressions.push_back(StartIndex);
3016 InitExpressions.push_back(EndIndex);
3033 InitExpressions, Loc, GNUSyntax,
3036 if (!getLangOpts().
C99)
3047 InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
3049 :
Parent(&Parent), Index(Index)
3052 Kind = EK_ArrayElement;
3053 Type = AT->getElementType();
3055 Kind = EK_VectorElement;
3056 Type = VT->getElementType();
3059 assert(CT &&
"Unexpected type");
3060 Kind = EK_ComplexElement;
3068 bool IsInheritedVirtualBase,
3071 Result.Kind = EK_Base;
3074 if (IsInheritedVirtualBase)
3075 Result.
Base |= 0x01;
3077 Result.Type = Base->
getType();
3084 case EK_Parameter_CF_Audited: {
3092 return Variable.VariableOrMember->getDeclName();
3094 case EK_LambdaCapture:
3098 case EK_StmtExprResult:
3104 case EK_ArrayElement:
3105 case EK_VectorElement:
3106 case EK_ComplexElement:
3107 case EK_BlockElement:
3108 case EK_LambdaToBlockConversionBlockElement:
3109 case EK_CompoundLiteralInit:
3110 case EK_RelatedResult:
3114 llvm_unreachable(
"Invalid EntityKind!");
3122 return Variable.VariableOrMember;
3125 case EK_Parameter_CF_Audited:
3129 case EK_StmtExprResult:
3135 case EK_ArrayElement:
3136 case EK_VectorElement:
3137 case EK_ComplexElement:
3138 case EK_BlockElement:
3139 case EK_LambdaToBlockConversionBlockElement:
3140 case EK_LambdaCapture:
3141 case EK_CompoundLiteralInit:
3142 case EK_RelatedResult:
3146 llvm_unreachable(
"Invalid EntityKind!");
3153 return LocAndNRVO.NRVO;
3155 case EK_StmtExprResult:
3158 case EK_Parameter_CF_Audited:
3163 case EK_CompoundLiteralInit:
3166 case EK_ArrayElement:
3167 case EK_VectorElement:
3168 case EK_ComplexElement:
3169 case EK_BlockElement:
3170 case EK_LambdaToBlockConversionBlockElement:
3171 case EK_LambdaCapture:
3172 case EK_RelatedResult:
3179 unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
3180 assert(getParent() !=
this);
3181 unsigned Depth = getParent() ? getParent()->dumpImpl(OS) : 0;
3182 for (
unsigned I = 0; I !=
Depth; ++I)
3186 case EK_Variable: OS <<
"Variable";
break;
3187 case EK_Parameter: OS <<
"Parameter";
break;
3188 case EK_Parameter_CF_Audited: OS <<
"CF audited function Parameter";
3190 case EK_Result: OS <<
"Result";
break;
3191 case EK_StmtExprResult: OS <<
"StmtExprResult";
break;
3192 case EK_Exception: OS <<
"Exception";
break;
3193 case EK_Member: OS <<
"Member";
break;
3194 case EK_Binding: OS <<
"Binding";
break;
3195 case EK_New: OS <<
"New";
break;
3196 case EK_Temporary: OS <<
"Temporary";
break;
3197 case EK_CompoundLiteralInit: OS <<
"CompoundLiteral";
break;
3198 case EK_RelatedResult: OS <<
"RelatedResult";
break;
3199 case EK_Base: OS <<
"Base";
break;
3200 case EK_Delegating: OS <<
"Delegating";
break;
3201 case EK_ArrayElement: OS <<
"ArrayElement " << Index;
break;
3202 case EK_VectorElement: OS <<
"VectorElement " << Index;
break;
3203 case EK_ComplexElement: OS <<
"ComplexElement " << Index;
break;
3204 case EK_BlockElement: OS <<
"Block";
break;
3205 case EK_LambdaToBlockConversionBlockElement:
3206 OS <<
"Block (lambda)";
3208 case EK_LambdaCapture:
3209 OS <<
"LambdaCapture ";
3214 if (
auto *D = getDecl()) {
3216 D->printQualifiedName(OS);
3219 OS <<
" '" << getType().getAsString() <<
"'\n";
3225 dumpImpl(llvm::errs());
3234 case SK_ResolveAddressOfOverloadedFunction:
3235 case SK_CastDerivedToBaseRValue:
3236 case SK_CastDerivedToBaseXValue:
3237 case SK_CastDerivedToBaseLValue:
3238 case SK_BindReference:
3239 case SK_BindReferenceToTemporary:
3241 case SK_ExtraneousCopyToTemporary:
3242 case SK_UserConversion:
3243 case SK_QualificationConversionRValue:
3244 case SK_QualificationConversionXValue:
3245 case SK_QualificationConversionLValue:
3246 case SK_AtomicConversion:
3247 case SK_LValueToRValue:
3248 case SK_ListInitialization:
3249 case SK_UnwrapInitList:
3250 case SK_RewrapInitList:
3251 case SK_ConstructorInitialization:
3252 case SK_ConstructorInitializationFromList:
3253 case SK_ZeroInitialization:
3254 case SK_CAssignment:
3256 case SK_ObjCObjectConversion:
3257 case SK_ArrayLoopIndex:
3258 case SK_ArrayLoopInit:
3260 case SK_GNUArrayInit:
3261 case SK_ParenthesizedArrayInit:
3262 case SK_PassByIndirectCopyRestore:
3263 case SK_PassByIndirectRestore:
3264 case SK_ProduceObjCObject:
3265 case SK_StdInitializerList:
3266 case SK_StdInitializerListConstructorCall:
3267 case SK_OCLSamplerInit:
3268 case SK_OCLZeroOpaqueType:
3271 case SK_ConversionSequence:
3272 case SK_ConversionSequenceNoNarrowing:
3279 for (
auto I = Steps.rbegin(); I != Steps.rend(); ++I) {
3280 if (I->Kind == SK_BindReference)
3282 if (I->Kind == SK_BindReferenceToTemporary)
3292 switch (getFailureKind()) {
3293 case FK_TooManyInitsForReference:
3294 case FK_ParenthesizedListInitForReference:
3295 case FK_ArrayNeedsInitList:
3296 case FK_ArrayNeedsInitListOrStringLiteral:
3297 case FK_ArrayNeedsInitListOrWideStringLiteral:
3298 case FK_NarrowStringIntoWideCharArray:
3299 case FK_WideStringIntoCharArray:
3300 case FK_IncompatWideStringIntoWideChar:
3301 case FK_PlainStringIntoUTF8Char:
3302 case FK_UTF8StringIntoPlainChar:
3303 case FK_AddressOfOverloadFailed:
3304 case FK_NonConstLValueReferenceBindingToTemporary:
3305 case FK_NonConstLValueReferenceBindingToBitfield:
3306 case FK_NonConstLValueReferenceBindingToVectorElement:
3307 case FK_NonConstLValueReferenceBindingToUnrelated:
3308 case FK_RValueReferenceBindingToLValue:
3309 case FK_ReferenceInitDropsQualifiers:
3310 case FK_ReferenceInitFailed:
3311 case FK_ConversionFailed:
3312 case FK_ConversionFromPropertyFailed:
3313 case FK_TooManyInitsForScalar:
3314 case FK_ParenthesizedListInitForScalar:
3315 case FK_ReferenceBindingToInitList:
3316 case FK_InitListBadDestinationType:
3317 case FK_DefaultInitOfConst:
3319 case FK_ArrayTypeMismatch:
3320 case FK_NonConstantArrayInit:
3321 case FK_ListInitializationFailed:
3322 case FK_VariableLengthArrayHasInitializer:
3323 case FK_PlaceholderType:
3324 case FK_ExplicitConstructor:
3325 case FK_AddressOfUnaddressableFunction:
3328 case FK_ReferenceInitOverloadFailed:
3329 case FK_UserConversionOverloadFailed:
3330 case FK_ConstructorOverloadFailed:
3331 case FK_ListConstructorOverloadFailed:
3335 llvm_unreachable(
"Invalid EntityKind!");
3339 return !Steps.empty() && Steps.back().Kind == SK_ConstructorInitialization;
3346 bool HadMultipleCandidates) {
3348 S.
Kind = SK_ResolveAddressOfOverloadedFunction;
3369 bool BindingTemporary) {
3371 S.
Kind = BindingTemporary? SK_BindReferenceToTemporary : SK_BindReference;
3378 S.
Kind = SK_FinalCopy;
3385 S.
Kind = SK_ExtraneousCopyToTemporary;
3394 bool HadMultipleCandidates) {
3396 S.
Kind = SK_UserConversion;
3407 S.
Kind = SK_QualificationConversionRValue;
3410 S.
Kind = SK_QualificationConversionRValue;
3413 S.
Kind = SK_QualificationConversionXValue;
3416 S.
Kind = SK_QualificationConversionLValue;
3425 S.
Kind = SK_AtomicConversion;
3431 assert(!Ty.
hasQualifiers() &&
"rvalues may not have qualifiers");
3434 S.Kind = SK_LValueToRValue;
3441 bool TopLevelOfInitList) {
3443 S.
Kind = TopLevelOfInitList ? SK_ConversionSequenceNoNarrowing
3444 : SK_ConversionSequence;
3452 S.
Kind = SK_ListInitialization;
3459 bool HadMultipleCandidates,
bool FromInitList,
bool AsInitList) {
3461 S.
Kind = FromInitList ? AsInitList ? SK_StdInitializerListConstructorCall
3462 : SK_ConstructorInitializationFromList
3463 : SK_ConstructorInitialization;
3473 S.
Kind = SK_ZeroInitialization;
3480 S.
Kind = SK_CAssignment;
3487 S.
Kind = SK_StringInit;
3494 S.
Kind = SK_ObjCObjectConversion;
3501 S.
Kind = IsGNUExtension ? SK_GNUArrayInit : SK_ArrayInit;
3508 S.
Kind = SK_ArrayLoopIndex;
3510 Steps.insert(Steps.begin(), S);
3512 S.
Kind = SK_ArrayLoopInit;
3519 S.
Kind = SK_ParenthesizedArrayInit;
3527 s.
Kind = (shouldCopy ? SK_PassByIndirectCopyRestore
3528 : SK_PassByIndirectRestore);
3535 S.
Kind = SK_ProduceObjCObject;
3542 S.
Kind = SK_StdInitializerList;
3549 S.
Kind = SK_OCLSamplerInit;
3556 S.
Kind = SK_OCLZeroOpaqueType;
3564 "Can only rewrap trivial init lists.");
3566 S.Kind = SK_UnwrapInitList;
3568 Steps.insert(Steps.begin(), S);
3570 S.Kind = SK_RewrapInitList;
3572 S.WrappingSyntacticList = Syntactic;
3578 setSequenceKind(FailedSequence);
3579 this->Failure = Failure;
3580 this->FailedOverloadResult =
Result;
3601 if (!Init.empty()) {
3621 "consuming an object of unretainable type?");
3642 bool TreatUnavailableAsInvalid);
3653 bool TreatUnavailableAsInvalid) {
3673 TreatUnavailableAsInvalid);
3703 bool CopyInitializing,
bool AllowExplicit,
3704 bool OnlyListConstructors,
bool IsListInit,
3705 bool SecondStepOfCopyInit =
false) {
3710 if (!Info.Constructor || Info.Constructor->isInvalidDecl())
3713 if (!AllowExplicit && Info.Constructor->isExplicit())
3730 bool SuppressUserConversions =
3731 SecondStepOfCopyInit ||
3732 (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
3735 if (Info.ConstructorTmpl)
3738 CandidateSet, SuppressUserConversions);
3747 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
3751 CandidateSet, SuppressUserConversions,
3768 if (S.
getLangOpts().CPlusPlus17 && Args.size() == 1 &&
3769 !SecondStepOfCopyInit) {
3770 Expr *Initializer = Args[0];
3774 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
3784 Conv = cast<CXXConversionDecl>(D);
3786 if ((AllowExplicit && !CopyInitializing) || !Conv->isExplicit()) {
3789 ActingDC, Initializer, DestType,
3790 CandidateSet, AllowExplicit,
3794 DestType, CandidateSet, AllowExplicit,
3821 bool IsListInit =
false,
3822 bool IsInitListCopy =
false) {
3823 assert(((!IsListInit && !IsInitListCopy) ||
3824 (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3825 "IsListInit/IsInitListCopy must come with a single initializer list " 3828 (IsListInit || IsInitListCopy) ? cast<InitListExpr>(Args[0]) :
nullptr;
3852 UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isRValue() &&
3862 assert(DestRecordType &&
"Constructor initialization requires record type");
3864 = cast<CXXRecordDecl>(DestRecordType->
getDecl());
3882 bool AsInitializerList =
false;
3894 AsInitializerList =
true;
3900 CandidateSet, DestType, Ctors, Best,
3901 CopyInitialization, AllowExplicit,
3912 AsInitializerList =
false;
3914 CandidateSet, DestType, Ctors, Best,
3915 CopyInitialization, AllowExplicit,
3927 bool HadMultipleCandidates = (CandidateSet.size() > 1);
3931 if (
auto *CD = dyn_cast<CXXConversionDecl>(Best->Function)) {
3933 QualType ConvType = CD->getConversionType();
3935 "should not have selected this conversion function");
3937 HadMultipleCandidates);
3974 Best->FoundDecl, CtorDecl, DestArrayType, HadMultipleCandidates,
3975 IsListInit | IsInitListCopy, AsInitializerList);
3988 bool HadMultipleCandidates =
false;
3991 UnqualifiedTargetType,
3993 &HadMultipleCandidates)) {
3995 HadMultipleCandidates);
3996 SourceType = Fn->getType();
4028 bool TreatUnavailableAsInvalid) {
4063 bool dummy1, dummy2, dummy3;
4070 T1Quals, cv2T2, T2, T2Quals, Sequence);
4085 TreatUnavailableAsInvalid);
4102 bool TreatUnavailableAsInvalid) {
4114 TreatUnavailableAsInvalid);
4140 Expr *InitListAsExpr = InitList;
4150 if (!isa<VariableArrayType>(DestAT) &&
4160 TreatUnavailableAsInvalid);
4193 TreatUnavailableAsInvalid))
4197 Expr *InitListAsExpr = InitList;
4199 DestType, Sequence,
true);
4217 ET && ET->getDecl()->isFixed() &&
4273 TreatUnavailableAsInvalid);
4280 InitListChecker CheckInitList(S, Entity, InitList,
4281 DestType,
true, TreatUnavailableAsInvalid);
4282 if (CheckInitList.HadError()) {
4295 Expr *Initializer,
bool AllowRValues,
bool IsLValueRef,
4304 bool ObjCConversion;
4305 bool ObjCLifetimeConversion;
4307 DerivedToBase, ObjCConversion,
4308 ObjCLifetimeConversion) &&
4309 "Must have incompatible references when binding via conversion");
4310 (void)DerivedToBase;
4311 (void)ObjCConversion;
4312 (void)ObjCLifetimeConversion;
4323 bool AllowExplicitCtors =
false;
4335 if (!Info.Constructor)
4338 if (!Info.Constructor->isInvalidDecl() &&
4339 Info.Constructor->isConvertingConstructor(AllowExplicitCtors)) {
4340 if (Info.ConstructorTmpl)
4343 Initializer, CandidateSet,
4347 Initializer, CandidateSet,
4363 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4366 if (isa<UsingShadowDecl>(D))
4367 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4374 Conv = cast<CXXConversionDecl>(D);
4382 if ((AllowExplicitConvs || !Conv->isExplicit()) &&
4383 (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){
4386 ActingDC, Initializer,
4387 DestType, CandidateSet,
4392 Initializer, DestType, CandidateSet,
4415 if (isa<CXXConversionDecl>(Function))
4428 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4430 HadMultipleCandidates);
4434 bool NewDerivedToBase =
false;
4435 bool NewObjCConversion =
false;
4436 bool NewObjCLifetimeConversion =
false;
4439 NewDerivedToBase, NewObjCConversion,
4440 NewObjCLifetimeConversion);
4444 assert(!isa<CXXConstructorDecl>(Function) &&
4445 "should not have conversion after constructor");
4449 ICS.
Standard = Best->FinalConversion;
4470 if (NewDerivedToBase)
4472 else if (NewObjCConversion)
4505 T1Quals, cv2T2, T2, T2Quals, Sequence);
4530 bool DerivedToBase =
false;
4531 bool ObjCConversion =
false;
4532 bool ObjCLifetimeConversion =
false;
4536 ObjCConversion, ObjCLifetimeConversion);
4549 if (isLValueRef || T1Function) {
4556 if (T1Quals != T2Quals)
4565 else if (ObjCConversion)
4584 (isLValueRef || InitCategory.
isRValue())) {
4586 S, Entity, Kind, Initializer, isRValueRef,
4587 isLValueRef, Sequence);
4612 switch (RefRelationship) {
4616 FK_NonConstLValueReferenceBindingToBitfield;
4619 FK_NonConstLValueReferenceBindingToVectorElement;
4621 llvm_unreachable(
"unexpected kind of compatible initializer");
4679 if (T1Quals != T2Quals)
4693 else if (ObjCConversion)
4707 S, Entity, Kind, Initializer,
true,
4708 isLValueRef, Sequence);
4718 isRValueRef && InitCategory.
isLValue()) {
4769 (T1CVRQuals | T2CVRQuals) != T1CVRQuals) {
4802 assert((!InitList || InitList->
getNumInits() == 0) &&
4803 "Shouldn't use value-init for non-empty init lists");
4814 if (
CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
4815 bool NeedZeroInitialization =
true;
4830 NeedZeroInitialization =
false;
4838 if (NeedZeroInitialization)
4852 ClassDecl->hasUninitializedReferenceMember()) {
4860 Expr *InitListAsExpr = InitList;
4862 bool InitListSyntax = InitList;
4867 S, Entity, Kind, Args, T, Entity.
getType(), Sequence, InitListSyntax);
4889 if (DestType->isRecordType() && S.
getLangOpts().CPlusPlus) {
4900 if (DestType.isConstQualified() && S.
getLangOpts().CPlusPlus) {
4907 if (DestType.getQualifiers().hasObjCLifetime()) {
4921 bool TopLevelOfInitList) {
4922 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
4924 assert((DestType->
isRecordType() || SourceType->isRecordType()) &&
4925 "Must have a class type to perform a user-defined conversion");
4940 = cast<CXXRecordDecl>(DestRecordType->getDecl());
4946 if (!Info.Constructor)
4949 if (!Info.Constructor->isInvalidDecl() &&
4950 Info.Constructor->isConvertingConstructor(AllowExplicit)) {
4951 if (Info.ConstructorTmpl)
4954 Initializer, CandidateSet,
4958 Initializer, CandidateSet,
4975 = cast<CXXRecordDecl>(SourceRecordType->getDecl());
4977 const auto &Conversions =
4979 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4982 if (isa<UsingShadowDecl>(D))
4983 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4990 Conv = cast<CXXConversionDecl>(D);
4992 if (AllowExplicit || !Conv->isExplicit()) {
4995 ActingDC, Initializer, DestType,
4996 CandidateSet, AllowExplicit);
4999 Initializer, DestType, CandidateSet,
5018 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5020 if (isa<CXXConstructorDecl>(Function)) {
5026 HadMultipleCandidates);
5055 HadMultipleCandidates);
5078 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
5079 Best->FinalConversion.Third) {
5082 ICS.
Standard = Best->FinalConversion;
5100 isa<CXXBoolLiteralExpr>(Init) &&
5101 !cast<CXXBoolLiteralExpr>(Init)->getValue() &&
5110 bool isAddressOf,
bool &isWeakAccess) {
5116 if (op->getOpcode() == UO_AddrOf)
5121 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
5122 switch (ce->getCastKind()) {
5125 case CK_LValueBitCast:
5129 case CK_ArrayToPointerDecay:
5132 case CK_NullToPointer:
5140 }
else if (isa<DeclRefExpr>(e)) {
5144 isWeakAccess =
true;
5148 VarDecl *var = dyn_cast<
VarDecl>(cast<DeclRefExpr>(e)->getDecl());
5162 }
else if (isa<ArraySubscriptExpr>(e)) {
5178 bool isWeakAccess =
false;
5182 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
5188 << ((
unsigned) iik - 1)
5213 Expr *Initializer) {
5214 bool ArrayDecay =
false;
5219 ArgPointee = ArgArrayType->getElementType();
5231 bool ShouldCopy =
true;
5236 if (ArrayDecay || Initializer->
isGLValue()) {
5260 Expr *Initializer) {
5278 Expr *Initializer) {
5302 "cl_intel_device_side_avc_motion_estimation") &&
5304 if (DestType->isOCLIntelSubgroupAVCMcePayloadType() ||
5305 DestType->isOCLIntelSubgroupAVCMceResultType())
5321 bool TopLevelOfInitList,
5322 bool TreatUnavailableAsInvalid)
5325 TreatUnavailableAsInvalid);
5332 if (!DRE || !isa<FunctionDecl>(DRE->getDecl()))
5336 cast<FunctionDecl>(DRE->getDecl()));
5353 return isa<DecompositionDecl>(Entity.
getDecl());
5379 bool TopLevelOfInitList,
5380 bool TreatUnavailableAsInvalid) {
5387 for (
unsigned I = 0, E = Args.size(); I != E; ++I)
5388 if (Args[I]->getType()->isNonOverloadPlaceholderType()) {
5395 Args[I] = result.
get();
5416 Expr *Initializer =
nullptr;
5417 if (Args.size() == 1) {
5418 Initializer = Args[0];
5421 DestType, Initializer->
getType(),
5424 Args[0] = Initializer;
5426 if (!isa<InitListExpr>(Initializer))
5427 SourceType = Initializer->
getType();
5433 if (
InitListExpr *InitList = dyn_cast_or_null<InitListExpr>(Initializer)) {
5435 TreatUnavailableAsInvalid);
5447 if (Args.size() != 1)
5453 else if (isa<InitListExpr>(Args[0]))
5479 if (Initializer && isa<VariableArrayType>(DestAT)) {
5511 if (Initializer && isa<ConstantArrayType>(DestAT) &&
5529 Expr *OVEAsExpr = &OVE;
5531 TreatUnavailableAsInvalid);
5542 isa<CompoundLiteralExpr>(Initializer->
IgnoreParens())) &&
5558 Initializer && isa<InitListExpr>(Initializer)) {
5560 *
this, TreatUnavailableAsInvalid);
5562 }
else if (DestAT->getElementType()->isCharType())
5574 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
5581 if (allowObjCWritebackConversion &&
5611 DestType, DestType, *
this);
5620 TopLevelOfInitList);
5624 assert(Args.size() >= 1 &&
"Zero-argument case handled above");
5627 if (Args.size() > 1) {
5630 }
else if (isa<InitListExpr>(Args[0])) {
5640 bool NeedAtomicConversion =
false;
5644 Atomic->getValueType())) {
5645 DestType = Atomic->getValueType();
5646 NeedAtomicConversion =
true;
5651 TopLevelOfInitList);
5653 if (!
Failed() && NeedAtomicConversion)
5670 allowObjCWritebackConversion);
5678 bool ShouldCopy =
true;
5694 }
else if (ICS.
isBad()) {
5715 for (
auto &S : Steps)
5767 llvm_unreachable(
"Invalid EntityKind!");
5799 llvm_unreachable(
"missed an InitializedEntity kind?");
5831 llvm_unreachable(
"missed an InitializedEntity kind?");
5836 Expr *Initializer) {
5868 llvm_unreachable(
"missed an InitializedEntity kind?");
5895 bool IsExtraneousCopy) {
5902 Class = cast<CXXRecordDecl>(Record->getDecl());
5920 S, Loc, CurInitExpr, CandidateSet, T, Ctors, Best,
5929 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
5930 : diag::err_temp_copy_no_viable)
5939 S.
Diag(Loc, diag::err_temp_copy_ambiguous)
5946 S.
Diag(Loc, diag::err_temp_copy_deleted)
5953 bool HadMultipleCandidates = CandidateSet.
size() > 1;
5962 if (IsExtraneousCopy) {
5973 for (
unsigned I = 1, N = Constructor->
getNumParams(); I != N; ++I) {
5976 diag::err_call_incomplete_argument))
6016 Best->Function->getParamDecl(0)->getType().getNonReferenceType(),
6023 HadMultipleCandidates,
6041 Expr *CurInitExpr) {
6060 S, Loc, CurInitExpr, CandidateSet, CurInitExpr->
getType(), Ctors, Best,
6072 Best->FoundDecl, Entity, Diag);
6093 void InitializationSequence::PrintInitLocationNote(
Sema &S,
6108 diag::note_method_return_type_change)
6132 return NumArgs != 1;
6144 bool &ConstructorInitRequiresZeroInit,
6145 bool IsListInitialization,
6146 bool IsStdInitListInitialization,
6149 unsigned NumArgs = Args.size();
6164 assert(Constructor->
getParent() &&
"No parent class for constructor.");
6178 bool AllowExplicitConv =
6186 Loc, ConstructorArgs,
6188 IsListInitialization))
6205 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
6216 ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
6217 IsListInitialization, IsStdInitListInitialization,
6218 ConstructorInitRequiresZeroInit);
6234 if (IsListInitialization)
6235 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
6246 HadMultipleCandidates,
6247 IsListInitialization,
6248 IsStdInitListInitialization,
6249 ConstructorInitRequiresZeroInit,
6257 HadMultipleCandidates,
6258 IsListInitialization,
6259 IsStdInitListInitialization,
6260 ConstructorInitRequiresZeroInit,
6304 using LifetimeResult =
6305 llvm::PointerIntPair<const InitializedEntity *, 3, LifetimeKind>;
6318 return {Entity, LK_Extended};
6338 : LK_MemInitializer};
6343 return {Entity, LK_Extended};
6350 return {
nullptr, LK_FullExpression};
6356 return {
nullptr, LK_Return};
6361 return {
nullptr, LK_StmtExprResult};
6367 return {
nullptr, LK_New};
6375 return {
nullptr, LK_FullExpression};
6385 return {InitField, LK_MemInitializer};
6392 return {InitField, LK_MemInitializer};
6399 return {
nullptr, LK_FullExpression};
6403 return {
nullptr, LK_FullExpression};
6405 llvm_unreachable(
"unknown entity kind");
6411 RK_ReferenceBinding,
6414 RK_StdInitializerList,
6422 using Local =
Expr*;
6427 struct IndirectLocalPathEntry {
6436 const Decl *D =
nullptr;
6437 IndirectLocalPathEntry() {}
6438 IndirectLocalPathEntry(EntryKind K,
Expr *E) :
Kind(K), E(E) {}
6439 IndirectLocalPathEntry(EntryKind K,
Expr *E,
const Decl *D)
6440 :
Kind(K), E(E), D(D) {}
6445 struct RevertToOldSizeRAII {
6446 IndirectLocalPath &Path;
6447 unsigned OldSize = Path.size();
6448 RevertToOldSizeRAII(IndirectLocalPath &Path) : Path(Path) {}
6449 ~RevertToOldSizeRAII() { Path.resize(OldSize); }
6452 using LocalVisitor = llvm::function_ref<
bool(IndirectLocalPath &Path, Local L,
6458 if (E.Kind == IndirectLocalPathEntry::VarInit && E.D == VD)
6464 return llvm::any_of(Path, [=](IndirectLocalPathEntry E) {
6465 return E.Kind == IndirectLocalPathEntry::DefaultInit ||
6466 E.Kind == IndirectLocalPathEntry::VarInit;
6471 Expr *Init, LocalVisitor Visit,
6472 bool RevisitSubinits);
6476 LocalVisitor Visit);
6496 LocalVisitor Visit) {
6500 if (
auto *CE = dyn_cast<CallExpr>(Call)) {
6501 Callee = CE->getDirectCallee();
6502 Args = llvm::makeArrayRef(CE->getArgs(), CE->getNumArgs());
6504 auto *CCE = cast<CXXConstructExpr>(Call);
6505 Callee = CCE->getConstructor();
6506 Args = llvm::makeArrayRef(CCE->getArgs(), CCE->getNumArgs());
6511 Expr *ObjectArg =
nullptr;
6513 ObjectArg = Args[0];
6514 Args = Args.slice(1);
6515 }
else if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(Call)) {
6516 ObjectArg = MCE->getImplicitObjectArgument();
6519 auto VisitLifetimeBoundArg = [&](
const Decl *D,
Expr *Arg) {
6520 Path.push_back({IndirectLocalPathEntry::LifetimeBoundCall, Arg, D});
6521 if (Arg->isGLValue())
6530 VisitLifetimeBoundArg(Callee, ObjectArg);
6532 for (
unsigned I = 0,
6533 N = std::min<unsigned>(Callee->
getNumParams(), Args.size());
6536 VisitLifetimeBoundArg(Callee->
getParamDecl(I), Args[I]);
6544 LocalVisitor Visit) {
6545 RevertToOldSizeRAII RAII(Path);
6552 if (
auto *FE = dyn_cast<FullExpr>(Init))
6553 Init = FE->getSubExpr();
6555 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6567 if (
CastExpr *CE = dyn_cast<CastExpr>(Init))
6568 if (CE->getSubExpr()->isGLValue())
6569 Init = CE->getSubExpr();
6573 if (
auto *ASE = dyn_cast<ArraySubscriptExpr>(Init)) {
6574 Init = ASE->getBase();
6576 if (ICE && ICE->getCastKind() == CK_ArrayToPointerDecay)
6577 Init = ICE->getSubExpr();
6586 if (
auto *DIE = dyn_cast<CXXDefaultInitExpr>(Init)) {
6588 {IndirectLocalPathEntry::DefaultInit, DIE, DIE->getField()});
6589 Init = DIE->getExpr();
6591 }
while (Init != Old);
6593 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Init)) {
6594 if (Visit(Path, Local(MTE), RK))
6599 if (isa<CallExpr>(Init))
6603 case Stmt::DeclRefExprClass: {
6606 auto *DRE = cast<DeclRefExpr>(Init);
6607 auto *VD = dyn_cast<
VarDecl>(DRE->getDecl());
6608 if (VD && VD->hasLocalStorage() &&
6609 !DRE->refersToEnclosingVariableOrCapture()) {
6610 if (!VD->getType()->isReferenceType()) {
6611 Visit(Path, Local(DRE), RK);
6612 }
else if (isa<ParmVarDecl>(DRE->getDecl())) {
6616 }
else if (VD->getInit() && !
isVarOnPath(Path, VD)) {
6617 Path.push_back({IndirectLocalPathEntry::VarInit, DRE, VD});
6619 RK_ReferenceBinding, Visit);
6625 case Stmt::UnaryOperatorClass: {
6635 case Stmt::OMPArraySectionExprClass: {
6637 Path, cast<OMPArraySectionExpr>(Init)->getBase(), Visit,
true);
6641 case Stmt::ConditionalOperatorClass:
6642 case Stmt::BinaryConditionalOperatorClass: {
6643 auto *
C = cast<AbstractConditionalOperator>(Init);
6644 if (!
C->getTrueExpr()->getType()->isVoidType())
6646 if (!
C->getFalseExpr()->getType()->isVoidType())
6661 Expr *Init, LocalVisitor Visit,
6662 bool RevisitSubinits) {
6663 RevertToOldSizeRAII RAII(Path);
6671 if (
auto *DIE = dyn_cast<CXXDefaultInitExpr>(Init)) {
6672 Path.push_back({IndirectLocalPathEntry::DefaultInit, DIE, DIE->getField()});
6673 Init = DIE->getExpr();
6676 if (
auto *FE = dyn_cast<FullExpr>(Init))
6677 Init = FE->getSubExpr();
6683 Init = BTE->getSubExpr();
6688 if (
auto *CE = dyn_cast<CastExpr>(Init)) {
6689 switch (CE->getCastKind()) {
6690 case CK_LValueToRValue:
6693 Path.push_back({IndirectLocalPathEntry::LValToRVal, CE});
6695 Path, Init, RK_ReferenceBinding,
6696 [&](IndirectLocalPath &Path, Local L,
ReferenceKind RK) ->
bool {
6697 if (
auto *DRE = dyn_cast<DeclRefExpr>(L)) {
6698 auto *VD = dyn_cast<
VarDecl>(DRE->getDecl());
6699 if (VD && VD->getType().isConstQualified() && VD->getInit() &&
6701 Path.push_back({IndirectLocalPathEntry::VarInit, DRE, VD});
6704 }
else if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(L)) {
6705 if (MTE->getType().isConstQualified())
6718 case CK_BaseToDerived:
6719 case CK_DerivedToBase:
6720 case CK_UncheckedDerivedToBase:
6723 case CK_UserDefinedConversion:
6724 case CK_ConstructorConversion:
6725 case CK_IntegralToPointer:
6726 case CK_PointerToIntegral:
6727 case CK_VectorSplat:
6728 case CK_IntegralCast:
6729 case CK_CPointerToObjCPointerCast:
6730 case CK_BlockPointerToObjCPointerCast:
6731 case CK_AnyPointerToBlockPointerCast:
6732 case CK_AddressSpaceConversion:
6735 case CK_ArrayToPointerDecay:
6738 Path.push_back({IndirectLocalPathEntry::AddressOf, CE});
6740 RK_ReferenceBinding, Visit);
6746 Init = CE->getSubExpr();
6748 }
while (Old != Init);
6753 if (
auto *ILE = dyn_cast<CXXStdInitializerListExpr>(Init))
6755 RK_StdInitializerList, Visit);
6757 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
6761 if (!RevisitSubinits)
6769 for (
unsigned I = 0, N = ILE->
getNumInits(); I != N; ++I)
6776 assert(RD->isAggregate() &&
"aggregate init on non-aggregate");
6784 RK_ReferenceBinding, Visit);
6787 for (
const auto *I : RD->fields()) {
6790 if (I->isUnnamedBitfield())
6793 if (I->getType()->isReferenceType())
6795 RK_ReferenceBinding, Visit);
6811 if (
auto *LE = dyn_cast<LambdaExpr>(Init)) {
6812 for (
Expr *E : LE->capture_inits()) {
6823 if (isa<CallExpr>(Init) || isa<CXXConstructExpr>(Init))
6827 case Stmt::UnaryOperatorClass: {
6828 auto *UO = cast<UnaryOperator>(Init);
6831 if (UO->getOpcode() == UO_AddrOf) {
6835 if (isa<MaterializeTemporaryExpr>(UO->getSubExpr()))
6838 Path.push_back({IndirectLocalPathEntry::AddressOf, UO});
6840 RK_ReferenceBinding, Visit);
6845 case Stmt::BinaryOperatorClass: {
6847 auto *BO = cast<BinaryOperator>(Init);
6849 if (!BO->getType()->isPointerType() || (BOK != BO_Add && BOK != BO_Sub))
6852 if (BO->getLHS()->getType()->isPointerType())
6854 else if (BO->getRHS()->getType()->isPointerType())
6859 case Stmt::ConditionalOperatorClass:
6860 case Stmt::BinaryConditionalOperatorClass: {
6861 auto *
C = cast<AbstractConditionalOperator>(Init);
6864 if (!
C->getTrueExpr()->getType()->isVoidType())
6866 if (!
C->getFalseExpr()->getType()->isVoidType())
6871 case Stmt::BlockExprClass:
6872 if (cast<BlockExpr>(Init)->getBlockDecl()->hasCaptures()) {
6874 Visit(Path, Local(cast<BlockExpr>(Init)), RK_ReferenceBinding);
6878 case Stmt::AddrLabelExprClass:
6880 Visit(Path, Local(cast<AddrLabelExpr>(Init)), RK_ReferenceBinding);
6891 for (
auto Elem : Path) {
6892 if (Elem.Kind != IndirectLocalPathEntry::DefaultInit)
6901 for (
unsigned N = Path.size(); I != N; ++I) {
6902 switch (Path[I].Kind) {
6903 case IndirectLocalPathEntry::AddressOf:
6904 case IndirectLocalPathEntry::LValToRVal:
6905 case IndirectLocalPathEntry::LifetimeBoundCall:
6910 case IndirectLocalPathEntry::DefaultInit:
6911 case IndirectLocalPathEntry::VarInit:
6912 return Path[I].E->getSourceRange();
6926 if (LK == LK_FullExpression)
6929 auto TemporaryVisitor = [&](IndirectLocalPath &Path, Local L,
6935 case LK_FullExpression:
6936 llvm_unreachable(
"already handled this");
6966 Diag(DiagLoc, diag::warn_unsupported_lifetime_extension)
6975 Diag(DiagLoc, diag::warn_dangling_variable)
6983 case LK_MemInitializer: {
6984 if (isa<MaterializeTemporaryExpr>(L)) {
6988 if (
auto *ExtendingDecl =
6989 ExtendingEntity ? ExtendingEntity->
getDecl() :
nullptr) {
6990 bool IsSubobjectMember = ExtendingEntity != &Entity;
6992 ? diag::err_dangling_member
6993 : diag::warn_dangling_member)
6994 << ExtendingDecl << IsSubobjectMember << RK << DiagRange;
6999 Path.back().Kind != IndirectLocalPathEntry::DefaultInit) {
7000 Diag(ExtendingDecl->getLocation(),
7001 diag::note_lifetime_extending_member_declared_here)
7002 << RK << IsSubobjectMember;
7021 auto *VD = DRE ? dyn_cast<
VarDecl>(DRE->getDecl()) :
nullptr;
7029 ExtendingEntity ? ExtendingEntity->
getDecl() :
nullptr) {
7031 Diag(DiagLoc, IsPointer ? diag::warn_init_ptr_member_to_parameter_addr
7032 : diag::warn_bind_ref_member_to_parameter)
7033 << Member << VD << isa<ParmVarDecl>(VD) << DiagRange;
7034 Diag(Member->getLocation(),
7035 diag::note_ref_or_ptr_member_declared_here)
7036 << (
unsigned)IsPointer;
7043 if (isa<MaterializeTemporaryExpr>(L)) {
7044 Diag(DiagLoc, RK == RK_ReferenceBinding
7045 ? diag::warn_new_dangling_reference
7046 : diag::warn_new_dangling_initializer_list)
7055 case LK_StmtExprResult:
7056 if (
auto *DRE = dyn_cast<DeclRefExpr>(L)) {
7059 if (LK == LK_StmtExprResult)
7061 Diag(DiagLoc, diag::warn_ret_stack_addr_ref)
7063 << isa<ParmVarDecl>(DRE->getDecl()) << DiagRange;
7064 }
else if (isa<BlockExpr>(L)) {
7065 Diag(DiagLoc, diag::err_ret_local_block) << DiagRange;
7066 }
else if (isa<AddrLabelExpr>(L)) {
7069 if (LK == LK_StmtExprResult)
7071 Diag(DiagLoc, diag::warn_ret_addr_label) << DiagRange;
7073 Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
7079 for (
unsigned I = 0; I != Path.size(); ++I) {
7080 auto Elem = Path[I];
7082 switch (Elem.Kind) {
7083 case IndirectLocalPathEntry::AddressOf:
7084 case IndirectLocalPathEntry::LValToRVal:
7089 case IndirectLocalPathEntry::LifetimeBoundCall:
7093 case IndirectLocalPathEntry::DefaultInit: {
7094 auto *FD = cast<FieldDecl>(Elem.D);
7095 Diag(FD->getLocation(), diag::note_init_with_default_member_initalizer)
7100 case IndirectLocalPathEntry::VarInit:
7101 const VarDecl *VD = cast<VarDecl>(Elem.D);
7127 const Expr *PostInit);
7131 bool IsReturnStmt) {
7142 unsigned DiagID = 0;
7172 if (VD->
hasAttr<BlocksAttr>())
7185 if (isa<ParmVarDecl>(VD))
7186 DiagID = diag::warn_redundant_move_on_return;
7188 DiagID = diag::warn_pessimizing_move_on_return;
7190 DiagID = diag::warn_pessimizing_move_on_initialization;
7232 if (UO->getOpcode() == UO_Deref &&
7233 UO->getSubExpr()->IgnoreParenCasts()->
7236 S.
PDiag(diag::warn_binding_null_to_reference)
7237 << UO->getSubExpr()->getSourceRange());
7243 bool BoundToLvalueReference) {
7244 auto MTE =
new (Context)
7253 Cleanup.setExprNeedsCleanups(
false);
7262 if (!E->
isRValue() || !getLangOpts().CPlusPlus11)
7269 if (RequireCompleteType(E->
getExprLoc(), T, diag::err_incomplete_type))
7272 return CreateMaterializeTemporaryExpr(E->
getType(), E,
false);
7279 ? CK_AddressSpaceConversion
7281 return ImpCastExprToType(E, Ty, CK, VK,
nullptr, CCK);
7293 if (!ZeroInitializationFixit.empty()) {
7294 unsigned DiagID = diag::err_default_init_const;
7296 if (S.
getLangOpts().MSVCCompat && D->hasAttr<SelectAnyAttr>())
7297 DiagID = diag::ext_default_init_const;
7306 ZeroInitializationFixit);
7325 if (isa<InitListExpr>((
Expr *)Args[0])) {
7329 if (
auto *DD = dyn_cast_or_null<DeclaratorDecl>(Entity.
getDecl())) {
7331 TypeLoc TL = TInfo->getTypeLoc();
7334 Brackets = ArrayLoc.getBracketsRange();
7341 ArrayT->getSizeModifier(),
7342 ArrayT->getIndexTypeCVRQualifiers(),
7366 Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
7371 Expr *Init = Args[0];
7372 S.
Diag(Init->
getBeginLoc(), diag::warn_cxx98_compat_reference_list_init)
7385 S.
Diag(Args[0]->getBeginLoc(), diag::err_opencl_atomic_init)
7405 switch (Steps.front().Kind) {
7439 assert(Args.size() == 1);
7457 CurInit.
get() && isa<InitListExpr>(CurInit.
get()));
7462 auto checkAbstractType = [&](
QualType T) ->
bool {
7467 diag::err_allocation_of_abstract_type);
7472 bool ConstructorInitRequiresZeroInit =
false;
7503 SourceType,
Step->
Type, CurInit.
get()->getBeginLoc(),
7504 CurInit.
get()->getSourceRange(), &BasePath, IgnoreBaseAccess))
7515 CurInit.
get(), &BasePath, VK);
7529 if (CurInit.
get()->getType()->isFunctionProtoType()) {
7530 if (
auto *DRE = dyn_cast<DeclRefExpr>(CurInit.
get()->IgnoreParens())) {
7531 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
7533 DRE->getBeginLoc()))
7544 assert(CurInit.
get()->isRValue() &&
"not a temporary");
7590 bool CreatedObject =
false;
7601 Loc, ConstructorArgs))
7606 FoundFn, Constructor,
7608 HadMultipleCandidates,
7622 CastKind = CK_ConstructorConversion;
7623 CreatedObject =
true;
7633 HadMultipleCandidates);
7637 CastKind = CK_UserDefinedConversion;
7638 CreatedObject = Conversion->getReturnType()->isRecordType();
7641 if (CreatedObject && checkAbstractType(CurInit.
get()->getType()))
7646 CurInit.
get()->getValueKind());
7662 S.
PDiag(diag::err_access_dtor_temp) << T);
7685 assert(CurInit.
get()->isRValue() &&
"cannot convert glvalue to atomic");
7692 assert(CurInit.
get()->isGLValue() &&
"cannot load from a prvalue");
7694 CK_LValueToRValue, CurInit.get(),
7701 if (
const auto *FromPtrType =
7704 if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
7705 !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
7706 S.
Diag(CurInit.
get()->getExprLoc(),
7707 diag::warn_noderef_to_dereferenceable_pointer)
7708 << CurInit.
get()->getSourceRange();
7726 CurInit = CurInitExprRes;
7747 InitListChecker PerformInitList(S, InitEntity,
7748 InitList, Ty,
false,
7750 if (PerformInitList.HadError())
7758 if ((*ResultType)->isRValueReferenceType())
7760 else if ((*ResultType)->isLValueReferenceType())
7767 PerformInitList.getFullyStructuredList();
7771 : StructuredInitList;
7788 assert(Args.size() == 1 &&
"expected a single argument for list init");
7790 S.
Diag(InitList->getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
7791 << InitList->getSourceRange();
7792 MultiExprArg Arg(InitList->getInits(), InitList->getNumInits());
7796 ConstructorInitRequiresZeroInit,
7799 InitList->getLBraceLoc(),
7800 InitList->getRBraceLoc());
7805 CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
7834 bool IsStdInitListInit =
7841 S, UseTemporary ? TempEntity : Entity, Kind,
7843 ConstructorInitRequiresZeroInit,
7854 if (NextStep != StepEnd &&
7859 ConstructorInitRequiresZeroInit =
true;
7899 CurInit = CurInitExprRes;
7904 InitialCurInit.
get(),
7907 PrintInitLocationNote(S, Entity);
7909 }
else if (Complained)
7910 PrintInitLocationNote(S, Entity);
7923 CK_ObjCObjectLValueCast,
7924 CurInit.
get()->getValueKind());
7936 ArrayLoopCommonExprs.push_back(BaseExpr);
7941 assert(!ArrayLoopCommonExprs.empty() &&
7942 "mismatched SK_ArrayLoopIndex and SK_ArrayLoopInit");
7943 Expr *Common = ArrayLoopCommonExprs.pop_back_val();
7954 << CurInit.
get()->getSourceRange();
7965 IncompleteDest->getElementType(),
7966 ConstantSource->getSize(),
7977 << CurInit.
get()->getSourceRange();
7995 S.
Diag(CurInit.get()->getExprLoc(),
7996 diag::warn_cxx98_compat_initializer_list_init)
7997 << CurInit.get()->getSourceRange();
8001 CurInit.get()->getType(), CurInit.get(),
8031 "Sampler initialization on non-sampler type.");
8032 Expr *Init = CurInit.get();
8033 QualType SourceType = Init->getType();
8040 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Init)) {
8041 auto Var = cast<VarDecl>(DRE->getDecl());
8044 if (!Var->hasGlobalStorage()) {
8046 CK_LValueToRValue, Init,
8056 if (!Var->getInit() || !isa<ImplicitCastExpr>(Var->getInit()))
8058 Init = cast<ImplicitCastExpr>(
const_cast<Expr*
>(
8059 Var->getInit()))->getSubExpr();
8060 SourceType = Init->getType();
8067 if (!Init->isConstantInitializer(S.
Context,
false))
8078 Init->EvaluateAsInt(EVResult, S.
Context);
8080 const uint64_t SamplerValue = Result.getLimitedValue();
8087 unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
8088 unsigned FilterMode = (0x30 & SamplerValue) >> 4;
8089 if (FilterMode != 1 && FilterMode != 2 &&
8091 "cl_intel_device_side_avc_motion_estimation"))
8093 diag::warn_sampler_initializer_invalid_bits)
8095 if (AddressingMode > 4)
8097 diag::warn_sampler_initializer_invalid_bits)
8098 <<
"Addressing Mode";
8104 CK_IntToOCLSampler);
8110 "Wrong type for initialization of OpenCL opaque type.");
8113 CK_ZeroToOCLOpaqueType,
8114 CurInit.get()->getValueKind());
8122 if (
auto *Init = CurInit.
get())
8127 cast<FieldDecl>(Entity.
getDecl())->isBitField())
8129 cast<FieldDecl>(Entity.
getDecl()),
8133 if (
const Expr *E = CurInit.
get()) {
8146 S.
Diag(Loc, diag::err_reference_without_init)
8155 for (
const auto *FI : RD->
fields()) {
8156 if (FI->isUnnamedBitfield())
8160 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
8165 for (
const auto &BI : RD->
bases()) {
8167 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
8222 if (
auto *D = Entity.
getDecl())
8223 Loc = D->getLocation();
8224 S.
Diag(Loc, diag::note_in_reference_temporary_list_initializer) << T;
8228 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
8231 assert(DiagnoseInitList.HadError() &&
8232 "Inconsistent init list check result.");
8245 if (Args.size() == 1) {
8247 if (List && List->getNumInits() == 1)
8248 OnlyArg = List->getInit(0);
8267 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
8271 <<
SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
8275 << 1 << Entity.
getType() << Args[0]->getSourceRange();
8288 S.
Diag(Kind.
getLocation(), diag::err_array_init_narrow_string_into_wchar);
8291 S.
Diag(Kind.
getLocation(), diag::err_array_init_wide_string_into_char);
8295 diag::err_array_init_incompat_wide_string_into_wchar);
8299 diag::err_array_init_plain_string_into_char8_t);
8300 S.
Diag(Args.front()->getBeginLoc(),
8301 diag::note_array_init_plain_string_into_char8_t)
8306 diag::err_array_init_utf8_string_into_char)
8313 ? diag::err_array_init_different_type
8314 : diag::err_array_init_non_constant_array))
8317 << Args[0]->getSourceRange();
8335 auto *FD = cast<FunctionDecl>(cast<DeclRefExpr>(OnlyArg)->getDecl());
8343 switch (FailedOverloadResult) {
8347 << OnlyArg->
getType() << DestType
8348 << Args[0]->getSourceRange();
8351 << DestType << OnlyArg->
getType()
8352 << Args[0]->getSourceRange();
8360 diag::err_typecheck_nonviable_condition_incomplete,
8361 OnlyArg->
getType(), Args[0]->getSourceRange()))
8364 << OnlyArg->
getType() << Args[0]->getSourceRange()
8373 << Args[0]->getSourceRange();
8376 = FailedCandidateSet.BestViableFunction(S, Kind.
getLocation(), Best);
8380 llvm_unreachable(
"Inconsistent overload resolution?");
8386 llvm_unreachable(
"Conversion did not fail!");
8391 if (isa<InitListExpr>(Args[0])) {
8393 diag::err_lvalue_reference_bind_to_initlist)
8396 << Args[0]->getSourceRange();
8404 ? diag::err_lvalue_reference_bind_to_temporary
8405 : diag::err_lvalue_reference_bind_to_unrelated)
8409 << Args[0]->getSourceRange();
8414 FieldDecl *BitField = Args[0]->getSourceBitField();
8418 << (BitField !=
nullptr)
8419 << Args[0]->getSourceRange();
8426 S.
Diag(Kind.
getLocation(), diag::err_reference_bind_to_vector_element)
8428 << Args[0]->getSourceRange();
8434 << Args[0]->getSourceRange();
8447 << Args[0]->getSourceRange();
8456 << Args[0]->getSourceRange();
8467 << Args[0]->getSourceRange();
8485 assert(Args.size() > 1 &&
"Expected multiple initializers!");
8486 R =
SourceRange(Args.front()->getEndLoc(), Args.back()->getEndLoc());
8491 S.
Diag(Kind.
getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
8501 << 0 << Entity.
getType() << Args[0]->getSourceRange();
8519 SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
8522 assert(Args.size() == 1 &&
8523 "List construction from other than 1 argument.");
8525 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
8530 switch (FailedOverloadResult) {
8533 << DestType << ArgsRange;
8550 InheritedFrom = Inherited.getShadowDecl()->getNominatedBaseClass();
8553 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
8566 << (InheritedFrom ? 2 : Constructor->
isImplicit() ? 1 : 0)
8572 diag::note_member_declared_at);
8576 S.
Diag(Record->getDecl()->getLocation(),
8577 diag::note_previous_decl)
8584 << DestType << ArgsRange;
8591 = FailedCandidateSet.BestViableFunction(S, Kind.
getLocation(), Best);
8594 <<
true << DestType << ArgsRange;
8595 llvm_unreachable(
"Inconsistent overload resolution?");
8605 << DestType << ArgsRange;
8608 <<
true << DestType << ArgsRange;
8615 llvm_unreachable(
"Conversion did not fail!");
8643 diag::err_init_incomplete_type);
8663 = FailedCandidateSet.BestViableFunction(S, Kind.
getLocation(), Best);
8665 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
8668 diag::note_explicit_ctor_deduction_guide_here) <<
false;
8673 PrintInitLocationNote(S, Entity);
8680 OS <<
"Failed sequence: ";
8683 OS <<
"too many initializers for reference";
8687 OS <<
"parenthesized list init for reference";
8691 OS <<
"array requires initializer list";
8695 OS <<
"address of unaddressable function was taken";
8699 OS <<
"array requires initializer list or string literal";
8703 OS <<
"array requires initializer list or wide string literal";
8707 OS <<
"narrow string into wide char array";
8711 OS <<
"wide string into char array";
8715 OS <<
"incompatible wide string into wide char array";
8719 OS <<
"plain string literal into char8_t array";
8723 OS <<
"u8 string literal into char array";
8727 OS <<
"array type mismatch";
8731 OS <<
"non-constant array initializer";
8735 OS <<
"address of overloaded function failed";
8739 OS <<
"overload resolution for reference initialization failed";
8743 OS <<
"non-const lvalue reference bound to temporary";
8747 OS <<
"non-const lvalue reference bound to bit-field";
8751 OS <<
"non-const lvalue reference bound to vector element";
8755 OS <<
"non-const lvalue reference bound to unrelated type";
8759 OS <<
"rvalue reference bound to an lvalue";
8763 OS <<
"reference initialization drops qualifiers";
8767 OS <<
"reference initialization failed";
8771 OS <<
"conversion failed";
8775 OS <<
"conversion from property failed";
8779 OS <<
"too many initializers for scalar";
8783 OS <<
"parenthesized list init for reference";
8787 OS <<
"referencing binding to initializer list";
8791 OS <<
"initializer list for non-aggregate, non-scalar type";
8795 OS <<
"overloading failed for user-defined conversion";
8799 OS <<
"constructor overloading failed";
8803 OS <<
"default initialization of a const variable";
8807 OS <<
"initialization of incomplete type";
8811 OS <<
"list initialization checker failure";
8815 OS <<
"variable length array has an initializer";
8819 OS <<
"initializer expression isn't contextually valid";
8823 OS <<
"list constructor overloading failed";
8827 OS <<
"list copy initialization chose explicit constructor";
8835 OS <<
"Dependent sequence\n";
8839 OS <<
"Normal sequence: ";
8850 OS <<
"resolve address of overloaded function";
8854 OS <<
"derived-to-base (rvalue)";
8858 OS <<
"derived-to-base (xvalue)";
8862 OS <<
"derived-to-base (lvalue)";
8866 OS <<
"bind reference to lvalue";
8870 OS <<
"bind reference to a temporary";
8874 OS <<
"final copy in class direct-initialization";
8878 OS <<
"extraneous C++03 copy to temporary";
8882 OS <<
"user-defined conversion via " << *S->Function.Function;
8886 OS <<
"qualification conversion (rvalue)";
8890 OS <<
"qualification conversion (xvalue)";
8894 OS <<
"qualification conversion (lvalue)";
8898 OS <<
"non-atomic-to-atomic conversion";
8902 OS <<
"load (lvalue to rvalue)";
8906 OS <<
"implicit conversion sequence (";
8912 OS <<
"implicit conversion sequence with narrowing prohibited (";
8918 OS <<
"list aggregate initialization";
8922 OS <<
"unwrap reference initializer list";
8926 OS <<
"rewrap reference initializer list";
8930 OS <<
"constructor initialization";
8934 OS <<
"list initialization via constructor";
8938 OS <<
"zero initialization";
8942 OS <<
"C assignment";
8946 OS <<
"string initialization";
8950 OS <<
"Objective-C object conversion";
8954 OS <<
"indexing for array initialization loop";
8958 OS <<
"array initialization loop";
8962 OS <<
"array initialization";
8966 OS <<
"array initialization (GNU extension)";
8970 OS <<
"parenthesized array initialization";
8974 OS <<
"pass by indirect copy and restore";
8978 OS <<
"pass by indirect restore";
8982 OS <<
"Objective-C object retension";
8986 OS <<
"std::initializer_list from initializer list";
8990 OS <<
"list initialization from std::initializer_list";
8994 OS <<
"OpenCL sampler_t from integer constant";
8998 OS <<
"OpenCL opaque type from zero";
9002 OS <<
" [" << S->Type.getAsString() <<
']';
9013 return L.CPlusPlus11 &&
9021 const Expr *PostInit) {
9051 ? diag::ext_init_list_type_narrowing
9052 : diag::warn_init_list_type_narrowing)
9062 ? diag::ext_init_list_constant_narrowing
9063 : diag::warn_init_list_constant_narrowing)
9073 ? diag::ext_init_list_variable_narrowing
9074 : diag::warn_init_list_variable_narrowing)
9082 llvm::raw_svector_ostream OS(StaticCast);
9083 OS <<
"static_cast<";
9090 OS << *TT->getDecl();
9099 S.
Diag(PostInit->
getBeginLoc(), diag::note_init_list_narrowing_silence)
9116 assert(InitE &&
"No initialization expression");
9121 return !Seq.Failed();
9128 bool TopLevelOfInitList,
9129 bool AllowExplicit) {
9134 assert(InitE &&
"No initialization expression?");
9144 const bool ShouldTrackCopy =
9146 if (ShouldTrackCopy) {
9147 if (llvm::find(CurrentParameterCopyTypes, Entity.
getType()) !=
9148 CurrentParameterCopyTypes.end()) {
9149 Seq.SetOverloadFailure(
9155 const auto LastStep = Seq.step_end() - 1;
9156 assert(LastStep->Kind ==
9158 const FunctionDecl *Function = LastStep->Function.Function;
9160 llvm::find_if(Seq.getFailedCandidateSet(),
9162 return Candidate.Viable &&
9163 Candidate.Function == Function &&
9164 Candidate.Conversions.size() > 0;
9166 if (Candidate != Seq.getFailedCandidateSet().end() &&
9168 Candidate->Viable =
false;
9175 CurrentParameterCopyTypes.push_back(Entity.
getType());
9180 if (ShouldTrackCopy)
9181 CurrentParameterCopyTypes.pop_back();
9189 auto NotSpecialization = [&] (
const CXXRecordDecl *Candidate) {
9193 return !(NotSpecialization(RD) && RD->
forallBases(NotSpecialization));
9201 assert(DeducedTST &&
"not a deduced template specialization type");
9212 diag::err_deduced_non_class_template_specialization_type)
9215 Diag(TD->getLocation(), diag::note_template_decl_here);
9222 diag::warn_cxx14_compat_class_template_argument_deduction)
9242 LookupResult Guides(*
this, NameInfo, LookupOrdinaryName);
9243 LookupQualifiedName(Guides, Template->getDeclContext());
9247 Guides.suppressDiagnostics();
9252 ? dyn_cast<InitListExpr>(Inits[0])
9267 auto tryToResolveOverload =
9270 for (
auto I = Guides.begin(), E = Guides.end(); I != E; ++I) {
9276 auto *GD = dyn_cast_or_null<CXXDeductionGuideDecl>(
9277 TD ? TD->getTemplatedDecl() : dyn_cast<
FunctionDecl>(D));
9288 if (GD->isExplicit())
9294 if (GD->getMinRequiredArguments() > 1 ||
9295 (GD->getNumParams() == 0 && !GD->isVariadic()))
9302 if (OnlyListConstructors && !isInitListConstructor(GD))
9317 bool SuppressUserConversions = Kind.
isCopyInit();
9320 AddTemplateOverloadCandidate(TD, I.getPair(),
nullptr,
9322 SuppressUserConversions);
9324 AddOverloadCandidate(GD, I.getPair(),
Inits, Candidates,
9325 SuppressUserConversions);
9327 return Candidates.BestViableFunction(*
this, Kind.
getLocation(), Best);
9335 bool TryListConstructors =
true;
9341 auto *FD = dyn_cast<
FunctionDecl>(D->getUnderlyingDecl());
9342 if (FD && FD->getMinRequiredArguments() == 0) {
9343 TryListConstructors =
false;
9355 if (!isa<InitListExpr>(E) && RD &&
9358 TryListConstructors =
false;
9361 if (TryListConstructors)
9362 Result = tryToResolveOverload(
true);
9371 Result = tryToResolveOverload(
false);
9375 Diag(Kind.
getLocation(), diag::err_deduced_class_template_ctor_ambiguous)
9385 cast<ClassTemplateDecl>(Template)->getTemplatedDecl();
9389 Complete ? diag::err_deduced_class_template_ctor_no_viable
9390 : diag::err_deduced_class_template_incomplete)
9399 NoteDeletedFunction(Best->Function);
9408 cast<CXXDeductionGuideDecl>(Best->Function)->isExplicit()) {
9409 bool IsDeductionGuide = !Best->Function->isImplicit();
9412 Diag(Best->Function->getLocation(),
9413 diag::note_explicit_ctor_deduction_guide_here)
9414 << IsDeductionGuide;
9420 DiagnoseUseOfDecl(Best->Function, Kind.
getLocation());
9421 MarkFunctionReferenced(Kind.
getLocation(), Best->Function);
9429 SubstAutoType(TSInfo->
getType(), Best->Function->getReturnType());
9431 diag::warn_cxx14_compat_class_template_argument_deduction)
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Represents a single C99 designator.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Perform a derived-to-base cast, producing an lvalue.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
bool isCallToStdMove() const
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Represents a function declaration or definition.
Expr * getArrayIndex(const Designator &D) const
static bool hasAccessibleDestructor(QualType ElementType, SourceLocation Loc, Sema &SemaRef)
Check if the type of a class element has an accessible destructor.
InitListExpr * WrappingSyntacticList
When Kind = SK_RewrapInitList, the syntactic form of the wrapping list.
NamespaceDecl * getStdNamespace() const
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
step_iterator step_begin() const
SourceLocation getRParenLoc() const
SourceLocation getEllipsisLoc() const
void setArrayFiller(Expr *filler)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
PointerType - C99 6.7.5.1 - Pointer Declarators.
SourceLocation getBeginLoc() const LLVM_READONLY
void SetZeroInitializationFixit(const std::string &Fixit, SourceLocation L)
Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied...
A (possibly-)qualified type.
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
Simple class containing the result of Sema::CorrectTypo.
StringKind getKind() const
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
DeclarationName getName() const
Retrieve the name of the entity being initialized.
void setFromType(QualType T)
Produce an Objective-C object pointer.
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
A cast other than a C-style cast.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr *> &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
Initializing char array with wide string literal.
Perform an implicit conversion sequence without narrowing.
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
const Expr * getInit(unsigned Init) const
InvalidICRKind
The non-zero enum values here are indexes into diagnostic alternatives.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static ExprResult CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value)
Check that the given Index expression is a valid array designator value.
static void TryReferenceInitializationCore(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, QualType cv1T1, QualType T1, Qualifiers T1Quals, QualType cv2T2, QualType T2, Qualifiers T2Quals, InitializationSequence &Sequence)
Reference initialization without resolving overloaded functions.
Perform a qualification conversion, producing an rvalue.
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
static OverloadingResult ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, MultiExprArg Args, OverloadCandidateSet &CandidateSet, QualType DestType, DeclContext::lookup_result Ctors, OverloadCandidateSet::iterator &Best, bool CopyInitializing, bool AllowExplicit, bool OnlyListConstructors, bool IsListInit, bool SecondStepOfCopyInit=false)
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
static OverloadingResult TryRefInitWithConversionFunction(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, bool AllowRValues, bool IsLValueRef, InitializationSequence &Sequence)
Try a reference initialization that involves calling a conversion function.
static DesignatedInitExpr * CloneDesignatedInitExpr(Sema &SemaRef, DesignatedInitExpr *DIE)
bool isRecordType() const
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
ConstructorInfo getConstructorInfo(NamedDecl *ND)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
uintptr_t Base
When Kind == EK_Base, the base specifier that provides the base class.
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
static bool canPerformArrayCopy(const InitializedEntity &Entity)
Determine whether we can perform an elementwise array copy for this kind of entity.
bool isExtVectorType() const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic, and whose semantics are that of the sole contained initializer)?
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators.
FailureKind getFailureKind() const
Determine why initialization failed.
Not a narrowing conversion.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
ParenExpr - This represents a parethesized expression, e.g.
NamedDecl * getDecl() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
The base class of the type hierarchy.
static bool tryObjCWritebackConversion(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity, Expr *Initializer)
The entity being initialized is a variable.
const IdentifierInfo * getField() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
Overloading for a user-defined conversion failed.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
Ambiguous candidates found.
SourceLocation getEndLoc() const LLVM_READONLY
QualType withConst() const
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST...
const TargetInfo & getTargetInfo() const
static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path, Expr *Init, ReferenceKind RK, LocalVisitor Visit)
Visit the locals that would be reachable through a reference bound to the glvalue expression Init...
A container of type source information.
QualType getCallResultType() const
Determine the type of an expression that calls this function.
void AddAddressOverloadResolutionStep(FunctionDecl *Function, DeclAccessPair Found, bool HadMultipleCandidates)
Add a new step in the initialization that resolves the address of an overloaded function to a specifi...
Perform a derived-to-base cast, producing an xvalue.
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda...
The entity being initialized is a base member subobject.
List-copy-initialization chose an explicit constructor.
The entity being initialized is the result of a statement expression.
static bool TryInitializerListConstruction(Sema &S, InitListExpr *List, QualType DestType, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
When initializing from init list via constructor, handle initialization of an object of type std::ini...
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
SourceLocation getEndLoc() const
Get the end source location.
QualType getElementType() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
The entity being initialized is a function parameter; function is member of group of audited CF APIs...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Initialize an OpenCL sampler from an integer.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static void TryUserDefinedConversion(Sema &S, QualType DestType, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt a user-defined conversion between two types (C++ [dcl.init]), which enumerates all conversion...
void AddCAssignmentStep(QualType T)
Add a C assignment step.
Initialization by string.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
QualType getReturnType() const
Array initialization by elementwise copy.
DiagnosticsEngine & Diags
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).
static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT, ASTContext &Context)
Check whether the array of type AT can be initialized by the Init expression by means of string initi...
SourceLocation getEqualLoc() const
Retrieve the location of the equal sign for copy initialization (if present).
static void warnBracedScalarInit(Sema &S, const InitializedEntity &Entity, SourceRange Braces)
Warn that Entity was of scalar type and was initialized by a single-element braced initializer list...
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
Represents a C++17 deduced template specialization type.
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
void setInit(unsigned Init, Expr *expr)
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
DeclClass * getCorrectionDeclAs() const
Non-const lvalue reference binding to an lvalue of unrelated type.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
bool isInvalidDecl() const
void setBegin(SourceLocation b)
Perform a derived-to-base cast, producing an rvalue.
void AddReferenceBindingStep(QualType T, bool BindingTemporary)
Add a new step binding a reference to an object.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
EntityKind getKind() const
Determine the kind of initialization.
Initializing char array with UTF-8 string literal.
void setElementIndex(unsigned Index)
If this is already the initializer for an array or vector element, sets the element index...
Represents a parameter to a function.
The entity being initialized is a temporary object.
Expr * getArrayRangeStart() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr *> Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, bool IsReturnStmt)
Provide warnings when std::move is used on construction.
Non-const lvalue reference binding to a vector element.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
bool isImplicitMemberInitializer() const
Is this the implicit initialization of a member of a class from a defaulted constructor?
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
SourceLocation getDotLoc() const
Represents a struct/union/class.
Represents a C99 designated initializer expression.
Construct a std::initializer_list from an initializer list.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Trying to take the address of a function that doesn't support having its address taken.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
static void CheckForNullPointerDereference(Sema &S, const Expr *E)
SourceLocation getBegin() const
static bool isExprAnUnaddressableFunction(Sema &S, const Expr *E)
Tries to get a FunctionDecl out of E.
bool isArrayRangeDesignator() const
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic)
Add steps to unwrap a initializer list for a reference around a single element and rewrap it at the e...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Expr * getInit() const
Retrieve the initializer value.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
The results of name lookup within a DeclContext.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion...
ImplicitConversionSequence * ICS
When Kind = SK_ConversionSequence, the implicit conversion sequence.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
static void TryConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType DestType, QualType DestArrayType, InitializationSequence &Sequence, bool IsListInit=false, bool IsInitListCopy=false)
Attempt initialization by constructor (C++ [dcl.init]), which enumerates the constructors of the init...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isSpelledAsLValue() const
field_range fields() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a member of a struct/union/class.
Represents a place-holder for an object not to be initialized by anything.
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr *> IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
bool isArrayDesignator() const
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
static bool isLibstdcxxPointerReturnFalseHack(Sema &S, const InitializedEntity &Entity, const Expr *Init)
An egregious hack for compatibility with libstdc++-4.2: in <tr1/hashtable>, a function with a pointer...
SourceLocation getRBraceLoc() const
Rewrap the single-element initializer list for a reference.
bool isReferenceType() const
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
specific_decl_iterator< FieldDecl > field_iterator
~InitializationSequence()
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD)
Perform initialization via a constructor taking a single std::initializer_list argument.
Describes an C or C++ initializer list.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
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)
SourceRange getParenOrBraceRange() const
Retrieve the source range containing the locations of the open and closing parentheses or braces for ...
Represents the results of name lookup.
SourceLocation getEndLoc() const LLVM_READONLY
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
static void ExpandAnonymousFieldDesignator(Sema &SemaRef, DesignatedInitExpr *DIE, unsigned DesigIdx, IndirectFieldDecl *IndirectField)
Expand a field designator that refers to a member of an anonymous struct or union into a series of fi...
StepKind Kind
The kind of conversion or initialization step we are taking.
bool isImplicitValueInit() const
Determine whether this initialization is an implicit value-initialization, e.g., as occurs during agg...
Succeeded, but refers to a deleted function.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, bool &DerivedToBase, bool &ObjCConversion, bool &ObjCLifetimeConversion)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
APValue Val
Val - This is the value the expression can be folded to.
static bool pathContainsInit(IndirectLocalPath &Path)
static bool TryOCLZeroOpaqueTypeInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
Ref_Compatible - The two types are reference-compatible.
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation Loc, bool GNUSyntax, ExprResult Init)
static void visitLocalsRetainedByInitializer(IndirectLocalPath &Path, Expr *Init, LocalVisitor Visit, bool RevisitSubinits)
Visit the locals that would be reachable through an object initialized by the prvalue expression Init...
bool hasAddressSpace() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
QualType getToType(unsigned Idx) const
InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList=false, bool TreatUnavailableAsInvalid=true)
Try to perform initialization of the given entity, creating a record of the steps required to perform...
std::string getAsString(ASTContext &Ctx, QualType Ty) const
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
LangAS getAddressSpace() const
Variable-length array must not have an initializer.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
static void visitLifetimeBoundArguments(IndirectLocalPath &Path, Expr *Call, LocalVisitor Visit)
Initialization of an incomplete type.
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes...
The entity being initialized is a non-static data member subobject.
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
bool isRValueReferenceType() const
CheckedConversionKind
The kind of conversion being performed.
A narrowing conversion, because a constant expression got narrowed.
Unwrap the single-element initializer list for a reference.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
void AddParenthesizedArrayInitStep(QualType T)
Add a parenthesized array initialization step.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
SmallVectorImpl< Step >::const_iterator step_iterator
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
field_iterator field_begin() const
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
The entity being initialized is an element of a vector.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents binding an expression to a temporary.
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
const LangOptions & getLangOpts() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
bool isScalarType() const
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
Perform initialization via a constructor.
Perform a user-defined conversion, either via a conversion function or via a constructor.
Implicit conversion failed.
Member name lookup, which finds the names of class/struct/union members.
is ARM Neon polynomial vector
The entity being initialized is a function parameter.
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, InitListExpr *InitList)
bool hasParenOrBraceRange() const
Determine whether this initialization has a source range containing the locations of open and closing...
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
Perform an implicit conversion sequence.
ConditionalOperator - The ?: ternary operator.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Sema - This implements semantic analysis and AST building for C.
void setField(FieldDecl *FD)
Overloading for list-initialization by constructor failed.
Perform list-initialization without a constructor.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Reference binding drops qualifiers.
unsigned getNumDesignators() const
void AddObjCObjectConversionStep(QualType T)
Add an Objective-C object conversion step, which is always a no-op.
Non-const lvalue reference binding to a bit-field.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Cannot resolve the address of an overloaded function.
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify().
void AddStdInitializerListConstructionStep(QualType T)
Add a step to construct a std::initializer_list object from an initializer list.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool isEnabled(llvm::StringRef Ext) const
InitListExpr * getUpdater() const
A narrowing conversion by virtue of the source and destination types.
bool isFunctionalCast() const
Determine whether this is a functional-style cast.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
unsigned allocateManglingNumber() const
The entity being initialized is a field of block descriptor for the copied-in c++ object...
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
Initializing wide char array with incompatible wide string literal.
SourceLocation getBeginLoc() const
Get the begin source location.
The entity being initialized is the real or imaginary part of a complex number.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
QualType getElementType() const
Type source information for an attributed type.
Implicit conversion failed.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
llvm::MutableArrayRef< Designator > designators()
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
void setRBraceLoc(SourceLocation Loc)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Initializing char8_t array with plain string literal.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
void dump() const
Dump a representation of the initialized entity to standard error, for debugging purposes.
Scalar initialized from a parenthesized initializer list.
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
static void updateStringLiteralType(Expr *E, QualType Ty)
Update the type of a string literal, including any surrounding parentheses, to match the type of the ...
The entity being initialized is an object (or array of objects) allocated via new.
Perform a qualification conversion, producing an xvalue.
void setSyntacticForm(InitListExpr *Init)
const T * castAs() const
Member-template castAs<specific type>.
bool isObjCRetainableType() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
Initializing a wide char array with narrow string literal.
bool isFieldDesignator() const
unsigned getNumInits() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void ClearExprs(Sema &Actions)
ClearExprs - Null out any expression references, which prevents them from being 'delete'd later...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
void AddProduceObjCObjectStep(QualType T)
Add a step to "produce" an Objective-C object (by retaining it).
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
field_iterator field_end() const
Resolve the address of an overloaded function to a specific function declaration. ...
DeclContext * getDeclContext()
Overload resolution succeeded.
bool isAnyComplexType() const
The entity being initialized is an exception object that is being thrown.
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
unsigned size() const
Returns the number of designators in this initializer.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
struct F Function
When Kind == SK_ResolvedOverloadedFunction or Kind == SK_UserConversion, the function that the expres...
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
Represents a C++ template name within the type system.
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
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++ [conv.fpint])
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
QualType getEncodedType() const
bool isExplicitCast() const
Determine whether this initialization is an explicit cast.
Expr * getArrayRangeEnd() const
static void TryDefaultInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence)
Attempt default initialization (C++ [dcl.init]p6).
QualType getRecordType(const RecordDecl *Decl) const
Initializer has a placeholder type which cannot be resolved by initialization.
SourceLocation getLBracketLoc() const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
static void TryReferenceInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence)
Attempt reference initialization (C++0x [dcl.init.ref])
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
An lvalue reference type, per C++11 [dcl.ref].
SourceLocation getBeginLoc() const LLVM_READONLY
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
SourceLocation getLocation() const
Retrieve the location at which initialization is occurring.
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
bool AllowExplicit() const
Retrieve whether this initialization allows the use of explicit constructors.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
Represents a C++ conversion function within a class.
void AddStringInitStep(QualType T)
Add a string init step.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call...
The result type of a method or function.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Pass an object by indirect restore.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Expr * getArrayIndex() const
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
InitKind getKind() const
Determine the initialization kind.
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
static void TryReferenceListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Attempt list initialization of a reference.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
SourceLocation getEndLoc() const LLVM_READONLY
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
FailureKind
Describes why initialization failed.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
Too many initializers for scalar.
Lvalue-to-rvalue conversion (C++ [conv.lval])
bool isConstQualified() const
Determine whether this type is const-qualified.
List initialization failed at some point.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
RecordDecl * getDecl() const
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr *> Args)
Diagnose an potentially-invalid initialization sequence.
bool isAtStartOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the beginning of the immediate macro expansion...
Initialize an opaque OpenCL type (event_t, queue_t, etc.) with zero.
QualType getWideCharType() const
Return the type of wide characters.
Perform a conversion adding _Atomic to a type.
void AddListInitializationStep(QualType T)
Add a list-initialization step.
chain_iterator chain_end() const
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool allowExplicitConversionFunctionsInRefBinding() const
Retrieve whether this initialization allows the use of explicit conversion functions when binding a r...
CXXConstructorDecl * Constructor
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Perform a qualification conversion, producing an lvalue.
Integral conversions (C++ [conv.integral])
SmallVectorImpl< OverloadCandidate >::iterator iterator
void AddLValueToRValueStep(QualType Ty)
Add a new step that performs a load of the given type.
Reference binding to an lvalue.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
bool isParameterKind() const
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
const Designator & getDesignator(unsigned Idx) const
QualType getCanonicalType() const
ArrayRef< NamedDecl * >::const_iterator chain_iterator
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
bool allowsNRVO() const
Determine whether this initialization allows the named return value optimization, which also applies ...
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
SequenceKind
Describes the kind of initialization sequence computed.
Array indexing for initialization by elementwise copy.
ASTContext & getASTContext() const
void AddOCLZeroOpaqueTypeStep(QualType T)
Add a step to initialzie an OpenCL opaque type (event_t, queue_t, etc.) from a zero constant...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor...
SourceLocation getFieldLoc() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Reference initialization from an initializer list.
LangAS getAddressSpace() const
Return the address space of this type.
static bool shouldLifetimeExtendThroughPath(const IndirectLocalPath &Path)
Determine whether this is an indirect path to a temporary that we are supposed to lifetime-extend alo...
static bool shouldBindAsTemporary(const InitializedEntity &Entity)
Whether we should bind a created object as a temporary when initializing the given entity...
Expr * getSubExpr() const
static LifetimeResult getEntityLifetime(const InitializedEntity *Entity, const InitializedEntity *InitField=nullptr)
Determine the declaration which an initialized entity ultimately refers to, for the purpose of lifeti...
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
Expr * getSubExpr(unsigned Idx) const
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
bool isCStyleOrFunctionalCast() const
Determine whether this initialization is a C-style cast.
MutableArrayRef< Expr * > MultiExprArg
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
QualType getElementType() const
void setReferenced(bool R=true)
llvm::iterator_range< base_class_iterator > base_class_range
static bool isVarOnPath(IndirectLocalPath &Path, VarDecl *VD)
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
static InvalidICRKind isInvalidICRSource(ASTContext &C, Expr *e, bool isAddressOf, bool &isWeakAccess)
Determines whether this expression is an acceptable ICR source.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
Initialization of some unused destination type with an initializer list.
The entity being initialized is the result of a function call.
void InitializeFrom(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList, bool TreatUnavailableAsInvalid)
Objective-C ARC writeback conversion.
The entity being implicitly initialized back to the formal result type.
const ParmVarDecl * getParamDecl(unsigned i) const
Zero-initialize the object.
The entity being initialized is the initializer for a compound literal.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
void AddExtraneousCopyToTemporary(QualType T)
Add a new step that makes an extraneous copy of the input to a temporary of the same class type...
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
Expr * updateInit(const ASTContext &C, unsigned Init, Expr *expr)
Updates the initializer at index Init with the new expression expr, and returns the old expression at...
SourceLocation getLBracketLoc() const
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool forallBases(ForallBasesCallback BaseMatches, bool AllowShortCircuit=true) const
Determines if the given callback holds for all the direct or indirect base classes of this type...
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
static bool hasCopyOrMoveCtorParam(ASTContext &Ctx, const ConstructorInfo &Info)
Determine if the constructor has the signature of a copy or move constructor for the type T of the cl...
The entity being initialized is an element of an array.
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Reference initialized from a parenthesized initializer list.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ExprResult PerformConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, const InitializationSequence::Step &Step, bool &ConstructorInitRequiresZeroInit, bool IsListInitialization, bool IsStdInitListInitialization, SourceLocation LBraceLoc, SourceLocation RBraceLoc)
static bool DiagnoseUninitializedReference(Sema &S, SourceLocation Loc, QualType T)
Somewhere within T there is an uninitialized reference subobject.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
Expr ** getInits()
Retrieve the set of initializers.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
Overloading for initialization by constructor failed.
static bool ResolveOverloadedFunctionForReferenceBinding(Sema &S, Expr *Initializer, QualType &SourceType, QualType &UnqualifiedSourceType, QualType UnqualifiedTargetType, InitializationSequence &Sequence)
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
Requests that all candidates be shown.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
static SourceRange nextPathEntryRange(const IndirectLocalPath &Path, unsigned I, Expr *E)
Find the range for the first interesting entry in the path at or after I.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=None)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Expr * getArrayRangeStart(const Designator &D) const
void AddAtomicConversionStep(QualType Ty)
Add a new step that performs conversion from non-atomic to atomic type.
bool HadMultipleCandidates
void AddArrayInitStep(QualType T, bool IsGNUExtension)
Add an array initialization step.
bool isVectorType() const
void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy)
Add a step to pass an object by indirect copy-restore.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
bool hasFlexibleArrayMember() const
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, Sema &S)
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
Pass an object by indirect copy-and-restore.
A POD class for pairing a NamedDecl* with an access specifier.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
Represents a C11 generic selection.
Rvalue reference binding to an lvalue.
void SetFailed(FailureKind Failure)
Note that this initialization sequence failed.
decl_iterator - Iterates through the declarations stored within this context.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
SourceLocation getEndLoc() const LLVM_READONLY
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Array must be initialized with an initializer list or a string literal.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
static bool isInvalid(LocType Loc, bool *Invalid)
QualType getType() const
Retrieve type being initialized.
Dataflow Directional Tag Classes.
static bool NarrowingErrs(const LangOptions &L)
bool isExplicit() const
Whether this function is explicit.
void setExtendingDecl(const ValueDecl *ExtendedBy, unsigned ManglingNumber)
bool isValid() const
Return true if this is a valid SourceLocation object.
Non-constant array initializer.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
void setIncompleteTypeFailure(QualType IncompleteType)
Note that this initialization sequence failed due to an incomplete type.
SourceLocation getBeginLoc() const LLVM_READONLY
A single step in the initialization sequence.
EvalResult is a struct with detailed info about an evaluated expression.
Array must be initialized with an initializer list or a wide string literal.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Too many initializers provided for a reference.
static bool hasCompatibleArrayTypes(ASTContext &Context, const ArrayType *Dest, const ArrayType *Source)
Determine whether we have compatible array types for the purposes of GNU by-copy array initialization...
static bool isNonReferenceableGLValue(Expr *E)
Determine whether an expression is a non-referenceable glvalue (one to which a reference can never bi...
Perform a load from a glvalue, producing an rvalue.
static void checkIndirectCopyRestoreSource(Sema &S, Expr *src)
Check whether the given expression is a valid operand for an indirect copy/restore.
Represents a field injected from an anonymous union/struct into the parent scope. ...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const Expr * getInit() const
Array-to-pointer conversion (C++ [conv.array])
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
SourceLocation getLBraceLoc() const
The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
static bool IsWideCharCompatible(QualType T, ASTContext &Context)
Check whether T is compatible with a wide character type (wchar_t, char16_t or char32_t).
Requests that only viable candidates be shown.
Array initialization (from an array rvalue) as a GNU extension.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
static ExprResult CopyObject(Sema &S, QualType T, const InitializedEntity &Entity, ExprResult CurInit, bool IsExtraneousCopy)
Make a (potentially elidable) temporary copy of the object provided by the given initializer by calli...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Overloading due to reference initialization failed.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
static bool isIdiomaticBraceElisionEntity(const InitializedEntity &Entity)
Determine whether Entity is an entity for which it is idiomatic to elide the braces in aggregate init...
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
Expr * getArrayRangeEnd(const Designator &D) const
static bool isRValueRef(QualType ParamType)
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
bool isStringLiteralInit() const
SourceLocation getFieldLoc() const
unsigned getIntWidth(QualType T) const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
bool isIncompleteArrayType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setAllToTypes(QualType T)
Complex values, per C99 6.2.5p11.
Array must be initialized with an initializer list.
static bool shouldDestroyEntity(const InitializedEntity &Entity)
Whether the given entity, when initialized with an object created for that initialization, requires destruction.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
The entity being initialized is a structured binding of a decomposition declaration.
static void emitBadConversionNotes(Sema &S, const InitializedEntity &entity, Expr *op)
Emit notes associated with an initialization that failed due to a "simple" conversion failure...
chain_iterator chain_begin() const
ObjCEncodeExpr, used for @encode in Objective-C.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
const llvm::APInt & getSize() const
Reference binding failed.
bool isAtomicType() const
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
bool isFunctionType() const
TypeSourceInfo * getTypeSourceInfo() const
FieldDecl * getField() const
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void AddArrayInitLoopStep(QualType T, QualType EltTy)
Add an array initialization loop step.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
step_iterator step_end() const
void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category)
Add a new step in the initialization that performs a derived-to- base cast.
bool isConstantArrayType() const
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
void setExprNeedsCleanups(bool SideEffects)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
static bool TryOCLSamplerInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
static SourceLocation getInitializationLoc(const InitializedEntity &Entity, Expr *Initializer)
Get the location at which initialization diagnostics should appear.
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isLValueReferenceType() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Reading or writing from this object requires a barrier call.
void AddUserConversionStep(FunctionDecl *Function, DeclAccessPair FoundDecl, QualType T, bool HadMultipleCandidates)
Add a new step invoking a conversion function, which is either a constructor or a conversion function...
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_RValue, CheckedConversionKind CCK=CCK_ImplicitConversion)
Direct-initialization from a reference-related object in the final stage of class copy-initialization...
DesignatorKind getKind() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
static void TryListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Attempt list initialization (C++0x [dcl.init.list])
bool Failed() const
Determine whether the initialization sequence is invalid.
static void TryStringLiteralInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence)
Attempt character array initialization from a string literal (C++ [dcl.init.string], C99 6.7.8).
Describes the sequence of initializations required to initialize a given object or reference with a s...
ActionResult< Expr * > ExprResult
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
Perform initialization via a constructor, taking arguments from a single InitListExpr.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr *> &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
Represents a loop initializing the elements of an array.
SourceRange getRange() const
Retrieve the source range that covers the initialization.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
Represents a C array with an unspecified size.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
The entity being initialized is a field of block descriptor for the copied-in lambda object that's us...
The parameter type of a method or function.
The entity being initialized is the field that captures a variable in a lambda.
void setSequenceKind(enum SequenceKind SK)
Set the kind of sequence computed.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
static void TryValueInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence, InitListExpr *InitList=nullptr)
Attempt value initialization (C++ [dcl.init]p7).
A dependent initialization, which could not be type-checked due to the presence of dependent types or...
Declaration of a class template.
bool isCStyleCast() const
Determine whether this is a C-style cast.
SourceLocation getRBracketLoc() const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
This class is used for builtin types like 'int'.
SourceManager & getSourceManager() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static bool isOrIsDerivedFromSpecializationOf(CXXRecordDecl *RD, ClassTemplateDecl *CTD)
Determine whether RD is, or is derived from, a specialization of CTD.
Designator * getDesignator(unsigned Idx)
unsigned getCVRQualifiers() const
Reference binding to a temporary.
bool isOCLIntelSubgroupAVCType() const
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
static Decl::Kind getKind(const Decl *D)
void AddConstructorInitializationStep(DeclAccessPair FoundDecl, CXXConstructorDecl *Constructor, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
Add a constructor-initialization step.
unsigned getNumElements() const
Designation - Represent a full designation, which is a sequence of designators.
static Sema::AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Designator - A designator in a C99 designated initializer.
bool isDeleted() const
Whether this function has been deleted.
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
bool isPointerType() const
The initialization is being done by a delegating constructor.
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
void AddQualificationConversionStep(QualType Ty, ExprValueKind Category)
Add a new step that performs a qualification conversion to the given type.
void AddFinalCopy(QualType T)
Add a new step that makes a copy of the input to an object of the given type, as the final step in cl...
__DEVICE__ int min(int __a, int __b)
SourceManager & SourceMgr
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
void addAddressSpace(LangAS space)
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
No viable function found.
A failed initialization sequence.
Array initialization (from an array rvalue).
static bool IsZeroInitializer(Expr *Initializer, Sema &S)
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
An l-value expression is a reference to an object with independent storage.
Default-initialization of a 'const' object.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
bool isFloatingType() const
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
Add a new step that applies an implicit conversion sequence.
A trivial tuple used to represent a source range.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
SourceLocation getBeginLoc() const LLVM_READONLY
This represents a decl that may have a name.
bool isOpenCLSpecificType() const
SourceLocation getDotLoc() const
Represents a C array with a specified size that is not an integer-constant-expression.
Automatic storage duration (most local variables).
static void DiagnoseNarrowingInInitList(Sema &S, const ImplicitConversionSequence &ICS, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit)
Describes an entity that is being initialized.
bool isDefaultMemberInitializer() const
Is this the default member initializer of a member (specified inside the class definition)?
void setToType(unsigned Idx, QualType T)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
ObjCMethodDecl * getMethodDecl() const
Retrieve the ObjectiveC method being initialized.
void removeAddressSpace()
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
bool hasDefaultConstructor() const
Determine whether this class has any default constructors.
bool isVariableLengthArrayNew() const
Determine whether this is an array new with an unknown bound.
static void CheckCXX98CompatAccessibleCopy(Sema &S, const InitializedEntity &Entity, Expr *CurInitExpr)
Check whether elidable copy construction for binding a reference to a temporary would have succeeded ...
Direct list-initialization.
bool isDependent() const
Determines whether this is a dependent template name.
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr *> Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
Array initialization from a parenthesized initializer list.
IdentifierInfo * getFieldName() const
Represents the canonical version of C arrays with a specified constant size.
InitListExpr * getSyntacticForm() const
static void MaybeProduceObjCObject(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Declaration of a template function.
Represents an implicitly-generated value initialization of an object of a given type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
SourceLocation getLocation() const
QualType getType() const
Return the type wrapped by this type source info.
static bool maybeRecoverWithZeroInitialization(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Tries to add a zero initializer. Returns true if that worked.
Non-const lvalue reference binding to a temporary.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
SourceRange getSourceRange() const LLVM_READONLY
static bool isExplicitTemporary(const InitializedEntity &Entity, const InitializationKind &Kind, unsigned NumArgs)
Returns true if the parameters describe a constructor initialization of an explicit temporary object...
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
QualType getType() const
Retrieves the type of the base class.