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);
448 diag::note_used_in_initialization_here);
450 SemaRef.
Diag(Loc, diag::note_used_in_initialization_here);
457 InitSeq.Diagnose(SemaRef, Entity, Kind, SubInit);
460 diag::note_in_omitted_aggregate_initializer)
463 SemaRef.
Diag(Loc, diag::note_in_omitted_aggregate_initializer)
469 return VerifyOnly ?
ExprResult(static_cast<Expr *>(
nullptr))
470 : InitSeq.Perform(SemaRef, Entity, Kind, SubInit);
476 "CheckEmptyInitializable is only inteded for verification mode.");
477 if (PerformEmptyInit(SemaRef, Loc, Entity,
true).
isInvalid())
481 void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
484 bool &RequiresSecondPass,
485 bool FillWithNoInit) {
492 if (!RType->getDecl()->isUnion())
493 assert(Init < NumInits &&
"This ILE should have been expanded");
495 if (Init >= NumInits || !ILE->
getInit(Init)) {
496 if (FillWithNoInit) {
518 RequiresSecondPass =
true;
528 SemaRef.
Diag(Loc, diag::err_init_reference_member_uninitialized)
532 diag::note_uninit_reference_member);
537 ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
546 }
else if (Init < NumInits) {
548 }
else if (!isa<ImplicitValueInitExpr>(MemberInit.
get())) {
554 RequiresSecondPass =
true;
557 = dyn_cast<InitListExpr>(ILE->
getInit(Init)))
558 FillInEmptyInitializations(MemberEntity, InnerILE,
559 RequiresSecondPass, FillWithNoInit);
561 = dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(Init)))
562 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
563 RequiresSecondPass,
true);
572 bool &RequiresSecondPass,
573 bool FillWithNoInit) {
575 "Should not have void type");
581 Entity, ILE, RequiresSecondPass, FillWithNoInit);
582 else if (RDecl->
isUnion() && isa<CXXRecordDecl>(RDecl) &&
583 cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) {
584 for (
auto *Field : RDecl->
fields()) {
586 FillInEmptyInitForField(0, Field, Entity, ILE, RequiresSecondPass,
595 unsigned NumFields = 0;
596 for (
auto *Field : RDecl->
fields())
599 if (ILE->getNumInits() < NumFields)
600 ILE->resizeInits(SemaRef.
Context, NumFields);
603 for (
auto *Field : RDecl->
fields()) {
610 FillInEmptyInitForField(Init, Field, Entity, ILE, RequiresSecondPass,
629 unsigned NumInits = ILE->getNumInits();
630 unsigned NumElements = NumInits;
632 ElementType = AType->getElementType();
634 NumElements = CAType->getSize().getZExtValue();
638 ElementType = VType->getElementType();
639 NumElements = VType->getNumElements();
643 ElementType = ILE->getType();
645 for (
unsigned Init = 0; Init != NumElements; ++Init) {
653 Expr *InitExpr = (Init < NumInits ? ILE->getInit(Init) :
nullptr);
654 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
655 ILE->setInit(Init, ILE->getArrayFiller());
656 else if (!InitExpr && !ILE->hasArrayFiller()) {
657 Expr *Filler =
nullptr;
662 ExprResult ElementInit = PerformEmptyInit(SemaRef, ILE->getLocEnd(),
675 }
else if (Init < NumInits) {
679 ILE->setArrayFiller(Filler);
681 ILE->setInit(Init, Filler);
686 ILE->setArrayFiller(Filler);
690 if (!isa<ImplicitValueInitExpr>(Filler) && !isa<NoInitExpr>(Filler)) {
695 ILE->updateInit(SemaRef.
Context, Init, Filler);
696 RequiresSecondPass =
true;
700 = dyn_cast_or_null<InitListExpr>(InitExpr))
701 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
704 = dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr))
705 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
706 RequiresSecondPass,
true);
714 : SemaRef(S), VerifyOnly(VerifyOnly) {
720 FullyStructuredList =
721 getStructuredSubobjectInit(IL, 0, T,
nullptr, 0, IL->getSourceRange());
722 CheckExplicitInitList(Entity, IL, T, FullyStructuredList,
725 if (!hadError && !VerifyOnly) {
726 bool RequiresSecondPass =
false;
727 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass);
728 if (RequiresSecondPass && !hadError)
729 FillInEmptyInitializations(Entity, FullyStructuredList,
734 int InitListChecker::numArrayElements(
QualType DeclType) {
736 int maxElements = 0x7FFFFFFF;
739 maxElements =
static_cast<int>(CAT->getSize().getZExtValue());
744 int InitListChecker::numStructUnionElements(
QualType DeclType) {
746 int InitializableMembers = 0;
747 for (
const auto *Field : structDecl->
fields())
749 ++InitializableMembers;
752 return std::min(InitializableMembers, 1);
766 unsigned &StructuredIndex) {
770 maxElements = numArrayElements(T);
772 maxElements = numStructUnionElements(T);
776 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
778 if (maxElements == 0) {
780 SemaRef.
Diag(ParentIList->
getInit(Index)->getLocStart(),
781 diag::err_implicit_empty_initializer);
789 = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList,
792 ParentIList->getSourceRange().getEnd()));
793 unsigned StructuredSubobjectInitIndex = 0;
796 unsigned StartIndex = Index;
797 CheckListElementTypes(Entity, ParentIList, T,
799 StructuredSubobjectInitList,
800 StructuredSubobjectInitIndex);
803 StructuredSubobjectInitList->
setType(T);
805 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
808 if (EndIndex < ParentIList->getNumInits() &&
809 ParentIList->
getInit(EndIndex)) {
811 = ParentIList->
getInit(EndIndex)->getSourceRange().getEnd();
818 diag::warn_missing_braces)
819 << StructuredSubobjectInitList->getSourceRange()
820 << FixItHint::CreateInsertion(
822 << FixItHint::CreateInsertion(
824 StructuredSubobjectInitList->
getLocEnd()),
843 case InitializedEntity::EK_VectorElement:
844 case InitializedEntity::EK_ComplexElement:
845 case InitializedEntity::EK_ArrayElement:
846 case InitializedEntity::EK_Parameter:
847 case InitializedEntity::EK_Parameter_CF_Audited:
848 case InitializedEntity::EK_Result:
850 DiagID = diag::warn_braces_around_scalar_init;
853 case InitializedEntity::EK_Member:
857 DiagID = diag::warn_braces_around_scalar_init;
860 case InitializedEntity::EK_Variable:
861 case InitializedEntity::EK_LambdaCapture:
866 case InitializedEntity::EK_New:
867 case InitializedEntity::EK_Temporary:
868 case InitializedEntity::EK_CompoundLiteralInit:
872 case InitializedEntity::EK_RelatedResult:
876 case InitializedEntity::EK_Exception:
877 case InitializedEntity::EK_Base:
878 case InitializedEntity::EK_Delegating:
879 case InitializedEntity::EK_BlockElement:
880 llvm_unreachable(
"unexpected braced scalar init");
886 << FixItHint::CreateRemoval(Braces.
getBegin())
887 << FixItHint::CreateRemoval(Braces.
getEnd());
900 bool TopLevelObject) {
902 SyntacticToSemantic[IList] = StructuredList;
906 unsigned Index = 0, StructuredIndex = 0;
907 CheckListElementTypes(Entity, IList, T,
true,
908 Index, StructuredList, StructuredIndex, TopLevelObject);
914 StructuredList->
setType(ExprTy);
919 if (Index < IList->getNumInits()) {
930 if (StructuredIndex == 1 &&
933 unsigned DK = diag::ext_excess_initializers_in_char_array_initializer;
935 DK = diag::err_excess_initializers_in_char_array_initializer;
939 SemaRef.
Diag(IList->
getInit(Index)->getLocStart(), DK)
940 << IList->
getInit(Index)->getSourceRange();
952 unsigned DK = diag::ext_excess_initializers;
954 DK = diag::err_excess_initializers;
957 if (SemaRef.
getLangOpts().OpenCL && initKind == 1) {
958 DK = diag::err_excess_initializers;
962 SemaRef.
Diag(IList->
getInit(Index)->getLocStart(), DK)
963 << initKind << IList->
getInit(Index)->getSourceRange();
975 bool SubobjectIsDesignatorContext,
978 unsigned &StructuredIndex,
979 bool TopLevelObject) {
983 CheckComplexType(Entity, IList, DeclType, Index,
984 StructuredList, StructuredIndex);
986 CheckScalarType(Entity, IList, DeclType, Index,
987 StructuredList, StructuredIndex);
989 CheckVectorType(Entity, IList, DeclType, Index,
990 StructuredList, StructuredIndex);
993 "non-aggregate records should be handed in CheckSubElementType");
995 CheckStructUnionTypes(Entity, IList, DeclType, RD->field_begin(),
996 SubobjectIsDesignatorContext, Index,
997 StructuredList, StructuredIndex,
1003 CheckArrayType(Entity, IList, DeclType, Zero,
1004 SubobjectIsDesignatorContext, Index,
1005 StructuredList, StructuredIndex);
1010 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1014 CheckReferenceType(Entity, IList, DeclType, Index,
1015 StructuredList, StructuredIndex);
1023 SemaRef.
Diag(IList->
getLocStart(), diag::err_illegal_initializer_type)
1034 unsigned &StructuredIndex) {
1038 return CheckReferenceType(Entity, IList, ElemType, Index,
1039 StructuredList, StructuredIndex);
1041 if (
InitListExpr *SubInitList = dyn_cast<InitListExpr>(expr)) {
1042 if (SubInitList->getNumInits() == 1 &&
1045 expr = SubInitList->getInit(0);
1048 = getStructuredSubobjectInit(IList, Index, ElemType,
1049 StructuredList, StructuredIndex,
1050 SubInitList->getSourceRange(),
true);
1051 CheckExplicitInitList(Entity, SubInitList, ElemType,
1052 InnerStructuredList);
1054 if (!hadError && !VerifyOnly) {
1055 bool RequiresSecondPass =
false;
1056 FillInEmptyInitializations(Entity, InnerStructuredList,
1057 RequiresSecondPass);
1058 if (RequiresSecondPass && !hadError)
1059 FillInEmptyInitializations(Entity, InnerStructuredList,
1060 RequiresSecondPass);
1067 }
else if (isa<ImplicitValueInitExpr>(expr)) {
1071 "found implicit initialization for the wrong type");
1073 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1085 InitializationKind::CreateCopy(expr->getLocStart(),
SourceLocation());
1095 if (Seq || isa<InitListExpr>(expr)) {
1098 Seq.Perform(SemaRef, Entity, Kind, expr);
1102 UpdateStructuredListElement(StructuredList, StructuredIndex,
1113 return CheckScalarType(Entity, IList, ElemType, Index,
1114 StructuredList, StructuredIndex);
1124 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1146 ElemType, ExprRes, !VerifyOnly) != Sema::Incompatible) {
1154 UpdateStructuredListElement(StructuredList, StructuredIndex,
1171 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1191 unsigned &StructuredIndex) {
1192 assert(Index == 0 &&
"Index in explicit init list must be zero");
1202 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1207 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1209 << IList->getSourceRange();
1214 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1216 for (
unsigned i = 0; i < 2; ++i) {
1218 CheckSubElementType(ElementEntity, IList, elementType, Index,
1219 StructuredList, StructuredIndex);
1228 unsigned &StructuredIndex) {
1233 diag::warn_cxx98_compat_empty_scalar_initializer :
1234 diag::err_empty_scalar_initializer)
1235 << IList->getSourceRange();
1243 if (
InitListExpr *SubIList = dyn_cast<InitListExpr>(expr)) {
1247 SemaRef.
Diag(SubIList->getLocStart(),
1248 diag::ext_many_braces_around_scalar_init)
1249 << SubIList->getSourceRange();
1251 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1254 }
else if (isa<DesignatedInitExpr>(expr)) {
1256 SemaRef.
Diag(expr->getLocStart(),
1257 diag::err_designator_for_scalar_init)
1258 << DeclType << expr->getSourceRange();
1276 Expr *ResultExpr =
nullptr;
1283 if (ResultExpr != expr) {
1285 IList->
setInit(Index, ResultExpr);
1291 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1299 unsigned &StructuredIndex) {
1307 diag::err_init_reference_member_uninitialized)
1309 << IList->getSourceRange();
1317 if (isa<InitListExpr>(expr) && !SemaRef.
getLangOpts().CPlusPlus11) {
1320 << DeclType << IList->getSourceRange();
1347 UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
1355 unsigned &StructuredIndex) {
1358 unsigned numEltsInit = 0;
1364 CheckEmptyInitializable(
1365 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity),
1386 Expr *ResultExpr =
nullptr;
1392 if (ResultExpr != Init) {
1394 IList->
setInit(Index, ResultExpr);
1400 UpdateStructuredListElement(StructuredList, StructuredIndex,
1407 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1409 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1413 CheckEmptyInitializable(ElementEntity, IList->
getLocEnd());
1418 CheckSubElementType(ElementEntity, IList, elementType, Index,
1419 StructuredList, StructuredIndex);
1427 if (isBigEndian && (T->
getVectorKind() == VectorType::NeonVector ||
1440 diag::warn_neon_vector_initializer_non_portable);
1442 const char *typeCode;
1452 llvm_unreachable(
"Invalid element type!");
1456 diag::note_neon_vector_initializer_non_portable_q :
1457 diag::note_neon_vector_initializer_non_portable)
1458 << typeCode << typeSize;
1465 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
1468 for (
unsigned i = 0; i < maxElements; ++i) {
1477 CheckSubElementType(ElementEntity, IList, elementType, Index,
1478 StructuredList, StructuredIndex);
1490 CheckSubElementType(ElementEntity, IList, VecType, Index,
1491 StructuredList, StructuredIndex);
1492 numEltsInit += numIElts;
1497 if (numEltsInit != maxElements) {
1500 diag::err_vector_incorrect_num_initializers)
1501 << (numEltsInit < maxElements) << maxElements << numEltsInit;
1508 llvm::APSInt elementIndex,
1509 bool SubobjectIsDesignatorContext,
1512 unsigned &StructuredIndex) {
1516 if (Index < IList->getNumInits()) {
1526 UpdateStructuredListElement(StructuredList, StructuredIndex,
1539 SemaRef.
Diag(VAT->getSizeExpr()->getLocStart(),
1540 diag::err_variable_object_no_init)
1541 << VAT->getSizeExpr()->getSourceRange();
1549 llvm::APSInt maxElements(elementIndex.getBitWidth(),
1550 elementIndex.isUnsigned());
1551 bool maxElementsKnown =
false;
1553 maxElements = CAT->getSize();
1554 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
1555 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1556 maxElementsKnown =
true;
1560 while (Index < IList->getNumInits()) {
1566 if (!SubobjectIsDesignatorContext)
1571 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1572 DeclType,
nullptr, &elementIndex, Index,
1573 StructuredList, StructuredIndex,
true,
1579 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
1580 maxElements = maxElements.extend(elementIndex.getBitWidth());
1581 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
1582 elementIndex = elementIndex.extend(maxElements.getBitWidth());
1583 elementIndex.setIsUnsigned(maxElements.isUnsigned());
1587 if (!maxElementsKnown && elementIndex > maxElements)
1588 maxElements = elementIndex;
1595 if (maxElementsKnown && elementIndex == maxElements)
1599 InitializedEntity::InitializeElement(SemaRef.
Context, StructuredIndex,
1602 CheckSubElementType(ElementEntity, IList, elementType, Index,
1603 StructuredList, StructuredIndex);
1608 if (!maxElementsKnown && elementIndex > maxElements)
1609 maxElements = elementIndex;
1614 llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
1615 if (maxElements == Zero) {
1619 diag::ext_typecheck_zero_array_size);
1623 ArrayType::Normal, 0);
1625 if (!hadError && VerifyOnly) {
1629 if (maxElementsKnown && elementIndex < maxElements)
1630 CheckEmptyInitializable(InitializedEntity::InitializeElement(
1639 bool TopLevelObject) {
1641 unsigned FlexArrayDiag;
1642 if (isa<InitListExpr>(InitExpr) &&
1643 cast<InitListExpr>(InitExpr)->getNumInits() == 0) {
1645 FlexArrayDiag = diag::ext_flexible_array_init;
1649 FlexArrayDiag = diag::err_flexible_array_init;
1650 }
else if (!TopLevelObject) {
1652 FlexArrayDiag = diag::err_flexible_array_init;
1653 }
else if (Entity.
getKind() != InitializedEntity::EK_Variable) {
1655 FlexArrayDiag = diag::err_flexible_array_init;
1656 }
else if (cast<VarDecl>(Entity.
getDecl())->hasLocalStorage()) {
1658 FlexArrayDiag = diag::err_flexible_array_init;
1661 FlexArrayDiag = diag::ext_flexible_array_init;
1665 SemaRef.
Diag(InitExpr->getLocStart(),
1667 << InitExpr->getLocStart();
1672 return FlexArrayDiag != diag::ext_flexible_array_init;
1679 bool SubobjectIsDesignatorContext,
1682 unsigned &StructuredIndex,
1683 bool TopLevelObject) {
1699 if (isa<CXXRecordDecl>(RD) && cast<CXXRecordDecl>(RD)->hasInClassInitializer()) {
1703 Field != FieldEnd; ++Field) {
1704 if (Field->hasInClassInitializer()) {
1715 Field != FieldEnd; ++Field) {
1716 if (!Field->isUnnamedBitfield()) {
1718 CheckEmptyInitializable(
1719 InitializedEntity::InitializeMember(*Field, &Entity),
1735 bool InitializedSomething =
false;
1736 bool CheckForMissingFields =
true;
1737 while (Index < IList->getNumInits()) {
1744 if (!SubobjectIsDesignatorContext)
1749 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
1750 DeclType, &Field,
nullptr, Index,
1751 StructuredList, StructuredIndex,
1752 true, TopLevelObject))
1755 InitializedSomething =
true;
1759 CheckForMissingFields =
false;
1763 if (Field == FieldEnd) {
1769 if (InitializedSomething && DeclType->
isUnionType())
1773 if (Field->getType()->isIncompleteArrayType())
1776 if (Field->isUnnamedBitfield()) {
1788 IList->
getInit(Index)->getLocStart());
1797 InitializedEntity::InitializeMember(*Field, &Entity);
1798 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1799 StructuredList, StructuredIndex);
1800 InitializedSomething =
true;
1804 StructuredList->setInitializedFieldInUnion(*Field);
1811 if (!VerifyOnly && InitializedSomething && CheckForMissingFields &&
1812 Field != FieldEnd && !Field->getType()->isIncompleteArrayType() &&
1818 if (!it->isUnnamedBitfield() && !it->hasInClassInitializer()) {
1819 SemaRef.
Diag(IList->getSourceRange().getEnd(),
1820 diag::warn_missing_field_initializers) << *it;
1827 if (VerifyOnly && Field != FieldEnd && !DeclType->
isUnionType() &&
1828 !Field->getType()->isIncompleteArrayType()) {
1830 for (; Field != FieldEnd && !hadError; ++Field) {
1831 if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
1832 CheckEmptyInitializable(
1833 InitializedEntity::InitializeMember(*Field, &Entity),
1838 if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
1842 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
1850 InitializedEntity::InitializeMember(*Field, &Entity);
1852 if (isa<InitListExpr>(IList->
getInit(Index)))
1853 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
1854 StructuredList, StructuredIndex);
1856 CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index,
1857 StructuredList, StructuredIndex);
1873 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
1881 assert(isa<FieldDecl>(*PI));
1882 Replacements.back().setField(cast<FieldDecl>(*PI));
1889 &Replacements[0] + Replacements.size());
1896 for (
unsigned I = 0;
I < NumIndexExprs; ++
I)
1899 DIE->
size(), IndexExprs,
1910 explicit FieldInitializerValidatorCCC(
RecordDecl *RD)
1966 llvm::APSInt *NextElementIndex,
1969 unsigned &StructuredIndex,
1970 bool FinishSubobjectInit,
1971 bool TopLevelObject) {
1972 if (DesigIdx == DIE->
size()) {
1974 bool prevHadError = hadError;
1979 unsigned OldIndex = Index;
1982 CheckSubElementType(Entity, IList, CurrentObjectType, Index,
1983 StructuredList, StructuredIndex);
1989 IList->
setInit(OldIndex, DIE);
1991 return hadError && !prevHadError;
1995 bool IsFirstDesignator = (DesigIdx == 0);
1997 assert((IsFirstDesignator || StructuredList) &&
1998 "Need a non-designated initializer list to start from");
2002 if (IsFirstDesignator)
2003 StructuredList = SyntacticToSemantic.lookup(IList);
2005 Expr *ExistingInit = StructuredIndex < StructuredList->
getNumInits() ?
2006 StructuredList->
getInit(StructuredIndex) :
nullptr;
2012 getStructuredSubobjectInit(IList, Index, CurrentObjectType,
2013 StructuredList, StructuredIndex,
2016 else if (
InitListExpr *Result = dyn_cast<InitListExpr>(ExistingInit))
2017 StructuredList = Result;
2020 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2021 StructuredList =
E->getUpdater();
2039 if (ExistingInit->getSourceRange().isValid()) {
2052 diag::warn_subobject_initializer_overrides)
2055 SemaRef.
Diag(ExistingInit->getLocStart(),
2056 diag::note_previous_initializer)
2058 << ExistingInit->getSourceRange();
2062 assert(StructuredList &&
"Expected a structured initializer list");
2081 SemaRef.
Diag(Loc, diag::err_field_designator_non_aggr)
2082 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2092 if (
auto *FD = dyn_cast<FieldDecl>(ND)) {
2096 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND)) {
2102 KnownField = cast<FieldDecl>(*IFD->chain_begin());
2113 if (!Lookup.empty()) {
2116 SemaRef.
Diag(Lookup.front()->getLocation(),
2117 diag::note_field_designator_found);
2126 Sema::LookupMemberName,
nullptr,
nullptr,
2127 llvm::make_unique<FieldInitializerValidatorCCC>(RT->
getDecl()),
2128 Sema::CTK_ErrorRecovery, RT->
getDecl())) {
2131 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2132 << FieldName << CurrentObjectType);
2133 KnownField = Corrected.getCorrectionDeclAs<
FieldDecl>();
2138 << FieldName << CurrentObjectType;
2145 unsigned FieldIndex = 0;
2147 if (FI->isUnnamedBitfield())
2149 if (KnownField == FI)
2163 if (CurrentField && CurrentField != *Field) {
2165 &&
"A union should never have more than one initializer!");
2169 diag::warn_initializer_overrides)
2172 SemaRef.
Diag(ExistingInit->getLocStart(),
2173 diag::note_previous_initializer)
2175 << ExistingInit->getSourceRange();
2208 if (Field->getType()->isIncompleteArrayType()) {
2210 if ((DesigIdx + 1) != DIE->
size()) {
2217 diag::err_designator_into_flexible_array_member)
2220 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2226 if (!hadError && !isa<InitListExpr>(DIE->
getInit()) &&
2227 !isa<StringLiteral>(DIE->
getInit())) {
2231 diag::err_flexible_array_init_needs_braces)
2232 << DIE->
getInit()->getSourceRange();
2233 SemaRef.
Diag(Field->getLocation(), diag::note_flexible_array_member)
2240 if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
2250 bool prevHadError = hadError;
2251 unsigned newStructuredIndex = FieldIndex;
2252 unsigned OldIndex = Index;
2256 InitializedEntity::InitializeMember(*Field, &Entity);
2257 CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
2258 StructuredList, newStructuredIndex);
2260 IList->
setInit(OldIndex, DIE);
2261 if (hadError && !prevHadError) {
2266 StructuredIndex = FieldIndex;
2271 QualType FieldType = Field->getType();
2272 unsigned newStructuredIndex = FieldIndex;
2275 InitializedEntity::InitializeMember(*Field, &Entity);
2276 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
2277 FieldType,
nullptr,
nullptr, Index,
2278 StructuredList, newStructuredIndex,
2290 if (IsFirstDesignator) {
2293 StructuredIndex = FieldIndex;
2297 if (!FinishSubobjectInit)
2305 bool prevHadError = hadError;
2307 CheckStructUnionTypes(Entity, IList, CurrentObjectType, Field,
false, Index,
2308 StructuredList, FieldIndex);
2309 return hadError && !prevHadError;
2331 << CurrentObjectType;
2336 Expr *IndexExpr =
nullptr;
2337 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
2341 DesignatedEndIndex = DesignatedStartIndex;
2345 DesignatedStartIndex =
2347 DesignatedEndIndex =
2356 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
2358 FullyStructuredList->sawArrayRangeDesignator();
2361 if (isa<ConstantArrayType>(AT)) {
2362 llvm::APSInt MaxElements(cast<ConstantArrayType>(AT)->getSize(),
false);
2363 DesignatedStartIndex
2364 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
2365 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
2367 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
2368 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
2369 if (DesignatedEndIndex >= MaxElements) {
2371 SemaRef.
Diag(IndexExpr->getLocStart(),
2372 diag::err_array_designator_too_large)
2373 << DesignatedEndIndex.toString(10) << MaxElements.toString(10)
2374 << IndexExpr->getSourceRange();
2379 unsigned DesignatedIndexBitWidth =
2380 ConstantArrayType::getMaxSizeBits(SemaRef.
Context);
2381 DesignatedStartIndex =
2382 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
2383 DesignatedEndIndex =
2384 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
2385 DesignatedStartIndex.setIsUnsigned(
true);
2386 DesignatedEndIndex.setIsUnsigned(
true);
2389 if (!VerifyOnly && StructuredList->isStringLiteralInit()) {
2402 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
2406 uint64_t StrLen = SL->getLength();
2407 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2408 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2409 StructuredList->resizeInits(Context, StrLen);
2413 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2414 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
2416 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2417 if (CharTy != PromotedCharTy)
2420 StructuredList->updateInit(Context, i, Init);
2428 uint64_t StrLen = Str.size();
2429 if (cast<ConstantArrayType>(AT)->getSize().ult(StrLen))
2430 StrLen = cast<ConstantArrayType>(AT)->getSize().getZExtValue();
2431 StructuredList->resizeInits(Context, StrLen);
2435 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
2436 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
2438 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
2439 if (CharTy != PromotedCharTy)
2442 StructuredList->updateInit(Context, i, Init);
2450 DesignatedEndIndex.getZExtValue() >= StructuredList->getNumInits())
2451 StructuredList->resizeInits(SemaRef.
Context,
2452 DesignatedEndIndex.getZExtValue() + 1);
2458 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
2459 unsigned OldIndex = Index;
2462 InitializedEntity::InitializeElement(SemaRef.
Context, 0, Entity);
2464 while (DesignatedStartIndex <= DesignatedEndIndex) {
2470 if (CheckDesignatedInitializer(ElementEntity, IList, DIE, DesigIdx + 1,
2471 ElementType,
nullptr,
nullptr, Index,
2472 StructuredList, ElementIndex,
2473 (DesignatedStartIndex == DesignatedEndIndex),
2478 ++DesignatedStartIndex;
2479 ElementIndex = DesignatedStartIndex.getZExtValue();
2484 if (IsFirstDesignator) {
2485 if (NextElementIndex)
2486 *NextElementIndex = DesignatedStartIndex;
2487 StructuredIndex = ElementIndex;
2491 if (!FinishSubobjectInit)
2495 bool prevHadError = hadError;
2496 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
2498 StructuredList, ElementIndex);
2499 return hadError && !prevHadError;
2505 InitListChecker::getStructuredSubobjectInit(
InitListExpr *IList,
unsigned Index,
2508 unsigned StructuredIndex,
2510 bool IsFullyOverwritten) {
2513 Expr *ExistingInit =
nullptr;
2514 if (!StructuredList)
2515 ExistingInit = SyntacticToSemantic.lookup(IList);
2516 else if (StructuredIndex < StructuredList->getNumInits())
2517 ExistingInit = StructuredList->
getInit(StructuredIndex);
2519 if (
InitListExpr *Result = dyn_cast_or_null<InitListExpr>(ExistingInit))
2528 if (!IsFullyOverwritten)
2544 diag::warn_subobject_initializer_overrides)
2546 SemaRef.
Diag(ExistingInit->getLocStart(),
2547 diag::note_previous_initializer)
2549 << ExistingInit->getSourceRange();
2557 QualType ResultType = CurrentObjectType;
2563 unsigned NumElements = 0;
2564 unsigned NumInits = 0;
2565 bool GotNumInits =
false;
2566 if (!StructuredList) {
2569 }
else if (Index < IList->getNumInits()) {
2571 NumInits = SubList->getNumInits();
2579 NumElements = CAType->getSize().getZExtValue();
2582 if (GotNumInits && NumElements > NumInits)
2586 NumElements = VType->getNumElements();
2603 SyntacticToSemantic[IList] = Result;
2611 void InitListChecker::UpdateStructuredListElement(
InitListExpr *StructuredList,
2612 unsigned &StructuredIndex,
2615 if (!StructuredList)
2619 StructuredIndex, expr)) {
2627 if (PrevInit->getSourceRange().isValid()) {
2628 SemaRef.
Diag(expr->getLocStart(),
2629 diag::warn_initializer_overrides)
2630 << expr->getSourceRange();
2632 SemaRef.
Diag(PrevInit->getLocStart(),
2633 diag::note_previous_initializer)
2635 << PrevInit->getSourceRange();
2658 if (Value.isSigned() && Value.isNegative())
2659 return S.
Diag(Loc, diag::err_array_designator_negative)
2660 << Value.toString(10) << Index->getSourceRange();
2662 Value.setIsUnsigned(
true);
2672 bool Invalid =
false;
2687 llvm::APSInt IndexValue;
2693 Designators.push_back(ASTDesignator(InitExpressions.size(),
2696 InitExpressions.push_back(Index);
2704 llvm::APSInt StartValue;
2705 llvm::APSInt EndValue;
2710 if (!StartDependent)
2716 if (!StartIndex || !EndIndex)
2720 if (StartDependent || EndDependent) {
2722 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
2723 EndValue = EndValue.extend(StartValue.getBitWidth());
2724 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
2725 StartValue = StartValue.extend(EndValue.getBitWidth());
2727 if (!StartDependent && !EndDependent && EndValue < StartValue) {
2729 << StartValue.toString(10) << EndValue.toString(10)
2730 << StartIndex->getSourceRange() << EndIndex->getSourceRange();
2733 Designators.push_back(ASTDesignator(InitExpressions.size(),
2737 InitExpressions.push_back(StartIndex);
2738 InitExpressions.push_back(EndIndex);
2754 Designators.data(), Designators.size(),
2755 InitExpressions, Loc, GNUSyntax,
2760 << DIE->getSourceRange();
2769 InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
2771 : Parent(&Parent), Index(Index)
2774 Kind = EK_ArrayElement;
2777 Kind = EK_VectorElement;
2781 assert(CT &&
"Unexpected type");
2782 Kind = EK_ComplexElement;
2790 bool IsInheritedVirtualBase) {
2793 Result.Parent =
nullptr;
2794 Result.
Base =
reinterpret_cast<uintptr_t
>(
Base);
2795 if (IsInheritedVirtualBase)
2796 Result.
Base |= 0x01;
2798 Result.Type = Base->
getType();
2832 llvm_unreachable(
"Invalid EntityKind!");
2861 llvm_unreachable(
"Invalid EntityKind!");
2891 unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
2894 for (
unsigned I = 0;
I !=
Depth; ++
I)
2905 case EK_New: OS <<
"New";
break;
2909 case EK_Base: OS <<
"Base";
break;
2916 OS <<
"LambdaCapture ";
2923 cast<NamedDecl>(D)->printQualifiedName(OS);
2932 dumpImpl(llvm::errs());
3025 llvm_unreachable(
"Invalid EntityKind!");
3036 bool HadMultipleCandidates) {
3059 bool BindingTemporary) {
3077 bool HadMultipleCandidates) {
3114 assert(!Ty.
hasQualifiers() &&
"rvalues may not have qualifiers");
3124 bool TopLevelOfInitList) {
3145 bool HadMultipleCandidates,
3146 bool FromInitList,
bool AsInitList) {
3240 "Can only rewrap trivial init lists.");
3244 Steps.insert(Steps.begin(),
S);
3248 S.WrappingSyntacticList = Syntactic;
3255 this->Failure = Failure;
3256 this->FailedOverloadResult =
Result;
3277 if (!Init.empty()) {
3297 "consuming an object of unretainable type?");
3357 bool CopyInitializing,
bool AllowExplicit,
3358 bool OnlyListConstructors,
bool IsListInit) {
3359 CandidateSet.
clear();
3363 bool SuppressUserConversions =
false;
3368 if (ConstructorTmpl)
3369 Constructor = cast<CXXConstructorDecl>(
3372 Constructor = cast<CXXConstructorDecl>(D);
3388 if ((CopyInitializing ||
3389 (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3391 SuppressUserConversions =
true;
3395 (AllowExplicit || !Constructor->
isExplicit()) &&
3397 if (ConstructorTmpl)
3400 CandidateSet, SuppressUserConversions);
3408 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
3412 SuppressUserConversions,
3435 bool IsListInit =
false,
3436 bool IsInitListCopy =
false) {
3437 assert((!IsListInit || (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
3438 "IsListInit must come with a single initializer list argument.");
3447 assert(DestRecordType &&
"Constructor initialization requires record type");
3449 = cast<CXXRecordDecl>(DestRecordType->
getDecl());
3467 bool AsInitializerList =
false;
3480 AsInitializerList =
true;
3486 CandidateSet, Ctors, Best,
3487 CopyInitialization, AllowExplicit,
3501 AsInitializerList =
false;
3503 CandidateSet, Ctors, Best,
3504 CopyInitialization, AllowExplicit,
3522 !cast<CXXConstructorDecl>(Best->Function)->isUserProvided()) {
3539 bool HadMultipleCandidates = (CandidateSet.size() > 1);
3541 CtorDecl, Best->FoundDecl.
getAccess(), DestType, HadMultipleCandidates,
3542 IsListInit | IsInitListCopy, AsInitializerList);
3555 bool HadMultipleCandidates =
false;
3558 UnqualifiedTargetType,
3560 &HadMultipleCandidates)) {
3562 HadMultipleCandidates);
3563 SourceType = Fn->getType();
3629 bool dummy1, dummy2, dummy3;
3636 T1Quals, cv2T2, T2, T2Quals, Sequence);
3712 if (!isa<VariableArrayType>(DestAT) &&
3757 Expr *InitListAsExpr = InitList;
3795 InitListChecker CheckInitList(S, Entity, InitList,
3797 if (CheckInitList.HadError()) {
3821 bool ObjCConversion;
3822 bool ObjCLifetimeConversion;
3824 T1, T2, DerivedToBase,
3826 ObjCLifetimeConversion) &&
3827 "Must have incompatible references when binding via conversion");
3828 (void)DerivedToBase;
3829 (void)ObjCConversion;
3830 (void)ObjCLifetimeConversion;
3835 CandidateSet.
clear();
3855 if (ConstructorTmpl)
3856 Constructor = cast<CXXConstructorDecl>(
3859 Constructor = cast<CXXConstructorDecl>(D);
3861 if (!Constructor->isInvalidDecl() &&
3862 Constructor->isConvertingConstructor(AllowExplicit)) {
3863 if (ConstructorTmpl)
3866 Initializer, CandidateSet,
3870 Initializer, CandidateSet,
3886 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
3889 if (isa<UsingShadowDecl>(D))
3890 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3897 Conv = cast<CXXConversionDecl>(D);
3905 if ((AllowExplicitConvs || !Conv->isExplicit()) &&
3906 (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){
3909 ActingDC, Initializer,
3910 DestType, CandidateSet,
3915 Initializer, DestType, CandidateSet,
3937 if (isa<CXXConversionDecl>(Function))
3943 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3945 T2.getNonLValueExprType(S.
Context),
3946 HadMultipleCandidates);
3951 if (T2->isLValueReferenceType())
3956 bool NewDerivedToBase =
false;
3957 bool NewObjCConversion =
false;
3958 bool NewObjCLifetimeConversion =
false;
3962 NewDerivedToBase, NewObjCConversion,
3963 NewObjCLifetimeConversion);
3971 ICS.
Standard = Best->FinalConversion;
3974 }
else if (NewDerivedToBase)
3979 else if (NewObjCConversion)
3984 if (cv1T1.
getQualifiers() != T2.getNonReferenceType().getQualifiers())
4018 T1Quals, cv2T2, T2, T2Quals, Sequence);
4046 if (IsNonAddressableType) {
4063 if (T1Quals != T2Quals) {
4087 bool DerivedToBase =
false;
4088 bool ObjCConversion =
false;
4089 bool ObjCLifetimeConversion =
false;
4093 ObjCConversion, ObjCLifetimeConversion);
4106 if (isLValueRef || T1Function) {
4123 else if (ObjCConversion)
4129 cv1T1, T1Quals, T2Quals,
4144 (isLValueRef || InitCategory.
isRValue())) {
4146 S, Entity, Kind, Initializer, isRValueRef, Sequence);
4207 else if (ObjCConversion)
4229 S, Entity, Kind, Initializer,
true, Sequence);
4240 isRValueRef && InitCategory.
isLValue()) {
4291 (T1CVRQuals | T2CVRQuals) != T1CVRQuals) {
4325 assert((!InitList || InitList->
getNumInits() == 0) &&
4326 "Shouldn't use value-init for non-empty init lists");
4338 bool NeedZeroInitialization =
true;
4345 if (ClassDecl->hasUserDeclaredConstructor())
4346 NeedZeroInitialization =
false;
4354 NeedZeroInitialization =
false;
4363 if (NeedZeroInitialization)
4377 ClassDecl->hasUninitializedReferenceMember()) {
4385 Expr *InitListAsExpr = InitList;
4387 bool InitListSyntax = InitList;
4412 if (DestType->isRecordType() && S.
getLangOpts().CPlusPlus) {
4422 if (DestType.isConstQualified() && S.
getLangOpts().CPlusPlus) {
4429 if (DestType.getQualifiers().hasObjCLifetime()) {
4443 bool TopLevelOfInitList) {
4444 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
4446 assert((DestType->
isRecordType() || SourceType->isRecordType()) &&
4447 "Must have a class type to perform a user-defined conversion");
4452 CandidateSet.
clear();
4462 = cast<CXXRecordDecl>(DestRecordType->getDecl());
4472 Con = CopyOfCon.begin(), ConEnd = CopyOfCon.end();
4473 Con != ConEnd; ++Con) {
4481 if (ConstructorTmpl)
4482 Constructor = cast<CXXConstructorDecl>(
4485 Constructor = cast<CXXConstructorDecl>(D);
4487 if (!Constructor->isInvalidDecl() &&
4488 Constructor->isConvertingConstructor(AllowExplicit)) {
4489 if (ConstructorTmpl)
4492 Initializer, CandidateSet,
4496 Initializer, CandidateSet,
4513 = cast<CXXRecordDecl>(SourceRecordType->getDecl());
4515 const auto &Conversions =
4517 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
4520 if (isa<UsingShadowDecl>(D))
4521 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4528 Conv = cast<CXXConversionDecl>(D);
4530 if (AllowExplicit || !Conv->isExplicit()) {
4533 ActingDC, Initializer, DestType,
4534 CandidateSet, AllowExplicit);
4537 Initializer, DestType, CandidateSet,
4556 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4558 if (isa<CXXConstructorDecl>(Function)) {
4564 HadMultipleCandidates);
4578 HadMultipleCandidates);
4583 HadMultipleCandidates);
4587 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
4588 Best->FinalConversion.Third) {
4591 ICS.
Standard = Best->FinalConversion;
4609 isa<CXXBoolLiteralExpr>(Init) &&
4610 !cast<CXXBoolLiteralExpr>(Init)->getValue() &&
4619 bool isAddressOf,
bool &isWeakAccess) {
4630 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
4631 switch (ce->getCastKind()) {
4649 }
else if (isa<DeclRefExpr>(e)) {
4653 isWeakAccess =
true;
4657 VarDecl *var = dyn_cast<
VarDecl>(cast<DeclRefExpr>(e)->getDecl());
4671 }
else if (isa<ArraySubscriptExpr>(e)) {
4687 bool isWeakAccess =
false;
4691 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
4697 << ((
unsigned) iik - 1)
4698 << src->getSourceRange();
4722 Expr *Initializer) {
4723 bool ArrayDecay =
false;
4728 ArgPointee = ArgArrayType->getElementType();
4740 bool ShouldCopy =
true;
4745 if (ArrayDecay || Initializer->
isGLValue()) {
4769 Expr *Initializer) {
4789 Expr *Initializer) {
4803 bool TopLevelOfInitList)
4812 if (!DRE || !isa<FunctionDecl>(DRE->getDecl()))
4816 cast<FunctionDecl>(DRE->getDecl()));
4823 bool TopLevelOfInitList) {
4830 for (
unsigned I = 0, E = Args.size();
I !=
E; ++
I)
4831 if (Args[
I]->getType()->isNonOverloadPlaceholderType()) {
4838 Args[
I] = result.
get();
4859 Expr *Initializer =
nullptr;
4860 if (Args.size() == 1) {
4861 Initializer = Args[0];
4864 DestType, Initializer->
getType(),
4867 Args[0] = Initializer;
4869 if (!isa<InitListExpr>(Initializer))
4870 SourceType = Initializer->
getType();
4876 if (
InitListExpr *InitList = dyn_cast_or_null<InitListExpr>(Initializer)) {
4889 if (Args.size() != 1)
4915 if (Initializer && isa<VariableArrayType>(DestAT)) {
4943 isa<CompoundLiteralExpr>(Initializer->
IgnoreParens()) &&
4959 Initializer && isa<InitListExpr>(Initializer)) {
4963 }
else if (DestAT->getElementType()->isCharType())
4975 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
4982 if (allowObjCWritebackConversion &&
5010 S.
IsDerivedFrom(Initializer->getLocStart(), SourceType, DestType))))
5021 TopLevelOfInitList);
5025 if (Args.size() > 1) {
5029 assert(Args.size() == 1 &&
"Zero-argument case handled above");
5036 bool NeedAtomicConversion =
false;
5040 Atomic->getValueType())) {
5041 DestType = Atomic->getValueType();
5042 NeedAtomicConversion =
true;
5047 TopLevelOfInitList);
5049 if (!
Failed() && NeedAtomicConversion)
5066 allowObjCWritebackConversion);
5074 bool ShouldCopy =
true;
5090 }
else if (ICS.
isBad()) {
5111 for (
auto &S : Steps)
5160 llvm_unreachable(
"Invalid EntityKind!");
5189 llvm_unreachable(
"missed an InitializedEntity kind?");
5218 llvm_unreachable(
"missed an InitializedEntity kind?");
5226 Expr *CurInitExpr) {
5233 CI = Ctors.begin(), CE = Ctors.end(); CI != CE; ++CI) {
5237 if ((Constructor = dyn_cast<CXXConstructorDecl>(D))) {
5247 CurInitExpr, CandidateSet);
5256 Constructor = cast<CXXConstructorDecl>(
5266 CurInitExpr, CandidateSet,
true);
5272 Expr *Initializer) {
5299 return Initializer->getLocStart();
5301 llvm_unreachable(
"missed an InitializedEntity kind?");
5328 bool IsExtraneousCopy) {
5335 Class = cast<CXXRecordDecl>(Record->getDecl());
5368 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5377 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
5378 : diag::err_temp_copy_no_viable)
5380 << CurInitExpr->getSourceRange();
5387 S.
Diag(Loc, diag::err_temp_copy_ambiguous)
5389 << CurInitExpr->getSourceRange();
5394 S.
Diag(Loc, diag::err_temp_copy_deleted)
5396 << CurInitExpr->getSourceRange();
5406 Best->FoundDecl.getAccess(), IsExtraneousCopy);
5408 if (IsExtraneousCopy) {
5422 diag::err_call_incomplete_argument))
5443 HadMultipleCandidates,
5461 Expr *CurInitExpr) {
5475 S, CandidateSet, cast<CXXRecordDecl>(Record->getDecl()), CurInitExpr);
5483 << CurInitExpr->getSourceRange();
5488 Entity, Best->FoundDecl.getAccess(),
Diag);
5509 void InitializationSequence::PrintInitLocationNote(
Sema &S,
5524 diag::note_method_return_type_change)
5553 return NumArgs != 1;
5565 bool &ConstructorInitRequiresZeroInit,
5566 bool IsListInitialization,
5567 bool IsStdInitListInitialization,
5570 unsigned NumArgs = Args.size();
5585 assert(Constructor->
getParent() &&
"No parent class for constructor.");
5606 Loc, ConstructorArgs,
5608 IsListInitialization))
5627 S.
Context, Constructor, TSInfo, ConstructorArgs, ParenOrBraceRange,
5628 HadMultipleCandidates, IsListInitialization,
5629 IsStdInitListInitialization, ConstructorInitRequiresZeroInit);
5645 if (IsListInitialization)
5646 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
5656 HadMultipleCandidates,
5657 IsListInitialization,
5658 IsStdInitListInitialization,
5659 ConstructorInitRequiresZeroInit,
5666 HadMultipleCandidates,
5667 IsListInitialization,
5668 IsStdInitListInitialization,
5669 ConstructorInitRequiresZeroInit,
5725 llvm_unreachable(
"unknown entity kind");
5785 return FallbackDecl;
5794 llvm_unreachable(
"unknown entity kind");
5811 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
5812 if (ILE->getNumInits() == 1 && ILE->isGLValue()) {
5814 Init = ILE->getInit(0);
5822 Init =
const_cast<Expr *
>(
5827 if (
CastExpr *CE = dyn_cast<CastExpr>(Init))
5828 if (CE->getSubExpr()->isGLValue())
5829 Init = CE->getSubExpr();
5834 }
while (Init != Old);
5839 ME->setExtendingDecl(ExtendingEntity->
getDecl(),
5855 Init =
const_cast<Expr *
>(
5859 Init = BTE->getSubExpr();
5862 dyn_cast<CXXStdInitializerListExpr>(Init)) {
5867 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
5868 if (ILE->getType()->isArrayType()) {
5869 for (
unsigned I = 0, N = ILE->getNumInits();
I != N; ++
I)
5874 if (
CXXRecordDecl *RD = ILE->getType()->getAsCXXRecordDecl()) {
5875 assert(RD->isAggregate() &&
"aggregate init on non-aggregate");
5880 if (RD->
isUnion() && ILE->getInitializedFieldInUnion() &&
5881 ILE->getInitializedFieldInUnion()->getType()->isReferenceType())
5885 for (
const auto *
I : RD->
fields()) {
5886 if (Index >= ILE->getNumInits())
5888 if (
I->isUnnamedBitfield())
5890 Expr *SubInit = ILE->getInit(Index);
5891 if (
I->getType()->isReferenceType())
5893 else if (isa<InitListExpr>(SubInit) ||
5894 isa<CXXStdInitializerListExpr>(SubInit))
5907 const Expr *Init,
bool IsInitializerList,
5910 if (isa<FieldDecl>(ExtendingDecl)) {
5911 if (IsInitializerList) {
5912 S.
Diag(Init->
getExprLoc(), diag::warn_dangling_std_initializer_list)
5917 bool IsSubobjectMember =
false;
5921 IsSubobjectMember =
true;
5926 diag::warn_bind_ref_member_to_temporary)
5927 << ExtendingDecl << Init->getSourceRange()
5928 << IsSubobjectMember << IsInitializerList;
5929 if (IsSubobjectMember)
5931 diag::note_ref_subobject_of_member_declared_here);
5934 diag::note_ref_or_ptr_member_declared_here)
5943 const Expr *PostInit);
5947 bool IsReturnStmt) {
5958 unsigned DiagID = 0;
6003 if (isa<ParmVarDecl>(VD))
6004 DiagID = diag::warn_redundant_move_on_return;
6006 DiagID = diag::warn_pessimizing_move_on_return;
6008 DiagID = diag::warn_pessimizing_move_on_initialization;
6055 if (!ZeroInitializationFixit.empty()) {
6056 unsigned DiagID = diag::err_default_init_const;
6058 if (S.
getLangOpts().MSVCCompat && D->hasAttr<SelectAnyAttr>())
6059 DiagID = diag::ext_default_init_const;
6068 ZeroInitializationFixit);
6087 if (isa<InitListExpr>((
Expr *)Args[0])) {
6093 TypeLoc TL = TInfo->getTypeLoc();
6096 Brackets = ArrayLoc.getBracketsRange();
6103 ArrayT->getSizeModifier(),
6104 ArrayT->getIndexTypeCVRQualifiers(),
6128 Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
6133 Expr *Init = Args[0];
6134 S.
Diag(Init->getLocStart(), diag::warn_cxx98_compat_reference_list_init)
6135 << Init->getSourceRange();
6140 if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
6143 Expr *Init = Args[0];
6146 S.
Diag(Init->getLocStart(), diag::warn_temporary_array_to_pointer_decay)
6147 << Init->getSourceRange();
6163 switch (Steps.front().Kind) {
6193 assert(Args.size() == 1);
6208 bool ConstructorInitRequiresZeroInit =
false;
6239 CurInit.
get()->getLocStart(),
6240 CurInit.
get()->getSourceRange(),
6241 &BasePath, IgnoreBaseAccess))
6252 CurInit.
get(), &BasePath, VK);
6264 << (BitField !=
nullptr)
6265 << CurInit.
get()->getSourceRange();
6274 S.
Diag(Kind.
getLocation(), diag::err_reference_bind_to_vector_element)
6276 << CurInit.
get()->getSourceRange();
6277 PrintInitLocationNote(S, Entity);
6295 ExtendingEntity->getDecl());
6301 assert(CurInit.
get()->
isRValue() &&
"not a temporary");
6318 ExtendingEntity->getDecl());
6343 bool IsCopy =
false;
6347 bool CreatedObject =
false;
6359 Loc, ConstructorArgs))
6365 HadMultipleCandidates,
6385 CreatedObject =
true;
6400 FoundFn, Conversion);
6403 CurInit = CurInitExprRes;
6407 HadMultipleCandidates);
6413 CreatedObject = Conversion->getReturnType()->isRecordType();
6425 S.
PDiag(diag::err_access_dtor_temp) << T);
6435 if (MaybeBindToTemp)
6458 assert(CurInit.
get()->
isRValue() &&
"cannot convert glvalue to atomic");
6465 assert(CurInit.
get()->
isGLValue() &&
"cannot load from a prvalue");
6484 CurInit = CurInitExprRes;
6501 InitListChecker PerformInitList(S, InitEntity,
6502 InitList, Ty,
false);
6503 if (PerformInitList.HadError())
6511 if ((*ResultType)->isRValueReferenceType())
6513 else if ((*ResultType)->isLValueReferenceType())
6520 PerformInitList.getFullyStructuredList();
6524 : StructuredInitList;
6538 assert(Args.size() == 1 &&
"expected a single argument for list init");
6540 S.
Diag(InitList->getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
6541 << InitList->getSourceRange();
6542 MultiExprArg Arg(InitList->getInits(), InitList->getNumInits());
6546 ConstructorInitRequiresZeroInit,
6549 InitList->getLBraceLoc(),
6550 InitList->getRBraceLoc());
6555 CurInit = cast<InitListExpr>(CurInit.
get())->getInit(0);
6581 bool IsStdInitListInit =
6584 S, UseTemporary ? TempEntity : Entity, Kind, Args, *
Step,
6585 ConstructorInitRequiresZeroInit,
6596 if (NextStep != StepEnd &&
6601 ConstructorInitRequiresZeroInit =
true;
6640 CurInit = CurInitExprRes;
6645 InitialCurInit.
get(),
6648 PrintInitLocationNote(S, Entity);
6650 }
else if (Complained)
6651 PrintInitLocationNote(S, Entity);
6673 << CurInit.
get()->getSourceRange();
6683 IncompleteDest->getElementType(),
6684 ConstantSource->getSize(),
6695 << CurInit.
get()->getSourceRange();
6713 S.
Diag(CurInit.get()->getExprLoc(),
6714 diag::warn_cxx98_compat_initializer_list_init)
6715 << CurInit.get()->getSourceRange();
6743 "Sampler initialization on non-sampler type.");
6745 QualType SourceType = CurInit.get()->getType();
6748 if (!SourceType->isSamplerT())
6752 llvm_unreachable(
"Invalid EntityKind!");
6759 "Event initialization on non-event type.");
6763 CurInit.get()->getValueKind());
6771 cast<FieldDecl>(Entity.
getDecl())->isBitField())
6773 cast<FieldDecl>(Entity.
getDecl()),
6777 if (
const Expr *E = CurInit.
get()) {
6790 S.
Diag(Loc, diag::err_reference_without_init)
6799 for (
const auto *FI : RD->
fields()) {
6800 if (FI->isUnnamedBitfield())
6804 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
6809 for (
const auto &BI : RD->
bases()) {
6811 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
6866 if (
auto *D = Entity.
getDecl())
6867 Loc = D->getLocation();
6868 S.
Diag(Loc, diag::note_in_reference_temporary_list_initializer) << T;
6872 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
6874 assert(DiagnoseInitList.HadError() &&
6875 "Inconsistent init list check result.");
6897 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
6901 <<
SourceRange(Args.front()->getLocStart(), Args.back()->getLocEnd());
6914 S.
Diag(Kind.
getLocation(), diag::err_array_init_narrow_string_into_wchar);
6917 S.
Diag(Kind.
getLocation(), diag::err_array_init_wide_string_into_char);
6921 diag::err_array_init_incompat_wide_string_into_wchar);
6927 ? diag::err_array_init_different_type
6928 : diag::err_array_init_non_constant_array))
6930 << Args[0]->getType()
6931 << Args[0]->getSourceRange();
6936 << Args[0]->getSourceRange();
6949 auto *FD = cast<FunctionDecl>(cast<DeclRefExpr>(Args[0])->getDecl());
6951 Args[0]->getLocStart());
6957 switch (FailedOverloadResult) {
6961 << Args[0]->getType() << DestType
6962 << Args[0]->getSourceRange();
6965 << DestType << Args[0]->getType()
6966 << Args[0]->getSourceRange();
6974 diag::err_typecheck_nonviable_condition_incomplete,
6975 Args[0]->getType(), Args[0]->getSourceRange()))
6978 << Args[0]->getType() << Args[0]->getSourceRange()
6987 << Args[0]->getSourceRange();
6995 llvm_unreachable(
"Inconsistent overload resolution?");
7001 llvm_unreachable(
"Conversion did not fail!");
7006 if (isa<InitListExpr>(Args[0])) {
7008 diag::err_lvalue_reference_bind_to_initlist)
7011 << Args[0]->getSourceRange();
7019 ? diag::err_lvalue_reference_bind_to_temporary
7020 : diag::err_lvalue_reference_bind_to_unrelated)
7023 << Args[0]->getType()
7024 << Args[0]->getSourceRange();
7030 << Args[0]->getSourceRange();
7034 QualType SourceType = Args[0]->getType();
7043 << Args[0]->getSourceRange();
7050 << Args[0]->isLValue()
7051 << Args[0]->getType()
7052 << Args[0]->getSourceRange();
7057 QualType FromType = Args[0]->getType();
7061 << Args[0]->isLValue()
7063 << Args[0]->getSourceRange();
7078 if (InitList && InitList->getNumInits() >= 1) {
7079 R =
SourceRange(InitList->getInit(0)->getLocEnd(), InitList->getLocEnd());
7081 assert(Args.size() > 1 &&
"Expected multiple initializers!");
7082 R =
SourceRange(Args.front()->getLocEnd(), Args.back()->getLocEnd());
7087 S.
Diag(Kind.
getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
7102 << (DestType->
isRecordType()) << DestType << Args[0]->getSourceRange();
7109 ArgsRange =
SourceRange(Args.front()->getLocStart(),
7110 Args.back()->getLocEnd());
7113 assert(Args.size() == 1 &&
7114 "List construction from other than 1 argument.");
7116 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
7121 switch (FailedOverloadResult) {
7124 << DestType << ArgsRange;
7160 diag::note_member_declared_at);
7164 S.
Diag(Record->getDecl()->getLocation(),
7165 diag::note_previous_decl)
7172 << DestType << ArgsRange;
7182 <<
true << DestType << ArgsRange;
7183 llvm_unreachable(
"Inconsistent overload resolution?");
7193 << DestType << ArgsRange;
7196 <<
true << DestType << ArgsRange;
7203 llvm_unreachable(
"Conversion did not fail!");
7231 diag::err_init_incomplete_type);
7248 << Args[0]->getSourceRange();
7253 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
7255 S.
Diag(CtorDecl->
getLocation(), diag::note_constructor_declared_here);
7260 PrintInitLocationNote(S, Entity);
7267 OS <<
"Failed sequence: ";
7270 OS <<
"too many initializers for reference";
7274 OS <<
"array requires initializer list";
7278 OS <<
"address of unaddressable function was taken";
7282 OS <<
"array requires initializer list or string literal";
7286 OS <<
"array requires initializer list or wide string literal";
7290 OS <<
"narrow string into wide char array";
7294 OS <<
"wide string into char array";
7298 OS <<
"incompatible wide string into wide char array";
7302 OS <<
"array type mismatch";
7306 OS <<
"non-constant array initializer";
7310 OS <<
"address of overloaded function failed";
7314 OS <<
"overload resolution for reference initialization failed";
7318 OS <<
"non-const lvalue reference bound to temporary";
7322 OS <<
"non-const lvalue reference bound to unrelated type";
7326 OS <<
"rvalue reference bound to an lvalue";
7330 OS <<
"reference initialization drops qualifiers";
7334 OS <<
"reference initialization failed";
7338 OS <<
"conversion failed";
7342 OS <<
"conversion from property failed";
7346 OS <<
"too many initializers for scalar";
7350 OS <<
"referencing binding to initializer list";
7354 OS <<
"initializer list for non-aggregate, non-scalar type";
7358 OS <<
"overloading failed for user-defined conversion";
7362 OS <<
"constructor overloading failed";
7366 OS <<
"default initialization of a const variable";
7370 OS <<
"initialization of incomplete type";
7374 OS <<
"list initialization checker failure";
7378 OS <<
"variable length array has an initializer";
7382 OS <<
"initializer expression isn't contextually valid";
7386 OS <<
"list constructor overloading failed";
7390 OS <<
"list copy initialization chose explicit constructor";
7398 OS <<
"Dependent sequence\n";
7402 OS <<
"Normal sequence: ";
7413 OS <<
"resolve address of overloaded function";
7417 OS <<
"derived-to-base case (rvalue" << S->Type.getAsString() <<
")";
7421 OS <<
"derived-to-base case (xvalue" << S->Type.getAsString() <<
")";
7425 OS <<
"derived-to-base case (lvalue" << S->Type.getAsString() <<
")";
7429 OS <<
"bind reference to lvalue";
7433 OS <<
"bind reference to a temporary";
7437 OS <<
"extraneous C++03 copy to temporary";
7441 OS <<
"user-defined conversion via " << *S->Function.Function;
7445 OS <<
"qualification conversion (rvalue)";
7449 OS <<
"qualification conversion (xvalue)";
7453 OS <<
"qualification conversion (lvalue)";
7457 OS <<
"non-atomic-to-atomic conversion";
7461 OS <<
"load (lvalue to rvalue)";
7465 OS <<
"implicit conversion sequence (";
7471 OS <<
"implicit conversion sequence with narrowing prohibited (";
7477 OS <<
"list aggregate initialization";
7481 OS <<
"unwrap reference initializer list";
7485 OS <<
"rewrap reference initializer list";
7489 OS <<
"constructor initialization";
7493 OS <<
"list initialization via constructor";
7497 OS <<
"zero initialization";
7501 OS <<
"C assignment";
7505 OS <<
"string initialization";
7509 OS <<
"Objective-C object conversion";
7513 OS <<
"array initialization";
7517 OS <<
"parenthesized array initialization";
7521 OS <<
"pass by indirect copy and restore";
7525 OS <<
"pass by indirect restore";
7529 OS <<
"Objective-C object retension";
7533 OS <<
"std::initializer_list from initializer list";
7537 OS <<
"list initialization from std::initializer_list";
7541 OS <<
"OpenCL sampler_t from integer constant";
7545 OS <<
"OpenCL event_t from zero";
7549 OS <<
" [" << S->Type.getAsString() <<
']';
7563 const Expr *PostInit) {
7591 S.
Diag(PostInit->getLocStart(),
7593 ? diag::warn_init_list_type_narrowing
7594 : diag::ext_init_list_type_narrowing)
7595 << PostInit->getSourceRange()
7602 S.
Diag(PostInit->getLocStart(),
7604 ? diag::warn_init_list_constant_narrowing
7605 : diag::ext_init_list_constant_narrowing)
7606 << PostInit->getSourceRange()
7613 S.
Diag(PostInit->getLocStart(),
7615 ? diag::warn_init_list_variable_narrowing
7616 : diag::ext_init_list_variable_narrowing)
7617 << PostInit->getSourceRange()
7624 llvm::raw_svector_ostream OS(StaticCast);
7625 OS <<
"static_cast<";
7632 OS << *TT->getDecl();
7641 S.
Diag(PostInit->getLocStart(), diag::note_init_list_narrowing_silence)
7642 << PostInit->getSourceRange()
7658 assert(InitE &&
"No initialization expression");
7663 return !Seq.Failed();
7670 bool TopLevelOfInitList,
7671 bool AllowExplicit) {
7676 assert(InitE &&
"No initialization expression?");
7679 EqualLoc = InitE->getLocStart();
7686 ExprResult Result = Seq.Perform(*
this, Entity, Kind, InitE);
unsigned getNumElements() const
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
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)
Update a glvalue expression that is used as the initializer of a reference to note that its lifetime ...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
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...
A (possibly-)qualified type.
bool isConstantArrayType() const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
DesignatorKind getKind() const
Simple class containing the result of Sema::CorrectTypo.
unsigned Index
When Kind == EK_ArrayElement, EK_VectorElement, or EK_ComplexElement, the index of the array or vecto...
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
step_iterator step_end() const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Produce an Objective-C object pointer.
A cast other than a C-style cast.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
QualType getCallResultType() const
Determine the type of an expression that calls this function.
void AddOCLZeroEventStep(QualType T)
Add a step to initialize an OpenCL event_t from a NULL constant.
Initializing char array with wide string literal.
QualType getType() const
Retrieves the type of the base class.
Perform an implicit conversion sequence without narrowing.
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
InvalidICRKind
The non-zero enum values here are indexes into diagnostic alternatives.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static ExprResult CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value)
Check that the given Index expression is a valid array designator value.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
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)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
static DesignatedInitExpr * CloneDesignatedInitExpr(Sema &SemaRef, DesignatedInitExpr *DIE)
bool isRecordType() const
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
unsigned size() const
Returns the number of designators in this initializer.
AccessSpecifier getAccess() const
uintptr_t Base
When Kind == EK_Base, the base specifier that provides the base class.
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, const InitializedEntity &Entity, AccessSpecifier Access, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Not a narrowing conversion.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
bool hasFlexibleArrayMember() const
ParenExpr - This represents a parethesized expression, e.g.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
std::string getAsString() const
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
The base class of the type hierarchy.
bool isInStdNamespace() const
SourceLocation getEqualLoc() const
Retrieve the location of the equal sign for copy initialization (if present).
static bool tryObjCWritebackConversion(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity, Expr *Initializer)
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
The entity being initialized is a variable.
InitListExpr * getSyntacticForm() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getInit() const
NamespaceDecl - Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
Overloading for a user-defined conversion failed.
Ambiguous candidates found.
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
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
bool isSpelledAsLValue() const
SourceLocation getDotLoc() const
const llvm::APInt & getSize() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
The entity being initialized is a function parameter; function is member of group of audited CF APIs...
static const InitializedEntity * getEntityForTemporaryLifetimeExtension(const InitializedEntity *Entity, const InitializedEntity *FallbackDecl=nullptr)
Determine the declaration which an initialized entity ultimately refers to, for the purpose of lifeti...
Initialize an OpenCL sampler from an integer.
EntityKind getKind() const
Determine the kind of initialization.
static 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...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CK_IntegralCast - A cast between integral types (other than to boolean).
ExprResult PerformObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
static void TryUserDefinedConversion(Sema &S, QualType DestType, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt a user-defined conversion between two types (C++ [dcl.init]), which enumerates all conversion...
void AddCAssignmentStep(QualType T)
Add a C assignment step.
Initialization by string.
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)
Warn that Entity was of scalar type and was initialized by a single-element braced initializer list...
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
SourceRange getParenRange() const
Retrieve the source range containing the locations of the open and closing parentheses for value and ...
SourceLocation getLBracketLoc() const
field_iterator field_begin() const
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void setInit(unsigned Init, Expr *expr)
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
Non-const lvalue reference binding to an lvalue of unrelated type.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
step_iterator step_begin() const
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
CK_Dependent - A conversion which cannot yet be analyzed because either the expression or target type...
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...
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
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * getArrayIndex(const Designator &D) const
bool allowExplicitConversionFunctionsInRefBinding() const
Retrieve whether this initialization allows the use of explicit conversion functions when binding a r...
The collection of all-type qualifiers we support.
static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, bool IsReturnStmt)
Provide warnings when std::move is used on construction.
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)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
RecordDecl - Represents a struct/union/class.
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.
Trying to take the address of a function that doesn't support having its address taken.
One of these records is kept for each identifier that is lexed.
bool isScalarType() const
Expr * getSubExpr(unsigned Idx) const
static bool isExprAnUnaddressableFunction(Sema &S, const Expr *E)
Tries to get a FunctionDecl out of E.
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic)
Add steps to unwrap a initializer list for a reference around a single element and rewrap it at the e...
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
ImplicitConversionSequence * ICS
When Kind = SK_ConversionSequence, the implicit conversion sequence.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isReferenceType() const
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...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a place-holder for an object not to be initialized by anything.
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call...
Converting between two Objective-C object types, which can occur when performing reference binding to...
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
static bool isLibstdcxxPointerReturnFalseHack(Sema &S, const InitializedEntity &Entity, const Expr *Init)
An egregious hack for compatibility with libstdc++-4.2: in <tr1/hashtable>, a function with a pointer r...
static void warnOnLifetimeExtension(Sema &S, const InitializedEntity &Entity, const Expr *Init, bool IsInitializerList, const ValueDecl *ExtendingDecl)
Rewrap the single-element initializer list for a reference.
unsigned getCVRQualifiers() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible...
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
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.
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
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.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceRange getRange() const
Retrieve the source range that covers the initialization.
Succeeded, but refers to a deleted function.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, bool &DerivedToBase, bool &ObjCConversion, bool &ObjCLifetimeConversion)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
Ref_Compatible - The two types are reference-compatible and have equivalent qualifiers (cv1 == cv2)...
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isDefaulted() const
Whether this function is defaulted per C++0x.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
field_range fields() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
SourceLocation getRBraceLoc() const
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Variable-length array must not have an initializer.
RecordDecl * getDecl() const
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
Initialization of an incomplete type.
The entity being initialized is a non-static data member subobject.
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
CheckedConversionKind
The kind of conversion being performed.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
A narrowing conversion, because a constant expression got narrowed.
Unwrap the single-element initializer list for a reference.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
void AddParenthesizedArrayInitStep(QualType T)
Add a parenthesized array initialization step.
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.
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.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
Represents binding an expression to a temporary.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Perform initialization via a constructor.
Perform a user-defined conversion, either via a conversion function or via a constructor.
bool isExtVectorType() const
Implicit conversion failed.
detail::InMemoryDirectory::const_iterator I
The entity being initialized is a function parameter.
NamedDecl *const * chain_iterator
bool ExprNeedsCleanups
ExprNeedsCleanups - True if the current evaluation context requires cleanups to be run at its conclus...
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, InitListExpr *InitList)
field_iterator field_end() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
Perform an implicit conversion sequence.
ConditionalOperator - The ?: ternary operator.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Sema - This implements semantic analysis and AST building for C.
void setField(FieldDecl *FD)
Overloading for list-initialization by constructor failed.
Perform list-initialization without a constructor.
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
IdentifierInfo * getFieldName() const
Reference binding drops qualifiers.
void AddObjCObjectConversionStep(QualType T)
Add an Objective-C object conversion step, which is always a no-op.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Cannot resolve the address of an overloaded function.
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
Represents a ValueDecl that came out of a declarator.
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify().
void AddStdInitializerListConstructionStep(QualType T)
Add a step to construct a std::initializer_list object from an initializer list.
static 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.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
bool isDeleted() const
Whether this function has been deleted.
SourceLocation getLocStart() const LLVM_READONLY
Implicit conversion failed.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
void setRBraceLoc(SourceLocation Loc)
SourceLocation getLocStart() const LLVM_READONLY
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
bool isAnyComplexType() const
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
static void updateStringLiteralType(Expr *E, QualType Ty)
Update the type of a string literal, including any surrounding parentheses, to match the type of the ...
uintptr_t Parameter
When Kind == EK_Parameter, the ParmVarDecl, with the low bit indicating whether the parameter is "con...
The entity being initialized is an object (or array of objects) allocated via new.
Perform a qualification conversion, producing an xvalue.
void setSyntacticForm(InitListExpr *Init)
Represents a C++ functional cast expression that builds a temporary object.
SourceLocation getLBraceLoc() const
static void performLifetimeExtension(Expr *Init, const InitializedEntity *ExtendingEntity)
Update a prvalue expression that is going to be materialized as a lifetime-extended temporary...
bool isAtomicType() const
Represents a C++ destructor within a class.
Initializing a wide char array with narrow string literal.
void ClearExprs(Sema &Actions)
ClearExprs - Null out any expression references, which prevents them from being 'delete'd later...
void AddProduceObjCObjectStep(QualType T)
Add a step to "produce" an Objective-C object (by retaining it).
SmallVectorImpl< OverloadCandidate >::iterator iterator
Passing zero to a function where OpenCL event_t is expected.
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)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
SourceLocation getLocEnd() const LLVM_READONLY
const ParmVarDecl * getParamDecl(unsigned i) const
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
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)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
struct F Function
When Kind == SK_ResolvedOverloadedFunction or Kind == SK_UserConversion, the function that the expres...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
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())
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
CK_ConstructorConversion - Conversion by constructor.
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.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
Represents a GCC generic vector type.
static void TryReferenceInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence)
Attempt reference initialization (C++0x [dcl.init.ref])
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
const IdentifierInfo * getField() const
FailureKind getFailureKind() const
Determine why initialization failed.
QualType getElementType() const
Represents a C++ conversion function within a class.
void AddStringInitStep(QualType T)
Add a string init step.
The result type of a method or function.
Pass an object by indirect restore.
InitKind getKind() const
Determine the initialization kind.
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
QualType getWideCharType() const
Return the type of wide characters.
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
CK_ArrayToPointerDecay - Array to pointer decay.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
InitListExpr * getUpdater() const
FailureKind
Describes why initialization failed.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
Too many initializers for scalar.
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)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Expr * getArrayRangeEnd(const Designator &D) const
CK_UserDefinedConversion - Conversion using a user defined type conversion function.
SequenceKind
Describes the kind of initialization sequence computed.
Encodes a location in the source.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
Reference initialization from an initializer list.
QualType getElementType() const
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
static bool shouldBindAsTemporary(const InitializedEntity &Entity)
Whether we should bind a created object as a temporary when initializing the given entity...
SourceLocation getLocation() const
Retrieve the location at which initialization is occurring.
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda...
bool isValid() const
Return true if this is a valid SourceLocation object.
Expr * getArrayRangeStart() const
FieldDecl * getField() const
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
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
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.
CK_DerivedToBase - A conversion from a C++ class pointer to a base class pointer. ...
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
Ref_Compatible_With_Added_Qualification - The two types are reference-compatible with added qualifica...
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
void AddExtraneousCopyToTemporary(QualType T)
Add a new step that makes an extraneous copy of the input to a temporary of the same class type...
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
Get the base element type of this type, potentially discarding type qualifiers.
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
bool isCStyleOrFunctionalCast() const
Determine whether this initialization is a C-style cast.
static ExprResult PerformConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, const InitializationSequence::Step &Step, bool &ConstructorInitRequiresZeroInit, bool IsListInitialization, bool IsStdInitListInitialization, SourceLocation LBraceLoc, SourceLocation RBraceLoc)
static bool DiagnoseUninitializedReference(Sema &S, SourceLocation Loc, QualType T)
Somewhere within T there is an uninitialized reference subobject.
Expr ** getInits()
Retrieve the set of initializers.
Overloading for initialization by constructor failed.
QualType getToType(unsigned Idx) const
static bool ResolveOverloadedFunctionForReferenceBinding(Sema &S, Expr *Initializer, QualType &SourceType, QualType &UnqualifiedSourceType, QualType UnqualifiedTargetType, InitializationSequence &Sequence)
SourceLocation getBegin() const
Requests that all candidates be shown.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
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
lookup - Find the declarations (if any) with the given Name in this context.
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.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, Sema &S)
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
MutableArrayRef< Expr * > MultiExprArg
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
Pass an object by indirect copy-and-restore.
A POD class for pairing a NamedDecl* with an access specifier.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
Represents a C11 generic selection.
Rvalue reference binding to an lvalue.
void SetFailed(FailureKind Failure)
Note that this initialization sequence failed.
decl_iterator - Iterates through the declarations stored within this context.
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)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Too many initializers provided for a reference.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
static bool hasCompatibleArrayTypes(ASTContext &Context, const ArrayType *Dest, const ArrayType *Source)
Determine whether we have compatible array types for the purposes of GNU by-copy array initialization...
Perform a load from a glvalue, producing an rvalue.
static void checkIndirectCopyRestoreSource(Sema &S, Expr *src)
Check whether the given expression is a valid operand for an indirect copy/restore.
bool isInvalidDecl() const
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
static bool InitializedEntityOutlivesFullExpression(const InitializedEntity &Entity)
Determine whether the specified InitializedEntity definitely has a lifetime longer than the current f...
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.
DeclarationName - The name of a declaration.
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.
detail::InMemoryDirectory::const_iterator E
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
getNumArgs - Return the number of actual arguments to this call.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static ExprResult CopyObject(Sema &S, QualType T, const InitializedEntity &Entity, ExprResult CurInit, bool IsExtraneousCopy)
Make a (potentially elidable) temporary copy of the object provided by the given initializer by calli...
bool isLValueReferenceType() const
Overloading due to reference initialization failed.
Expr * getArrayIndex() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
unsigned getNumArgs() const
bool isParameterKind() const
void setInitializedFieldInUnion(FieldDecl *FD)
DeclClass * getCorrectionDeclAs() const
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static bool isRValueRef(QualType ParamType)
bool isObjCObjectType() const
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setAllToTypes(QualType T)
Complex values, per C99 6.2.5p11.
static bool TryOCLZeroEventInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
SourceManager & getSourceManager() const
const T * getAs() const
Member-template getAs<specific type>'.
SourceLocation getLocEnd() const LLVM_READONLY
QualType getCanonicalType() const
Array must be initialized with an initializer list.
bool isConvertingConstructor(bool AllowExplicit) const
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for u...
static void emitBadConversionNotes(Sema &S, const InitializedEntity &entity, Expr *op)
Emit notes associated with an initialization that failed due to a "simple" conversion failure...
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
ObjCEncodeExpr, used for @encode in Objective-C.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
SourceLocation getFieldLoc() const
[ARC] Produces a retainable object pointer so that it may be consumed, e.g.
Reference binding failed.
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() const
CK_LValueBitCast - A conversion which reinterprets the address of an l-value as an l-value of a diffe...
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.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXConstructorDecl * getConstructor() const
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)
Checks access to an overloaded member operator, including conversion operators.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
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...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
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
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool 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)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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.
void dump() const
Dump a representation of the initialized entity to standard error, for debugging purposes.
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)
Converts the target of reference initialization so that it has the appropriate qualifiers and value k...
bool isObjCObjectPointerType() const
Represents a C array with an unspecified size.
QualType getEncodedType() const
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Expr * getArrayRangeEnd() const
The entity being initialized is 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.
This class is used for builtin types like 'int'.
bool isImplicitValueInit() const
Determine whether this initialization is an implicit value-initialization, e.g., as occurs during agg...
unsigned allocateManglingNumber() const
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
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)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
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
Designation - Represent a full designation, which is a sequence of designators.
static Sema::AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Designator - A designator in a C99 designated initializer.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
QualType getElementType() const
The initialization is being done by a delegating constructor.
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
void AddQualificationConversionStep(QualType Ty, ExprValueKind Category)
Add a new step that performs a qualification conversion to the given type.
void 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
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
const Expr * getInit(unsigned Init) const
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
No viable function found.
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
A failed initialization sequence.
bool isFieldDesignator() const
Array initialization (from an array rvalue).
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
An l-value expression is a reference to an object with independent storage.
Default-initialization of a 'const' object.
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
Add a new step that applies an implicit conversion sequence.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
NamedDecl - This represents a decl with a name.
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes...
Represents a C array with a specified size that is not an integer-constant-expression.
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
Automatic storage duration (most local variables).
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isConstQualified() const
Determine whether this type is const-qualified.
static void DiagnoseNarrowingInInitList(Sema &S, const ImplicitConversionSequence &ICS, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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.
Represents the canonical version of C arrays with a specified constant size.
bool isArrayDesignator() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static void MaybeProduceObjCObject(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Declaration of a template function.
Represents an implicitly-generated value initialization of an object of a given type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
static 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
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
Non-const lvalue reference binding to a temporary.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool hasInClassInitializer() const
hasInClassInitializer - Determine whether this member has a C++11 in-class initializer.
bool isPointerType() const
SourceRange getSourceRange() const LLVM_READONLY
static bool isExplicitTemporary(const InitializedEntity &Entity, const InitializationKind &Kind, unsigned NumArgs)
Returns true if the parameters describe a constructor initialization of an explicit temporary object...
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).