24 #include "llvm/ADT/APInt.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/Support/ErrorHandling.h"
27 #include "llvm/Support/raw_ostream.h"
29 using namespace clang;
61 if (!isa<ConstantArrayType>(AT) && !isa<IncompleteArrayType>(AT))
120 llvm_unreachable(
"missed a StringLiteral kind?");
136 if (isa<StringLiteral>(E) || isa<ObjCEncodeExpr>(E))
138 else if (
ParenExpr *PE = dyn_cast<ParenExpr>(E))
139 E = PE->getSubExpr();
141 E = UO->getSubExpr();
143 E = GSE->getResultExpr();
145 llvm_unreachable(
"unexpected expr in string literal init");
152 auto *ConstantArrayTy =
154 uint64_t StrLength = ConstantArrayTy->getSize().getZExtValue();
159 llvm::APInt ConstVal(32, StrLength);
184 if (StrLength > CAT->
getSize().getZExtValue())
185 S.
Diag(Str->getLocStart(),
186 diag::err_initializer_string_for_char_array_too_long)
187 << Str->getSourceRange();
190 if (StrLength-1 > CAT->
getSize().getZExtValue())
191 S.
Diag(Str->getLocStart(),
192 diag::ext_initializer_string_for_char_array_too_long)
193 << Str->getSourceRange();
235 class InitListChecker {
239 llvm::DenseMap<InitListExpr *, InitListExpr *> SyntacticToSemantic;
245 unsigned &StructuredIndex);
249 bool TopLevelObject =
false);
252 bool SubobjectIsDesignatorContext,
255 unsigned &StructuredIndex,
256 bool TopLevelObject =
false);
261 unsigned &StructuredIndex);
266 unsigned &StructuredIndex);
271 unsigned &StructuredIndex);
276 unsigned &StructuredIndex);
280 unsigned &StructuredIndex);
284 bool SubobjectIsDesignatorContext,
unsigned &Index,
286 unsigned &StructuredIndex,
287 bool TopLevelObject =
false);
290 llvm::APSInt elementIndex,
291 bool SubobjectIsDesignatorContext,
unsigned &Index,
293 unsigned &StructuredIndex);
299 llvm::APSInt *NextElementIndex,
302 unsigned &StructuredIndex,
303 bool FinishSubobjectInit,
304 bool TopLevelObject);
308 unsigned StructuredIndex,
310 bool IsFullyOverwritten =
false);
311 void UpdateStructuredListElement(
InitListExpr *StructuredList,
312 unsigned &StructuredIndex,
314 int numArrayElements(
QualType DeclType);
315 int numStructUnionElements(
QualType DeclType);
341 void FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
344 bool FillWithNoInit =
false);
347 bool FillWithNoInit =
false);
350 bool TopLevelObject);
357 bool HadError() {
return hadError; }
361 InitListExpr *getFullyStructuredList()
const {
return FullyStructuredList; }
379 bool EmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
392 InitExpr = VerifyOnly ? &DummyInitList :
new (SemaRef.
Context)
408 if (!InitSeq && EmptyInitList && InitSeq.getFailureKind() ==
412 InitSeq.getFailedCandidateSet()
413 .BestViableFunction(SemaRef, Kind.
getLocation(), Best);
415 assert(O ==
OR_Success &&
"Inconsistent overload resolution");
424 bool IsInStd =
false;
425 for (
NamespaceDecl *ND = dyn_cast<NamespaceDecl>(R->getDeclContext());
426 ND && !IsInStd; ND = dyn_cast<
NamespaceDecl>(ND->getParent())) {
431 if (IsInStd && llvm::StringSwitch<bool>(R->getName())
432 .Cases(
"basic_string",
"deque",
"forward_list",
true)
433 .Cases(
"list",
"map",
"multimap",
"multiset",
true)
434 .Cases(
"priority_queue",
"queue",
"set",
"stack",
true)
435 .Cases(
"unordered_map",
"unordered_set",
"vector",
true)
437 InitSeq.InitializeFrom(
445 diag::warn_invalid_initializer_from_system_header);
447 diag::note_used_in_initialization_here);
454 InitSeq.Diagnose(SemaRef, Entity, Kind, SubInit);
457 diag::note_in_omitted_aggregate_initializer)
460 SemaRef.
Diag(Loc, diag::note_in_omitted_aggregate_initializer)
466 return VerifyOnly ?
ExprResult(static_cast<Expr *>(
nullptr))
467 : InitSeq.Perform(SemaRef, Entity, Kind, SubInit);
473 "CheckEmptyInitializable is only inteded for verification mode.");
474 if (PerformEmptyInit(SemaRef, Loc, Entity,
true).
isInvalid())
478 void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
481 bool &RequiresSecondPass,
482 bool FillWithNoInit) {
489 if (!RType->getDecl()->isUnion())
490 assert(Init < NumInits &&
"This ILE should have been expanded");
492 if (Init >= NumInits || !ILE->
getInit(Init)) {
493 if (FillWithNoInit) {
515 RequiresSecondPass =
true;
525 SemaRef.
Diag(Loc, diag::err_init_reference_member_uninitialized)
529 diag::note_uninit_reference_member);
534 ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
543 }
else if (Init < NumInits) {
545 }
else if (!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
551 RequiresSecondPass =
true;
554 = dyn_cast<InitListExpr>(ILE->
getInit(Init)))
555 FillInEmptyInitializations(MemberEntity, InnerILE,
556 RequiresSecondPass, FillWithNoInit);
558 = dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init)))
559 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
560 RequiresSecondPass,
true);
569 bool &RequiresSecondPass,
570 bool FillWithNoInit) {
572 "Should not have void type");
578 Entity, ILE, RequiresSecondPass, FillWithNoInit);
579 else if (RDecl->
isUnion() && isa<CXXRecordDecl>(RDecl) &&
580 cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) {
581 for (
auto *Field : RDecl->
fields()) {
583 FillInEmptyInitForField(0, Field, Entity, ILE, RequiresSecondPass,
592 unsigned NumFields = 0;
593 for (
auto *Field : RDecl->
fields())
596 if (ILE->getNumInits() < NumFields)
597 ILE->resizeInits(SemaRef.
Context, NumFields);
600 for (
auto *Field : RDecl->
fields()) {
607 FillInEmptyInitForField(Init, Field, Entity, ILE, RequiresSecondPass,
626 unsigned NumInits = ILE->getNumInits();
627 unsigned NumElements = NumInits;
629 ElementType = AType->getElementType();
631 NumElements = CAType->getSize().getZExtValue();
635 ElementType = VType->getElementType();
636 NumElements = VType->getNumElements();
640 ElementType = ILE->getType();
642 for (
unsigned Init = 0; Init != NumElements; ++Init) {
650 Expr *InitExpr = (Init < NumInits ? ILE->getInit(Init) :
nullptr);
651 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
652 ILE->setInit(Init, ILE->getArrayFiller());
653 else if (!InitExpr && !ILE->hasArrayFiller()) {
654 Expr *Filler =
nullptr;
659 ExprResult ElementInit = PerformEmptyInit(SemaRef, ILE->getLocEnd(),
672 }
else if (Init < NumInits) {
676 ILE->setArrayFiller(Filler);
678 ILE->setInit(Init, Filler);
683 ILE->setArrayFiller(Filler);
687 if (!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
692 ILE->updateInit(SemaRef.
Context, Init, Filler);
693 RequiresSecondPass =
true;
697 = dyn_cast_or_null<InitListExpr>(InitExpr))
698 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
701 = dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr))
702 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
703 RequiresSecondPass,
true);
711 : SemaRef(S), VerifyOnly(VerifyOnly) {
717 FullyStructuredList =
718 getStructuredSubobjectInit(IL, 0, T,
nullptr, 0, IL->getSourceRange());
719 CheckExplicitInitList(Entity, IL, T, FullyStructuredList,
722 if (!hadError && !VerifyOnly) {
723 bool RequiresSecondPass =
false;
724 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass);
725 if (RequiresSecondPass && !hadError)
726 FillInEmptyInitializations(Entity, FullyStructuredList,
731 int InitListChecker::numArrayElements(
QualType DeclType) {
733 int maxElements = 0x7FFFFFFF;
736 maxElements =
static_cast<int>(CAT->getSize().getZExtValue());
741 int InitListChecker::numStructUnionElements(
QualType DeclType) {
743 int InitializableMembers = 0;
744 for (
const auto *Field : structDecl->
fields())
746 ++InitializableMembers;
749 return std::min(InitializableMembers, 1);
763 unsigned &StructuredIndex) {
767 maxElements = numArrayElements(T);
769 maxElements = numStructUnionElements(T);
773 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
775 if (maxElements == 0) {
777 SemaRef.
Diag(ParentIList->
getInit(Index)->getLocStart(),
778 diag::err_implicit_empty_initializer);
786 = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList,
789 ParentIList->getSourceRange().getEnd()));
790 unsigned StructuredSubobjectInitIndex = 0;
793 unsigned StartIndex = Index;
794 CheckListElementTypes(Entity, ParentIList, T,
796 StructuredSubobjectInitList,
797 StructuredSubobjectInitIndex);
800 StructuredSubobjectInitList->
setType(T);
802 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
805 if (EndIndex < ParentIList->getNumInits()) {
807 = ParentIList->
getInit(EndIndex)->getSourceRange().getEnd();
814 diag::warn_missing_braces)
815 << StructuredSubobjectInitList->getSourceRange()
816 << FixItHint::CreateInsertion(
818 << FixItHint::CreateInsertion(
820 StructuredSubobjectInitList->
getLocEnd()),
839 case InitializedEntity::EK_VectorElement:
840 case InitializedEntity::EK_ComplexElement:
841 case InitializedEntity::EK_ArrayElement:
842 case InitializedEntity::EK_Parameter:
843 case InitializedEntity::EK_Parameter_CF_Audited:
844 case InitializedEntity::EK_Result:
846 DiagID = diag::warn_braces_around_scalar_init;
849 case InitializedEntity::EK_Member:
853 DiagID = diag::warn_braces_around_scalar_init;
856 case InitializedEntity::EK_Variable:
857 case InitializedEntity::EK_LambdaCapture:
862 case InitializedEntity::EK_New:
863 case InitializedEntity::EK_Temporary:
864 case InitializedEntity::EK_CompoundLiteralInit:
868 case InitializedEntity::EK_RelatedResult:
872 case InitializedEntity::EK_Exception:
873 case InitializedEntity::EK_Base:
874 case InitializedEntity::EK_Delegating:
875 case InitializedEntity::EK_BlockElement:
876 llvm_unreachable(
"unexpected braced scalar init");
882 << FixItHint::CreateRemoval(Braces.
getBegin())
883 << FixItHint::CreateRemoval(Braces.
getEnd());
896 bool TopLevelObject) {
898 SyntacticToSemantic[IList] = StructuredList;
902 unsigned Index = 0, StructuredIndex = 0;
903 CheckListElementTypes(Entity, IList, T,
true,
904 Index, StructuredList, StructuredIndex, TopLevelObject);
910 StructuredList->
setType(ExprTy);
915 if (Index < IList->getNumInits()) {
926 if (StructuredIndex == 1 &&
929 unsigned DK = diag::ext_excess_initializers_in_char_array_initializer;
931 DK = diag::err_excess_initializers_in_char_array_initializer;
935 SemaRef.
Diag(IList->
getInit(Index)->getLocStart(), DK)
936 << IList->
getInit(Index)->getSourceRange();
948 unsigned DK = diag::ext_excess_initializers;
950 DK = diag::err_excess_initializers;
953 if (SemaRef.
getLangOpts().OpenCL && initKind == 1) {
954 DK = diag::err_excess_initializers;
958 SemaRef.
Diag(IList->
getInit(Index)->getLocStart(), DK)
959 << initKind << IList->
getInit(Index)->getSourceRange();
971 bool SubobjectIsDesignatorContext,
974 unsigned &StructuredIndex,
975 bool TopLevelObject) {
979 CheckComplexType(Entity, IList, DeclType, Index,
980 StructuredList, StructuredIndex);
982 CheckScalarType(Entity, IList, DeclType, Index,
983 StructuredList, StructuredIndex);
985 CheckVectorType(Entity, IList, DeclType, Index,
986 StructuredList, StructuredIndex);
989 "non-aggregate records should be handed in CheckSubElementType");
991 CheckStructUnionTypes(Entity, IList, DeclType, RD->field_begin(),
992 SubobjectIsDesignatorContext, Index,
993 StructuredList, StructuredIndex,
999 CheckArrayType(Entity, IList, DeclType, Zero,
1000 SubobjectIsDesignatorContext, Index,
1001 StructuredList, StructuredIndex);
1006 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1010 CheckReferenceType(Entity, IList, DeclType, Index,
1011 StructuredList, StructuredIndex);
1019 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1030 unsigned &StructuredIndex) {
1034 return CheckReferenceType(Entity, IList, ElemType, Index,
1035 StructuredList, StructuredIndex);
1037 if (
InitListExpr *SubInitList = dyn_cast<InitListExpr>(expr)) {
1038 if (SubInitList->getNumInits() == 1 &&
1041 expr = SubInitList->getInit(0);
1044 = getStructuredSubobjectInit(IList, Index, ElemType,
1045 StructuredList, StructuredIndex,
1046 SubInitList->getSourceRange(),
true);
1047 CheckExplicitInitList(Entity, SubInitList, ElemType,
1048 InnerStructuredList);
1050 if (!hadError && !VerifyOnly) {
1051 bool RequiresSecondPass =
false;
1052 FillInEmptyInitializations(Entity, InnerStructuredList,
1053 RequiresSecondPass);
1054 if (RequiresSecondPass && !hadError)
1055 FillInEmptyInitializations(Entity, InnerStructuredList,
1056 RequiresSecondPass);
1063 }
else if (isa<ImplicitValueInitExpr>(expr)) {
1067 "found implicit initialization for the wrong type");
1069 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1081 InitializationKind::CreateCopy(expr->getLocStart(),
SourceLocation());
1091 if (Seq || isa<InitListExpr>(expr)) {
1094 Seq.Perform(SemaRef, Entity, Kind, expr);
1098 UpdateStructuredListElement(StructuredList, StructuredIndex,
1109 return CheckScalarType(Entity, IList, ElemType, Index,
1110 StructuredList, StructuredIndex);
1120 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1142 ElemType, ExprRes, !VerifyOnly) != Sema::Incompatible) {
1150 UpdateStructuredListElement(StructuredList, StructuredIndex,
1167 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1187 unsigned &StructuredIndex) {
1188 assert(Index == 0 &&
"Index in explicit init list must be zero");
1198 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1203 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1205 << IList->getSourceRange();
1210 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1212 for (
unsigned i = 0; i < 2; ++i) {
1214 CheckSubElementType(ElementEntity, IList, elementType, Index,
1215 StructuredList, StructuredIndex);
1224 unsigned &StructuredIndex) {
1229 diag::warn_cxx98_compat_empty_scalar_initializer :
1230 diag::err_empty_scalar_initializer)
1231 << IList->getSourceRange();
1239 if (
InitListExpr *SubIList = dyn_cast<InitListExpr>(expr)) {
1243 SemaRef.
Diag(SubIList->getLocStart(),
1244 diag::ext_many_braces_around_scalar_init)
1245 << SubIList->getSourceRange();
1247 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1250 }
else if (isa<DesignatedInitExpr>(expr)) {
1252 SemaRef.
Diag(expr->getLocStart(),
1253 diag::err_designator_for_scalar_init)
1254 << DeclType << expr->getSourceRange();
1272 Expr *ResultExpr =
nullptr;
1279 if (ResultExpr != expr) {
1281 IList->
setInit(Index, ResultExpr);
1287 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1295 unsigned &StructuredIndex) {
1303 diag::err_init_reference_member_uninitialized)
1305 << IList->getSourceRange();
1313 if (isa<InitListExpr>(expr) && !SemaRef.
getLangOpts().CPlusPlus11) {
1316 << DeclType << IList->getSourceRange();
1343 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1351 unsigned &StructuredIndex) {
1354 unsigned numEltsInit = 0;
1360 CheckEmptyInitializable(
1361 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity),
1382 Expr *ResultExpr =
nullptr;
1388 if (ResultExpr != Init) {
1390 IList->
setInit(Index, ResultExpr);
1396 UpdateStructuredListElement(StructuredList, StructuredIndex,
1403 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1405 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1409 CheckEmptyInitializable(ElementEntity, IList->
getLocEnd());
1414 CheckSubElementType(ElementEntity, IList, elementType, Index,
1415 StructuredList, StructuredIndex);
1423 if (isBigEndian && (T->
getVectorKind() == VectorType::NeonVector ||
1436 diag::warn_neon_vector_initializer_non_portable);
1438 const char *typeCode;
1448 llvm_unreachable(
"Invalid element type!");
1452 diag::note_neon_vector_initializer_non_portable_q :
1453 diag::note_neon_vector_initializer_non_portable)
1454 << typeCode << typeSize;
1461 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1464 for (
unsigned i = 0; i < maxElements; ++i) {
1473 CheckSubElementType(ElementEntity, IList, elementType, Index,
1474 StructuredList, StructuredIndex);
1486 CheckSubElementType(ElementEntity, IList, VecType, Index,
1487 StructuredList, StructuredIndex);
1488 numEltsInit += numIElts;
1493 if (numEltsInit != maxElements) {
1496 diag::err_vector_incorrect_num_initializers)
1497 << (numEltsInit < maxElements) << maxElements << numEltsInit;
1504 llvm::APSInt elementIndex,
1505 bool SubobjectIsDesignatorContext,
1508 unsigned &StructuredIndex) {
1512 if (Index < IList->getNumInits()) {
1522 UpdateStructuredListElement(StructuredList, StructuredIndex,
1535 SemaRef.
Diag(VAT->getSizeExpr()->getLocStart(),
1536 diag::err_variable_object_no_init)
1537 << VAT->getSizeExpr()->getSourceRange();
1545 llvm::APSInt maxElements(elementIndex.getBitWidth(),
1546 elementIndex.isUnsigned());
1547 bool maxElementsKnown =
false;
1549 maxElements = CAT->getSize();
1550 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
1551 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1552 maxElementsKnown =
true;
1556 while (Index < IList->getNumInits()) {
1562 if (!SubobjectIsDesignatorContext)
1567 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1568 DeclType,
nullptr, &elementIndex, Index,
1569 StructuredList, StructuredIndex,
true,
1575 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
1576 maxElements = maxElements.extend(elementIndex.getBitWidth());
1577 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
1578 elementIndex = elementIndex.extend(maxElements.getBitWidth());
1579 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1583 if (!maxElementsKnown && elementIndex > maxElements)
1584 maxElements = elementIndex;
1591 if (maxElementsKnown && elementIndex == maxElements)
1595 InitializedEntity::InitializeElement(SemaRef.
Context, StructuredIndex,
1598 CheckSubElementType(ElementEntity, IList, elementType, Index,
1599 StructuredList, StructuredIndex);
1604 if (!maxElementsKnown && elementIndex > maxElements)
1605 maxElements = elementIndex;
1610 llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
1611 if (maxElements == Zero) {
1615 diag::ext_typecheck_zero_array_size);
1619 ArrayType::Normal, 0);
1621 if (!hadError && VerifyOnly) {
1625 if (maxElementsKnown && elementIndex < maxElements)
1626 CheckEmptyInitializable(InitializedEntity::InitializeElement(
1635 bool TopLevelObject) {
1637 unsigned FlexArrayDiag;
1638 if (isa<InitListExpr>(InitExpr) &&
1639 cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
1641 FlexArrayDiag = diag::ext_flexible_array_init;
1645 FlexArrayDiag = diag::err_flexible_array_init;
1646 }
else if (!TopLevelObject) {
1648 FlexArrayDiag = diag::err_flexible_array_init;
1649 }
else if (Entity.
getKind() != InitializedEntity::EK_Variable) {
1651 FlexArrayDiag = diag::err_flexible_array_init;
1652 }
else if (cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
1654 FlexArrayDiag = diag::err_flexible_array_init;
1657 FlexArrayDiag = diag::ext_flexible_array_init;
1661 SemaRef.
Diag(InitExpr->getLocStart(),
1663 << InitExpr->getLocStart();
1668 return FlexArrayDiag != diag::ext_flexible_array_init;
1675 bool SubobjectIsDesignatorContext,
1678 unsigned &StructuredIndex,
1679 bool TopLevelObject) {
1695 if (isa<CXXRecordDecl>(RD) && cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
1699 Field != FieldEnd; ++Field) {
1700 if (Field->hasInClassInitializer()) {
1711 Field != FieldEnd; ++Field) {
1712 if (!Field->isUnnamedBitfield()) {
1714 CheckEmptyInitializable(
1715 InitializedEntity::InitializeMember(*Field, &Entity),
1731 bool InitializedSomething =
false;
1732 bool CheckForMissingFields =
true;
1733 while (Index < IList->getNumInits()) {
1740 if (!SubobjectIsDesignatorContext)
1745 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1746 DeclType, &Field,
nullptr, Index,
1747 StructuredList, StructuredIndex,
1748 true, TopLevelObject))
1751 InitializedSomething =
true;
1755 CheckForMissingFields =
false;
1759 if (Field == FieldEnd) {
1765 if (InitializedSomething && DeclType->
isUnionType())
1769 if (Field->getType()->isIncompleteArrayType())
1772 if (Field->isUnnamedBitfield()) {
1784 IList->
getInit(Index)->getLocStart());
1793 InitializedEntity::InitializeMember(*Field, &Entity);
1794 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1795 StructuredList, StructuredIndex);
1796 InitializedSomething =
true;
1800 StructuredList->setInitializedFieldInUnion(*Field);
1807 if (!VerifyOnly && InitializedSomething && CheckForMissingFields &&
1808 Field != FieldEnd && !Field->getType()->isIncompleteArrayType() &&
1814 if (!it->isUnnamedBitfield() && !it->hasInClassInitializer()) {
1815 SemaRef.
Diag(IList->getSourceRange().getEnd(),
1816 diag::warn_missing_field_initializers) << *it;
1823 if (VerifyOnly && Field != FieldEnd && !DeclType->
isUnionType() &&
1824 !Field->getType()->isIncompleteArrayType()) {
1826 for (; Field != FieldEnd && !hadError; ++Field) {
1827 if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
1828 CheckEmptyInitializable(
1829 InitializedEntity::InitializeMember(*Field, &Entity),
1834 if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
1838 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
1846 InitializedEntity::InitializeMember(*Field, &Entity);
1848 if (isa<InitListExpr>(IList->
getInit(Index)))
1849 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1850 StructuredList, StructuredIndex);
1852 CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index,
1853 StructuredList, StructuredIndex);
1869 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
1877 assert(isa<FieldDecl>(*PI));
1878 Replacements.back().setField(cast<FieldDecl>(*PI));
1885 &Replacements[0] + Replacements.size());
1892 for (
unsigned I = 0; I < NumIndexExprs; ++I)
1895 DIE->
size(), IndexExprs,
1906 explicit FieldInitializerValidatorCCC(
RecordDecl *RD)
1962 llvm::APSInt *NextElementIndex,
1965 unsigned &StructuredIndex,
1966 bool FinishSubobjectInit,
1967 bool TopLevelObject) {
1968 if (DesigIdx == DIE->
size()) {
1970 bool prevHadError = hadError;
1975 unsigned OldIndex = Index;
1978 CheckSubElementType(Entity, IList, CurrentObjectType, Index,
1979 StructuredList, StructuredIndex);
1985 IList->
setInit(OldIndex, DIE);
1987 return hadError && !prevHadError;
1991 bool IsFirstDesignator = (DesigIdx == 0);
1993 assert((IsFirstDesignator || StructuredList) &&
1994 "Need a non-designated initializer list to start from");
1998 if (IsFirstDesignator)
1999 StructuredList = SyntacticToSemantic.lookup(IList);
2001 Expr *ExistingInit = StructuredIndex < StructuredList->
getNumInits() ?
2002 StructuredList->
getInit(StructuredIndex) :
nullptr;
2008 getStructuredSubobjectInit(IList, Index, CurrentObjectType,
2009 StructuredList, StructuredIndex,
2012 else if (
InitListExpr *Result = dyn_cast<InitListExpr>(ExistingInit))
2013 StructuredList = Result;
2016 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2017 StructuredList = E->getUpdater();
2035 if (ExistingInit->getSourceRange().isValid()) {
2048 diag::warn_subobject_initializer_overrides)
2051 SemaRef.
Diag(ExistingInit->getLocStart(),
2052 diag::note_previous_initializer)
2054 << ExistingInit->getSourceRange();
2058 assert(StructuredList &&
"Expected a structured initializer list");
2077 SemaRef.
Diag(Loc, diag::err_field_designator_non_aggr)
2078 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2088 if (
auto *FD = dyn_cast<FieldDecl>(ND)) {
2092 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND)) {
2098 KnownField = cast<FieldDecl>(*IFD->chain_begin());
2109 if (!Lookup.empty()) {
2112 SemaRef.
Diag(Lookup.front()->getLocation(),
2113 diag::note_field_designator_found);
2122 Sema::LookupMemberName,
nullptr,
nullptr,
2123 llvm::make_unique<FieldInitializerValidatorCCC>(RT->
getDecl()),
2124 Sema::CTK_ErrorRecovery, RT->
getDecl())) {
2127 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2128 << FieldName << CurrentObjectType);
2129 KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2134 << FieldName << CurrentObjectType;
2141 unsigned FieldIndex = 0;
2143 if (FI->isUnnamedBitfield())
2145 if (KnownField == FI)
2159 if (CurrentField && CurrentField != *Field) {
2161 &&
"A union should never have more than one initializer!");
2165 diag::warn_initializer_overrides)
2168 SemaRef.
Diag(ExistingInit->getLocStart(),
2169 diag::note_previous_initializer)
2171 << ExistingInit->getSourceRange();
2204 if (Field->getType()->isIncompleteArrayType()) {
2205 bool Invalid =
false;
2206 if ((DesigIdx + 1) != DIE->
size()) {
2213 diag::err_designator_into_flexible_array_member)
2216 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2222 if (!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
2223 !isa<StringLiteral>(DIE->
getInit())) {
2227 diag::err_flexible_array_init_needs_braces)
2228 << DIE->
getInit()->getSourceRange();
2229 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2236 if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
2246 bool prevHadError = hadError;
2247 unsigned newStructuredIndex = FieldIndex;
2248 unsigned OldIndex = Index;
2252 InitializedEntity::InitializeMember(*Field, &Entity);
2253 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2254 StructuredList, newStructuredIndex);
2256 IList->
setInit(OldIndex, DIE);
2257 if (hadError && !prevHadError) {
2262 StructuredIndex = FieldIndex;
2267 QualType FieldType = Field->getType();
2268 unsigned newStructuredIndex = FieldIndex;
2271 InitializedEntity::InitializeMember(*Field, &Entity);
2272 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
2273 FieldType,
nullptr,
nullptr, Index,
2274 StructuredList, newStructuredIndex,
2286 if (IsFirstDesignator) {
2289 StructuredIndex = FieldIndex;
2293 if (!FinishSubobjectInit)
2301 bool prevHadError = hadError;
2303 CheckStructUnionTypes(Entity, IList, CurrentObjectType, Field,
false, Index,
2304 StructuredList, FieldIndex);
2305 return hadError && !prevHadError;
2327 << CurrentObjectType;
2332 Expr *IndexExpr =
nullptr;
2333 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
2337 DesignatedEndIndex = DesignatedStartIndex;
2341 DesignatedStartIndex =
2343 DesignatedEndIndex =
2352 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
2354 FullyStructuredList->sawArrayRangeDesignator();
2357 if (isa<ConstantArrayType>(AT)) {
2358 llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
2359 DesignatedStartIndex
2360 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
2361 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
2363 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
2364 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
2365 if (DesignatedEndIndex >= MaxElements) {
2367 SemaRef.
Diag(IndexExpr->getLocStart(),
2368 diag::err_array_designator_too_large)
2369 << DesignatedEndIndex.toString(10) << MaxElements.toString(10)
2370 << IndexExpr->getSourceRange();
2375 unsigned DesignatedIndexBitWidth =
2376 ConstantArrayType::getMaxSizeBits(SemaRef.
Context);
2377 DesignatedStartIndex =
2378 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
2379 DesignatedEndIndex =
2380 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
2381 DesignatedStartIndex.setIsUnsigned(
true);
2382 DesignatedEndIndex.setIsUnsigned(
true);
2385 if (!VerifyOnly && StructuredList->isStringLiteralInit()) {
2398 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
2402 uint64_t StrLen = SL->getLength();
2403 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2404 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2405 StructuredList->resizeInits(Context, StrLen);
2409 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2410 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
2412 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2413 if (CharTy != PromotedCharTy)
2416 StructuredList->updateInit(Context, i, Init);
2424 uint64_t StrLen = Str.size();
2425 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2426 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2427 StructuredList->resizeInits(Context, StrLen);
2431 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2432 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
2434 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2435 if (CharTy != PromotedCharTy)
2438 StructuredList->updateInit(Context, i, Init);
2446 DesignatedEndIndex.getZExtValue() >= StructuredList->getNumInits())
2447 StructuredList->resizeInits(SemaRef.
Context,
2448 DesignatedEndIndex.getZExtValue() + 1);
2454 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
2455 unsigned OldIndex = Index;
2458 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
2460 while (DesignatedStartIndex <= DesignatedEndIndex) {
2466 if (CheckDesignatedInitializer(ElementEntity, IList, DIE, DesigIdx + 1,
2467 ElementType,
nullptr,
nullptr, Index,
2468 StructuredList, ElementIndex,
2469 (DesignatedStartIndex == DesignatedEndIndex),
2474 ++DesignatedStartIndex;
2475 ElementIndex = DesignatedStartIndex.getZExtValue();
2480 if (IsFirstDesignator) {
2481 if (NextElementIndex)
2482 *NextElementIndex = DesignatedStartIndex;
2483 StructuredIndex = ElementIndex;
2487 if (!FinishSubobjectInit)
2491 bool prevHadError = hadError;
2492 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
2494 StructuredList, ElementIndex);
2495 return hadError && !prevHadError;
2501 InitListChecker::getStructuredSubobjectInit(
InitListExpr *IList,
unsigned Index,
2504 unsigned StructuredIndex,
2506 bool IsFullyOverwritten) {
2509 Expr *ExistingInit =
nullptr;
2510 if (!StructuredList)
2511 ExistingInit = SyntacticToSemantic.lookup(IList);
2512 else if (StructuredIndex < StructuredList->getNumInits())
2513 ExistingInit = StructuredList->
getInit(StructuredIndex);
2515 if (
InitListExpr *Result = dyn_cast_or_null<InitListExpr>(ExistingInit))
2524 if (!IsFullyOverwritten)
2540 diag::warn_subobject_initializer_overrides)
2542 SemaRef.
Diag(ExistingInit->getLocStart(),
2543 diag::note_previous_initializer)
2545 << ExistingInit->getSourceRange();
2553 QualType ResultType = CurrentObjectType;
2559 unsigned NumElements = 0;
2560 unsigned NumInits = 0;
2561 bool GotNumInits =
false;
2562 if (!StructuredList) {
2565 }
else if (Index < IList->getNumInits()) {
2567 NumInits = SubList->getNumInits();
2575 NumElements = CAType->getSize().getZExtValue();
2578 if (GotNumInits && NumElements > NumInits)
2582 NumElements = VType->getNumElements();
2599 SyntacticToSemantic[IList] = Result;
2607 void InitListChecker::UpdateStructuredListElement(
InitListExpr *StructuredList,
2608 unsigned &StructuredIndex,
2611 if (!StructuredList)
2615 StructuredIndex, expr)) {
2623 if (PrevInit->getSourceRange().isValid()) {
2624 SemaRef.
Diag(expr->getLocStart(),
2625 diag::warn_initializer_overrides)
2626 << expr->getSourceRange();
2628 SemaRef.
Diag(PrevInit->getLocStart(),
2629 diag::note_previous_initializer)
2631 << PrevInit->getSourceRange();
2654 if (Value.isSigned() && Value.isNegative())
2655 return S.
Diag(Loc, diag::err_array_designator_negative)
2656 << Value.toString(10) << Index->getSourceRange();
2658 Value.setIsUnsigned(
true);
2668 bool Invalid =
false;
2683 llvm::APSInt IndexValue;
2689 Designators.push_back(ASTDesignator(InitExpressions.size(),
2692 InitExpressions.push_back(Index);
2700 llvm::APSInt StartValue;
2701 llvm::APSInt EndValue;
2706 if (!StartDependent)
2712 if (!StartIndex || !EndIndex)
2716 if (StartDependent || EndDependent) {
2718 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
2719 EndValue = EndValue.extend(StartValue.getBitWidth());
2720 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
2721 StartValue = StartValue.extend(EndValue.getBitWidth());
2723 if (!StartDependent && !EndDependent && EndValue < StartValue) {
2725 << StartValue.toString(10) << EndValue.toString(10)
2726 << StartIndex->getSourceRange() << EndIndex->getSourceRange();
2729 Designators.push_back(ASTDesignator(InitExpressions.size(),
2733 InitExpressions.push_back(StartIndex);
2734 InitExpressions.push_back(EndIndex);
2750 Designators.data(), Designators.size(),
2751 InitExpressions, Loc, GNUSyntax,
2756 << DIE->getSourceRange();
2765 InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
2767 : Parent(&Parent), Index(Index)
2770 Kind = EK_ArrayElement;
2773 Kind = EK_VectorElement;
2777 assert(CT &&
"Unexpected type");
2778 Kind = EK_ComplexElement;
2786 bool IsInheritedVirtualBase) {
2789 Result.Parent =
nullptr;
2790 Result.
Base =
reinterpret_cast<uintptr_t
>(
Base);
2791 if (IsInheritedVirtualBase)
2792 Result.
Base |= 0x01;
2794 Result.Type = Base->
getType();
2828 llvm_unreachable(
"Invalid EntityKind!");
2857 llvm_unreachable(
"Invalid EntityKind!");
2887 unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
2890 for (
unsigned I = 0; I !=
Depth; ++I)
2901 case EK_New: OS <<
"New";
break;
2905 case EK_Base: OS <<
"Base";
break;
2912 OS <<
"LambdaCapture ";
2919 cast<NamedDecl>(D)->printQualifiedName(OS);
2928 dumpImpl(llvm::errs());
3020 llvm_unreachable(
"Invalid EntityKind!");
3031 bool HadMultipleCandidates) {
3054 bool BindingTemporary) {
3072 bool HadMultipleCandidates) {
3109 assert(!Ty.
hasQualifiers() &&
"rvalues may not have qualifiers");
3119 bool TopLevelOfInitList) {
3140 bool HadMultipleCandidates,
3141 bool FromInitList,
bool AsInitList) {
3235 "Can only rewrap trivial init lists.");
3239 Steps.insert(Steps.begin(),
S);
3243 S.WrappingSyntacticList = Syntactic;
3250 this->Failure = Failure;
3251 this->FailedOverloadResult =
Result;
3272 if (!Init.empty()) {
3292 "consuming an object of unretainable type?");
3352 bool CopyInitializing,
bool AllowExplicit,
3353 bool OnlyListConstructors,
bool IsListInit) {
3354 CandidateSet.
clear();
3358 bool SuppressUserConversions =
false;
3363 if (ConstructorTmpl)
3364 Constructor = cast<CXXConstructorDecl>(
3367 Constructor = cast<CXXConstructorDecl>(D);
3383 if ((CopyInitializing ||
3384 (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3386 SuppressUserConversions =
true;
3390 (AllowExplicit || !Constructor->
isExplicit()) &&
3392 if (ConstructorTmpl)
3395 CandidateSet, SuppressUserConversions);
3403 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
3407 SuppressUserConversions,
3430 bool IsListInit =
false,
3431 bool IsInitListCopy =
false) {
3432 assert((!IsListInit || (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3433 "IsListInit must come with a single initializer list argument.");
3442 assert(DestRecordType &&
"Constructor initialization requires record type");
3444 = cast<CXXRecordDecl>(DestRecordType->
getDecl());
3462 bool AsInitializerList =
false;
3475 AsInitializerList =
true;
3481 CandidateSet, Ctors, Best,
3482 CopyInitialization, AllowExplicit,
3496 AsInitializerList =
false;
3498 CandidateSet, Ctors, Best,
3499 CopyInitialization, AllowExplicit,
3517 !cast<CXXConstructorDecl>(Best->Function)->isUserProvided()) {
3534 bool HadMultipleCandidates = (CandidateSet.size() > 1);
3536 CtorDecl, Best->FoundDecl.
getAccess(), DestType, HadMultipleCandidates,
3537 IsListInit | IsInitListCopy, AsInitializerList);
3550 bool HadMultipleCandidates =
false;
3553 UnqualifiedTargetType,
3555 &HadMultipleCandidates)) {
3557 HadMultipleCandidates);
3558 SourceType = Fn->getType();
3624 bool dummy1, dummy2, dummy3;
3631 T1Quals, cv2T2, T2, T2Quals, Sequence);
3707 if (!isa<VariableArrayType>(DestAT) &&
3750 Expr *InitListAsExpr = InitList;
3788 InitListChecker CheckInitList(S, Entity, InitList,
3790 if (CheckInitList.HadError()) {
3814 bool ObjCConversion;
3815 bool ObjCLifetimeConversion;
3817 T1, T2, DerivedToBase,
3819 ObjCLifetimeConversion) &&
3820 "Must have incompatible references when binding via conversion");
3821 (void)DerivedToBase;
3822 (void)ObjCConversion;
3823 (void)ObjCLifetimeConversion;
3828 CandidateSet.
clear();
3848 if (ConstructorTmpl)
3849 Constructor = cast<CXXConstructorDecl>(
3852 Constructor = cast<CXXConstructorDecl>(D);
3854 if (!Constructor->isInvalidDecl() &&
3855 Constructor->isConvertingConstructor(AllowExplicit)) {
3856 if (ConstructorTmpl)
3859 Initializer, CandidateSet,
3863 Initializer, CandidateSet,
3879 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
3882 if (isa<UsingShadowDecl>(D))
3883 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3890 Conv = cast<CXXConversionDecl>(D);
3898 if ((AllowExplicitConvs || !Conv->isExplicit()) &&
3899 (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){
3902 ActingDC, Initializer,
3903 DestType, CandidateSet,
3908 Initializer, DestType, CandidateSet,
3930 if (isa<CXXConversionDecl>(Function))
3936 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3938 T2.getNonLValueExprType(S.
Context),
3939 HadMultipleCandidates);
3944 if (T2->isLValueReferenceType())
3949 bool NewDerivedToBase =
false;
3950 bool NewObjCConversion =
false;
3951 bool NewObjCLifetimeConversion =
false;
3955 NewDerivedToBase, NewObjCConversion,
3956 NewObjCLifetimeConversion);
3964 ICS.
Standard = Best->FinalConversion;
3967 }
else if (NewDerivedToBase)
3972 else if (NewObjCConversion)
3977 if (cv1T1.
getQualifiers() != T2.getNonReferenceType().getQualifiers())
4011 T1Quals, cv2T2, T2, T2Quals, Sequence);
4039 if (IsNonAddressableType) {
4056 if (T1Quals != T2Quals) {
4080 bool DerivedToBase =
false;
4081 bool ObjCConversion =
false;
4082 bool ObjCLifetimeConversion =
false;
4086 ObjCConversion, ObjCLifetimeConversion);
4099 if (isLValueRef || T1Function) {
4116 else if (ObjCConversion)
4122 cv1T1, T1Quals, T2Quals,
4137 (isLValueRef || InitCategory.
isRValue())) {
4139 S, Entity, Kind, Initializer, isRValueRef, Sequence);
4200 else if (ObjCConversion)
4222 S, Entity, Kind, Initializer,
true, Sequence);
4233 isRValueRef && InitCategory.
isLValue()) {
4284 (T1CVRQuals | T2CVRQuals) != T1CVRQuals) {
4318 assert((!InitList || InitList->
getNumInits() == 0) &&
4319 "Shouldn't use value-init for non-empty init lists");
4331 bool NeedZeroInitialization =
true;
4338 if (ClassDecl->hasUserDeclaredConstructor())
4339 NeedZeroInitialization =
false;
4347 NeedZeroInitialization =
false;
4356 if (NeedZeroInitialization)
4370 ClassDecl->hasUninitializedReferenceMember()) {
4378 Expr *InitListAsExpr = InitList;
4380 bool InitListSyntax = InitList;
4405 if (DestType->isRecordType() && S.
getLangOpts().CPlusPlus) {
4415 if (DestType.isConstQualified() && S.
getLangOpts().CPlusPlus) {
4422 if (DestType.getQualifiers().hasObjCLifetime()) {
4436 bool TopLevelOfInitList) {
4437 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
4439 assert((DestType->
isRecordType() || SourceType->isRecordType()) &&
4440 "Must have a class type to perform a user-defined conversion");
4445 CandidateSet.
clear();
4455 = cast<CXXRecordDecl>(DestRecordType->getDecl());
4465 Con = CopyOfCon.begin(), ConEnd = CopyOfCon.end();
4466 Con != ConEnd; ++Con) {
4474 if (ConstructorTmpl)
4475 Constructor = cast<CXXConstructorDecl>(
4478 Constructor = cast<CXXConstructorDecl>(D);
4480 if (!Constructor->isInvalidDecl() &&
4481 Constructor->isConvertingConstructor(AllowExplicit)) {
4482 if (ConstructorTmpl)
4485 Initializer, CandidateSet,
4489 Initializer, CandidateSet,
4506 = cast<CXXRecordDecl>(SourceRecordType->getDecl());
4508 const auto &Conversions =
4510 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4513 if (isa<UsingShadowDecl>(D))
4514 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4521 Conv = cast<CXXConversionDecl>(D);
4523 if (AllowExplicit || !Conv->isExplicit()) {
4526 ActingDC, Initializer, DestType,
4527 CandidateSet, AllowExplicit);
4530 Initializer, DestType, CandidateSet,
4549 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4551 if (isa<CXXConstructorDecl>(Function)) {
4557 HadMultipleCandidates);
4571 HadMultipleCandidates);
4576 HadMultipleCandidates);
4580 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
4581 Best->FinalConversion.Third) {
4584 ICS.
Standard = Best->FinalConversion;
4602 isa<CXXBoolLiteralExpr>(Init) &&
4603 !cast<CXXBoolLiteralExpr>(Init)->getValue() &&
4612 bool isAddressOf,
bool &isWeakAccess) {
4623 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
4624 switch (ce->getCastKind()) {
4642 }
else if (isa<DeclRefExpr>(e)) {
4646 isWeakAccess =
true;
4650 VarDecl *var = dyn_cast<
VarDecl>(cast<DeclRefExpr>(e)->getDecl());
4664 }
else if (isa<ArraySubscriptExpr>(e)) {
4680 bool isWeakAccess =
false;
4684 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
4690 << ((
unsigned) iik - 1)
4691 << src->getSourceRange();
4715 Expr *Initializer) {
4716 bool ArrayDecay =
false;
4721 ArgPointee = ArgArrayType->getElementType();
4733 bool ShouldCopy =
true;
4738 if (ArrayDecay || Initializer->
isGLValue()) {
4762 Expr *Initializer) {
4782 Expr *Initializer) {
4796 bool TopLevelOfInitList)
4805 bool TopLevelOfInitList) {
4812 for (
unsigned I = 0, E = Args.size(); I != E; ++I)
4813 if (Args[I]->getType()->isNonOverloadPlaceholderType()) {
4820 Args[I] = result.
get();
4841 Expr *Initializer =
nullptr;
4842 if (Args.size() == 1) {
4843 Initializer = Args[0];
4846 DestType, Initializer->
getType(),
4849 Args[0] = Initializer;
4851 if (!isa<InitListExpr>(Initializer))
4852 SourceType = Initializer->
getType();
4858 if (
InitListExpr *InitList = dyn_cast_or_null<InitListExpr>(Initializer)) {
4871 if (Args.size() != 1)
4897 if (Initializer && isa<VariableArrayType>(DestAT)) {
4925 isa<CompoundLiteralExpr>(Initializer->
IgnoreParens()) &&
4941 Initializer && isa<InitListExpr>(Initializer)) {
4945 }
else if (DestAT->getElementType()->isCharType())
4957 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
4964 if (allowObjCWritebackConversion &&
5003 TopLevelOfInitList);
5007 if (Args.size() > 1) {
5011 assert(Args.size() == 1 &&
"Zero-argument case handled above");
5018 bool NeedAtomicConversion =
false;
5022 DestType = Atomic->getValueType();
5023 NeedAtomicConversion =
true;
5028 TopLevelOfInitList);
5030 if (!
Failed() && NeedAtomicConversion)
5047 allowObjCWritebackConversion);
5055 bool ShouldCopy =
true;
5071 }
else if (ICS.
isBad()) {
5089 for (
auto &S : Steps)
5138 llvm_unreachable(
"Invalid EntityKind!");
5167 llvm_unreachable(
"missed an InitializedEntity kind?");
5196 llvm_unreachable(
"missed an InitializedEntity kind?");
5204 Expr *CurInitExpr) {
5211 CI = Ctors.begin(), CE = Ctors.end(); CI != CE; ++CI) {
5215 if ((Constructor = dyn_cast<CXXConstructorDecl>(D))) {
5225 CurInitExpr, CandidateSet);
5234 Constructor = cast<CXXConstructorDecl>(
5244 CurInitExpr, CandidateSet,
true);
5250 Expr *Initializer) {
5277 return Initializer->getLocStart();
5279 llvm_unreachable(
"missed an InitializedEntity kind?");
5306 bool IsExtraneousCopy) {
5313 Class = cast<CXXRecordDecl>(Record->getDecl());
5346 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5355 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
5356 : diag::err_temp_copy_no_viable)
5358 << CurInitExpr->getSourceRange();
5365 S.
Diag(Loc, diag::err_temp_copy_ambiguous)
5367 << CurInitExpr->getSourceRange();
5372 S.
Diag(Loc, diag::err_temp_copy_deleted)
5374 << CurInitExpr->getSourceRange();
5384 Best->FoundDecl.getAccess(), IsExtraneousCopy);
5386 if (IsExtraneousCopy) {
5397 for (
unsigned I = 1, N = Constructor->
getNumParams(); I != N; ++I) {
5400 diag::err_call_incomplete_argument))
5421 HadMultipleCandidates,
5439 Expr *CurInitExpr) {
5453 S, CandidateSet, cast<CXXRecordDecl>(Record->getDecl()), CurInitExpr);
5461 << CurInitExpr->getSourceRange();
5466 Entity, Best->FoundDecl.getAccess(),
Diag);
5487 void InitializationSequence::PrintInitLocationNote(
Sema &S,
5502 diag::note_method_return_type_change)
5531 return NumArgs != 1;
5543 bool &ConstructorInitRequiresZeroInit,
5544 bool IsListInitialization,
5545 bool IsStdInitListInitialization,
5548 unsigned NumArgs = Args.size();
5563 assert(Constructor->
getParent() &&
"No parent class for constructor.");
5584 Loc, ConstructorArgs,
5586 IsListInitialization))
5605 S.
Context, Constructor, TSInfo, ConstructorArgs, ParenOrBraceRange,
5606 HadMultipleCandidates, IsListInitialization,
5607 IsStdInitListInitialization, ConstructorInitRequiresZeroInit);
5623 if (IsListInitialization)
5624 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
5634 HadMultipleCandidates,
5635 IsListInitialization,
5636 IsStdInitListInitialization,
5637 ConstructorInitRequiresZeroInit,
5644 HadMultipleCandidates,
5645 IsListInitialization,
5646 IsStdInitListInitialization,
5647 ConstructorInitRequiresZeroInit,
5703 llvm_unreachable(
"unknown entity kind");
5763 return FallbackDecl;
5772 llvm_unreachable(
"unknown entity kind");
5789 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
5790 if (ILE->getNumInits() == 1 && ILE->isGLValue()) {
5792 Init = ILE->getInit(0);
5800 Init =
const_cast<Expr *
>(
5805 if (
CastExpr *CE = dyn_cast<CastExpr>(Init))
5806 if (CE->getSubExpr()->isGLValue())
5807 Init = CE->getSubExpr();
5812 }
while (Init != Old);
5817 ME->setExtendingDecl(ExtendingEntity->
getDecl(),
5833 Init =
const_cast<Expr *
>(
5837 Init = BTE->getSubExpr();
5840 dyn_cast<CXXStdInitializerListExpr>(Init)) {
5845 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
5846 if (ILE->getType()->isArrayType()) {
5847 for (
unsigned I = 0, N = ILE->getNumInits(); I != N; ++I)
5852 if (
CXXRecordDecl *RD = ILE->getType()->getAsCXXRecordDecl()) {
5853 assert(RD->isAggregate() &&
"aggregate init on non-aggregate");
5858 if (RD->
isUnion() && ILE->getInitializedFieldInUnion() &&
5859 ILE->getInitializedFieldInUnion()->getType()->isReferenceType())
5863 for (
const auto *I : RD->
fields()) {
5864 if (Index >= ILE->getNumInits())
5866 if (I->isUnnamedBitfield())
5868 Expr *SubInit = ILE->getInit(Index);
5869 if (I->getType()->isReferenceType())
5871 else if (isa<InitListExpr>(SubInit) ||
5872 isa<CXXStdInitializerListExpr>(SubInit))
5885 const Expr *Init,
bool IsInitializerList,
5888 if (isa<FieldDecl>(ExtendingDecl)) {
5889 if (IsInitializerList) {
5890 S.
Diag(Init->
getExprLoc(), diag::warn_dangling_std_initializer_list)
5895 bool IsSubobjectMember =
false;
5899 IsSubobjectMember =
true;
5904 diag::warn_bind_ref_member_to_temporary)
5905 << ExtendingDecl << Init->getSourceRange()
5906 << IsSubobjectMember << IsInitializerList;
5907 if (IsSubobjectMember)
5909 diag::note_ref_subobject_of_member_declared_here);
5912 diag::note_ref_or_ptr_member_declared_here)
5921 const Expr *PostInit);
5925 bool IsReturnStmt) {
5936 unsigned DiagID = 0;
5981 if (isa<ParmVarDecl>(VD))
5982 DiagID = diag::warn_redundant_move_on_return;
5984 DiagID = diag::warn_pessimizing_move_on_return;
5986 DiagID = diag::warn_pessimizing_move_on_initialization;
6033 if (!ZeroInitializationFixit.empty()) {
6034 unsigned DiagID = diag::err_default_init_const;
6036 if (S.
getLangOpts().MSVCCompat && D->hasAttr<SelectAnyAttr>())
6037 DiagID = diag::ext_default_init_const;
6046 ZeroInitializationFixit);
6065 if (isa<InitListExpr>((
Expr *)Args[0])) {
6071 TypeLoc TL = TInfo->getTypeLoc();
6074 Brackets = ArrayLoc.getBracketsRange();
6081 ArrayT->getSizeModifier(),
6082 ArrayT->getIndexTypeCVRQualifiers(),
6106 Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
6111 Expr *Init = Args[0];
6112 S.
Diag(Init->getLocStart(), diag::warn_cxx98_compat_reference_list_init)
6113 << Init->getSourceRange();
6118 if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
6121 Expr *Init = Args[0];
6124 S.
Diag(Init->getLocStart(), diag::warn_temporary_array_to_pointer_decay)
6125 << Init->getSourceRange();
6141 switch (Steps.front().Kind) {
6171 assert(Args.size() == 1);
6186 bool ConstructorInitRequiresZeroInit =
false;
6217 CurInit.
get()->getLocStart(),
6218 CurInit.
get()->getSourceRange(),
6219 &BasePath, IgnoreBaseAccess))
6230 CurInit.
get(), &BasePath, VK);
6242 << (BitField !=
nullptr)
6243 << CurInit.
get()->getSourceRange();
6252 S.
Diag(Kind.
getLocation(), diag::err_reference_bind_to_vector_element)
6254 << CurInit.
get()->getSourceRange();
6255 PrintInitLocationNote(S, Entity);
6273 ExtendingEntity->getDecl());
6279 assert(CurInit.
get()->
isRValue() &&
"not a temporary");
6296 ExtendingEntity->getDecl());
6321 bool IsCopy =
false;
6325 bool CreatedObject =
false;
6337 Loc, ConstructorArgs))
6343 HadMultipleCandidates,
6363 CreatedObject =
true;
6378 FoundFn, Conversion);
6381 CurInit = CurInitExprRes;
6385 HadMultipleCandidates);
6391 CreatedObject = Conversion->getReturnType()->isRecordType();
6403 S.
PDiag(diag::err_access_dtor_temp) << T);
6413 if (MaybeBindToTemp)
6436 assert(CurInit.
get()->
isRValue() &&
"cannot convert glvalue to atomic");
6443 assert(CurInit.
get()->
isGLValue() &&
"cannot load from a prvalue");
6462 CurInit = CurInitExprRes;
6479 InitListChecker PerformInitList(S, InitEntity,
6480 InitList, Ty,
false);
6481 if (PerformInitList.HadError())
6489 if ((*ResultType)->isRValueReferenceType())
6491 else if ((*ResultType)->isLValueReferenceType())
6498 PerformInitList.getFullyStructuredList();
6502 : StructuredInitList;
6516 assert(Args.size() == 1 &&
"expected a single argument for list init");
6518 S.
Diag(InitList->getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
6519 << InitList->getSourceRange();
6520 MultiExprArg Arg(InitList->getInits(), InitList->getNumInits());
6524 ConstructorInitRequiresZeroInit,
6527 InitList->getLBraceLoc(),
6528 InitList->getRBraceLoc());
6533 CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
6559 bool IsStdInitListInit =
6562 S, UseTemporary ? TempEntity : Entity, Kind, Args, *
Step,
6563 ConstructorInitRequiresZeroInit,
6574 if (NextStep != StepEnd &&
6579 ConstructorInitRequiresZeroInit =
true;
6616 CurInit = CurInitExprRes;
6624 PrintInitLocationNote(S, Entity);
6626 }
else if (Complained)
6627 PrintInitLocationNote(S, Entity);
6649 << CurInit.
get()->getSourceRange();
6659 IncompleteDest->getElementType(),
6660 ConstantSource->getSize(),
6671 << CurInit.
get()->getSourceRange();
6689 S.
Diag(CurInit.get()->getExprLoc(),
6690 diag::warn_cxx98_compat_initializer_list_init)
6691 << CurInit.get()->getSourceRange();
6719 "Sampler initialization on non-sampler type.");
6721 QualType SourceType = CurInit.get()->getType();
6724 if (!SourceType->isSamplerT())
6728 llvm_unreachable(
"Invalid EntityKind!");
6735 "Event initialization on non-event type.");
6739 CurInit.get()->getValueKind());
6747 cast<FieldDecl>(Entity.
getDecl())->isBitField())
6749 cast<FieldDecl>(Entity.
getDecl()),
6753 if (
const Expr *E = CurInit.
get()) {
6766 S.
Diag(Loc, diag::err_reference_without_init)
6775 for (
const auto *FI : RD->
fields()) {
6776 if (FI->isUnnamedBitfield())
6780 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
6785 for (
const auto &BI : RD->
bases()) {
6787 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
6842 if (
auto *D = Entity.
getDecl())
6843 Loc = D->getLocation();
6844 S.
Diag(Loc, diag::note_in_reference_temporary_list_initializer) << T;
6848 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
6850 assert(DiagnoseInitList.HadError() &&
6851 "Inconsistent init list check result.");
6873 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
6877 <<
SourceRange(Args.front()->getLocStart(), Args.back()->getLocEnd());
6890 S.
Diag(Kind.
getLocation(), diag::err_array_init_narrow_string_into_wchar);
6893 S.
Diag(Kind.
getLocation(), diag::err_array_init_wide_string_into_char);
6897 diag::err_array_init_incompat_wide_string_into_wchar);
6903 ? diag::err_array_init_different_type
6904 : diag::err_array_init_non_constant_array))
6906 << Args[0]->getType()
6907 << Args[0]->getSourceRange();
6912 << Args[0]->getSourceRange();
6926 switch (FailedOverloadResult) {
6930 << Args[0]->getType() << DestType
6931 << Args[0]->getSourceRange();
6934 << DestType << Args[0]->getType()
6935 << Args[0]->getSourceRange();
6943 diag::err_typecheck_nonviable_condition_incomplete,
6944 Args[0]->getType(), Args[0]->getSourceRange()))
6946 << Args[0]->getType() << Args[0]->getSourceRange()
6955 << Args[0]->getSourceRange();
6963 llvm_unreachable(
"Inconsistent overload resolution?");
6969 llvm_unreachable(
"Conversion did not fail!");
6974 if (isa<InitListExpr>(Args[0])) {
6976 diag::err_lvalue_reference_bind_to_initlist)
6979 << Args[0]->getSourceRange();
6987 ? diag::err_lvalue_reference_bind_to_temporary
6988 : diag::err_lvalue_reference_bind_to_unrelated)
6991 << Args[0]->getType()
6992 << Args[0]->getSourceRange();
6998 << Args[0]->getSourceRange();
7002 QualType SourceType = Args[0]->getType();
7011 << Args[0]->getSourceRange();
7018 << Args[0]->isLValue()
7019 << Args[0]->getType()
7020 << Args[0]->getSourceRange();
7025 QualType FromType = Args[0]->getType();
7029 << Args[0]->isLValue()
7031 << Args[0]->getSourceRange();
7046 if (InitList && InitList->getNumInits() == 1)
7047 R =
SourceRange(InitList->getInit(0)->getLocEnd(), InitList->getLocEnd());
7049 R =
SourceRange(Args.front()->getLocEnd(), Args.back()->getLocEnd());
7053 S.
Diag(Kind.
getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
7068 << (DestType->
isRecordType()) << DestType << Args[0]->getSourceRange();
7075 ArgsRange =
SourceRange(Args.front()->getLocStart(),
7076 Args.back()->getLocEnd());
7079 assert(Args.size() == 1 &&
7080 "List construction from other than 1 argument.");
7082 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
7087 switch (FailedOverloadResult) {
7090 << DestType << ArgsRange;
7126 diag::note_member_declared_at);
7130 S.
Diag(Record->getDecl()->getLocation(),
7131 diag::note_previous_decl)
7138 << DestType << ArgsRange;
7148 <<
true << DestType << ArgsRange;
7149 llvm_unreachable(
"Inconsistent overload resolution?");
7159 << DestType << ArgsRange;
7162 <<
true << DestType << ArgsRange;
7169 llvm_unreachable(
"Conversion did not fail!");
7197 diag::err_init_incomplete_type);
7214 << Args[0]->getSourceRange();
7219 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
7221 S.
Diag(CtorDecl->
getLocation(), diag::note_constructor_declared_here);
7226 PrintInitLocationNote(S, Entity);
7233 OS <<
"Failed sequence: ";
7236 OS <<
"too many initializers for reference";
7240 OS <<
"array requires initializer list";
7244 OS <<
"array requires initializer list or string literal";
7248 OS <<
"array requires initializer list or wide string literal";
7252 OS <<
"narrow string into wide char array";
7256 OS <<
"wide string into char array";
7260 OS <<
"incompatible wide string into wide char array";
7264 OS <<
"array type mismatch";
7268 OS <<
"non-constant array initializer";
7272 OS <<
"address of overloaded function failed";
7276 OS <<
"overload resolution for reference initialization failed";
7280 OS <<
"non-const lvalue reference bound to temporary";
7284 OS <<
"non-const lvalue reference bound to unrelated type";
7288 OS <<
"rvalue reference bound to an lvalue";
7292 OS <<
"reference initialization drops qualifiers";
7296 OS <<
"reference initialization failed";
7300 OS <<
"conversion failed";
7304 OS <<
"conversion from property failed";
7308 OS <<
"too many initializers for scalar";
7312 OS <<
"referencing binding to initializer list";
7316 OS <<
"initializer list for non-aggregate, non-scalar type";
7320 OS <<
"overloading failed for user-defined conversion";
7324 OS <<
"constructor overloading failed";
7328 OS <<
"default initialization of a const variable";
7332 OS <<
"initialization of incomplete type";
7336 OS <<
"list initialization checker failure";
7340 OS <<
"variable length array has an initializer";
7344 OS <<
"initializer expression isn't contextually valid";
7348 OS <<
"list constructor overloading failed";
7352 OS <<
"list copy initialization chose explicit constructor";
7360 OS <<
"Dependent sequence\n";
7364 OS <<
"Normal sequence: ";
7375 OS <<
"resolve address of overloaded function";
7379 OS <<
"derived-to-base case (rvalue" << S->Type.getAsString() <<
")";
7383 OS <<
"derived-to-base case (xvalue" << S->Type.getAsString() <<
")";
7387 OS <<
"derived-to-base case (lvalue" << S->Type.getAsString() <<
")";
7391 OS <<
"bind reference to lvalue";
7395 OS <<
"bind reference to a temporary";
7399 OS <<
"extraneous C++03 copy to temporary";
7403 OS <<
"user-defined conversion via " << *S->Function.Function;
7407 OS <<
"qualification conversion (rvalue)";
7411 OS <<
"qualification conversion (xvalue)";
7415 OS <<
"qualification conversion (lvalue)";
7419 OS <<
"non-atomic-to-atomic conversion";
7423 OS <<
"load (lvalue to rvalue)";
7427 OS <<
"implicit conversion sequence (";
7433 OS <<
"implicit conversion sequence with narrowing prohibited (";
7439 OS <<
"list aggregate initialization";
7443 OS <<
"unwrap reference initializer list";
7447 OS <<
"rewrap reference initializer list";
7451 OS <<
"constructor initialization";
7455 OS <<
"list initialization via constructor";
7459 OS <<
"zero initialization";
7463 OS <<
"C assignment";
7467 OS <<
"string initialization";
7471 OS <<
"Objective-C object conversion";
7475 OS <<
"array initialization";
7479 OS <<
"parenthesized array initialization";
7483 OS <<
"pass by indirect copy and restore";
7487 OS <<
"pass by indirect restore";
7491 OS <<
"Objective-C object retension";
7495 OS <<
"std::initializer_list from initializer list";
7499 OS <<
"list initialization from std::initializer_list";
7503 OS <<
"OpenCL sampler_t from integer constant";
7507 OS <<
"OpenCL event_t from zero";
7511 OS <<
" [" << S->Type.getAsString() <<
']';
7525 const Expr *PostInit) {
7553 S.
Diag(PostInit->getLocStart(),
7555 ? diag::warn_init_list_type_narrowing
7556 : diag::ext_init_list_type_narrowing)
7557 << PostInit->getSourceRange()
7564 S.
Diag(PostInit->getLocStart(),
7566 ? diag::warn_init_list_constant_narrowing
7567 : diag::ext_init_list_constant_narrowing)
7568 << PostInit->getSourceRange()
7575 S.
Diag(PostInit->getLocStart(),
7577 ? diag::warn_init_list_variable_narrowing
7578 : diag::ext_init_list_variable_narrowing)
7579 << PostInit->getSourceRange()
7586 llvm::raw_svector_ostream OS(StaticCast);
7587 OS <<
"static_cast<";
7594 OS << *TT->getDecl();
7603 S.
Diag(PostInit->getLocStart(), diag::note_init_list_narrowing_silence)
7604 << PostInit->getSourceRange()
7620 assert(InitE &&
"No initialization expression");
7625 return !Seq.Failed();
7632 bool TopLevelOfInitList,
7633 bool AllowExplicit) {
7638 assert(InitE &&
"No initialization expression?");
7641 EqualLoc = InitE->getLocStart();
7648 ExprResult Result = Seq.Perform(*
this, Entity, Kind, InitE);
unsigned getNumElements() const
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
Represents a single C99 designator.
Perform a derived-to-base cast, producing an lvalue.
Defines the clang::ASTContext interface.
unsigned getNumInits() const
SourceLocation getEnd() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static bool performReferenceExtension(Expr *Init, const InitializedEntity *ExtendingEntity)
InitListExpr * WrappingSyntacticList
When Kind = SK_RewrapInitList, the syntactic form of the wrapping list.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
void SetZeroInitializationFixit(const std::string &Fixit, SourceLocation L)
Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied...
bool isConstantArrayType() const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
DesignatorKind getKind() const
Simple class containing the result of Sema::CorrectTypo.
unsigned Index
When Kind == EK_ArrayElement, EK_VectorElement, or EK_ComplexElement, the index of the array or vecto...
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
step_iterator step_end() const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Produce an Objective-C object pointer.
A cast other than a C-style cast.
DestructionKind isDestructedType() const
QualType getCallResultType() const
Determine the type of an expression that calls this function.
void AddOCLZeroEventStep(QualType T)
Add a step to initialize an OpenCL event_t from a NULL constant.
Initializing char array with wide string literal.
QualType getType() const
Retrieves the type of the base class.
Perform an implicit conversion sequence without narrowing.
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
IdentifierInfo * getIdentifier() 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)
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
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.
SmallVectorImpl< Step >::const_iterator step_iterator
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Expr * getInit() const
Retrieve the initializer value.
ActionResult< Expr * > ExprResult
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
static DesignatedInitExpr * CloneDesignatedInitExpr(Sema &SemaRef, DesignatedInitExpr *DIE)
bool isRecordType() const
UserDefinedConversionSequence UserDefined
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
unsigned size() const
Returns the number of designators in this initializer.
AccessSpecifier getAccess() const
uintptr_t Base
When Kind == EK_Base, the base specifier that provides the base class. The lower bit specifies whethe...
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, const InitializedEntity &Entity, AccessSpecifier Access, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
Not a narrowing conversion.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
bool hasFlexibleArrayMember() const
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
std::string getAsString() const
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
bool isInStdNamespace() const
SourceLocation getEqualLoc() const
Retrieve the location of the equal sign for copy initialization (if present).
static bool tryObjCWritebackConversion(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity, Expr *Initializer)
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
The entity being initialized is a variable.
InitListExpr * getSyntacticForm() const
const Expr * getInit() const
NamespaceDecl - Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
Overloading for a user-defined conversion failed.
Ambiguous candidates found.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
void AddAddressOverloadResolutionStep(FunctionDecl *Function, DeclAccessPair Found, bool HadMultipleCandidates)
Add a new step in the initialization that resolves the address of an overloaded function to a specifi...
Perform a derived-to-base cast, producing an xvalue.
The entity being initialized is a base member subobject.
bool isFunctionalCast() const
Determine whether this is a functional-style cast.
List-copy-initialization chose an explicit constructor.
SourceLocation getLocEnd() const LLVM_READONLY
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
bool isSpelledAsLValue() const
SourceLocation getDotLoc() const
const llvm::APInt & getSize() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
The entity being initialized is a function parameter; function is member of group of audited CF APIs...
static const InitializedEntity * getEntityForTemporaryLifetimeExtension(const InitializedEntity *Entity, const InitializedEntity *FallbackDecl=nullptr)
Initialize an OpenCL sampler from an integer.
EntityKind getKind() const
Determine the kind of initialization.
static void LookupCopyAndMoveConstructors(Sema &S, OverloadCandidateSet &CandidateSet, CXXRecordDecl *Class, Expr *CurInitExpr)
Look for copy and move constructors and constructor templates, for copying an object via direct-initi...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ExprResult PerformObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
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.
DiagnosticsEngine & Diags
const Expr * getCallee() const
static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT, ASTContext &Context)
Check whether the array of type AT can be initialized by the Init expression by means of string initi...
AccessSpecifier getAccess() const
static void warnBracedScalarInit(Sema &S, const InitializedEntity &Entity, SourceRange Braces)
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
SourceRange getParenRange() const
Retrieve the source range containing the locations of the open and closing parentheses for value and ...
SourceLocation getLBracketLoc() const
field_iterator field_begin() const
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void setInit(unsigned Init, Expr *expr)
Expr * IgnoreImplicit() LLVM_READONLY
Non-const lvalue reference binding to an lvalue of unrelated type.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
step_iterator step_begin() const
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
void setBegin(SourceLocation b)
Perform a derived-to-base cast, producing an rvalue.
void AddReferenceBindingStep(QualType T, bool BindingTemporary)
Add a new step binding a reference to an object.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
static DesignatedInitExpr * Create(const ASTContext &C, Designator *Designators, unsigned NumDesignators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
bool allowsNRVO() const
Determine whether this initialization allows the named return value optimization, which also applies ...
void setElementIndex(unsigned Index)
If this is already the initializer for an array or vector element, sets the element index...
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false)
ParmVarDecl - Represents a parameter to a function.
The entity being initialized is a temporary object.
bool isObjCRetainableType() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * getArrayIndex(const Designator &D) const
bool allowExplicitConversionFunctionsInRefBinding() const
Retrieve whether this initialization allows the use of explicit conversion functions when binding a r...
static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, bool IsReturnStmt)
Provide warnings when std::move is used on construction.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
void InitializeFrom(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList)
Represents a C99 designated initializer expression.
Construct a std::initializer_list from an initializer list.
bool isScalarType() const
Expr * getSubExpr(unsigned Idx) 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...
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext. This is either a single result (with no stable stora...
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...
bool isReferenceType() const
DeclaratorDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
QualType getReturnType() const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a place-holder for an object not to be initialized by anything.
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call...
Converting between two Objective-C object types, which can occur when performing reference binding to...
static bool isLibstdcxxPointerReturnFalseHack(Sema &S, const InitializedEntity &Entity, const Expr *Init)
static void warnOnLifetimeExtension(Sema &S, const InitializedEntity &Entity, const Expr *Init, bool IsInitializerList, const ValueDecl *ExtendingDecl)
Rewrap the single-element initializer list for a reference.
unsigned getCVRQualifiers() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr)
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceLocation getRParenLoc() const
~InitializationSequence()
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Perform initialization via a constructor taking a single std::initializer_list argument.
static bool shouldDestroyTemporary(const InitializedEntity &Entity)
Whether the given entity, when initialized with an object created for that initialization, requires destruction.
Describes an C or C++ initializer list.
const TargetInfo & getTargetInfo() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static void ExpandAnonymousFieldDesignator(Sema &SemaRef, DesignatedInitExpr *DIE, unsigned DesigIdx, IndirectFieldDecl *IndirectField)
Expand a field designator that refers to a member of an anonymous struct or union into a series of fi...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
const LangOptions & getLangOpts() const
StepKind Kind
The kind of conversion or initialization step we are taking.
SourceRange getRange() const
Retrieve the source range that covers the initialization.
Succeeded, but refers to a deleted function.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, bool &DerivedToBase, bool &ObjCConversion, bool &ObjCLifetimeConversion)
unsigned getMinRequiredArguments() const
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
const CXXRecordDecl * getParent() const
An x-value expression is a reference to an object with independent storage but which can be "moved"...
field_range fields() const
bool isObjCLifetimeType() const
const ArrayType * getAsArrayType(QualType T) const
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
SourceLocation getRBraceLoc() const
bool isValueDependent() const
Variable-length array must not have an initializer.
RecordDecl * getDecl() const
ImplicitConversionKind Second
Initialization of an incomplete type.
The entity being initialized is a non-static data member subobject.
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
CheckedConversionKind
The kind of conversion being performed.
bool isUnsignedIntegerType() const
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
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)
void AddParenthesizedArrayInitStep(QualType T)
Add a parenthesized array initialization step.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
chain_iterator chain_begin() const
The entity being initialized is an element of a vector. or vector.
bool CanUseDecl(NamedDecl *D)
Determine whether the use of this declaration is valid, without emitting diagnostics.
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
Represents binding an expression to a temporary.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
Perform initialization via a constructor.
Perform a user-defined conversion, either via a conversion function or via a constructor.
bool isExtVectorType() const
Implicit conversion failed.
The entity being initialized is a function parameter.
NamedDecl *const * chain_iterator
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, InitListExpr *InitList)
field_iterator field_end() const
const ArrayType * getAsArrayTypeUnsafe() const
Perform an implicit conversion sequence.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Sema - This implements semantic analysis and AST building for C.
void setField(FieldDecl *FD)
Overloading for list-initialization by constructor failed.
Perform list-initialization without a constructor.
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
IdentifierInfo * getFieldName() const
Reference binding drops qualifiers.
void AddObjCObjectConversionStep(QualType T)
Add an Objective-C object conversion step, which is always a no-op.
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - Returns lifetime attribute of this type.
Cannot resolve the address of an overloaded function.
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
Represents a ValueDecl that came out of a declarator. Contains type source information through TypeSo...
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify(). Represents the C++11 expression taxonomy.
void AddStdInitializerListConstructionStep(QualType T)
Add a step to construct a std::initializer_list object from an initializer list.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a member subobject.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
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.
A narrowing conversion by virtue of the source and destination types.
The entity being initialized is a field of block descriptor for the copied-in c++ object...
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
SourceLocation getEllipsisLoc() const
designators_iterator designators_begin()
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
Initializing wide char array with incompatible wide string literal.
The entity being initialized is the real or imaginary part of a complex number.
bool isDeleted() const
Whether this function has been deleted.
SourceLocation getLocStart() const LLVM_READONLY
Implicit conversion failed.
void setRBraceLoc(SourceLocation Loc)
SourceLocation getLocStart() const LLVM_READONLY
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isAnyComplexType() const
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
StandardConversionSequence After
static void updateStringLiteralType(Expr *E, QualType Ty)
uintptr_t Parameter
When Kind == EK_Parameter, the ParmVarDecl, with the low bit indicating whether the parameter is "con...
The entity being initialized is an object (or array of objects) allocated via new.
Perform a qualification conversion, producing an xvalue.
void setSyntacticForm(InitListExpr *Init)
Represents a C++ functional cast expression that builds a temporary object.
SourceLocation getLBraceLoc() const
static void performLifetimeExtension(Expr *Init, const InitializedEntity *ExtendingEntity)
bool isAtomicType() const
Represents a C++ destructor within a class.
Initializing a wide char array with narrow string literal.
void ClearExprs(Sema &Actions)
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr)
void AddProduceObjCObjectStep(QualType T)
Add a step to "produce" an Objective-C object (by retaining it).
SmallVectorImpl< OverloadCandidate >::iterator iterator
Passing zero to a function where OpenCL event_t is expected.
void AddConstructorInitializationStep(CXXConstructorDecl *Constructor, AccessSpecifier Access, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
Add a constructor-initialization step.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
SourceLocation getLocEnd() const LLVM_READONLY
const ParmVarDecl * getParamDecl(unsigned i) const
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
bool isInitListConstructor(const CXXConstructorDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
Resolve the address of an overloaded function to a specific function declaration. ...
Expr * getArrayRangeStart(const Designator &D) const
DeclContext * getDeclContext()
Overload resolution succeeded.
void AddArrayInitStep(QualType T)
Add an array initialization step.
The entity being initialized is an exception object that is being thrown.
bool isFloatingType() const
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
ExprResult CheckPlaceholderExpr(Expr *E)
struct F Function
When Kind == SK_ResolvedOverloadedFunction or Kind == SK_UserConversion, the function that the expres...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
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.
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isExplicit() const
Determine whether this constructor was marked "explicit" or not.
ObjCMethodDecl * getMethodDecl() const
Retrieve the ObjectiveC method being initialized.
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation())
bool isDependentType() const
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
StandardConversionSequence Standard
bool IsDerivedFrom(QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
static void TryDefaultInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence)
Attempt default initialization (C++ [dcl.init]p6).
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
Initializer has a placeholder type which cannot be resolved by initialization.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
static void TryReferenceInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence)
Attempt reference initialization (C++0x [dcl.init.ref])
DeclarationName getDeclName() const
const IdentifierInfo * getField() const
FailureKind getFailureKind() const
Determine why initialization failed.
QualType getElementType() const
Represents a C++ conversion function within a class.
void AddStringInitStep(QualType T)
Add a string init step.
The result type of a method or function.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E)
Pass an object by indirect restore.
InitKind getKind() const
Determine the initialization kind.
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
QualType getWideCharType() const
Return the type of wide characters. In C++, this returns the unique wchar_t type. In C99...
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
InitListExpr * getUpdater() const
FailureKind
Describes why initialization failed.
Too many initializers for scalar.
static void TryListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence)
Attempt list initialization (C++0x [dcl.init.list])
bool isArrayRangeDesignator() const
Lvalue-to-rvalue conversion (C++ 4.1)
List initialization failed at some point.
Perform a conversion adding _Atomic to a type.
void AddListInitializationStep(QualType T)
Add a list-initialization step.
SourceLocation getDotLoc() const
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
Perform a qualification conversion, producing an lvalue.
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)
Expr * getArrayRangeEnd(const Designator &D) const
SequenceKind
Describes the kind of initialization sequence computed.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
unsigned getNumParams() const
Reference initialization from an initializer list.
QualType getElementType() const
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
static bool shouldBindAsTemporary(const InitializedEntity &Entity)
Whether we should bind a created object as a temporary when initializing the given entity...
SourceLocation getLocation() const
Retrieve the location at which initialization is occurring.
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda...
bool isValid() const
Return true if this is a valid SourceLocation object.
Expr * getArrayRangeStart() const
FieldDecl * getField() const
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.
ASTContext & getASTContext() const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setReferenced(bool R=true)
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
QualType withConst() const
static InvalidICRKind isInvalidICRSource(ASTContext &C, Expr *e, bool isAddressOf, bool &isWeakAccess)
Determines whether this expression is an acceptable ICR source.
bool isExplicitCast() const
Determine whether this initialization is an explicit cast.
const Designator & getDesignator(unsigned Idx) const
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
Adds a conversion function template specialization candidate to the overload set, using template argu...
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
Initialization of some unused destination type with an initializer list.
The entity being initialized is the result of a function call.
SourceLocation getLBracketLoc() const
Objective-C ARC writeback conversion.
The entity being implicitly initialized back to the formal result type.
SourceLocation getRBracketLoc() const
Zero-initialize the object.
The entity being initialized is the initializer for a compound literal.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
void AddExtraneousCopyToTemporary(QualType T)
Add a new step that makes an extraneous copy of the input to a temporary of the same class type...
Expr * updateInit(const ASTContext &C, unsigned Init, Expr *expr)
Updates the initializer at index Init with the new expression expr, and returns the old expression at...
Describes the kind of initialization being performed, along with location information for tokens rela...
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
The entity being initialized is an element of an array.
const Type * getBaseElementTypeUnsafe() const
void setAsIdentityConversion()
bool isCStyleOrFunctionalCast() const
Determine whether this initialization is a C-style cast.
static ExprResult PerformConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, const InitializationSequence::Step &Step, bool &ConstructorInitRequiresZeroInit, bool IsListInitialization, bool IsStdInitListInitialization, SourceLocation LBraceLoc, SourceLocation RBraceLoc)
static bool DiagnoseUninitializedReference(Sema &S, SourceLocation Loc, QualType T)
Expr ** getInits()
Retrieve the set of initializers.
Overloading for initialization by constructor failed.
QualType getToType(unsigned Idx) const
static bool ResolveOverloadedFunctionForReferenceBinding(Sema &S, Expr *Initializer, QualType &SourceType, QualType &UnqualifiedSourceType, QualType UnqualifiedTargetType, InitializationSequence &Sequence)
SourceLocation getBegin() const
bool isTypeDependent() const
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
static bool TryInitializerListConstruction(Sema &S, InitListExpr *List, QualType DestType, InitializationSequence &Sequence)
When initializing from init list via constructor, handle initialization of an object of type std::ini...
lookup_result lookup(DeclarationName Name) const
bool isVectorType() const
void AddAtomicConversionStep(QualType Ty)
Add a new step that performs conversion from non-atomic to atomic type.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
bool HadMultipleCandidates
void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy)
Add a step to pass an object by indirect copy-restore.
SourceLocation getLocStart() const LLVM_READONLY
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, Sema &S)
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
MutableArrayRef< Expr * > MultiExprArg
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getExprLoc() const LLVM_READONLY
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
Pass an object by indirect copy-and-restore.
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.
bool isCStyleCast() const
Determine whether this is a C-style cast.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
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 const Type * getElementType(const Expr *BaseExpr)
Non-constant array initializer.
void setIncompleteTypeFailure(QualType IncompleteType)
Note that this initialization sequence failed due to an incomplete type.
A single step in the initialization sequence.
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
Array must be initialized with an initializer list or a wide string literal.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
Too many initializers provided for a reference.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
static bool hasCompatibleArrayTypes(ASTContext &Context, const ArrayType *Dest, const ArrayType *Source)
Determine whether we have compatible array types for the purposes of GNU by-copy array initialization...
Perform a load from a glvalue, producing an rvalue.
static void checkIndirectCopyRestoreSource(Sema &S, Expr *src)
bool isInvalidDecl() const
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
static bool InitializedEntityOutlivesFullExpression(const InitializedEntity &Entity)
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
bool isAtStartOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the beginning of the immediate macro expansion...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
Array-to-pointer conversion (C++ 4.2)
std::pair< SourceLocation, SourceLocation > getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
chain_iterator chain_end() const
static void TryConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType DestType, InitializationSequence &Sequence, bool IsListInit=false, bool IsInitListCopy=false)
Attempt initialization by constructor (C++ [dcl.init]), which enumerates the constructors of the init...
static bool IsWideCharCompatible(QualType T, ASTContext &Context)
Check whether T is compatible with a wide character type (wchar_t, char16_t or char32_t).
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
std::string getAsString(ASTContext &Ctx, QualType Ty) const
StringKind getKind() const
Requests that only viable candidates be shown.
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
DeclaratorDecl * VariableOrMember
When Kind == EK_Variable, or EK_Member, the VarDecl or FieldDecl, respectively.
unsigned getNumArgs() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static ExprResult CopyObject(Sema &S, QualType T, const InitializedEntity &Entity, ExprResult CurInit, bool IsExtraneousCopy)
Make a (potentially elidable) temporary copy of the object provided by the given initializer by calli...
bool isLValueReferenceType() const
Overloading due to reference initialization failed.
Expr * getArrayIndex() const
unsigned getNumArgs() const
bool isParameterKind() const
void setInitializedFieldInUnion(FieldDecl *FD)
DeclClass * getCorrectionDeclAs() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
bool isRValueReferenceType() const
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase)
Create the initialization entity for a base class subobject.
QualType getNonReferenceType() const
static bool isRValueRef(QualType ParamType)
bool isObjCObjectType() const
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
void setAllToTypes(QualType T)
static bool TryOCLZeroEventInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
SourceManager & getSourceManager() const
SourceLocation getLocEnd() const LLVM_READONLY
QualType getCanonicalType() const
Array must be initialized with an initializer list.
bool isConvertingConstructor(bool AllowExplicit) const
static void emitBadConversionNotes(Sema &S, const InitializedEntity &entity, Expr *op)
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
SourceLocation getFieldLoc() const
[ARC] Produces a retainable object pointer so that it may be consumed, e.g. by being passed to a cons...
Reference binding failed.
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() const
Converts from T to _Atomic(T).
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
DeclContext * getRedeclContext()
CXXConstructorDecl * getConstructor() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
static bool isInvalid(SourceLocation Loc, bool *Invalid)
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category)
Add a new step in the initialization that performs a derived-to- base cast.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
Represents a base class of a C++ class.
const CXXConstructorDecl * getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
static bool TryOCLSamplerInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
QualType getType() const
Retrieve type being initialized.
static OverloadingResult ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, MultiExprArg Args, OverloadCandidateSet &CandidateSet, DeclContext::lookup_result Ctors, OverloadCandidateSet::iterator &Best, bool CopyInitializing, bool AllowExplicit, bool OnlyListConstructors, bool IsListInit)
static SourceLocation getInitializationLoc(const InitializedEntity &Entity, Expr *Initializer)
Get the location at which initialization diagnostics should appear.
bool isDefaultConstructor() const
bool AllowExplicit() const
Retrieve whether this initialization allows the use of explicit constructors.
Reading or writing from this object requires a barrier call.
void AddUserConversionStep(FunctionDecl *Function, DeclAccessPair FoundDecl, QualType T, bool HadMultipleCandidates)
Add a new step invoking a conversion function, which is either a constructor or a conversion function...
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
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...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false)
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
Perform initialization via a constructor, taking arguments from a single InitListExpr.
static ExprValueKind convertQualifiersAndValueKindIfNecessary(Sema &S, InitializationSequence &Sequence, Expr *Initializer, QualType cv1T1, Qualifiers T1Quals, Qualifiers T2Quals, bool IsLValueRef)
bool isObjCObjectPointerType() const
QualType getEncodedType() const
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Expr * getArrayRangeEnd() const
The entity being initialized is 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...
InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList=false)
Try to perform initialization of the given entity, creating a record of the steps required to perform...
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.
bool isImplicitValueInit() const
Determine whether this initialization is an implicit value-initialization, e.g., as occurs during agg...
unsigned allocateManglingNumber() const
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
Defines the clang::TargetInfo interface.
static OverloadingResult TryRefInitWithConversionFunction(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, bool AllowRValues, InitializationSequence &Sequence)
Try a reference initialization that involves calling a conversion function.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Designator * getDesignator(unsigned Idx)
Reference binding to a temporary.
DeclarationName getName() const
Retrieve the name of the entity being initialized.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
static bool isReferenceBinding(const InitializationSequence::Step &s)
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
bool isIncompleteArrayType() const
static Sema::AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
QualType getElementType() const
The initialization is being done by a delegating constructor.
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
void AddQualificationConversionStep(QualType Ty, ExprValueKind Category)
Add a new step that performs a qualification conversion to the given type.
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool OdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool hasQualifiers() const
Determine whether this type has any qualifiers.
SourceManager & SourceMgr
void clear()
Clear out all of the candidates.
bool hasDefaultConstructor() const
Determine whether this class has any default constructors.
ImplicitConversionKind First
const Expr * getInit(unsigned Init) const
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
No viable function found.
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
A failed initialization sequence. The failure kind tells what happened.
bool isFieldDesignator() const
Array initialization (from an array rvalue). This is a GNU C extension.
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
An l-value expression is a reference to an object with independent storage.
Default-initialization of a 'const' object.
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
Add a new step that applies an implicit conversion sequence.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes...
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
Automatic storage duration (most local variables).
bool isSignedIntegerType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
static void DiagnoseNarrowingInInitList(Sema &S, const ImplicitConversionSequence &ICS, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit)
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
Describes an entity that is being initialized.
NamespaceDecl * getStdNamespace() const
unsigned getNumDesignators() const
SourceLocation getFieldLoc() const
static void CheckCXX98CompatAccessibleCopy(Sema &S, const InitializedEntity &Entity, Expr *CurInitExpr)
Check whether elidable copy construction for binding a reference to a temporary would have succeeded ...
Direct list-initialization.
Array initialization from a parenthesized initializer list. This is a GNU C++ extension.
bool isArrayDesignator() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static void MaybeProduceObjCObject(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Declaration of a template function.
Represents an implicitly-generated value initialization of an object of a given type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
static void TryReferenceListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence)
Attempt list initialization of a reference.
static bool maybeRecoverWithZeroInitialization(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Tries to add a zero initializer. Returns true if that worked.
bool hasLocalStorage() const
Non-const lvalue reference binding to a temporary.
Expr * IgnoreParens() LLVM_READONLY
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool hasInClassInitializer() const
bool isPointerType() const
SourceRange getSourceRange() const LLVM_READONLY
static bool isExplicitTemporary(const InitializedEntity &Entity, const InitializationKind &Kind, unsigned NumArgs)