33#include "llvm/ADT/APInt.h"
34#include "llvm/ADT/DenseMap.h"
35#include "llvm/ADT/PointerIntPair.h"
36#include "llvm/ADT/SmallString.h"
37#include "llvm/ADT/SmallVector.h"
38#include "llvm/ADT/StringExtras.h"
39#include "llvm/Support/ErrorHandling.h"
40#include "llvm/Support/raw_ostream.h"
51 if (Context.typesAreCompatible(Context.getWideCharType(),
T))
53 if (Context.getLangOpts().CPlusPlus || Context.getLangOpts().C11) {
54 return Context.typesAreCompatible(Context.Char16Ty,
T) ||
55 Context.typesAreCompatible(Context.Char32Ty,
T);
94 auto IsCharOrUnsignedChar = [](
const QualType &
T) {
95 const BuiltinType *BT = dyn_cast<BuiltinType>(
T.getTypePtr());
106 (Context.getLangOpts().Char8 &&
116 Context.getLangOpts().Char8)
130 if (Context.typesAreCompatible(Context.Char16Ty, ElemTy))
138 if (Context.typesAreCompatible(Context.Char32Ty, ElemTy))
146 if (Context.typesAreCompatible(Context.getWideCharType(), ElemTy))
154 assert(
false &&
"Unevaluated string literal in initialization");
158 llvm_unreachable(
"missed a StringLiteral kind?");
205 if (
const auto *VD = dyn_cast_if_present<VarDecl>(D); VD && VD->isConstexpr())
216 bool CheckC23ConstexprInit =
false) {
218 auto *ConstantArrayTy =
220 uint64_t StrLength = ConstantArrayTy->getZExtSize();
222 if (CheckC23ConstexprInit)
229 llvm::APInt ConstVal(32, StrLength);
254 if (StrLength > ArrayLen)
256 diag::err_initializer_string_for_char_array_too_long)
260 if (StrLength - 1 > ArrayLen)
262 diag::ext_initializer_string_for_char_array_too_long)
264 else if (StrLength - 1 == ArrayLen) {
267 const auto *SL = dyn_cast<StringLiteral>(Str->
IgnoreParens());
268 bool IsSLSafe = SL && SL->getLength() > 0 &&
269 SL->getCodeUnit(SL->getLength() - 1) == 0;
276 auto FindCorrectEntity =
288 if (
const ValueDecl *D = FindCorrectEntity(&Entity);
289 !D || !D->
hasAttr<NonStringAttr>())
293 warn_initializer_string_for_char_array_too_long_no_nonstring)
298 diag::warn_initializer_string_for_char_array_too_long_for_cpp)
311 for (
const FieldDecl *Field : R->fields()) {
312 if (Field->hasAttr<ExplicitInitAttr>())
313 S.
Diag(Field->getLocation(), diag::note_entity_declared_at) << Field;
354class InitListChecker {
356 bool hadError =
false;
358 bool TreatUnavailableAsInvalid;
359 bool InOverloadResolution;
360 InitListExpr *FullyStructuredList =
nullptr;
361 NoInitExpr *DummyExpr =
nullptr;
362 SmallVectorImpl<QualType> *AggrDeductionCandidateParamTypes =
nullptr;
363 EmbedExpr *CurEmbed =
nullptr;
364 unsigned CurEmbedIndex = 0;
366 NoInitExpr *getDummyInit() {
372 void CheckImplicitInitList(
const InitializedEntity &Entity,
373 InitListExpr *ParentIList, QualType
T,
374 unsigned &Index, InitListExpr *StructuredList,
375 unsigned &StructuredIndex);
376 void CheckExplicitInitList(
const InitializedEntity &Entity,
377 InitListExpr *IList, QualType &
T,
378 InitListExpr *StructuredList,
379 bool TopLevelObject =
false);
380 void CheckListElementTypes(
const InitializedEntity &Entity,
381 InitListExpr *IList, QualType &DeclType,
382 bool SubobjectIsDesignatorContext,
384 InitListExpr *StructuredList,
385 unsigned &StructuredIndex,
386 bool TopLevelObject =
false);
387 void CheckSubElementType(
const InitializedEntity &Entity,
388 InitListExpr *IList, QualType ElemType,
390 InitListExpr *StructuredList,
391 unsigned &StructuredIndex,
392 bool DirectlyDesignated =
false);
393 void CheckComplexType(
const InitializedEntity &Entity,
394 InitListExpr *IList, QualType DeclType,
396 InitListExpr *StructuredList,
397 unsigned &StructuredIndex);
398 void CheckScalarType(
const InitializedEntity &Entity,
399 InitListExpr *IList, QualType DeclType,
401 InitListExpr *StructuredList,
402 unsigned &StructuredIndex);
403 void CheckReferenceType(
const InitializedEntity &Entity,
404 InitListExpr *IList, QualType DeclType,
406 InitListExpr *StructuredList,
407 unsigned &StructuredIndex);
408 void CheckMatrixType(
const InitializedEntity &Entity, InitListExpr *IList,
409 QualType DeclType,
unsigned &Index,
410 InitListExpr *StructuredList,
unsigned &StructuredIndex);
411 void CheckVectorType(
const InitializedEntity &Entity,
412 InitListExpr *IList, QualType DeclType,
unsigned &Index,
413 InitListExpr *StructuredList,
414 unsigned &StructuredIndex);
415 void CheckStructUnionTypes(
const InitializedEntity &Entity,
416 InitListExpr *IList, QualType DeclType,
419 bool SubobjectIsDesignatorContext,
unsigned &Index,
420 InitListExpr *StructuredList,
421 unsigned &StructuredIndex,
422 bool TopLevelObject =
false);
423 void CheckArrayType(
const InitializedEntity &Entity,
424 InitListExpr *IList, QualType &DeclType,
425 llvm::APSInt elementIndex,
426 bool SubobjectIsDesignatorContext,
unsigned &Index,
427 InitListExpr *StructuredList,
428 unsigned &StructuredIndex);
429 bool CheckDesignatedInitializer(
const InitializedEntity &Entity,
430 InitListExpr *IList, DesignatedInitExpr *DIE,
432 QualType &CurrentObjectType,
434 llvm::APSInt *NextElementIndex,
436 InitListExpr *StructuredList,
437 unsigned &StructuredIndex,
438 bool FinishSubobjectInit,
439 bool TopLevelObject);
440 InitListExpr *getStructuredSubobjectInit(InitListExpr *IList,
unsigned Index,
441 QualType CurrentObjectType,
442 InitListExpr *StructuredList,
443 unsigned StructuredIndex,
444 SourceRange InitRange,
445 bool IsFullyOverwritten =
false);
446 void UpdateStructuredListElement(InitListExpr *StructuredList,
447 unsigned &StructuredIndex,
449 InitListExpr *createInitListExpr(QualType CurrentObjectType,
450 SourceRange InitRange,
451 unsigned ExpectedNumInits,
bool IsExplicit);
452 int numArrayElements(QualType DeclType);
453 int numStructUnionElements(QualType DeclType);
455 ExprResult PerformEmptyInit(SourceLocation Loc,
456 const InitializedEntity &Entity);
459 void diagnoseInitOverride(Expr *OldInit, SourceRange NewInitRange,
460 bool UnionOverride =
false,
461 bool FullyOverwritten =
true) {
466 ? (UnionOverride ? diag::ext_initializer_union_overrides
467 : diag::ext_initializer_overrides)
468 : diag::warn_initializer_overrides;
470 if (InOverloadResolution && SemaRef.
getLangOpts().CPlusPlus) {
491 DiagID = diag::err_initializer_overrides_destructed;
511 << NewInitRange << FullyOverwritten << OldInit->
getType();
537 void FillInEmptyInitForBase(
unsigned Init,
const CXXBaseSpecifier &Base,
538 const InitializedEntity &ParentEntity,
539 InitListExpr *ILE,
bool &RequiresSecondPass,
540 bool FillWithNoInit);
541 void FillInEmptyInitForField(
unsigned Init, FieldDecl *Field,
542 const InitializedEntity &ParentEntity,
543 InitListExpr *ILE,
bool &RequiresSecondPass,
544 bool FillWithNoInit =
false);
545 void FillInEmptyInitializations(
const InitializedEntity &Entity,
546 InitListExpr *ILE,
bool &RequiresSecondPass,
547 InitListExpr *OuterILE,
unsigned OuterIndex,
548 bool FillWithNoInit =
false);
549 bool CheckFlexibleArrayInit(
const InitializedEntity &Entity,
550 Expr *InitExpr, FieldDecl *Field,
551 bool TopLevelObject);
552 void CheckEmptyInitializable(
const InitializedEntity &Entity,
555 Expr *HandleEmbed(EmbedExpr *Embed,
const InitializedEntity &Entity) {
571 assert(AType &&
"expected array type when initializing array");
573 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
574 ElsCount = std::min(CAType->getSize().getZExtValue() - ArrIndex,
575 ElsCount - CurEmbedIndex);
585 CurEmbedIndex, ElsCount);
586 CurEmbedIndex += ElsCount;
596 Sema &S,
const InitializedEntity &Entity, InitListExpr *IL, QualType &
T,
597 bool VerifyOnly,
bool TreatUnavailableAsInvalid,
598 bool InOverloadResolution =
false,
599 SmallVectorImpl<QualType> *AggrDeductionCandidateParamTypes =
nullptr);
600 InitListChecker(Sema &S,
const InitializedEntity &Entity, InitListExpr *IL,
602 SmallVectorImpl<QualType> &AggrDeductionCandidateParamTypes)
603 : InitListChecker(S, Entity, IL,
T,
true,
606 &AggrDeductionCandidateParamTypes) {}
608 bool HadError() {
return hadError; }
612 InitListExpr *getFullyStructuredList()
const {
return FullyStructuredList; }
630 bool EmptyInitList = SemaRef.
getLangOpts().CPlusPlus11 &&
643 InitExpr = VerifyOnly ? &DummyInitList
661 if (!InitSeq && EmptyInitList &&
662 InitSeq.getFailureKind() ==
667 InitSeq.getFailedCandidateSet()
668 .BestViableFunction(SemaRef,
Kind.getLocation(), Best);
670 assert(O ==
OR_Success &&
"Inconsistent overload resolution");
677 bool IsInStd =
false;
678 for (
NamespaceDecl *ND = dyn_cast<NamespaceDecl>(
R->getDeclContext());
679 ND && !IsInStd; ND = dyn_cast<NamespaceDecl>(ND->getParent())) {
685 llvm::StringSwitch<bool>(
R->getName())
686 .Cases({
"basic_string",
"deque",
"forward_list"},
true)
687 .Cases({
"list",
"map",
"multimap",
"multiset"},
true)
688 .Cases({
"priority_queue",
"queue",
"set",
"stack"},
true)
689 .Cases({
"unordered_map",
"unordered_set",
"vector"},
true)
691 InitSeq.InitializeFrom(
695 TreatUnavailableAsInvalid);
700 diag::warn_invalid_initializer_from_system_header);
703 diag::note_used_in_initialization_here);
705 SemaRef.
Diag(Loc, diag::note_used_in_initialization_here);
712 InitSeq.Diagnose(SemaRef, Entity, Kind, SubInit);
715 diag::note_in_omitted_aggregate_initializer)
718 bool IsTrailingArrayNewMember =
721 SemaRef.
Diag(Loc, diag::note_in_omitted_aggregate_initializer)
722 << (IsTrailingArrayNewMember ? 2 : 0)
731 : InitSeq.Perform(SemaRef, Entity,
Kind, SubInit);
739 if (FullyStructuredList)
741 PerformEmptyInit(Loc, Entity);
744void InitListChecker::FillInEmptyInitForBase(
747 bool &RequiresSecondPass,
bool FillWithNoInit) {
749 SemaRef.
Context, &Base,
false, &ParentEntity);
754 : PerformEmptyInit(ILE->
getEndLoc(), BaseEntity);
761 assert(
Init < ILE->getNumInits() &&
"should have been expanded");
766 FillInEmptyInitializations(BaseEntity, InnerILE, RequiresSecondPass,
767 ILE,
Init, FillWithNoInit);
769 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(
Init))) {
770 FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
771 RequiresSecondPass, ILE,
Init,
776void InitListChecker::FillInEmptyInitForField(
unsigned Init,
FieldDecl *Field,
779 bool &RequiresSecondPass,
780 bool FillWithNoInit) {
788 if (!RType->getDecl()->isUnion())
789 assert((
Init < NumInits || VerifyOnly) &&
790 "This ILE should have been expanded");
792 if (FillWithNoInit) {
793 assert(!VerifyOnly &&
"should not fill with no-init in verify-only mode");
802 if (!VerifyOnly &&
Field->hasAttr<ExplicitInitAttr>() &&
804 SemaRef.
Diag(ILE->
getExprLoc(), diag::warn_field_requires_explicit_init)
806 SemaRef.
Diag(
Field->getLocation(), diag::note_entity_declared_at)
814 if (
Field->hasInClassInitializer()) {
831 RequiresSecondPass =
true;
836 if (
Field->getType()->isReferenceType()) {
842 SemaRef.
Diag(Loc, diag::err_init_reference_member_uninitialized)
846 SemaRef.
Diag(
Field->getLocation(), diag::note_uninit_reference_member);
852 ExprResult MemberInit = PerformEmptyInit(Loc, MemberEntity);
858 if (hadError || VerifyOnly) {
860 }
else if (
Init < NumInits) {
868 RequiresSecondPass =
true;
872 FillInEmptyInitializations(MemberEntity, InnerILE,
873 RequiresSecondPass, ILE,
Init, FillWithNoInit);
875 dyn_cast<DesignatedInitUpdateExpr>(ILE->
getInit(
Init))) {
876 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
877 RequiresSecondPass, ILE,
Init,
888 bool &RequiresSecondPass,
891 bool FillWithNoInit) {
893 "Should not have void type");
897 if (FillWithNoInit && VerifyOnly)
907 struct UpdateOuterILEWithUpdatedInit {
910 ~UpdateOuterILEWithUpdatedInit() {
914 } UpdateOuterRAII = {OuterILE, OuterIndex};
924 RequiresSecondPass, FillWithNoInit);
928 "We should have computed initialized fields already");
932 unsigned NumElems = numStructUnionElements(ILE->
getType());
933 if (!RDecl->isUnion() && RDecl->hasFlexibleArrayMember())
940 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RDecl)) {
941 for (
auto &Base : CXXRD->bases()) {
945 FillInEmptyInitForBase(
Init, Base, Entity, ILE, RequiresSecondPass,
951 for (
auto *Field : RDecl->fields()) {
952 if (
Field->isUnnamedBitField())
958 FillInEmptyInitForField(
Init, Field, Entity, ILE, RequiresSecondPass,
966 if (RDecl->isUnion())
980 ElementType = AType->getElementType();
981 if (
const auto *CAType = dyn_cast<ConstantArrayType>(AType))
982 NumElements = CAType->getZExtSize();
990 ElementType = VType->getElementType();
991 NumElements = VType->getNumElements();
997 bool SkipEmptyInitChecks =
false;
1016 if (SkipEmptyInitChecks)
1019 Expr *Filler =
nullptr;
1025 PerformEmptyInit(ILE->
getEndLoc(), ElementEntity);
1036 }
else if (VerifyOnly) {
1037 SkipEmptyInitChecks =
true;
1038 }
else if (
Init < NumInits) {
1059 RequiresSecondPass =
true;
1063 = dyn_cast_or_null<InitListExpr>(InitExpr)) {
1064 FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass,
1065 ILE,
Init, FillWithNoInit);
1067 dyn_cast_or_null<DesignatedInitUpdateExpr>(InitExpr)) {
1068 FillInEmptyInitializations(ElementEntity, InnerDIUE->getUpdater(),
1069 RequiresSecondPass, ILE,
Init,
1077 if (isa_and_nonnull<DesignatedInitExpr>(
Init))
1082InitListChecker::InitListChecker(
1084 bool VerifyOnly,
bool TreatUnavailableAsInvalid,
bool InOverloadResolution,
1086 : SemaRef(S), VerifyOnly(VerifyOnly),
1087 TreatUnavailableAsInvalid(TreatUnavailableAsInvalid),
1088 InOverloadResolution(InOverloadResolution),
1089 AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes) {
1091 FullyStructuredList = createInitListExpr(
1100 CheckExplicitInitList(Entity, IL,
T, FullyStructuredList,
1103 if (!hadError && !AggrDeductionCandidateParamTypes && FullyStructuredList) {
1104 bool RequiresSecondPass =
false;
1105 FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass,
1107 if (RequiresSecondPass && !hadError)
1108 FillInEmptyInitializations(Entity, FullyStructuredList,
1109 RequiresSecondPass,
nullptr, 0);
1111 if (hadError && FullyStructuredList)
1115int InitListChecker::numArrayElements(
QualType DeclType) {
1117 int maxElements = 0x7FFFFFFF;
1118 if (
const ConstantArrayType *CAT =
1120 maxElements =
static_cast<int>(CAT->getZExtSize());
1125int InitListChecker::numStructUnionElements(QualType DeclType) {
1127 int InitializableMembers = 0;
1128 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(structDecl))
1129 InitializableMembers += CXXRD->getNumBases();
1130 for (
const auto *Field : structDecl->fields())
1131 if (!
Field->isUnnamedBitField())
1132 ++InitializableMembers;
1134 if (structDecl->isUnion())
1135 return std::min(InitializableMembers, 1);
1136 return InitializableMembers - structDecl->hasFlexibleArrayMember();
1163 if (
CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ParentRD)) {
1164 if (CXXRD->getNumBases()) {
1169 assert(FieldIt != ParentRD->field_end() &&
1170 "no fields but have initializer for member?");
1171 return ++FieldIt == ParentRD->field_end();
1183void InitListChecker::CheckImplicitInitList(
const InitializedEntity &Entity,
1184 InitListExpr *ParentIList,
1185 QualType
T,
unsigned &Index,
1186 InitListExpr *StructuredList,
1187 unsigned &StructuredIndex) {
1188 int maxElements = 0;
1191 maxElements = numArrayElements(
T);
1193 maxElements = numStructUnionElements(
T);
1195 maxElements =
T->
castAs<VectorType>()->getNumElements();
1197 llvm_unreachable(
"CheckImplicitInitList(): Illegal type");
1199 if (maxElements == 0) {
1202 diag::err_implicit_empty_initializer);
1209 InitListExpr *StructuredSubobjectInitList = getStructuredSubobjectInit(
1210 ParentIList, Index,
T, StructuredList, StructuredIndex,
1213 unsigned StructuredSubobjectInitIndex = 0;
1216 unsigned StartIndex = Index;
1217 CheckListElementTypes(Entity, ParentIList,
T,
1219 StructuredSubobjectInitList,
1220 StructuredSubobjectInitIndex);
1222 if (StructuredSubobjectInitList) {
1223 StructuredSubobjectInitList->
setType(
T);
1225 unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
1228 if (EndIndex < ParentIList->getNumInits() &&
1229 ParentIList->
getInit(EndIndex)) {
1230 SourceLocation EndLoc
1240 diag::warn_missing_braces)
1246 StructuredSubobjectInitList->
getEndLoc()),
1252 if (!VerifyOnly && CXXRD && CXXRD->hasUserDeclaredConstructor()) {
1254 diag::warn_cxx20_compat_aggregate_init_with_ctors)
1270 unsigned DiagID = 0;
1283 DiagID = diag::warn_braces_around_init;
1290 DiagID = diag::warn_braces_around_init;
1316 llvm_unreachable(
"unexpected braced scalar init");
1332void InitListChecker::CheckExplicitInitList(
const InitializedEntity &Entity,
1333 InitListExpr *IList, QualType &
T,
1334 InitListExpr *StructuredList,
1335 bool TopLevelObject) {
1336 unsigned Index = 0, StructuredIndex = 0;
1337 CheckListElementTypes(Entity, IList,
T,
true,
1338 Index, StructuredList, StructuredIndex, TopLevelObject);
1339 if (StructuredList) {
1341 if (!
ExprTy->isArrayType())
1345 StructuredList->
setType(ExprTy);
1355 SourceLocation ExtraInitLoc =
1357 SourceRange ExtraInitRange =
1359 bool ExtraInitsIsError = SemaRef.
getLangOpts().CPlusPlus ||
1361 hadError = ExtraInitsIsError;
1364 }
else if (StructuredIndex == 1 && StructuredList->
getNumInits() != 0 &&
1370 ? diag::err_excess_initializers_in_char_array_initializer
1371 : diag::ext_excess_initializers_in_char_array_initializer;
1372 SemaRef.
Diag(ExtraInitLoc, DK) << ExtraInitRange;
1374 unsigned DK = ExtraInitsIsError
1375 ? diag::err_excess_initializers_for_sizeless_type
1376 : diag::ext_excess_initializers_for_sizeless_type;
1377 SemaRef.
Diag(ExtraInitLoc, DK) <<
T << ExtraInitRange;
1386 unsigned DK = ExtraInitsIsError ? diag::err_excess_initializers
1387 : diag::ext_excess_initializers;
1388 SemaRef.
Diag(ExtraInitLoc, DK) << initKind << ExtraInitRange;
1400 if (CXXRD && CXXRD->hasUserDeclaredConstructor()) {
1403 bool HasEquivCtor =
false;
1406 HasEquivCtor = CD && !CD->isDeleted();
1409 if (!HasEquivCtor) {
1411 diag::warn_cxx20_compat_aggregate_init_with_ctors)
1418void InitListChecker::CheckListElementTypes(
const InitializedEntity &Entity,
1419 InitListExpr *IList,
1421 bool SubobjectIsDesignatorContext,
1423 InitListExpr *StructuredList,
1424 unsigned &StructuredIndex,
1425 bool TopLevelObject) {
1429 CheckComplexType(Entity, IList, DeclType, Index,
1430 StructuredList, StructuredIndex);
1432 CheckScalarType(Entity, IList, DeclType, Index,
1433 StructuredList, StructuredIndex);
1435 CheckVectorType(Entity, IList, DeclType, Index,
1436 StructuredList, StructuredIndex);
1438 CheckMatrixType(Entity, IList, DeclType, Index, StructuredList,
1446 "non-aggregate records should be handed in CheckSubElementType");
1447 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
1448 Bases = CXXRD->bases();
1452 CheckStructUnionTypes(Entity, IList, DeclType, Bases, RD->field_begin(),
1453 SubobjectIsDesignatorContext, Index, StructuredList,
1454 StructuredIndex, TopLevelObject);
1459 CheckArrayType(Entity, IList, DeclType,
Zero,
1460 SubobjectIsDesignatorContext, Index,
1461 StructuredList, StructuredIndex);
1466 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1470 CheckReferenceType(Entity, IList, DeclType, Index,
1471 StructuredList, StructuredIndex);
1474 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_init_objc_class) << DeclType;
1479 CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1486 assert(AggrDeductionCandidateParamTypes);
1487 AggrDeductionCandidateParamTypes->push_back(DeclType);
1490 SemaRef.
Diag(IList->
getBeginLoc(), diag::err_illegal_initializer_type)
1496void InitListChecker::CheckSubElementType(
const InitializedEntity &Entity,
1497 InitListExpr *IList,
1500 InitListExpr *StructuredList,
1501 unsigned &StructuredIndex,
1502 bool DirectlyDesignated) {
1506 return CheckReferenceType(Entity, IList, ElemType, Index,
1507 StructuredList, StructuredIndex);
1509 if (InitListExpr *SubInitList = dyn_cast<InitListExpr>(
expr)) {
1510 if (SubInitList->getNumInits() == 1 &&
1515 expr = SubInitList->getInit(0);
1522 "found implicit initialization for the wrong type");
1523 UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1534 InitializationKind
Kind =
1545 if (TmpEntity.getType()->isDependentType()) {
1550 assert(AggrDeductionCandidateParamTypes);
1565 !isa_and_present<ConstantArrayType>(
1568 AggrDeductionCandidateParamTypes->push_back(ElemType);
1572 InitializationSequence
Seq(SemaRef, TmpEntity, Kind,
expr,
1581 if (
auto *Embed = dyn_cast<EmbedExpr>(
expr)) {
1582 expr = HandleEmbed(Embed, Entity);
1589 UpdateStructuredListElement(StructuredList, StructuredIndex,
1593 }
else if (StructuredList) {
1594 UpdateStructuredListElement(StructuredList, StructuredIndex,
1599 if (AggrDeductionCandidateParamTypes)
1600 AggrDeductionCandidateParamTypes->push_back(ElemType);
1608 return CheckScalarType(Entity, IList, ElemType, Index,
1609 StructuredList, StructuredIndex);
1623 UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1646 AssignConvertType::Incompatible) {
1654 UpdateStructuredListElement(StructuredList, StructuredIndex,
1655 ExprRes.
getAs<Expr>());
1672 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
1677 if (DirectlyDesignated && SemaRef.
getLangOpts().CPlusPlus && !hadError) {
1678 if (InOverloadResolution)
1682 diag::ext_designated_init_brace_elision)
1683 <<
expr->getSourceRange()
1698 assert(
Copy.isInvalid() &&
1699 "expected non-aggregate initialization to fail");
1707void InitListChecker::CheckComplexType(
const InitializedEntity &Entity,
1708 InitListExpr *IList, QualType DeclType,
1710 InitListExpr *StructuredList,
1711 unsigned &StructuredIndex) {
1712 assert(Index == 0 &&
"Index in explicit init list must be zero");
1722 return CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
1727 if (!SemaRef.
getLangOpts().CPlusPlus && !VerifyOnly)
1732 QualType elementType = DeclType->
castAs<ComplexType>()->getElementType();
1733 InitializedEntity ElementEntity =
1736 for (
unsigned i = 0; i < 2; ++i) {
1738 CheckSubElementType(ElementEntity, IList, elementType, Index,
1739 StructuredList, StructuredIndex);
1743void InitListChecker::CheckScalarType(
const InitializedEntity &Entity,
1744 InitListExpr *IList, QualType DeclType,
1746 InitListExpr *StructuredList,
1747 unsigned &StructuredIndex) {
1754 ? diag::warn_cxx98_compat_empty_sizeless_initializer
1755 : diag::err_empty_sizeless_initializer)
1760 ? diag::warn_cxx98_compat_empty_scalar_initializer
1761 : diag::err_empty_scalar_initializer)
1773 if (InitListExpr *SubIList = dyn_cast<InitListExpr>(
expr)) {
1777 SemaRef.
Diag(SubIList->getBeginLoc(), diag::ext_many_braces_around_init)
1780 CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList,
1786 diag::err_designator_for_scalar_or_sizeless_init)
1788 <<
expr->getSourceRange();
1793 }
else if (
auto *Embed = dyn_cast<EmbedExpr>(
expr)) {
1794 expr = HandleEmbed(Embed, Entity);
1809 Expr *ResultExpr =
nullptr;
1814 ResultExpr =
Result.getAs<Expr>();
1816 if (ResultExpr !=
expr && !VerifyOnly && !CurEmbed) {
1819 IList->
setInit(Index, ResultExpr);
1823 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1826 if (AggrDeductionCandidateParamTypes)
1827 AggrDeductionCandidateParamTypes->push_back(DeclType);
1830void InitListChecker::CheckReferenceType(
const InitializedEntity &Entity,
1831 InitListExpr *IList, QualType DeclType,
1833 InitListExpr *StructuredList,
1834 unsigned &StructuredIndex) {
1842 diag::err_init_reference_member_uninitialized)
1878 if (!VerifyOnly &&
expr)
1881 UpdateStructuredListElement(StructuredList, StructuredIndex,
expr);
1883 if (AggrDeductionCandidateParamTypes)
1884 AggrDeductionCandidateParamTypes->push_back(DeclType);
1887void InitListChecker::CheckMatrixType(
const InitializedEntity &Entity,
1888 InitListExpr *IList, QualType DeclType,
1890 InitListExpr *StructuredList,
1891 unsigned &StructuredIndex) {
1895 const ConstantMatrixType *MT = DeclType->
castAs<ConstantMatrixType>();
1902 "Inits must equal Matrix element count");
1907 InitializedEntity Element =
1910 while (Index < IList->getNumInits()) {
1915 CheckSubElementType(Element, IList, ElemTy, Index, StructuredList,
1920void InitListChecker::CheckVectorType(
const InitializedEntity &Entity,
1921 InitListExpr *IList, QualType DeclType,
1923 InitListExpr *StructuredList,
1924 unsigned &StructuredIndex) {
1925 const VectorType *VT = DeclType->
castAs<VectorType>();
1927 unsigned numEltsInit = 0;
1932 CheckEmptyInitializable(
1955 Expr *ResultExpr =
nullptr;
1959 ResultExpr =
Result.getAs<Expr>();
1961 if (ResultExpr !=
Init && !VerifyOnly) {
1964 IList->
setInit(Index, ResultExpr);
1967 UpdateStructuredListElement(StructuredList, StructuredIndex, ResultExpr);
1969 if (AggrDeductionCandidateParamTypes)
1970 AggrDeductionCandidateParamTypes->push_back(elementType);
1974 InitializedEntity ElementEntity =
1977 for (
unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
1980 CheckEmptyInitializable(ElementEntity, IList->
getEndLoc());
1985 CheckSubElementType(ElementEntity, IList, elementType, Index,
1986 StructuredList, StructuredIndex);
1994 if (isBigEndian && (
T->getVectorKind() == VectorKind::Neon ||
1995 T->getVectorKind() == VectorKind::NeonPoly)) {
2007 diag::warn_neon_vector_initializer_non_portable);
2009 const char *typeCode;
2021 llvm_unreachable(
"Invalid element type!");
2025 ? diag::note_neon_vector_initializer_non_portable_q
2026 : diag::note_neon_vector_initializer_non_portable)
2027 << typeCode << typeSize;
2033 InitializedEntity ElementEntity =
2037 for (
unsigned i = 0; i < maxElements; ++i) {
2046 CheckSubElementType(ElementEntity, IList, elementType, Index,
2047 StructuredList, StructuredIndex);
2051 const VectorType *IVT = IType->
castAs<VectorType>();
2059 CheckSubElementType(ElementEntity, IList, VecType, Index,
2060 StructuredList, StructuredIndex);
2061 numEltsInit += numIElts;
2066 if (numEltsInit != maxElements) {
2069 diag::err_vector_incorrect_num_elements)
2070 << (numEltsInit < maxElements) << maxElements << numEltsInit
2088 auto *CXXRD = ElementType->getAsCXXRecordDecl();
2094 if (!CXXRD || !CXXRD->hasDefinition())
2102 SemaRef.
PDiag(diag::err_access_dtor_temp)
2122 ExprList.size() == 1
2123 ? dyn_cast_if_present<EmbedExpr>(ExprList[0]->IgnoreParens())
2136void InitListChecker::CheckArrayType(
const InitializedEntity &Entity,
2137 InitListExpr *IList, QualType &DeclType,
2138 llvm::APSInt elementIndex,
2139 bool SubobjectIsDesignatorContext,
2141 InitListExpr *StructuredList,
2142 unsigned &StructuredIndex) {
2160 if (Index < IList->getNumInits()) {
2173 if (StructuredList) {
2174 UpdateStructuredListElement(StructuredList, StructuredIndex,
2179 if (AggrDeductionCandidateParamTypes)
2180 AggrDeductionCandidateParamTypes->push_back(DeclType);
2184 if (
const VariableArrayType *VAT = dyn_cast<VariableArrayType>(
arrayType)) {
2201 SemaRef.
Diag(VAT->getSizeExpr()->getBeginLoc(),
2202 diag::err_variable_object_no_init)
2203 << VAT->getSizeExpr()->getSourceRange();
2212 if (elementIndex.getBitWidth() < 64)
2213 elementIndex = elementIndex.extend(64);
2216 llvm::APSInt maxElements(elementIndex.getBitWidth(),
2217 elementIndex.isUnsigned());
2218 bool maxElementsKnown =
false;
2219 if (
const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(
arrayType)) {
2220 maxElements = CAT->getSize();
2221 elementIndex = elementIndex.extOrTrunc(maxElements.getBitWidth());
2222 elementIndex.setIsUnsigned(maxElements.isUnsigned());
2223 maxElementsKnown =
true;
2226 QualType elementType =
arrayType->getElementType();
2227 while (Index < IList->getNumInits()) {
2229 if (DesignatedInitExpr *DIE = dyn_cast<DesignatedInitExpr>(
Init)) {
2233 if (!SubobjectIsDesignatorContext)
2238 if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
2239 DeclType,
nullptr, &elementIndex, Index,
2240 StructuredList, StructuredIndex,
true,
2246 if (elementIndex.getBitWidth() > maxElements.getBitWidth())
2247 maxElements = maxElements.extend(elementIndex.getBitWidth());
2248 else if (elementIndex.getBitWidth() < maxElements.getBitWidth())
2249 elementIndex = elementIndex.extend(maxElements.getBitWidth());
2250 elementIndex.setIsUnsigned(maxElements.isUnsigned());
2254 if (!maxElementsKnown && elementIndex > maxElements)
2255 maxElements = elementIndex;
2262 if (maxElementsKnown && elementIndex == maxElements)
2266 SemaRef.
Context, StructuredIndex, Entity);
2269 unsigned EmbedElementIndexBeforeInit = CurEmbedIndex;
2271 CheckSubElementType(ElementEntity, IList, elementType, Index,
2272 StructuredList, StructuredIndex);
2277 elementIndex + CurEmbedIndex - EmbedElementIndexBeforeInit - 1;
2281 EmbedElementIndexBeforeInit - 1;
2287 if (!maxElementsKnown && elementIndex > maxElements)
2288 maxElements = elementIndex;
2293 llvm::APSInt
Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
2297 SemaRef.
Diag(IList->
getBeginLoc(), diag::ext_typecheck_zero_array_size);
2307 elementType, maxElements,
nullptr, ArraySizeModifier::Normal, 0);
2314 if ((maxElementsKnown && elementIndex < maxElements) ||
2316 CheckEmptyInitializable(
2322bool InitListChecker::CheckFlexibleArrayInit(
const InitializedEntity &Entity,
2325 bool TopLevelObject) {
2327 unsigned FlexArrayDiag;
2331 FlexArrayDiag = diag::ext_flexible_array_init;
2332 }
else if (!TopLevelObject) {
2334 FlexArrayDiag = diag::err_flexible_array_init;
2337 FlexArrayDiag = diag::err_flexible_array_init;
2340 FlexArrayDiag = diag::err_flexible_array_init;
2343 FlexArrayDiag = diag::ext_flexible_array_init;
2349 SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
2353 return FlexArrayDiag != diag::ext_flexible_array_init;
2357 return StructuredList && StructuredList->
getNumInits() == 1U;
2360void InitListChecker::CheckStructUnionTypes(
2361 const InitializedEntity &Entity, InitListExpr *IList, QualType DeclType,
2363 bool SubobjectIsDesignatorContext,
unsigned &Index,
2364 InitListExpr *StructuredList,
unsigned &StructuredIndex,
2365 bool TopLevelObject) {
2379 for (FieldDecl *FD : RD->
fields()) {
2390 if (!StructuredList)
2393 Field != FieldEnd; ++Field) {
2394 if (
Field->hasInClassInitializer() ||
2395 (
Field->isAnonymousStructOrUnion() &&
2397 ->castAsCXXRecordDecl()
2398 ->hasInClassInitializer())) {
2404 llvm_unreachable(
"Couldn't find in-class initializer");
2410 Field != FieldEnd; ++Field) {
2411 if (!
Field->isUnnamedBitField()) {
2412 CheckEmptyInitializable(
2423 bool InitializedSomething =
false;
2426 for (
auto I = Bases.begin(), E = Bases.end(); I != E; ++I) {
2432 if (isa_and_nonnull<DesignatedInitExpr>(
Init))
2449 if (AggrDeductionCandidateParamTypes &&
Base.isPackExpansion()) {
2450 AggrDeductionCandidateParamTypes->push_back(
2455 if (Index < IList->getNumInits())
2465 SemaRef.
Context, &Base,
false, &Entity);
2467 CheckSubElementType(BaseEntity, IList,
Base.getType(), Index,
2468 StructuredList, StructuredIndex);
2469 InitializedSomething =
true;
2471 CheckEmptyInitializable(BaseEntity, InitLoc);
2486 size_t NumRecordDecls = llvm::count_if(RD->
decls(), [&](
const Decl *D) {
2487 return isa<FieldDecl>(D) || isa<RecordDecl>(D);
2489 bool HasDesignatedInit =
false;
2491 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
2493 while (Index < IList->getNumInits()) {
2495 SourceLocation InitLoc =
Init->getBeginLoc();
2497 if (DesignatedInitExpr *DIE = dyn_cast<DesignatedInitExpr>(
Init)) {
2501 if (!SubobjectIsDesignatorContext)
2504 HasDesignatedInit =
true;
2508 bool DesignatedInitFailed = CheckDesignatedInitializer(
2509 Entity, IList, DIE, 0, DeclType, &Field,
nullptr, Index,
2510 StructuredList, StructuredIndex,
true, TopLevelObject);
2511 if (DesignatedInitFailed)
2515 DesignatedInitExpr::Designator *D = DIE->getDesignator(0);
2518 InitializedFields.insert(F);
2519 if (!DesignatedInitFailed) {
2528 InitializedSomething =
true;
2545 if (NumRecordDecls == 1)
2547 if (
const auto *IL = dyn_cast<IntegerLiteral>(I))
2548 return IL->getValue().isZero();
2556 SemaRef.
Diag(InitLoc, diag::err_non_designated_init_used);
2561 if (Field == FieldEnd) {
2567 if (InitializedSomething && RD->
isUnion())
2571 if (
Field->getType()->isIncompleteArrayType())
2574 if (
Field->isUnnamedBitField()) {
2583 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
2602 InitializedEntity MemberEntity =
2604 CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
2605 StructuredList, StructuredIndex);
2606 InitializedSomething =
true;
2607 InitializedFields.insert(*Field);
2619 bool IsCDesignatedInitializer =
2620 HasDesignatedInit && !SemaRef.
getLangOpts().CPlusPlus;
2621 if (!VerifyOnly && InitializedSomething && !RD->
isUnion() &&
2623 !IsCDesignatedInitializer) {
2630 if (HasDesignatedInit && InitializedFields.count(*it))
2633 if (!it->isUnnamedBitField() && !it->hasInClassInitializer() &&
2634 !it->getType()->isIncompleteArrayType()) {
2635 auto Diag = HasDesignatedInit
2636 ? diag::warn_missing_designated_field_initializers
2637 : diag::warn_missing_field_initializers;
2646 if (!StructuredList && Field != FieldEnd && !RD->
isUnion() &&
2647 !
Field->getType()->isIncompleteArrayType()) {
2648 for (;
Field != FieldEnd && !hadError; ++
Field) {
2649 if (!
Field->isUnnamedBitField() && !
Field->hasInClassInitializer())
2650 CheckEmptyInitializable(
2671 if (Field == FieldEnd || !
Field->getType()->isIncompleteArrayType() ||
2675 if (CheckFlexibleArrayInit(Entity, IList->
getInit(Index), *Field,
2682 InitializedEntity MemberEntity =
2686 AggrDeductionCandidateParamTypes)
2687 CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
2688 StructuredList, StructuredIndex);
2690 CheckImplicitInitList(MemberEntity, IList,
Field->getType(), Index,
2691 StructuredList, StructuredIndex);
2712 PE = IndirectField->
chain_end(); PI != PE; ++PI) {
2728 &Replacements[0] + Replacements.size());
2735 for (
unsigned I = 0; I < NumIndexExprs; ++I)
2747class FieldInitializerValidatorCCC final :
public CorrectionCandidateCallback {
2749 explicit FieldInitializerValidatorCCC(
const RecordDecl *RD)
2752 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2757 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
2758 return std::make_unique<FieldInitializerValidatorCCC>(*
this);
2762 const RecordDecl *
Record;
2805InitListChecker::CheckDesignatedInitializer(
const InitializedEntity &Entity,
2806 InitListExpr *IList,
2807 DesignatedInitExpr *DIE,
2809 QualType &CurrentObjectType,
2811 llvm::APSInt *NextElementIndex,
2813 InitListExpr *StructuredList,
2814 unsigned &StructuredIndex,
2815 bool FinishSubobjectInit,
2816 bool TopLevelObject) {
2817 if (DesigIdx == DIE->
size()) {
2825 "designator result in direct non-list initialization?");
2828 InitializationSequence
Seq(SemaRef, Entity, Kind,
Init,
2830 if (StructuredList) {
2834 UpdateStructuredListElement(StructuredList, StructuredIndex,
2838 if (AggrDeductionCandidateParamTypes)
2839 AggrDeductionCandidateParamTypes->push_back(CurrentObjectType);
2844 bool prevHadError = hadError;
2849 unsigned OldIndex = Index;
2851 dyn_cast_if_present<DesignatedInitExpr>(IList->
getInit(OldIndex));
2854 IList->
setInit(OldIndex, OldDIE->getInit());
2856 CheckSubElementType(Entity, IList, CurrentObjectType, Index, StructuredList,
2857 StructuredIndex,
true);
2861 if (IList->
getInit(OldIndex) != OldDIE->getInit())
2862 OldDIE->setInit(IList->
getInit(OldIndex));
2863 IList->
setInit(OldIndex, OldDIE);
2865 return hadError && !prevHadError;
2868 DesignatedInitExpr::Designator *D = DIE->
getDesignator(DesigIdx);
2869 bool IsFirstDesignator = (DesigIdx == 0);
2870 if (IsFirstDesignator ? FullyStructuredList : StructuredList) {
2873 if (IsFirstDesignator)
2874 StructuredList = FullyStructuredList;
2876 Expr *ExistingInit = StructuredIndex < StructuredList->getNumInits() ?
2877 StructuredList->getInit(StructuredIndex) :
nullptr;
2878 if (!ExistingInit && StructuredList->hasArrayFiller())
2879 ExistingInit = StructuredList->getArrayFiller();
2882 StructuredList = getStructuredSubobjectInit(
2883 IList, Index, CurrentObjectType, StructuredList, StructuredIndex,
2885 else if (InitListExpr *
Result = dyn_cast<InitListExpr>(ExistingInit))
2899 diagnoseInitOverride(ExistingInit,
2905 if (DesignatedInitUpdateExpr *E =
2906 dyn_cast<DesignatedInitUpdateExpr>(ExistingInit))
2907 StructuredList = E->getUpdater();
2909 DesignatedInitUpdateExpr *DIUE =
new (SemaRef.
Context)
2912 StructuredList->updateInit(SemaRef.
Context, StructuredIndex, DIUE);
2921 StructuredList =
nullptr;
2943 SemaRef.
Diag(Loc, diag::err_field_designator_non_aggr)
2944 << SemaRef.
getLangOpts().CPlusPlus << CurrentObjectType;
2953 if (
auto *FD = dyn_cast_if_present<FieldDecl>(VD)) {
2955 }
else if (
auto *IFD = dyn_cast_if_present<IndirectFieldDecl>(VD)) {
2976 if (DeclContextLookupResult Lookup = RD->
lookup(FieldName);
2980 SemaRef.
Diag(Lookup.front()->getLocation(),
2981 diag::note_field_designator_found);
2988 FieldInitializerValidatorCCC CCC(RD);
2989 if (TypoCorrection Corrected = SemaRef.
CorrectTypo(
2992 CorrectTypoKind::ErrorRecovery, RD)) {
2995 SemaRef.
PDiag(diag::err_field_designator_unknown_suggest)
2996 << FieldName << CurrentObjectType);
2997 KnownField = Corrected.getCorrectionDeclAs<FieldDecl>();
3008 SemaRef.
Diag(Loc, diag::err_field_designator_unknown)
3016 unsigned NumBases = 0;
3017 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
3018 NumBases = CXXRD->getNumBases();
3020 unsigned FieldIndex = NumBases;
3022 for (
auto *FI : RD->
fields()) {
3023 if (FI->isUnnamedBitField())
3039 if (StructuredList) {
3040 FieldDecl *CurrentField = StructuredList->getInitializedFieldInUnion();
3042 assert(StructuredList->getNumInits() == 1
3043 &&
"A union should never have more than one initializer!");
3045 Expr *ExistingInit = StructuredList->getInit(0);
3048 diagnoseInitOverride(
3056 StructuredList->resizeInits(SemaRef.
Context, 0);
3057 StructuredList->setInitializedFieldInUnion(
nullptr);
3060 StructuredList->setInitializedFieldInUnion(*Field);
3067 InvalidUse = !SemaRef.
CanUseDecl(*Field, TreatUnavailableAsInvalid);
3090 if (IsFirstDesignator && !VerifyOnly && SemaRef.
getLangOpts().CPlusPlus &&
3093 (*NextField)->getFieldIndex() >
Field->getFieldIndex() + 1)) {
3095 FieldDecl *PrevField =
nullptr;
3097 if (FI->isUnnamedBitField())
3105 const auto GenerateDesignatedInitReorderingFixit =
3106 [&](SemaBase::SemaDiagnosticBuilder &
Diag) {
3107 struct ReorderInfo {
3109 const Expr *InitExpr{};
3112 llvm::SmallDenseMap<IdentifierInfo *, int> MemberNameInx{};
3113 llvm::SmallVector<ReorderInfo, 16> ReorderedInitExprs{};
3115 const auto *CxxRecord =
3118 for (
const FieldDecl *Field : CxxRecord->fields())
3119 MemberNameInx[
Field->getIdentifier()] =
Field->getFieldIndex();
3121 for (
const Expr *
Init : IList->
inits()) {
3122 if (
const auto *DI =
3123 dyn_cast_if_present<DesignatedInitExpr>(
Init)) {
3125 if (DI->size() != 1)
3128 const IdentifierInfo *
const FieldName =
3129 DI->getDesignator(0)->getFieldName();
3132 if (MemberNameInx.contains(FieldName))
3133 ReorderedInitExprs.emplace_back(
3134 ReorderInfo{MemberNameInx.at(FieldName),
Init});
3138 llvm::sort(ReorderedInitExprs,
3139 [](
const ReorderInfo &A,
const ReorderInfo &B) {
3140 return A.Pos < B.Pos;
3144 const LangOptions &LangOpts = SemaRef.
getLangOpts();
3148 const ArrayRef<clang::Expr *> IListInits =
3149 IList->
inits().drop_front(CxxRecord->getNumBases());
3151 for (
const auto &[OrigExpr, Repl] :
3152 llvm::zip(IListInits, ReorderedInitExprs)) {
3154 Repl.InitExpr->getSourceRange());
3155 const StringRef InitText =
3166 diag::ext_designated_init_reordered)
3169 unsigned OldIndex = StructuredIndex - 1;
3170 if (StructuredList && OldIndex <= StructuredList->getNumInits()) {
3171 if (Expr *PrevInit = StructuredList->getInit(OldIndex)) {
3172 auto Diag = SemaRef.
Diag(PrevInit->getBeginLoc(),
3173 diag::note_previous_field_init)
3175 GenerateDesignatedInitReorderingFixit(
Diag);
3188 if (StructuredList && FieldIndex >= StructuredList->getNumInits())
3189 StructuredList->resizeInits(SemaRef.
Context, FieldIndex + 1);
3192 if (
Field->getType()->isIncompleteArrayType()) {
3194 if ((DesigIdx + 1) != DIE->
size()) {
3198 DesignatedInitExpr::Designator *NextD
3201 diag::err_designator_into_flexible_array_member)
3203 SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
3214 diag::err_flexible_array_init_needs_braces)
3216 SemaRef.
Diag(
Field->getLocation(), diag::note_flexible_array_member)
3223 if (!
Invalid && CheckFlexibleArrayInit(Entity, DIE->
getInit(), *Field,
3233 bool prevHadError = hadError;
3234 unsigned newStructuredIndex = FieldIndex;
3235 unsigned OldIndex = Index;
3238 InitializedEntity MemberEntity =
3240 CheckSubElementType(MemberEntity, IList,
Field->getType(), Index,
3241 StructuredList, newStructuredIndex);
3243 IList->
setInit(OldIndex, DIE);
3244 if (hadError && !prevHadError) {
3249 StructuredIndex = FieldIndex;
3254 QualType FieldType =
Field->getType();
3255 unsigned newStructuredIndex = FieldIndex;
3257 InitializedEntity MemberEntity =
3259 if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
3260 FieldType,
nullptr,
nullptr, Index,
3261 StructuredList, newStructuredIndex,
3262 FinishSubobjectInit,
false))
3273 if (IsFirstDesignator) {
3280 StructuredIndex = FieldIndex;
3284 if (!FinishSubobjectInit)
3292 bool prevHadError = hadError;
3297 CheckStructUnionTypes(Entity, IList, CurrentObjectType, NoBases, Field,
3298 false, Index, StructuredList, FieldIndex);
3299 return hadError && !prevHadError;
3321 << CurrentObjectType;
3326 Expr *IndexExpr =
nullptr;
3327 llvm::APSInt DesignatedStartIndex, DesignatedEndIndex;
3331 DesignatedEndIndex = DesignatedStartIndex;
3335 DesignatedStartIndex =
3337 DesignatedEndIndex =
3346 if (DesignatedStartIndex.getZExtValue()!=DesignatedEndIndex.getZExtValue()&&
3353 DesignatedStartIndex
3354 = DesignatedStartIndex.extOrTrunc(MaxElements.getBitWidth());
3355 DesignatedStartIndex.setIsUnsigned(MaxElements.isUnsigned());
3357 = DesignatedEndIndex.extOrTrunc(MaxElements.getBitWidth());
3358 DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned());
3359 if (DesignatedEndIndex >= MaxElements) {
3362 diag::err_array_designator_too_large)
3369 unsigned DesignatedIndexBitWidth =
3371 DesignatedStartIndex =
3372 DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
3373 DesignatedEndIndex =
3374 DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
3375 DesignatedStartIndex.setIsUnsigned(
true);
3376 DesignatedEndIndex.setIsUnsigned(
true);
3379 bool IsStringLiteralInitUpdate =
3380 StructuredList && StructuredList->isStringLiteralInit();
3381 if (IsStringLiteralInitUpdate && VerifyOnly) {
3384 StructuredList =
nullptr;
3385 }
else if (IsStringLiteralInitUpdate) {
3388 ASTContext &Context = SemaRef.
Context;
3389 Expr *SubExpr = StructuredList->getInit(0)->IgnoreParenImpCasts();
3395 QualType PromotedCharTy = CharTy;
3398 unsigned PromotedCharTyWidth = Context.
getTypeSize(PromotedCharTy);
3400 if (StringLiteral *SL = dyn_cast<StringLiteral>(SubExpr)) {
3403 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT);
3404 CAT && CAT->getSize().ult(StrLen))
3405 StrLen = CAT->getZExtSize();
3406 StructuredList->resizeInits(Context, StrLen);
3410 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
3411 llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
3412 Expr *
Init =
new (Context) IntegerLiteral(
3413 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
3414 if (CharTy != PromotedCharTy)
3417 FPOptionsOverride());
3418 StructuredList->updateInit(Context, i,
Init);
3427 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT);
3428 CAT && CAT->getSize().ult(StrLen))
3429 StrLen = CAT->getZExtSize();
3430 StructuredList->resizeInits(Context, StrLen);
3434 for (
unsigned i = 0, e = StrLen; i != e; ++i) {
3435 llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
3436 Expr *
Init =
new (Context) IntegerLiteral(
3437 Context, CodeUnit, PromotedCharTy, SubExpr->
getExprLoc());
3438 if (CharTy != PromotedCharTy)
3441 FPOptionsOverride());
3442 StructuredList->updateInit(Context, i,
Init);
3449 if (StructuredList &&
3450 DesignatedEndIndex.getZExtValue() >= StructuredList->getNumInits())
3451 StructuredList->resizeInits(SemaRef.
Context,
3452 DesignatedEndIndex.getZExtValue() + 1);
3458 unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
3459 unsigned OldIndex = Index;
3461 InitializedEntity ElementEntity =
3464 while (DesignatedStartIndex <= DesignatedEndIndex) {
3470 if (CheckDesignatedInitializer(
3471 ElementEntity, IList, DIE, DesigIdx + 1, ElementType,
nullptr,
3472 nullptr, Index, StructuredList, ElementIndex,
3473 FinishSubobjectInit && (DesignatedStartIndex == DesignatedEndIndex),
3478 ++DesignatedStartIndex;
3479 ElementIndex = DesignatedStartIndex.getZExtValue();
3484 if (IsFirstDesignator) {
3485 if (NextElementIndex)
3486 *NextElementIndex = std::move(DesignatedStartIndex);
3487 StructuredIndex = ElementIndex;
3491 if (!FinishSubobjectInit)
3495 bool prevHadError = hadError;
3496 CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex,
3498 StructuredList, ElementIndex);
3499 return hadError && !prevHadError;
3505InitListChecker::getStructuredSubobjectInit(InitListExpr *IList,
unsigned Index,
3506 QualType CurrentObjectType,
3507 InitListExpr *StructuredList,
3508 unsigned StructuredIndex,
3509 SourceRange InitRange,
3510 bool IsFullyOverwritten) {
3511 if (!StructuredList)
3514 Expr *ExistingInit =
nullptr;
3515 if (StructuredIndex < StructuredList->getNumInits())
3516 ExistingInit = StructuredList->
getInit(StructuredIndex);
3518 if (InitListExpr *
Result = dyn_cast_or_null<InitListExpr>(ExistingInit))
3527 if (!IsFullyOverwritten)
3550 diagnoseInitOverride(ExistingInit, InitRange);
3553 unsigned ExpectedNumInits = 0;
3554 if (Index < IList->getNumInits()) {
3555 if (
auto *
Init = dyn_cast_or_null<InitListExpr>(IList->
getInit(Index)))
3556 ExpectedNumInits =
Init->getNumInits();
3561 InitListExpr *
Result = createInitListExpr(
3562 CurrentObjectType, InitRange, ExpectedNumInits,
false);
3570InitListExpr *InitListChecker::createInitListExpr(QualType CurrentObjectType,
3571 SourceRange InitRange,
3572 unsigned ExpectedNumInits,
3576 {}, InitRange.
getEnd(), IsExplicit);
3578 QualType ResultType = CurrentObjectType;
3581 Result->setType(ResultType);
3584 unsigned NumElements = 0;
3586 if (
const ArrayType *AType
3588 if (
const ConstantArrayType *CAType = dyn_cast<ConstantArrayType>(AType)) {
3589 NumElements = CAType->getZExtSize();
3592 if (NumElements > ExpectedNumInits)
3595 }
else if (
const VectorType *VType = CurrentObjectType->
getAs<VectorType>()) {
3596 NumElements = VType->getNumElements();
3598 NumElements = numStructUnionElements(CurrentObjectType);
3610void InitListChecker::UpdateStructuredListElement(InitListExpr *StructuredList,
3611 unsigned &StructuredIndex,
3614 if (!StructuredList)
3618 StructuredIndex,
expr)) {
3624 diagnoseInitOverride(PrevInit,
expr->getSourceRange());
3633 InitListChecker Check(*
this, Entity, From,
Type,
true,
3636 return !Check.HadError();
3641 auto AsMultiElementEmbed = [](
Expr *
Init) {
3642 auto *Embed = dyn_cast<EmbedExpr>(
Init->IgnoreParenImpCasts());
3645 if (llvm::none_of(ILE->
inits(), AsMultiElementEmbed))
3653 Storage.push_back(
Init);
3683 return S.
Diag(Loc, diag::err_array_designator_negative)
3686 Value.setIsUnsigned(
true);
3705 Designators.push_back(ASTDesignator::CreateFieldDesignator(
3709 llvm::APSInt IndexValue;
3715 Designators.push_back(ASTDesignator::CreateArrayDesignator(
3717 InitExpressions.push_back(Index);
3722 llvm::APSInt StartValue;
3723 llvm::APSInt EndValue;
3728 if (!StartDependent)
3734 if (!StartIndex || !EndIndex)
3738 if (StartDependent || EndDependent) {
3740 }
else if (StartValue.getBitWidth() > EndValue.getBitWidth())
3741 EndValue = EndValue.extend(StartValue.getBitWidth());
3742 else if (StartValue.getBitWidth() < EndValue.getBitWidth())
3743 StartValue = StartValue.extend(EndValue.getBitWidth());
3745 if (!StartDependent && !EndDependent && EndValue < StartValue) {
3751 Designators.push_back(ASTDesignator::CreateArrayRangeDesignator(
3754 InitExpressions.push_back(StartIndex);
3755 InitExpressions.push_back(EndIndex);
3765 EqualOrColonLoc, GNUSyntax,
3773InitializedEntity::InitializedEntity(
ASTContext &Context,
unsigned Index,
3775 : Parent(&Parent), Index(Index)
3778 Kind = EK_ArrayElement;
3779 Type = AT->getElementType();
3781 Kind = EK_VectorElement;
3782 Type = VT->getElementType();
3784 Kind = EK_MatrixElement;
3785 Type = MT->getElementType();
3787 const ComplexType *CT = Parent.getType()->getAs<ComplexType>();
3788 assert(CT &&
"Unexpected type");
3789 Kind = EK_ComplexElement;
3790 Type = CT->getElementType();
3797 bool IsInheritedVirtualBase,
3798 const InitializedEntity *Parent) {
3799 InitializedEntity
Result;
3802 Result.Base = {
Base, IsInheritedVirtualBase};
3820 return Variable.VariableOrMember->getDeclName();
3843 llvm_unreachable(
"Invalid EntityKind!");
3878 llvm_unreachable(
"Invalid EntityKind!");
3914unsigned InitializedEntity::dumpImpl(raw_ostream &OS)
const {
3917 for (
unsigned I = 0; I != Depth; ++I)
3934 case EK_New: OS <<
"New";
break;
3938 case EK_Base: OS <<
"Base";
break;
3943 OS <<
"MatrixElement " <<
Index;
3948 OS <<
"Block (lambda)";
3951 OS <<
"LambdaCapture ";
3958 D->printQualifiedName(OS);
3967 dumpImpl(llvm::errs());
4023 for (
const Step &S : llvm::reverse(Steps)) {
4084 llvm_unreachable(
"Invalid EntityKind!");
4092InitializationSequence
4095 bool HadMultipleCandidates) {
4120 bool BindingTemporary) {
4145 bool HadMultipleCandidates) {
4190 bool TopLevelOfInitList) {
4208 bool HadMultipleCandidates,
bool FromInitList,
bool AsInitList) {
4259 Steps.insert(Steps.begin(), S);
4320 "Can only unwrap trivial init lists.");
4324 Steps.insert(Steps.begin(), S);
4330 "Can only rewrap trivial init lists.");
4334 Steps.insert(Steps.begin(), S);
4352 this->Failure = Failure;
4353 this->FailedOverloadResult =
Result;
4374 if (!
Init.empty()) {
4394 "consuming an object of unretainable type?");
4414 bool TreatUnavailableAsInvalid) {
4432 Expr *OVEAsExpr = OVE;
4435 TreatUnavailableAsInvalid);
4441 const InitializedEntity &Entity,
4442 const InitializationKind &Kind,
4443 InitListExpr *InitList,
4445 bool TreatUnavailableAsInvalid);
4456 bool TreatUnavailableAsInvalid) {
4477 TreatUnavailableAsInvalid);
4504 bool CopyInitializing,
bool AllowExplicit,
bool OnlyListConstructors,
4505 bool IsListInit,
bool RequireActualConstructor,
4506 bool SecondStepOfCopyInit =
false) {
4512 if (!Info.Constructor || Info.Constructor->isInvalidDecl())
4529 bool SuppressUserConversions =
4530 SecondStepOfCopyInit ||
4534 if (Info.ConstructorTmpl)
4536 Info.ConstructorTmpl, Info.FoundDecl,
4537 nullptr, Args, CandidateSet, SuppressUserConversions,
4538 false, AllowExplicit);
4547 bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
4551 CandidateSet, SuppressUserConversions,
4552 false, AllowExplicit,
4568 if (S.
getLangOpts().CPlusPlus17 && Args.size() == 1 &&
4569 !RequireActualConstructor && !SecondStepOfCopyInit) {
4571 auto *SourceRD =
Initializer->getType()->getAsCXXRecordDecl();
4573 const auto &Conversions = SourceRD->getVisibleConversionFunctions();
4574 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4588 ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
4589 CandidateSet, AllowExplicit, AllowExplicit,
4593 DestType, CandidateSet, AllowExplicit,
4620 bool IsListInit =
false,
4621 bool IsInitListCopy =
false) {
4622 assert(((!IsListInit && !IsInitListCopy) ||
4624 "IsListInit/IsInitListCopy must come with a single initializer list "
4638 bool RequireActualConstructor =
4644 bool CopyElisionPossible =
false;
4645 auto ElideConstructor = [&] {
4661 if (S.
getLangOpts().CPlusPlus17 && !RequireActualConstructor &&
4662 UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isPRValue() &&
4684 assert(!IsInitListCopy &&
4685 "IsInitListCopy only possible with aggregate types");
4686 CopyElisionPossible =
true;
4700 bool AllowExplicit = Kind.AllowExplicit() || IsListInit;
4710 bool AsInitializerList =
false;
4722 AsInitializerList =
true;
4728 S, Kind.getLocation(), Args, CandidateSet, DestType, Ctors, Best,
4729 CopyInitialization, AllowExplicit,
4730 true, IsListInit, RequireActualConstructor);
4747 Args[0]->getType().getNonReferenceType(),
4749 RequireActualConstructor =
true;
4757 AsInitializerList =
false;
4759 S, Kind.getLocation(), UnwrappedArgs, CandidateSet, DestType, Ctors,
4760 Best, CopyInitialization, AllowExplicit,
4761 false, IsListInit, RequireActualConstructor);
4773 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4777 if (
auto *CD = dyn_cast<CXXConversionDecl>(Best->Function)) {
4779 QualType ConvType = CD->getConversionType();
4781 "should not have selected this conversion function");
4783 HadMultipleCandidates);
4797 DestRecordDecl->isAggregate() &&
4798 DestRecordDecl->hasUninitializedExplicitInitFields() &&
4800 S.
Diag(Kind.getLocation(), diag::warn_field_requires_explicit_init)
4801 << 1 << DestRecordDecl;
4826 if (IsListInit && !Kind.AllowExplicit() && CtorDecl->
isExplicit()) {
4846 Best->FoundDecl, CtorDecl, DestArrayType, HadMultipleCandidates,
4847 IsListInit | IsInitListCopy, AsInitializerList);
4851 Sema &S,
const InitializedEntity &Entity,
const InitializationKind &Kind,
4867 bool IsAggrListInit) {
4885 Sequence,
false, IsAggrListInit);
4913 bool HadMultipleCandidates =
false;
4916 UnqualifiedTargetType,
4918 &HadMultipleCandidates)) {
4920 HadMultipleCandidates);
4921 SourceType = Fn->getType();
4932 const InitializedEntity &Entity,
4933 const InitializationKind &Kind,
4935 QualType cv1T1, QualType T1,
4937 QualType cv2T2, QualType T2,
4940 bool TopLevelOfInitList);
4943 const InitializedEntity &Entity,
4944 const InitializationKind &Kind,
4946 InitListExpr *InitList =
nullptr);
4954 bool TreatUnavailableAsInvalid) {
4994 T1Quals, cv2T2, T2, T2Quals, Sequence,
5002 if (!Sequence.
steps().empty())
5025 TreatUnavailableAsInvalid);
5060 bool TreatUnavailableAsInvalid) {
5078 TreatUnavailableAsInvalid);
5116 !IsDesignatedInit) {
5127 Expr *InitListAsExpr = InitList;
5129 S, Entity, SubKind, InitListAsExpr, DestType, Sequence,
5150 "Deduced to other type?");
5152 "List-initialize structured bindings but not "
5153 "direct-list-initialization?");
5158 Entity, SubInit[0], DestType, Sequence,
5159 TreatUnavailableAsInvalid);
5175 TreatUnavailableAsInvalid);
5208 TreatUnavailableAsInvalid))
5212 Expr *InitListAsExpr = InitList;
5214 DestType, Sequence,
true);
5280 if (
Init->getType()->isRecordType() ||
5291 TreatUnavailableAsInvalid);
5298 InitListChecker CheckInitList(S, Entity, InitList,
5299 DestType,
true, TreatUnavailableAsInvalid);
5300 if (CheckInitList.HadError()) {
5322 "Must have incompatible references when binding via conversion");
5333 bool AllowExplicitCtors =
false;
5334 bool AllowExplicitConvs = Kind.allowExplicitConversionFunctionsInRefBinding();
5339 if (T1RecordDecl->isInvalidDecl())
5345 if (!Info.Constructor)
5348 if (!Info.Constructor->isInvalidDecl() &&
5349 Info.Constructor->isConvertingConstructor(
true)) {
5350 if (Info.ConstructorTmpl)
5352 Info.ConstructorTmpl, Info.FoundDecl,
5355 false, AllowExplicitCtors);
5358 Info.Constructor, Info.FoundDecl,
Initializer, CandidateSet,
5360 false, AllowExplicitCtors);
5367 if (T2RecordDecl->isInvalidDecl())
5371 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5372 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5391 if ((AllowRValues ||
5395 ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
5397 false, AllowExplicitConvs);
5400 Conv, I.getPair(), ActingDC,
Initializer, DestType, CandidateSet,
5401 false, AllowExplicitConvs);
5422 cv3T3 = Function->getReturnType();
5434 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5436 HadMultipleCandidates);
5447 "should not have conversion after constructor");
5451 ICS.
Standard = Best->FinalConversion;
5472 if (RefConv & Sema::ReferenceConversions::DerivedToBase)
5474 else if (RefConv & Sema::ReferenceConversions::ObjC)
5476 else if (RefConv & Sema::ReferenceConversions::Function)
5478 else if (RefConv & Sema::ReferenceConversions::Qualification) {
5487 const InitializedEntity &Entity,
5495 bool TopLevelOfInitList) {
5513 T1Quals, cv2T2, T2, T2Quals, Sequence,
5514 TopLevelOfInitList);
5538 bool TopLevelOfInitList) {
5562 if (isLValueRef || T1Function) {
5565 (Kind.isCStyleOrFunctionalCast() &&
5569 if (RefConv & (Sema::ReferenceConversions::DerivedToBase |
5570 Sema::ReferenceConversions::ObjC)) {
5573 if (RefConv & (Sema::ReferenceConversions::Qualification))
5577 if (RefConv & Sema::ReferenceConversions::DerivedToBase)
5581 }
else if (RefConv & Sema::ReferenceConversions::Qualification) {
5585 }
else if (RefConv & Sema::ReferenceConversions::Function) {
5605 (isLValueRef || InitCategory.
isRValue())) {
5610 isLValueRef, Sequence);
5645 switch (RefRelationship) {
5648 FK = InitializationSequence::
5649 FK_NonConstLValueReferenceBindingToBitfield;
5651 FK = InitializationSequence::
5652 FK_NonConstLValueReferenceBindingToVectorElement;
5654 FK = InitializationSequence::
5655 FK_NonConstLValueReferenceBindingToMatrixElement;
5657 llvm_unreachable(
"unexpected kind of compatible initializer");
5663 FK = InitializationSequence::
5664 FK_NonConstLValueReferenceBindingToUnrelated;
5681 (Kind.isCStyleOrFunctionalCast() &&
5710 auto T1QualsIgnoreAS = T1Quals;
5711 auto T2QualsIgnoreAS = T2Quals;
5713 T1QualsIgnoreAS.removeAddressSpace();
5714 T2QualsIgnoreAS.removeAddressSpace();
5726 if (T1QualsIgnoreAS != T2QualsIgnoreAS)
5736 cv1T4 = cv1T4WithAS;
5741 if (RefConv & Sema::ReferenceConversions::DerivedToBase)
5743 else if (RefConv & Sema::ReferenceConversions::ObjC)
5745 else if (RefConv & Sema::ReferenceConversions::Qualification) {
5762 isLValueRef, Sequence);
5802 Sema::AllowedExplicit::None,
5804 Kind.isCStyleOrFunctionalCast(),
5823 TopLevelOfInitList);
5832 ((T1CVRQuals | T2CVRQuals) != T1CVRQuals ||
5877 assert((!InitList || InitList->
getNumInits() == 0) &&
5878 "Shouldn't use value-init for non-empty init lists");
5884 assert(!
T->isVoidType() &&
"Cannot value-init void");
5889 if (
auto *ClassDecl =
T->getAsCXXRecordDecl()) {
5890 bool NeedZeroInitialization =
true;
5905 NeedZeroInitialization =
false;
5913 if (NeedZeroInitialization)
5927 ClassDecl->hasUninitializedReferenceMember()) {
5935 Expr *InitListAsExpr = InitList;
5937 bool InitListSyntax = InitList;
5942 S, Entity, Kind, Args,
T, Entity.
getType(), Sequence, InitListSyntax);
5991 unsigned EntityIndexToProcess = 0;
5994 Expr *ArrayFiller =
nullptr;
5995 FieldDecl *InitializedFieldInUnion =
nullptr;
5999 Expr *Arg,
Expr **InitExpr =
nullptr) {
6001 S, SubEntity, SubKind,
6017 ER = IS.
Perform(S, SubEntity, SubKind,
6024 *InitExpr = ER.
get();
6026 InitExprs.push_back(ER.
get());
6033 uint64_t ArrayLength;
6041 ArrayLength = CAT->getZExtSize();
6042 ResultType = Entity.
getType();
6049 const Expr *SE = VAT->getSizeExpr();
6055 ArrayLength = Args.size();
6057 EntityIndexToProcess = ArrayLength;
6061 for (
Expr *E : Args) {
6066 if (!HandleInitializedEntity(SubEntity, SubKind, E))
6074 Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
true);
6075 if (!HandleInitializedEntity(SubEntity, SubKind,
nullptr, &ArrayFiller))
6079 if (ResultType.
isNull()) {
6099 if (EntityIndexToProcess < Args.size()) {
6105 Expr *E = Args[EntityIndexToProcess];
6108 if (!HandleInitializedEntity(SubEntity, SubKind, E))
6116 Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
6118 if (!HandleInitializedEntity(SubEntity, SubKind,
nullptr))
6121 EntityIndexToProcess++;
6134 if (EntityIndexToProcess < Args.size()) {
6136 Expr *E = Args[EntityIndexToProcess];
6154 if (!HandleInitializedEntity(SubEntity, SubKind, E))
6162 InitializedFieldInUnion = FD;
6163 EntityIndexToProcess = 1;
6169 if (!VerifyOnly && FD->
hasAttr<ExplicitInitAttr>() &&
6171 S.
Diag(Kind.getLocation(), diag::warn_field_requires_explicit_init)
6182 Kind.getParenOrBraceRange().getEnd(), FD, SubEntity);
6185 InitExprs.push_back(DIE.
get());
6195 S.
Diag(SR.
getEnd(), diag::err_init_reference_member_uninitialized)
6202 Kind.getLocation(), Kind.getLocation(), Kind.getLocation(),
true);
6203 if (!HandleInitializedEntity(SubEntity, SubKind,
nullptr))
6207 EntityIndexToProcess++;
6209 ResultType = Entity.
getType();
6214 if (EntityIndexToProcess < Args.size()) {
6218 int InitKind =
T->isArrayType() ? 0 :
T->isUnionType() ? 4 : 5;
6219 SourceRange ExcessInitSR(Args[EntityIndexToProcess]->getBeginLoc(),
6220 Args.back()->getEndLoc());
6221 S.
Diag(Kind.getLocation(), diag::err_excess_initializers)
6222 << InitKind << ExcessInitSR;
6236 CPLIE->setArrayFiller(ArrayFiller);
6237 if (InitializedFieldInUnion)
6238 CPLIE->setInitializedFieldInUnion(InitializedFieldInUnion);
6240 S.
Diag(Kind.getLocation(),
6241 diag::warn_cxx17_compat_aggregate_init_paren_list)
6242 << Kind.getLocation() << SR << ResultType;
6254 bool TopLevelOfInitList) {
6255 assert(!DestType->
isReferenceType() &&
"References are handled elsewhere");
6258 "Must have a class type to perform a user-defined conversion");
6268 bool AllowExplicit = Kind.AllowExplicit();
6278 if (!Info.Constructor)
6281 if (!Info.Constructor->isInvalidDecl() &&
6282 Info.Constructor->isConvertingConstructor(
true)) {
6283 if (Info.ConstructorTmpl)
6285 Info.ConstructorTmpl, Info.FoundDecl,
6288 false, AllowExplicit);
6293 false, AllowExplicit);
6309 const auto &Conversions =
6311 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
6326 ConvTemplate, I.getPair(), ActingDC,
Initializer, DestType,
6327 CandidateSet, AllowExplicit, AllowExplicit);
6330 DestType, CandidateSet, AllowExplicit,
6356 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
6364 HadMultipleCandidates);
6391 QualType ConvType = Function->getCallResultType();
6393 HadMultipleCandidates);
6413 Function->getReturnType()->isReferenceType() ||
6423 assert(Best->HasFinalConversion);
6424 if (Best->FinalConversion.First || Best->FinalConversion.Second ||
6425 Best->FinalConversion.Third) {
6428 ICS.
Standard = Best->FinalConversion;
6438 bool isAddressOf,
bool &isWeakAccess) {
6444 if (op->getOpcode() == UO_AddrOf)
6449 }
else if (
CastExpr *ce = dyn_cast<CastExpr>(e)) {
6450 switch (ce->getCastKind()) {
6453 case CK_LValueBitCast:
6457 case CK_ArrayToPointerDecay:
6460 case CK_NullToPointer:
6472 isWeakAccess =
true;
6506 bool isWeakAccess =
false;
6510 if (S.
getLangOpts().ObjCAutoRefCount && isWeakAccess)
6530 if (!Context.hasSameType(Dest->
getElementType(), Source->getElementType()))
6542 bool ArrayDecay =
false;
6547 ArgPointee = ArgArrayType->getElementType();
6559 bool ShouldCopy =
true;
6599 std::optional<llvm::APSInt>
Value =
Init->getIntegerConstantExpr(Ctx);
6630 "cl_intel_device_side_avc_motion_estimation", S.
getLangOpts()) &&
6632 if (DestType->isOCLIntelSubgroupAVCMcePayloadType() ||
6633 DestType->isOCLIntelSubgroupAVCMceResultType())
6647 MultiExprArg Args,
bool TopLevelOfInitList,
bool TreatUnavailableAsInvalid)
6651 TreatUnavailableAsInvalid);
6657 auto *DRE = dyn_cast<DeclRefExpr>(E);
6728 bool TopLevelOfInitList,
6729 bool TreatUnavailableAsInvalid) {
6736 for (
unsigned I = 0, E = Args.size(); I != E; ++I)
6737 if (Args[I]->
getType()->isNonOverloadPlaceholderType()) {
6744 Args[I] = result.
get();
6766 if (Args.size() == 1) {
6784 TreatUnavailableAsInvalid);
6793 if (Rec->hasUninitializedExplicitInitFields()) {
6805 if (Var && !
Initializer && !Rec->isUnion() && !Rec->isInvalidDecl()) {
6807 unsigned DiagID = diag::warn_default_init_const_field_unsafe;
6810 DiagID = diag::warn_default_init_const_field;
6813 diag::warn_cxx_compat_hack_fake_diagnostic_do_not_emit,
6817 S.
Diag(FD->
getLocation(), diag::note_default_init_const_member) << FD;
6830 if (Args.size() != 1)
6840 TopLevelOfInitList);
6865 const ArrayType *DestAT = Context.getAsArrayType(DestType);
6903 TreatUnavailableAsInvalid);
6915 TreatUnavailableAsInvalid);
6941 *
this, TreatUnavailableAsInvalid);
6943 }
else if (S.
getLangOpts().CPlusPlus20 && !TopLevelOfInitList &&
6959 bool allowObjCWritebackConversion = S.
getLangOpts().ObjCAutoRefCount &&
6968 assert(
Initializer &&
"Initializer must be non-null");
6970 if (allowObjCWritebackConversion &&
6998 (Context.hasSameUnqualifiedType(SourceType, DestType) ||
7000 SourceType, DestType))))) {
7010 assert(
Initializer &&
"Initializer must be non-null");
7012 TopLevelOfInitList);
7017 assert(Args.size() >= 1 &&
"Zero-argument case handled above");
7022 auto ShouldTryListInitialization = [&]() ->
bool {
7032 if (!DestIsVec && !DestIsMat)
7037 if (Args.size() == 1) {
7038 assert(!SourceType.
isNull() &&
7039 "Source QualType should not be null when arg size is exactly 1");
7043 if (DestIsMat && !SourceIsVec)
7045 if (DestIsVec && !SourceIsMat)
7051 return SourceType.
isNull() ||
7052 !Context.hasSameUnqualifiedType(SourceType, DestType);
7054 if (ShouldTryListInitialization()) {
7057 Args.back()->getEndLoc(),
false);
7061 TreatUnavailableAsInvalid);
7066 if (Args.size() > 1) {
7081 assert(
Initializer &&
"Initializer must be non-null");
7084 bool NeedAtomicConversion =
false;
7086 if (Context.hasSameUnqualifiedType(SourceType,
Atomic->getValueType()) ||
7088 Atomic->getValueType())) {
7089 DestType =
Atomic->getValueType();
7090 NeedAtomicConversion =
true;
7095 TopLevelOfInitList);
7097 if (!
Failed() && NeedAtomicConversion)
7124 Sema::AllowedExplicit::None,
7126 Kind.isCStyleOrFunctionalCast(),
7127 allowObjCWritebackConversion);
7135 bool ShouldCopy =
true;
7151 }
else if (ICS.
isBad()) {
7157 else if (
Initializer->getType()->isFunctionType() &&
7170 for (
auto &S : Steps)
7178 bool Diagnose =
false) {
7230 llvm_unreachable(
"Invalid EntityKind!");
7265 llvm_unreachable(
"missed an InitializedEntity kind?");
7300 llvm_unreachable(
"missed an InitializedEntity kind?");
7340 llvm_unreachable(
"missed an InitializedEntity kind?");
7367 bool IsExtraneousCopy) {
7372 auto *Class =
T->getAsCXXRecordDecl();
7390 S, Loc, CurInitExpr, CandidateSet,
T, Ctors, Best,
7402 ? diag::ext_rvalue_to_reference_temp_copy_no_viable
7403 : diag::err_temp_copy_no_viable)
7421 S.
Diag(Loc, diag::err_temp_copy_deleted)
7428 bool HadMultipleCandidates = CandidateSet.
size() > 1;
7437 if (IsExtraneousCopy) {
7448 for (
unsigned I = 1, N =
Constructor->getNumParams(); I != N; ++I) {
7451 diag::err_call_incomplete_argument))
7492 Best->Function->getParamDecl(0)->getType().getNonReferenceType(),
7497 Loc,
T, Best->FoundDecl,
Constructor, Elidable, ConstructorArgs,
7498 HadMultipleCandidates,
7514 Expr *CurInitExpr) {
7532 S, Loc, CurInitExpr, CandidateSet, CurInitExpr->
getType(), Ctors, Best,
7545 Best->FoundDecl, Entity,
Diag);
7566void InitializationSequence::PrintInitLocationNote(
Sema &S,
7581 diag::note_method_return_type_change)
7599 switch (Kind.getKind()) {
7605 return NumArgs != 1;
7617 bool &ConstructorInitRequiresZeroInit,
7618 bool IsListInitialization,
7619 bool IsStdInitListInitialization,
7622 unsigned NumArgs = Args.size();
7629 SourceLocation Loc = (Kind.isCopyInit() && Kind.getEqualLoc().isValid())
7630 ? Kind.getEqualLoc()
7631 : Kind.getLocation();
7637 assert(
Constructor->getParent() &&
"No parent class for constructor.");
7654 bool AllowExplicitConv =
7655 Kind.AllowExplicit() && !Kind.isCopyInit() && Args.size() == 1 &&
7660 if (NumArgs == 1 && !Kind.isExplicitCast())
7662 Entity.
getType(), Args.front()->getType(), Kind.getLocation());
7667 ConstructorArgs, AllowExplicitConv,
7668 IsListInitialization))
7682 if (I >= ConstructorArgs.size() && FD->
hasAttr<ExplicitInitAttr>() &&
7684 S.
Diag(Loc, diag::warn_field_requires_explicit_init)
7699 : Kind.getParenOrBraceRange();
7702 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
7712 ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
7713 IsListInitialization, IsStdInitListInitialization,
7714 ConstructorInitRequiresZeroInit),
7730 if (IsListInitialization)
7731 ParenOrBraceRange =
SourceRange(LBraceLoc, RBraceLoc);
7733 ParenOrBraceRange = Kind.getParenOrBraceRange();
7742 HadMultipleCandidates,
7743 IsListInitialization,
7744 IsStdInitListInitialization,
7745 ConstructorInitRequiresZeroInit,
7753 HadMultipleCandidates,
7754 IsListInitialization,
7755 IsStdInitListInitialization,
7756 ConstructorInitRequiresZeroInit,
7787 const Expr *PostInit);
7794 bool IsReturnStmt) {
7805 unsigned DiagID = 0;
7835 if (VD->
hasAttr<BlocksAttr>())
7849 DiagID = diag::warn_redundant_move_on_return;
7851 DiagID = diag::warn_pessimizing_move_on_return;
7853 DiagID = diag::warn_pessimizing_move_on_initialization;
7895 if (UO->getOpcode() == UO_Deref &&
7896 UO->getSubExpr()->IgnoreParenCasts()->
7899 S.
PDiag(diag::warn_binding_null_to_reference)
7900 << UO->getSubExpr()->getSourceRange());
7906 bool BoundToLvalueReference) {
7916 Cleanup.setExprNeedsCleanups(
false);
7952 if (!PointeeTy.isNull() &&
7953 PointeeTy.getAddressSpace() != ExprPointeeTy.getAddressSpace())
7954 CK = CK_AddressSpaceConversion;
7956 CK = CK_AddressSpaceConversion;
7971 if (!ZeroInitializationFixit.empty()) {
7973 const auto *VD = dyn_cast_or_null<VarDecl>(D);
7979 if (!DestType->
isRecordType() && VD && VD->isConstexpr()) {
7981 S.
Diag(Kind.getLocation(), diag::err_constexpr_var_requires_const_init)
7984 ZeroInitializationFixit);
7986 unsigned DiagID = diag::err_default_init_const;
7988 DiagID = diag::ext_default_init_const;
7990 S.
Diag(Kind.getLocation(), DiagID)
7993 ZeroInitializationFixit);
8015 ArrayT->getElementType(),
8016 nullptr, ArrayT->getSizeModifier(),
8017 ArrayT->getIndexTypeCVRQualifiers());
8021 !Kind.isExplicitCast()) {
8023 SourceRange ParenRange = Kind.getParenOrBraceRange();
8028 Kind.isExplicitCast() ||
8044 S.
Diag(
Init->getBeginLoc(), diag::warn_cxx98_compat_reference_list_init)
8045 <<
Init->getSourceRange();
8048 if (S.
getLangOpts().MicrosoftExt && Args.size() == 1 &&
8054 S.
Diag(
Init->getBeginLoc(), diag::ext_init_from_predefined) <<
Init;
8065 S.
Diag(Args[0]->getBeginLoc(), diag::err_opencl_atomic_init)
8084 bool IsHLSLVectorOrMatrixInit =
8088 (void)IsHLSLVectorOrMatrixInit;
8093 switch (Steps.front().Kind) {
8128 assert(Args.size() == 1 || IsHLSLVectorOrMatrixInit);
8147 isa_and_nonnull<InitListExpr>(CurInit.
get()));
8152 auto checkAbstractType = [&](
QualType T) ->
bool {
8157 diag::err_allocation_of_abstract_type);
8162 bool ConstructorInitRequiresZeroInit =
false;
8195 bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
8207 CK_DerivedToBase, CurInit.
get(),
8223 if (
auto *DRE = dyn_cast<DeclRefExpr>(CurInit.
get()->
IgnoreParens())) {
8224 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
8237 assert(CurInit.
get()->
isPRValue() &&
"not a temporary");
8295 bool CreatedObject =
false;
8312 HadMultipleCandidates,
8324 CastKind = CK_ConstructorConversion;
8325 CreatedObject =
true;
8335 HadMultipleCandidates);
8339 CastKind = CK_UserDefinedConversion;
8343 if (CreatedObject && checkAbstractType(CurInit.
get()->
getType()))
8360 if (
auto *
Record =
T->castAsCXXRecordDecl()) {
8363 S.
PDiag(diag::err_access_dtor_temp) <<
T);
8387 "function reference should be lvalue");
8393 assert(CurInit.
get()->
isPRValue() &&
"cannot convert glvalue to atomic");
8401 if (
const auto *FromPtrType =
8404 if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
8405 !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
8408 if (!Kind.isStaticCast()) {
8410 diag::warn_noderef_to_dereferenceable_pointer)
8429 CurInit = CurInitExprRes;
8450 InitListChecker PerformInitList(S, InitEntity,
8451 InitList, Ty,
false,
8453 if (PerformInitList.HadError())
8461 if ((*ResultType)->isRValueReferenceType())
8463 else if ((*ResultType)->isLValueReferenceType())
8470 PerformInitList.getFullyStructuredList();
8473 : StructuredInitList;
8490 assert(Args.size() == 1 &&
"expected a single argument for list init");
8492 S.
Diag(InitList->
getExprLoc(), diag::warn_cxx98_compat_ctor_list_init)
8499 ConstructorInitRequiresZeroInit,
8538 bool IsStdInitListInit =
8542 ? Kind.getParenOrBraceRange()
8545 S, UseTemporary ? TempEntity : Entity, Kind,
8547 ConstructorInitRequiresZeroInit,
8558 if (NextStep != StepEnd &&
8563 ConstructorInitRequiresZeroInit =
true;
8566 !Kind.isImplicitValueInit()) {
8570 Kind.getRange().getBegin());
8574 Kind.getRange().getEnd());
8609 CurInit = CurInitExprRes;
8625 S.
Diag(Kind.getLocation(), diag::err_c23_constexpr_pointer_not_null);
8640 InitialCurInit.
get(),
8643 PrintInitLocationNote(S, Entity);
8645 }
else if (Complained)
8646 PrintInitLocationNote(S, Entity);
8662 CK_ObjCObjectLValueCast,
8674 BaseExpr, Kind.getLocation(), IndexExpr, Kind.getLocation());
8675 ArrayLoopCommonExprs.push_back(BaseExpr);
8680 assert(!ArrayLoopCommonExprs.empty() &&
8681 "mismatched SK_ArrayLoopIndex and SK_ArrayLoopInit");
8682 Expr *Common = ArrayLoopCommonExprs.pop_back_val();
8691 S.
Diag(Kind.getLocation(), diag::ext_array_init_copy)
8705 IncompleteDest->getElementType(), ConstantSource->getSize(),
8715 S.
Diag(Kind.getLocation(), diag::ext_array_init_parens)
8735 diag::warn_cxx98_compat_initializer_list_init)
8748 [[maybe_unused]]
bool IsStdInitializerList =
8750 assert(IsStdInitializerList &&
8751 "StdInitializerList step to non-std::initializer_list");
8753 assert(
Record->isCompleteDefinition() &&
8754 "std::initializer_list should have already be "
8755 "complete/instantiated by this point");
8757 auto InvalidType = [&] {
8759 diag::err_std_initializer_list_malformed)
8766 return InvalidType();
8769 if (Field ==
Record->field_end())
8770 return InvalidType();
8773 if (!Field->getType()->isPointerType() ||
8775 ElementType.withConst()))
8776 return InvalidType();
8778 if (++Field ==
Record->field_end())
8779 return InvalidType();
8782 if (
const auto *PT = Field->getType()->getAs<
PointerType>()) {
8784 ElementType.withConst()))
8785 return InvalidType();
8787 if (Field->isBitField() ||
8789 return InvalidType();
8792 if (++Field !=
Record->field_end())
8793 return InvalidType();
8820 "Sampler initialization on non-sampler type.");
8826 S.
Diag(Kind.getLocation(), diag::err_sampler_argument_required)
8833 if (!Var->hasGlobalStorage()) {
8848 Var->getInit()))->getSubExpr();
8849 SourceType =
Init->getType();
8861 S.
Diag(Kind.getLocation(), diag::err_sampler_initializer_not_integer)
8869 const uint64_t SamplerValue =
Result.getLimitedValue();
8876 unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
8877 unsigned FilterMode = (0x30 & SamplerValue) >> 4;
8878 if (FilterMode != 1 && FilterMode != 2 &&
8880 "cl_intel_device_side_avc_motion_estimation", S.
getLangOpts()))
8881 S.
Diag(Kind.getLocation(),
8882 diag::warn_sampler_initializer_invalid_bits)
8884 if (AddressingMode > 4)
8885 S.
Diag(Kind.getLocation(),
8886 diag::warn_sampler_initializer_invalid_bits)
8887 <<
"Addressing Mode";
8893 CK_IntToOCLSampler);
8899 "Wrong type for initialization of OpenCL opaque type.");
8902 CK_ZeroToOCLOpaqueType,
8910 if (CurInit.
get() && ResultType)
8939 S.CheckBitFieldInitialization(Kind.getLocation(),
8953 if (
T->isReferenceType()) {
8954 S.
Diag(Loc, diag::err_reference_without_init)
8955 <<
T.getNonReferenceType();
8959 CXXRecordDecl *RD =
T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
8963 for (
const auto *FI : RD->
fields()) {
8964 if (FI->isUnnamedBitField())
8968 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
8973 for (
const auto &BI : RD->
bases()) {
8975 S.
Diag(Loc, diag::note_value_initialization_here) << RD;
9010 if (fromDecl && destDecl && fromDecl->getDeclKind() == Decl::CXXRecord &&
9011 destDecl->getDeclKind() == Decl::CXXRecord &&
9012 !fromDecl->isInvalidDecl() && !destDecl->isInvalidDecl() &&
9013 !fromDecl->hasDefinition() &&
9016 S.
Diag(fromDecl->getLocation(), diag::note_forward_class_conversion)
9044 if (
auto *D = Entity.
getDecl())
9045 Loc = D->getLocation();
9046 S.
Diag(Loc, diag::note_in_reference_temporary_list_initializer) <<
T;
9050 InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
9053 assert(DiagnoseInitList.HadError() &&
9054 "Inconsistent init list check result.");
9069 if (Args.size() == 1) {
9070 auto *List = dyn_cast<InitListExpr>(Args[0]);
9071 if (List && List->hasOneInit())
9072 OnlyArg = List->getInit(0);
9081 if (
Expr *Resolved =
9101 assert(Diagnosed &&
"couldn't find uninitialized reference to diagnose");
9104 S.
Diag(Kind.getLocation(), diag::err_reference_has_multiple_inits)
9105 <<
SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
9108 S.
Diag(Kind.getLocation(), diag::err_list_init_in_parens)
9109 << 1 << Entity.
getType() << Args[0]->getSourceRange();
9113 S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 0;
9116 S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 1;
9119 S.
Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << 2;
9122 S.
Diag(Kind.getLocation(), diag::err_array_init_narrow_string_into_wchar);
9125 S.
Diag(Kind.getLocation(), diag::err_array_init_wide_string_into_char);
9128 S.
Diag(Kind.getLocation(),
9129 diag::err_array_init_incompat_wide_string_into_wchar);
9132 S.
Diag(Kind.getLocation(),
9133 diag::err_array_init_plain_string_into_char8_t);
9134 S.
Diag(Args.front()->getBeginLoc(),
9135 diag::note_array_init_plain_string_into_char8_t)
9139 S.
Diag(Kind.getLocation(), diag::err_array_init_utf8_string_into_char)
9144 S.
Diag(Kind.getLocation(),
9146 ? diag::err_array_init_different_type
9147 : diag::err_array_init_non_constant_array))
9150 << Args[0]->getSourceRange();
9154 S.
Diag(Kind.getLocation(), diag::err_variable_object_no_init)
9155 << Args[0]->getSourceRange();
9176 switch (FailedOverloadResult) {
9179 FailedCandidateSet.NoteCandidates(
9183 ? (S.
PDiag(diag::err_typecheck_ambiguous_condition)
9184 << OnlyArg->
getType() << DestType
9185 << Args[0]->getSourceRange())
9186 : (S.
PDiag(diag::err_ref_init_ambiguous)
9187 << DestType << OnlyArg->
getType()
9188 << Args[0]->getSourceRange())),
9196 diag::err_typecheck_nonviable_condition_incomplete,
9197 OnlyArg->
getType(), Args[0]->getSourceRange()))
9198 S.
Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
9200 << OnlyArg->
getType() << Args[0]->getSourceRange()
9203 FailedCandidateSet.NoteCandidates(S, Args, Cands);
9209 = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
9212 S.
Diag(Kind.getLocation(), diag::err_typecheck_deleted_function)
9214 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
9215 << Args[0]->getSourceRange();
9219 llvm_unreachable(
"Inconsistent overload resolution?");
9225 llvm_unreachable(
"Conversion did not fail!");
9231 S.
Diag(Kind.getLocation(),
9232 diag::err_lvalue_reference_bind_to_initlist)
9235 << Args[0]->getSourceRange();
9241 S.
Diag(Kind.getLocation(),
9243 ? diag::err_lvalue_reference_bind_to_temporary
9244 : diag::err_lvalue_reference_bind_to_unrelated)
9248 << Args[0]->getSourceRange();
9253 FieldDecl *BitField = Args[0]->getSourceBitField();
9254 S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_bitfield)
9257 << (BitField !=
nullptr)
9258 << Args[0]->getSourceRange();
9265 S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_vector_element)
9267 << Args[0]->getSourceRange();
9271 S.
Diag(Kind.getLocation(), diag::err_reference_bind_to_matrix_element)
9276 S.
Diag(Kind.getLocation(), diag::err_lvalue_to_rvalue_ref)
9278 << Args[0]->getSourceRange();
9282 S.
Diag(Kind.getLocation(), diag::err_reference_bind_temporary_addrspace)
9283 << DestType << Args[0]->getSourceRange();
9294 S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
9295 << NonRefType << SourceType << 1
9296 << Args[0]->getSourceRange();
9298 S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
9299 << NonRefType << SourceType << 0
9305 S.
Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)
9306 << NonRefType << SourceType << 2
9307 << Args[0]->getSourceRange();
9312 S.
Diag(Kind.getLocation(), diag::err_reference_bind_failed)
9317 << Args[0]->getSourceRange();
9325 if (FromType == S.
Context.AMDGPUFeaturePredicateTy &&
9328 diag::err_amdgcn_predicate_type_needs_explicit_bool_cast)
9329 << OnlyArg << DestType;
9337 << Args[0]->getSourceRange();
9339 S.
Diag(Kind.getLocation(), PDiag);
9351 auto *InitList = dyn_cast<InitListExpr>(Args[0]);
9352 if (InitList && InitList->getNumInits() >= 1) {
9353 R =
SourceRange(InitList->getInit(0)->getEndLoc(), InitList->getEndLoc());
9355 assert(Args.size() > 1 &&
"Expected multiple initializers!");
9356 R =
SourceRange(Args.front()->getEndLoc(), Args.back()->getEndLoc());
9360 if (Kind.isCStyleOrFunctionalCast())
9361 S.
Diag(Kind.getLocation(), diag::err_builtin_func_cast_more_than_one_arg)
9364 S.
Diag(Kind.getLocation(), diag::err_excess_initializers)
9370 S.
Diag(Kind.getLocation(), diag::err_list_init_in_parens)
9371 << 0 << Entity.
getType() << Args[0]->getSourceRange();
9375 S.
Diag(Kind.getLocation(), diag::err_reference_bind_init_list)
9380 S.
Diag(Kind.getLocation(), diag::err_init_list_bad_dest_type)
9381 << (DestType->
isRecordType()) << DestType << Args[0]->getSourceRange();
9389 SourceRange(Args.front()->getBeginLoc(), Args.back()->getEndLoc());
9393 assert(Args.size() == 1 &&
9394 "List construction from other than 1 argument.");
9401 switch (FailedOverloadResult) {
9403 FailedCandidateSet.NoteCandidates(
9405 S.
PDiag(diag::err_ovl_ambiguous_init)
9406 << DestType << ArgsRange),
9423 if (
auto Inherited =
Constructor->getInheritedConstructor())
9424 InheritedFrom = Inherited.getShadowDecl()->getNominatedBaseClass();
9426 S.
Diag(Kind.getLocation(), diag::err_missing_default_ctor)
9427 << (InheritedFrom ? 2
9431 << 0 << Entity.
getType() << InheritedFrom;
9435 S.
Diag(BaseDecl->getLocation(), diag::note_previous_decl)
9438 S.
Diag(Kind.getLocation(), diag::err_missing_default_ctor)
9439 << (InheritedFrom ? 2
9443 << 1 << Entity.
getName() << InheritedFrom;
9445 diag::note_member_declared_at);
9448 S.
Diag(
Record->getDecl()->getLocation(), diag::note_previous_decl)
9454 FailedCandidateSet.NoteCandidates(
9457 S.
PDiag(diag::err_ovl_no_viable_function_in_init)
9458 << DestType << ArgsRange),
9465 = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
9467 S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
9468 << DestType << ArgsRange;
9469 llvm_unreachable(
"Inconsistent overload resolution?");
9477 S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_special_init)
9479 << DestType << ArgsRange;
9482 S.
Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
9483 << DestType << (Msg !=
nullptr)
9484 << (Msg ? Msg->
getString() : StringRef()) << ArgsRange;
9495 diag::note_default_constructed_field)
9503 llvm_unreachable(
"Conversion did not fail!");
9515 S.
Diag(Kind.getLocation(), diag::err_uninitialized_member_in_ctor)
9523 }
else if (
const auto *VD = dyn_cast_if_present<VarDecl>(Entity.
getDecl());
9524 VD && VD->isConstexpr()) {
9525 S.
Diag(Kind.getLocation(), diag::err_constexpr_var_requires_const_init)
9528 S.
Diag(Kind.getLocation(), diag::err_default_init_const)
9535 diag::err_init_incomplete_type);
9559 S.
Diag(Kind.getLocation(), diag::err_selected_explicit_constructor)
9560 << Args[0]->getSourceRange();
9563 = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
9565 assert(Ovl ==
OR_Success &&
"Inconsistent overload resolution");
9568 diag::note_explicit_ctor_deduction_guide_here) <<
false;
9579 S.
Diag(Kind.getLocation(), diag::err_designated_init_for_non_aggregate)
9584 PrintInitLocationNote(S, Entity);
9591 OS <<
"Failed sequence: ";
9594 OS <<
"too many initializers for reference";
9598 OS <<
"parenthesized list init for reference";
9602 OS <<
"array requires initializer list";
9606 OS <<
"address of unaddressable function was taken";
9610 OS <<
"array requires initializer list or string literal";
9614 OS <<
"array requires initializer list or wide string literal";
9618 OS <<
"narrow string into wide char array";
9622 OS <<
"wide string into char array";
9626 OS <<
"incompatible wide string into wide char array";
9630 OS <<
"plain string literal into char8_t array";
9634 OS <<
"u8 string literal into char array";
9638 OS <<
"array type mismatch";
9642 OS <<
"non-constant array initializer";
9646 OS <<
"address of overloaded function failed";
9650 OS <<
"overload resolution for reference initialization failed";
9654 OS <<
"non-const lvalue reference bound to temporary";
9658 OS <<
"non-const lvalue reference bound to bit-field";
9662 OS <<
"non-const lvalue reference bound to vector element";
9666 OS <<
"non-const lvalue reference bound to matrix element";
9670 OS <<
"non-const lvalue reference bound to unrelated type";
9674 OS <<
"rvalue reference bound to an lvalue";
9678 OS <<
"reference initialization drops qualifiers";
9682 OS <<
"reference with mismatching address space bound to temporary";
9686 OS <<
"reference initialization failed";
9690 OS <<
"conversion failed";
9694 OS <<
"conversion from property failed";
9698 OS <<
"too many initializers for scalar";
9702 OS <<
"parenthesized list init for reference";
9706 OS <<
"referencing binding to initializer list";
9710 OS <<
"initializer list for non-aggregate, non-scalar type";
9714 OS <<
"overloading failed for user-defined conversion";
9718 OS <<
"constructor overloading failed";
9722 OS <<
"default initialization of a const variable";
9726 OS <<
"initialization of incomplete type";
9730 OS <<
"list initialization checker failure";
9734 OS <<
"variable length array has an initializer";
9738 OS <<
"initializer expression isn't contextually valid";
9742 OS <<
"list constructor overloading failed";
9746 OS <<
"list copy initialization chose explicit constructor";
9750 OS <<
"parenthesized list initialization failed";
9754 OS <<
"designated initializer for non-aggregate type";
9758 OS <<
"HLSL initialization list flattening failed";
9766 OS <<
"Dependent sequence\n";
9770 OS <<
"Normal sequence: ";
9781 OS <<
"resolve address of overloaded function";
9785 OS <<
"derived-to-base (prvalue)";
9789 OS <<
"derived-to-base (xvalue)";
9793 OS <<
"derived-to-base (lvalue)";
9797 OS <<
"bind reference to lvalue";
9801 OS <<
"bind reference to a temporary";
9805 OS <<
"final copy in class direct-initialization";
9809 OS <<
"extraneous C++03 copy to temporary";
9813 OS <<
"user-defined conversion via " << *S->Function.Function;
9817 OS <<
"qualification conversion (prvalue)";
9821 OS <<
"qualification conversion (xvalue)";
9825 OS <<
"qualification conversion (lvalue)";
9829 OS <<
"function reference conversion";
9833 OS <<
"non-atomic-to-atomic conversion";
9837 OS <<
"implicit conversion sequence (";
9843 OS <<
"implicit conversion sequence with narrowing prohibited (";
9849 OS <<
"list aggregate initialization";
9853 OS <<
"unwrap reference initializer list";
9857 OS <<
"rewrap reference initializer list";
9861 OS <<
"constructor initialization";
9865 OS <<
"list initialization via constructor";
9869 OS <<
"zero initialization";
9873 OS <<
"C assignment";
9877 OS <<
"string initialization";
9881 OS <<
"Objective-C object conversion";
9885 OS <<
"indexing for array initialization loop";
9889 OS <<
"array initialization loop";
9893 OS <<
"array initialization";
9897 OS <<
"array initialization (GNU extension)";
9901 OS <<
"parenthesized array initialization";
9905 OS <<
"pass by indirect copy and restore";
9909 OS <<
"pass by indirect restore";
9913 OS <<
"Objective-C object retension";
9917 OS <<
"std::initializer_list from initializer list";
9921 OS <<
"list initialization from std::initializer_list";
9925 OS <<
"OpenCL sampler_t from integer constant";
9929 OS <<
"OpenCL opaque type from zero";
9933 OS <<
"initialization from a parenthesized list of values";
9937 OS <<
"HLSL buffer conversion";
9941 OS <<
" [" << S->Type <<
']';
9954 const auto *Embed = dyn_cast<EmbedExpr>(
Init->IgnoreParenImpCasts());
9969 const Expr *PostInit) {
9985 auto MakeDiag = [&](
bool IsConstRef,
unsigned DefaultDiagID,
9986 unsigned ConstRefDiagID,
unsigned WarnDiagID) {
9989 if (L.CPlusPlus11 && !L.HLSL &&
9991 DiagID = IsConstRef ? ConstRefDiagID : DefaultDiagID;
9993 DiagID = WarnDiagID;
10013 MakeDiag(
T != EntityType, diag::ext_init_list_type_narrowing,
10014 diag::ext_init_list_type_narrowing_const_reference,
10015 diag::warn_init_list_type_narrowing)
10017 <<
T.getLocalUnqualifiedType();
10024 diag::ext_init_list_constant_narrowing,
10025 diag::ext_init_list_constant_narrowing_const_reference,
10026 diag::warn_init_list_constant_narrowing)
10035 diag::ext_init_list_variable_narrowing,
10036 diag::ext_init_list_variable_narrowing_const_reference,
10037 diag::warn_init_list_variable_narrowing)
10045 llvm::raw_svector_ostream OS(StaticCast);
10046 OS <<
"static_cast<";
10053 OS << *TT->getDecl();
10062 S.
Diag(PostInit->
getBeginLoc(), diag::note_init_list_narrowing_silence)
10073 Init->IgnoreParenImpCasts(), ToType,
false,
10074 Sema::AllowedExplicit::None,
10086 PreNarrowingType)) {
10089 S.
Diag(
Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
10090 <<
Value.getAsString(S.
Context, PreNarrowingType) << ToType;
10095 S.
Diag(
Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
10096 << ToType << FromType;
10106 llvm_unreachable(
"unhandled case in switch");
10118 for (
unsigned I = 0, N = SE->
getLength(); I != N; ++I) {
10123 diag::err_c23_constexpr_init_not_representable)
10136 if (
Init.isInvalid())
10140 assert(InitE &&
"No initialization expression");
10145 return !
Seq.Failed();
10152 bool TopLevelOfInitList,
10153 bool AllowExplicit) {
10154 if (
Init.isInvalid())
10158 assert(InitE &&
"No initialization expression?");
10164 Context.AMDGPUFeaturePredicateTy &&
10166 Diag(EqualLoc, diag::err_amdgcn_predicate_type_is_not_constructible)
10176 const bool ShouldTrackCopy =
10178 if (ShouldTrackCopy) {
10180 Seq.SetOverloadFailure(
10186 const auto LastStep =
Seq.step_end() - 1;
10187 assert(LastStep->Kind ==
10191 llvm::find_if(
Seq.getFailedCandidateSet(),
10193 return Candidate.Viable &&
10194 Candidate.Function == Function &&
10195 Candidate.Conversions.size() > 0;
10197 if (Candidate !=
Seq.getFailedCandidateSet().end() &&
10199 Candidate->
Viable =
false;
10203 Function->getParamDecl(0)->getType());
10211 if (ShouldTrackCopy)
10220 auto NotSpecialization = [&] (
const CXXRecordDecl *Candidate) {
10221 auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Candidate);
10224 return !(NotSpecialization(RD) && RD->
forallBases(NotSpecialization));
10230 auto *DeducedTST = dyn_cast<DeducedTemplateSpecializationType>(
10232 assert(DeducedTST &&
"not a deduced template specialization type");
10243 if (
auto *
AliasTemplate = dyn_cast_or_null<TypeAliasTemplateDecl>(
10245 DiagCompat(Kind.getLocation(), diag_compat::ctad_for_alias_templates);
10248 ->getUnderlyingType()
10249 .getCanonicalType();
10253 if (
const auto *TST =
10254 UnderlyingType->getAs<TemplateSpecializationType>()) {
10255 Template = dyn_cast_or_null<ClassTemplateDecl>(
10256 TST->getTemplateName().getAsTemplateDecl());
10257 }
else if (
const auto *RT = UnderlyingType->getAs<RecordType>()) {
10261 if (
const auto *CTSD =
10262 llvm::dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl()))
10263 Template = CTSD->getSpecializedTemplate();
10268 Diag(Kind.getLocation(),
10269 diag::err_deduced_non_class_or_alias_template_specialization_type)
10279 diag::warn_cxx14_compat_class_template_argument_deduction)
10295 Context.DeclarationNames.getCXXDeductionGuideName(LookupTemplateDecl),
10307 ? dyn_cast<InitListExpr>(
Inits[0])
10324 bool AllowExplicit = !Kind.isCopyInit() ||
ListInit;
10330 bool OnlyListConstructors,
10331 bool AllowAggregateDeductionCandidate) {
10337 if (!AllowExplicit) {
10344 if (GD->getMinRequiredArguments() > 1 ||
10345 (GD->getNumParams() == 0 && !GD->isVariadic()))
10355 if (!AllowAggregateDeductionCandidate &&
10375 for (
auto [I, E] : llvm::enumerate(
Inits)) {
10376 if (
auto *DI = dyn_cast<DesignatedInitExpr>(E))
10377 TmpInits[I] = DI->getInit();
10383 TD, FoundDecl,
nullptr, TmpInits, Candidates,
10385 false, AllowExplicit, ADLCallKind::NotADL,
10386 {}, AllowAggregateDeductionCandidate);
10390 false, AllowExplicit);
10394 bool FoundDeductionGuide =
false;
10396 auto TryToResolveOverload =
10399 bool HasAnyDeductionGuide =
false;
10403 while (Pattern->getInstantiatedFromMemberTemplate()) {
10404 if (Pattern->isMemberSpecialization())
10406 Pattern = Pattern->getInstantiatedFromMemberTemplate();
10415 InitListChecker CheckInitList(*
this, Entity,
ListInit, Ty, ElementTypes);
10416 if (!CheckInitList.HadError()) {
10425 for (
int I = 0, E =
ListInit->getNumInits();
10427 if (ElementTypes[I]->isArrayType()) {
10429 ElementTypes[I] =
Context.getRValueReferenceType(ElementTypes[I]);
10431 ListInit->getInit(I)->IgnoreParenImpCasts()))
10433 Context.getLValueReferenceType(ElementTypes[I].withConst());
10438 LookupTemplateDecl, ElementTypes,
10440 auto *TD = GD->getDescribedFunctionTemplate();
10442 OnlyListConstructors,
10444 HasAnyDeductionGuide =
true;
10449 for (
auto I = Guides.
begin(), E = Guides.
end(); I != E; ++I) {
10450 NamedDecl *D = (*I)->getUnderlyingDecl();
10454 auto *TD = dyn_cast<FunctionTemplateDecl>(D);
10455 auto *GD = dyn_cast_if_present<CXXDeductionGuideDecl>(
10460 if (!GD->isImplicit())
10461 HasAnyDeductionGuide =
true;
10463 addDeductionCandidate(TD, GD, I.getPair(), OnlyListConstructors,
10478 }
else if (
Inits.size()) {
10485 SynthesizeAggrGuide(&TempListInit);
10489 FoundDeductionGuide = FoundDeductionGuide || HasAnyDeductionGuide;
10499 bool TryListConstructors =
true;
10505 auto *FD = dyn_cast<FunctionDecl>(D->getUnderlyingDecl());
10506 if (FD && FD->getMinRequiredArguments() == 0) {
10507 TryListConstructors =
false;
10511 }
else if (
ListInit->hasOneInit()) {
10522 TryListConstructors =
false;
10525 if (TryListConstructors)
10526 Result = TryToResolveOverload(
true);
10535 Result = TryToResolveOverload(
false);
10544 Kind.getLocation(),
10545 PDiag(diag::err_deduced_class_template_ctor_ambiguous)
10554 Context.getCanonicalTagType(Primary));
10557 Kind.getLocation(),
10558 PDiag(
Complete ? diag::err_deduced_class_template_ctor_no_viable
10559 : diag::err_deduced_class_template_incomplete)
10569 Diag(Kind.getLocation(), diag::err_deduced_class_template_deleted)
10579 if (Kind.isCopyInit() &&
ListInit &&
10581 bool IsDeductionGuide = !Best->Function->isImplicit();
10582 Diag(Kind.getLocation(), diag::err_deduced_class_template_explicit)
10584 Diag(Best->Function->getLocation(),
10585 diag::note_explicit_ctor_deduction_guide_here)
10586 << IsDeductionGuide;
10604 diag::warn_cxx14_compat_class_template_argument_deduction)
10609 if (!FoundDeductionGuide) {
10611 diag::warn_ctad_maybe_unsupported)
10613 Diag(
Template->getLocation(), diag::note_suppress_ctad_maybe_unsupported);
10616 return DeducedType;
Defines the clang::ASTContext interface.
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
static bool isRValueRef(QualType ParamType)
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
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.
llvm::MachO::Record Record
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static void CheckForNullPointerDereference(Sema &S, Expr *E)
This file declares semantic analysis for HLSL constructs.
static bool isExprAnUnaddressableFunction(Sema &S, const Expr *E)
Tries to get a FunctionDecl out of E.
static void updateStringLiteralType(Expr *E, QualType Ty)
Update the type of a string literal, including any surrounding parentheses, to match the type of the ...
static void updateGNUCompoundLiteralRValue(Expr *E)
Fix a compound literal initializing an array so it's correctly marked as an rvalue.
static bool initializingConstexprVariable(const InitializedEntity &Entity)
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.
static bool shouldDestroyEntity(const InitializedEntity &Entity)
Whether the given entity, when initialized with an object created for that initialization,...
static SourceLocation getInitializationLoc(const InitializedEntity &Entity, Expr *Initializer)
Get the location at which initialization diagnostics should appear.
static bool hasAnyDesignatedInits(const InitListExpr *IL)
static bool tryObjCWritebackConversion(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity, Expr *Initializer)
static DesignatedInitExpr * CloneDesignatedInitExpr(Sema &SemaRef, DesignatedInitExpr *DIE)
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...
static void TryOrBuildParenListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args, InitializationSequence &Sequence, bool VerifyOnly, ExprResult *Result=nullptr)
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, Sema &S, const InitializedEntity &Entity, bool CheckC23ConstexprInit=false)
static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, bool IsReturnStmt)
Provide warnings when std::move is used on construction.
static void CheckC23ConstexprInitStringLiteral(const StringLiteral *SE, Sema &SemaRef, QualType &TT)
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 ...
static bool isOrIsDerivedFromSpecializationOf(CXXRecordDecl *RD, ClassTemplateDecl *CTD)
Determine whether RD is, or is derived from, a specialization of CTD.
static bool canInitializeArrayWithEmbedDataString(ArrayRef< Expr * > ExprList, const InitializedEntity &Entity, ASTContext &Context)
static bool TryInitializerListConstruction(Sema &S, InitListExpr *List, QualType DestType, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
When initializing from init list via constructor, handle initialization of an object of type std::ini...
static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT, ASTContext &Context)
Check whether the array of type AT can be initialized by the Init expression by means of string initi...
static void TryArrayCopy(Sema &S, const InitializationKind &Kind, const InitializedEntity &Entity, Expr *Initializer, QualType DestType, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Initialize an array from another array.
static bool isInitializedStructuredList(const InitListExpr *StructuredList)
@ SIF_PlainStringIntoUTF8Char
@ SIF_IncompatWideStringIntoWideChar
@ SIF_UTF8StringIntoPlainChar
@ SIF_NarrowStringIntoWideChar
static void TryDefaultInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence)
Attempt default initialization (C++ [dcl.init]p6).
static bool TryOCLSamplerInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
static bool maybeRecoverWithZeroInitialization(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
Tries to add a zero initializer. Returns true if that worked.
static ExprResult CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value)
Check that the given Index expression is a valid array designator value.
static bool canPerformArrayCopy(const InitializedEntity &Entity)
Determine whether we can perform an elementwise array copy for this kind of entity.
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, bool TopLevelOfInitList)
Reference initialization without resolving overloaded functions.
static void CheckC23ConstexprInitConversion(Sema &S, QualType FromType, QualType ToType, Expr *Init)
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 void TryValueInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence, InitListExpr *InitList=nullptr)
Attempt value initialization (C++ [dcl.init]p7).
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...
static OverloadingResult ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, MultiExprArg Args, OverloadCandidateSet &CandidateSet, QualType DestType, DeclContext::lookup_result Ctors, OverloadCandidateSet::iterator &Best, bool CopyInitializing, bool AllowExplicit, bool OnlyListConstructors, bool IsListInit, bool RequireActualConstructor, bool SecondStepOfCopyInit=false)
static AssignmentAction getAssignmentAction(const InitializedEntity &Entity, bool Diagnose=false)
static void TryListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Attempt list initialization (C++0x [dcl.init.list])
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],...
static bool checkDestructorReference(QualType ElementType, SourceLocation Loc, Sema &SemaRef)
Check if the type of a class element has an accessible destructor, and marks it referenced.
static void TryReferenceInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt reference initialization (C++0x [dcl.init.ref])
static void DiagnoseNarrowingInInitList(Sema &S, const ImplicitConversionSequence &ICS, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit)
static bool hasCompatibleArrayTypes(ASTContext &Context, const ArrayType *Dest, const ArrayType *Source)
Determine whether we have compatible array types for the purposes of GNU by-copy array initialization...
static bool isExplicitTemporary(const InitializedEntity &Entity, const InitializationKind &Kind, unsigned NumArgs)
Returns true if the parameters describe a constructor initialization of an explicit temporary object,...
static bool isNonReferenceableGLValue(Expr *E)
Determine whether an expression is a non-referenceable glvalue (one to which a reference can never bi...
static bool TryOCLZeroOpaqueTypeInitialization(Sema &S, InitializationSequence &Sequence, QualType DestType, Expr *Initializer)
static bool IsWideCharCompatible(QualType T, ASTContext &Context)
Check whether T is compatible with a wide character type (wchar_t, char16_t or char32_t).
static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, InitListExpr *InitList)
static NarrowingKind getNarrowingKindWithEmbedExpanded(Sema &S, const StandardConversionSequence &SCS, const Expr *Init, APValue &ConstantValue, QualType &ConstantType)
static OverloadingResult TryRefInitWithConversionFunction(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, bool AllowRValues, bool IsLValueRef, InitializationSequence &Sequence)
Try a reference initialization that involves calling a conversion function.
void emitUninitializedExplicitInitFields(Sema &S, const RecordDecl *R)
static void TryConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType DestType, QualType DestArrayType, InitializationSequence &Sequence, bool IsListInit=false, bool IsInitListCopy=false)
Attempt initialization by constructor (C++ [dcl.init]), which enumerates the constructors of the init...
static void emitBadConversionNotes(Sema &S, const InitializedEntity &entity, Expr *op)
Emit notes associated with an initialization that failed due to a "simple" conversion failure.
static bool isIdiomaticBraceElisionEntity(const InitializedEntity &Entity)
Determine whether Entity is an entity for which it is idiomatic to elide the braces in aggregate init...
static void MaybeProduceObjCObject(Sema &S, InitializationSequence &Sequence, const InitializedEntity &Entity)
static void checkIndirectCopyRestoreSource(Sema &S, Expr *src)
Check whether the given expression is a valid operand for an indirect copy/restore.
static bool shouldBindAsTemporary(const InitializedEntity &Entity)
Whether we should bind a created object as a temporary when initializing the given entity.
static void TryConstructorOrParenListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType DestType, InitializationSequence &Sequence, bool IsAggrListInit)
Attempt to initialize an object of a class type either by direct-initialization, or by copy-initializ...
static bool IsZeroInitializer(const Expr *Init, ASTContext &Ctx)
static const FieldDecl * getConstField(const RecordDecl *RD)
static bool ResolveOverloadedFunctionForReferenceBinding(Sema &S, Expr *Initializer, QualType &SourceType, QualType &UnqualifiedSourceType, QualType UnqualifiedTargetType, InitializationSequence &Sequence)
InvalidICRKind
The non-zero enum values here are indexes into diagnostic alternatives.
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 void TryReferenceListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, InitializationSequence &Sequence, bool TreatUnavailableAsInvalid)
Attempt list initialization of a reference.
static bool hasCopyOrMoveCtorParam(ASTContext &Ctx, const ConstructorInfo &Info)
Determine if the constructor has the signature of a copy or move constructor for the type T of the cl...
static bool DiagnoseUninitializedReference(Sema &S, SourceLocation Loc, QualType T)
Somewhere within T there is an uninitialized reference subobject.
static InvalidICRKind isInvalidICRSource(ASTContext &C, Expr *e, bool isAddressOf, bool &isWeakAccess)
Determines whether this expression is an acceptable ICR source.
This file declares semantic analysis for Objective-C.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
Defines the clang::TypeLoc interface and its subclasses.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
bool isNullPointer() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
CanQualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
CanQualType getCanonicalTagType(const TagDecl *TD) const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Represents a loop initializing the elements of an array.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
QualType getType() const
Retrieves the type of the base class.
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Represents a C++ constructor within a class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
Represents a C++ conversion function within a class.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a C++ deduction guide declaration.
Represents a C++ destructor within a class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Represents a C++ struct/union/class.
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
CXXBaseSpecifier * base_class_iterator
Iterator that traverses the base classes of a class.
llvm::iterator_range< base_class_const_iterator > base_class_const_range
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
bool isHLSLBuiltinRecord() const
Returns true if the class is a built-in HLSL record.
const CXXBaseSpecifier * base_class_const_iterator
Iterator that traverses the base classes of a class.
llvm::iterator_range< base_class_iterator > base_class_range
bool forallBases(ForallBasesCallback BaseMatches) const
Determines if the given callback holds for all the direct or indirect base classes of this type.
An expression "T()" which creates an rvalue of a non-class type T.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr * > Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const
bool isCallToStdMove() const
SourceLocation getRParenLoc() const
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
static CharSourceRange getTokenRange(SourceRange R)
SourceLocation getBegin() const
Declaration of a class template.
void setExprNeedsCleanups(bool SideEffects)
ConditionalOperator - The ?
Represents the canonical version of C arrays with a specified constant size.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
unsigned getNumElementsFlattened() const
Returns the number of elements required to embed the matrix into a vector.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
DeclContextLookupResult lookup_result
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...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
A reference to a declared variable, function, enum, etc.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
static bool isFlexibleArrayMemberLike(const ASTContext &Context, const Decl *D, QualType Ty, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution)
Whether it resembles a flexible array member.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isInvalidDecl() const
SourceLocation getLocation() const
void setReferenced(bool R=true)
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
The name of a declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a single C99 designator.
bool isFieldDesignator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isArrayRangeDesignator() const
void setFieldDecl(FieldDecl *FD)
FieldDecl * getFieldDecl() const
bool isArrayDesignator() const
SourceLocation getFieldLoc() const
const IdentifierInfo * getFieldName() const
SourceLocation getDotLoc() const
SourceLocation getLBracketLoc() const
Represents a C99 designated initializer expression.
bool isDirectInit() const
Whether this designated initializer should result in direct-initialization of the designated subobjec...
Expr * getArrayRangeEnd(const Designator &D) const
Expr * getSubExpr(unsigned Idx) const
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Expr * getArrayRangeStart(const Designator &D) 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).
MutableArrayRef< Designator > designators()
Expr * getArrayIndex(const Designator &D) const
Designator * getDesignator(unsigned Idx)
Expr * getInit() const
Retrieve the initializer value.
unsigned size() const
Returns the number of designators in this initializer.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression,...
static DesignatedInitExpr * Create(const ASTContext &C, ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
InitListExpr * getUpdater() const
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
Designator - A designator in a C99 designated initializer.
SourceLocation getFieldLoc() const
SourceLocation getDotLoc() const
Expr * getArrayRangeStart() const
bool isArrayDesignator() const
SourceLocation getLBracketLoc() const
bool isArrayRangeDesignator() const
bool isFieldDesignator() const
SourceLocation getRBracketLoc() const
SourceLocation getEllipsisLoc() const
Expr * getArrayRangeEnd() const
const IdentifierInfo * getFieldDecl() const
Expr * getArrayIndex() const
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a reference to emded data.
unsigned getStartingElementPos() const
StringLiteral * getDataStringLiteral() const
EmbedDataStorage * getData() const
fake_child_range underlying_data_elements()
SourceLocation getLocation() const
size_t getDataElementCount() const
RAII object that enters a new expression evaluation context.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
The return type of classify().
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToMatrixElement() const
Returns whether this expression refers to a matrix element.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
QualType getReturnType() const
bool isDeleted() const
Whether this function has been deleted.
bool isDefaulted() const
Whether this function is defaulted.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
One of these records is kept for each identifier that is lexed.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
Represents an implicitly-generated value initialization of an object of a given type.
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
chain_iterator chain_end() const
chain_iterator chain_begin() const
ArrayRef< NamedDecl * >::const_iterator chain_iterator
Describes an C or C++ initializer list.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
void setSyntacticForm(InitListExpr *Init)
void markError()
Mark the semantic form of the InitListExpr as error when the semantic analysis fails.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
bool hasOneInit() const
Whether getNumInitsWithEmbedExpanded() is 1, without walking the list.
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setInit(unsigned Init, Expr *expr)
bool hasZeroInits() const
SourceLocation getLBraceLoc() const
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...
void setArrayFiller(Expr *filler)
InitListExpr * getSyntacticForm() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
unsigned getNumInitsWithEmbedExpanded() const
getNumInits but if the list has an EmbedExpr inside includes full length of embedded data.
SourceLocation getRBraceLoc() const
InitListExpr * getSemanticForm() const
const Expr * getInit(unsigned Init) const
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
SourceLocation getEndLoc() const LLVM_READONLY
void setInitializedFieldInUnion(FieldDecl *FD)
bool isSyntacticForm() const
void setRBraceLoc(SourceLocation Loc)
ArrayRef< Expr * > inits() const
void sawArrayRangeDesignator(bool ARD=true)
Expr ** getInits()
Retrieve the set of initializers.
Describes the kind of initialization being performed, along with location information for tokens rela...
@ IK_DirectList
Direct list-initialization.
@ IK_Value
Value initialization.
@ IK_Direct
Direct initialization.
@ IK_Copy
Copy initialization.
@ IK_Default
Default initialization.
InitKind getKind() const
Determine the initialization kind.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
A single step in the initialization sequence.
StepKind Kind
The kind of conversion or initialization step we are taking.
InitListExpr * WrappingSyntacticList
When Kind = SK_RewrapInitList, the syntactic form of the wrapping list.
ImplicitConversionSequence * ICS
When Kind = SK_ConversionSequence, the implicit conversion sequence.
struct F Function
When Kind == SK_ResolvedOverloadedFunction or Kind == SK_UserConversion, the function that the expres...
Describes the sequence of initializations required to initialize a given object or reference with a s...
step_iterator step_begin() const
void AddListInitializationStep(QualType T)
Add a list-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.
void AddStringInitStep(QualType T)
Add a string init step.
void AddStdInitializerListConstructionStep(QualType T)
Add a step to construct a std::initializer_list object from an initializer list.
void AddConstructorInitializationStep(DeclAccessPair FoundDecl, CXXConstructorDecl *Constructor, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
Add a constructor-initialization step.
@ SK_StdInitializerListConstructorCall
Perform initialization via a constructor taking a single std::initializer_list argument.
@ SK_AtomicConversion
Perform a conversion adding _Atomic to a type.
@ SK_ObjCObjectConversion
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
@ SK_GNUArrayInit
Array initialization (from an array rvalue) as a GNU extension.
@ SK_CastDerivedToBaseLValue
Perform a derived-to-base cast, producing an lvalue.
@ SK_ProduceObjCObject
Produce an Objective-C object pointer.
@ SK_FunctionReferenceConversion
Perform a function reference conversion, see [dcl.init.ref]p4.
@ SK_BindReference
Reference binding to an lvalue.
@ SK_ArrayLoopInit
Array initialization by elementwise copy.
@ SK_ConstructorInitialization
Perform initialization via a constructor.
@ SK_OCLSamplerInit
Initialize an OpenCL sampler from an integer.
@ SK_StringInit
Initialization by string.
@ SK_ZeroInitialization
Zero-initialize the object.
@ SK_CastDerivedToBaseXValue
Perform a derived-to-base cast, producing an xvalue.
@ SK_QualificationConversionXValue
Perform a qualification conversion, producing an xvalue.
@ SK_UserConversion
Perform a user-defined conversion, either via a conversion function or via a constructor.
@ SK_CastDerivedToBasePRValue
Perform a derived-to-base cast, producing an rvalue.
@ SK_BindReferenceToTemporary
Reference binding to a temporary.
@ SK_PassByIndirectRestore
Pass an object by indirect restore.
@ SK_ParenthesizedArrayInit
Array initialization from a parenthesized initializer list.
@ SK_ParenthesizedListInit
Initialize an aggreagate with parenthesized list of values.
@ SK_ArrayInit
Array initialization (from an array rvalue).
@ SK_ExtraneousCopyToTemporary
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
@ SK_ArrayLoopIndex
Array indexing for initialization by elementwise copy.
@ SK_ConversionSequenceNoNarrowing
Perform an implicit conversion sequence without narrowing.
@ SK_RewrapInitList
Rewrap the single-element initializer list for a reference.
@ SK_CAssignment
C assignment.
@ SK_ConstructorInitializationFromList
Perform initialization via a constructor, taking arguments from a single InitListExpr.
@ SK_PassByIndirectCopyRestore
Pass an object by indirect copy-and-restore.
@ SK_ResolveAddressOfOverloadedFunction
Resolve the address of an overloaded function to a specific function declaration.
@ SK_UnwrapInitList
Unwrap the single-element initializer list for a reference.
@ SK_FinalCopy
Direct-initialization from a reference-related object in the final stage of class copy-initialization...
@ SK_QualificationConversionLValue
Perform a qualification conversion, producing an lvalue.
@ SK_StdInitializerList
Construct a std::initializer_list from an initializer list.
@ SK_QualificationConversionPRValue
Perform a qualification conversion, producing a prvalue.
@ SK_HLSLBufferConversion
@ SK_ConversionSequence
Perform an implicit conversion sequence.
@ SK_ListInitialization
Perform list-initialization without a constructor.
@ SK_OCLZeroOpaqueType
Initialize an opaque OpenCL type (event_t, queue_t, etc.) with zero.
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...
void AddHLSLBufferConversionStep(QualType T)
void SetZeroInitializationFixit(const std::string &Fixit, SourceLocation L)
Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied...
InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList=false, bool TreatUnavailableAsInvalid=true)
Try to perform initialization of the given entity, creating a record of the steps required to perform...
void AddQualificationConversionStep(QualType Ty, ExprValueKind Category)
Add a new step that performs a qualification conversion to the given type.
void AddFunctionReferenceConversionStep(QualType Ty)
Add a new step that performs a function reference conversion to the given type.
~InitializationSequence()
void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category)
Add a new step in the initialization that performs a derived-to- base cast.
FailureKind getFailureKind() const
Determine why initialization failed.
void InitializeFrom(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList, bool TreatUnavailableAsInvalid)
void AddParenthesizedListInitStep(QualType T)
void SetFailed(FailureKind Failure)
Note that this initialization sequence failed.
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
void AddUnwrapInitListInitStep(InitListExpr *Syntactic)
Only used when initializing structured bindings from an array with direct-list-initialization.
void AddOCLZeroOpaqueTypeStep(QualType T)
Add a step to initialzie an OpenCL opaque type (event_t, queue_t, etc.) from a zero constant.
void AddFinalCopy(QualType T)
Add a new step that makes a copy of the input to an object of the given type, as the final step in cl...
OverloadingResult getFailedOverloadResult() const
Get the overloading result, for when the initialization sequence failed due to a bad overload.
void setSequenceKind(enum SequenceKind SK)
Set the kind of sequence computed.
void AddObjCObjectConversionStep(QualType T)
Add an Objective-C object conversion step, which is always a no-op.
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
step_iterator step_end() const
void AddParenthesizedArrayInitStep(QualType T)
Add a parenthesized array initialization step.
void AddExtraneousCopyToTemporary(QualType T)
Add a new step that makes an extraneous copy of the input to a temporary of the same class type.
void setIncompleteTypeFailure(QualType IncompleteType)
Note that this initialization sequence failed due to an incomplete type.
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
void AddCAssignmentStep(QualType T)
Add a C assignment step.
void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy)
Add a step to pass an object by indirect copy-restore.
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 Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
bool Failed() const
Determine whether the initialization sequence is invalid.
void AddAtomicConversionStep(QualType Ty)
Add a new step that performs conversion from non-atomic to atomic type.
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes.
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
Add a new step that applies an implicit conversion sequence.
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
void AddProduceObjCObjectStep(QualType T)
Add a step to "produce" an Objective-C object (by retaining it).
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
SequenceKind
Describes the kind of initialization sequence computed.
@ NormalSequence
A normal sequence.
@ FailedSequence
A failed initialization sequence.
@ DependentSequence
A dependent initialization, which could not be type-checked due to the presence of dependent types or...
void AddReferenceBindingStep(QualType T, bool BindingTemporary)
Add a new step binding a reference to an object.
FailureKind
Describes why initialization failed.
@ FK_UserConversionOverloadFailed
Overloading for a user-defined conversion failed.
@ FK_NarrowStringIntoWideCharArray
Initializing a wide char array with narrow string literal.
@ FK_ArrayTypeMismatch
Array type mismatch.
@ FK_ParenthesizedListInitForReference
Reference initialized from a parenthesized initializer list.
@ FK_NonConstLValueReferenceBindingToVectorElement
Non-const lvalue reference binding to a vector element.
@ FK_ReferenceInitDropsQualifiers
Reference binding drops qualifiers.
@ FK_InitListBadDestinationType
Initialization of some unused destination type with an initializer list.
@ FK_ConversionFromPropertyFailed
Implicit conversion failed.
@ FK_NonConstLValueReferenceBindingToUnrelated
Non-const lvalue reference binding to an lvalue of unrelated type.
@ FK_ListConstructorOverloadFailed
Overloading for list-initialization by constructor failed.
@ FK_ReferenceInitFailed
Reference binding failed.
@ FK_DesignatedInitForNonAggregate
@ FK_ArrayNeedsInitList
Array must be initialized with an initializer list.
@ FK_PlainStringIntoUTF8Char
Initializing char8_t array with plain string literal.
@ FK_NonConstantArrayInit
Non-constant array initializer.
@ FK_NonConstLValueReferenceBindingToTemporary
Non-const lvalue reference binding to a temporary.
@ FK_ConversionFailed
Implicit conversion failed.
@ FK_ArrayNeedsInitListOrStringLiteral
Array must be initialized with an initializer list or a string literal.
@ FK_ParenthesizedListInitForScalar
Scalar initialized from a parenthesized initializer list.
@ FK_HLSLInitListFlatteningFailed
HLSL initialization list flattening failed.
@ FK_PlaceholderType
Initializer has a placeholder type which cannot be resolved by initialization.
@ FK_IncompatWideStringIntoWideChar
Initializing wide char array with incompatible wide string literal.
@ FK_NonConstLValueReferenceBindingToMatrixElement
Non-const lvalue reference binding to a matrix element.
@ FK_TooManyInitsForReference
Too many initializers provided for a reference.
@ FK_NonConstLValueReferenceBindingToBitfield
Non-const lvalue reference binding to a bit-field.
@ FK_ReferenceAddrspaceMismatchTemporary
Reference with mismatching address space binding to temporary.
@ FK_ListInitializationFailed
List initialization failed at some point.
@ FK_TooManyInitsForScalar
Too many initializers for scalar.
@ FK_AddressOfOverloadFailed
Cannot resolve the address of an overloaded function.
@ FK_VariableLengthArrayHasInitializer
Variable-length array must not have an initializer.
@ FK_ArrayNeedsInitListOrWideStringLiteral
Array must be initialized with an initializer list or a wide string literal.
@ FK_RValueReferenceBindingToLValue
Rvalue reference binding to an lvalue.
@ FK_Incomplete
Initialization of an incomplete type.
@ FK_WideStringIntoCharArray
Initializing char array with wide string literal.
@ FK_ExplicitConstructor
List-copy-initialization chose an explicit constructor.
@ FK_ReferenceInitOverloadFailed
Overloading due to reference initialization failed.
@ FK_ConstructorOverloadFailed
Overloading for initialization by constructor failed.
@ FK_ReferenceBindingToInitList
Reference initialization from an initializer list.
@ FK_DefaultInitOfConst
Default-initialization of a 'const' object.
@ FK_ParenthesizedListInitFailed
Parenthesized list initialization failed at some point.
@ FK_AddressOfUnaddressableFunction
Trying to take the address of a function that doesn't support having its address taken.
@ FK_UTF8StringIntoPlainChar
Initializing char array with UTF-8 string literal.
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init....
void AddArrayInitLoopStep(QualType T, QualType EltTy)
Add an array initialization loop step.
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...
void AddArrayInitStep(QualType T, bool IsGNUExtension)
Add an array initialization step.
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
SmallVectorImpl< Step >::const_iterator step_iterator
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
Describes an entity that is being initialized.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
VD Variable
When Kind == EK_Variable, EK_Member, EK_Binding, or EK_TemplateParameter, the variable,...
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a member subobject.
EntityKind getKind() const
Determine the kind of initialization.
DeclarationName getName() const
Retrieve the name of the entity being initialized.
QualType getType() const
Retrieve type being initialized.
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
bool isImplicitMemberInitializer() const
Is this the implicit initialization of a member of a class from a defaulted constructor?
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
void setElementIndex(unsigned Index)
If this is already the initializer for an array or vector element, sets the element index.
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda.
bool isParamOrTemplateParamKind() const
llvm::PointerIntPair< const CXXBaseSpecifier *, 1 > Base
When Kind == EK_Base, the base specifier that provides the base class.
bool allowsNRVO() const
Determine whether this initialization allows the named return value optimization, which also applies ...
bool isParameterKind() const
void dump() const
Dump a representation of the initialized entity to standard error, for debugging purposes.
EntityKind
Specifies the kind of entity being initialized.
@ EK_Variable
The entity being initialized is a variable.
@ EK_Temporary
The entity being initialized is a temporary object.
@ EK_Binding
The entity being initialized is a structured binding of a decomposition declaration.
@ EK_BlockElement
The entity being initialized is a field of block descriptor for the copied-in c++ object.
@ EK_MatrixElement
The entity being initialized is an element of a matrix.
@ EK_Parameter_CF_Audited
The entity being initialized is a function parameter; function is member of group of audited CF APIs.
@ EK_LambdaToBlockConversionBlockElement
The entity being initialized is a field of block descriptor for the copied-in lambda object that's us...
@ EK_Member
The entity being initialized is a non-static data member subobject.
@ EK_Base
The entity being initialized is a base member subobject.
@ EK_Result
The entity being initialized is the result of a function call.
@ EK_TemplateParameter
The entity being initialized is a non-type template parameter.
@ EK_StmtExprResult
The entity being initialized is the result of a statement expression.
@ EK_ParenAggInitMember
The entity being initialized is a non-static data member subobject of an object initialized via paren...
@ EK_VectorElement
The entity being initialized is an element of a vector.
@ EK_New
The entity being initialized is an object (or array of objects) allocated via new.
@ EK_CompoundLiteralInit
The entity being initialized is the initializer for a compound literal.
@ EK_Parameter
The entity being initialized is a function parameter.
@ EK_Delegating
The initialization is being done by a delegating constructor.
@ EK_ComplexElement
The entity being initialized is the real or imaginary part of a complex number.
@ EK_ArrayElement
The entity being initialized is an element of an array.
@ EK_LambdaCapture
The entity being initialized is the field that captures a variable in a lambda.
@ EK_Exception
The entity being initialized is an exception object that is being thrown.
@ EK_RelatedResult
The entity being implicitly initialized back to the formal result type.
static InitializedEntity InitializeMemberFromParenAggInit(FieldDecl *Member)
Create the initialization entity for a member subobject initialized via parenthesized aggregate init.
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
unsigned Index
When Kind == EK_ArrayElement, EK_VectorElement, EK_MatrixElement, or EK_ComplexElement,...
bool isVariableLengthArrayNew() const
Determine whether this is an array new with an unknown bound.
llvm::PointerIntPair< ParmVarDecl *, 1 > Parameter
When Kind == EK_Parameter, the ParmVarDecl, with the integer indicating whether the parameter is "con...
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
ObjCMethodDecl * getMethodDecl() const
Retrieve the ObjectiveC method being initialized.
An lvalue reference type, per C++11 [dcl.ref].
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Represents the results of name lookup.
bool empty() const
Return true if no decls were found.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Represents a matrix type, as defined in the Matrix Types clang extensions.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represent a C++ namespace.
Represents a place-holder for an object not to be initialized by anything.
QualType getEncodedType() const
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
void setDestAS(LangAS AS)
llvm::MutableArrayRef< Expr * > getPersistentArgsArray(unsigned N)
Provide storage for any Expr* arg that must be preserved until deferred template candidates are deduc...
@ CSK_InitByConstructor
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor,...
@ CSK_InitByUserDefinedConversion
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
CandidateSetKind getKind() const
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
bool NeedsStdLibCxxWorkaroundBefore(std::uint64_t FixedVersion)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void addAddressSpace(LangAS space)
@ OCL_Weak
Reading or writing from this object requires a barrier call.
bool hasQualifiers() const
Return true if the set contains any qualifiers.
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
bool hasAddressSpace() const
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
Qualifiers withoutAddressSpace() const
static Qualifiers fromCVRMask(unsigned CVR)
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
field_iterator field_end() const
field_range fields() const
bool isRandomized() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool hasUninitializedExplicitInitFields() const
specific_decl_iterator< FieldDecl > field_iterator
field_iterator field_begin() const
Base for LValueReferenceType and RValueReferenceType.
bool isSpelledAsLValue() const
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
bool transformInitList(const InitializedEntity &Entity, InitListExpr *Init)
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type,...
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
Sema - This implements semantic analysis and AST building for C.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
bool DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, RecordDecl *ClassDecl, const IdentifierInfo *Name)
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
bool IsStringInit(Expr *Init, const ArrayType *AT)
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, QualType DeclInitType, 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 ...
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
Preprocessor & getPreprocessor() const
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
FPOptionsOverride CurFPFeatureOverrides()
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
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...
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
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....
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized.
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true, bool StrictPackMatch=false)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_PRValue, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
ReferenceConversionsScope::ReferenceConversions ReferenceConversions
ExprResult BuildCXXAggregateDefaultInitExpr(SourceLocation Loc, FieldDecl *Field, const InitializedEntity &MemberEntity)
bool checkArrayTooLarge(QualType ElementType, const llvm::APSInt &NumElements, SourceLocation Loc, SourceRange Range=SourceRange())
Diagnose an array of NumElements elements of type ElementType that is too large.
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, unsigned ByteNo) const
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool IsAssignConvertCompatible(AssignConvertType ConvTy)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived, CXXRecordDecl *Base, CXXBasePaths &Paths)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
bool BoundsSafetyCheckInitialization(const InitializedEntity &Entity, const InitializationKind &Kind, AssignmentAction Action, QualType LHSType, Expr *RHSExpr)
Perform Bounds Safety Semantic checks for initializing a Bounds Safety pointer.
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
TypeSourceInfo * SubstAutoTypeSourceInfoDependent(TypeSourceInfo *TypeWithAuto)
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
bool isSFINAEContext() const
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
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,...
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, ReferenceConversions *Conv=nullptr)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
MultiExprArg getInitsWithEmbedExpanded(InitListExpr *ILE, SmallVectorImpl< Expr * > &Storage)
The initializers of ILE with each multi-element EmbedExpr split into one EmbedExpr per embedded eleme...
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
SourceManager & SourceMgr
TypeSourceInfo * SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
friend class InitializationSequence
CXXDeductionGuideDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
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...
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool isAtStartOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the beginning of the immediate macro expansion.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
void setFromType(QualType T)
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion,...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false, bool AllowRelaxedEval=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
void setToType(unsigned Idx, QualType T)
void setAllToTypes(QualType T)
QualType getToType(unsigned Idx) const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
unsigned getLength() const
StringLiteralKind getKind() const
int64_t getCodeUnitS(size_t I, uint64_t BitWidth) const
StringRef getString() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool isDependent() const
Determines whether this is a dependent template name.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isBooleanType() const
bool isMFloat8Type() const
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
CXXRecordDecl * castAsCXXRecordDecl() const
bool isConstantMatrixType() const
bool isArrayParameterType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isSizelessBuiltinType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isExtVectorType() const
bool isOCLIntelSubgroupAVCType() const
bool isLValueReferenceType() const
bool isOpenCLSpecificType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
RecordDecl * castAsRecordDecl() const
bool isAnyComplexType() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isAtomicType() const
bool isFunctionProtoType() const
bool isMatrixType() const
EnumDecl * castAsEnumDecl() const
bool isObjCObjectType() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isRealFloatingType() const
Floating point categories.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isFloatingType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
bool isObjCRetainableType() const
DeclClass * getCorrectionDeclAs() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
const Expr * getInit() const
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorKind getVectorKind() const
QualType getElementType() const
Defines the clang::TargetInfo interface.
const clang::Expr * ExprTy
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
void checkInitLifetime(Sema &SemaRef, const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for initializing the ent...
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ ovl_fail_bad_conversion
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
MutableArrayRef< Expr * > MultiExprArg
@ SD_Thread
Thread storage duration.
@ SD_Static
Static storage duration.
@ SD_Automatic
Automatic storage duration (most local variables).
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Writeback_Conversion
Objective-C ARC writeback conversion.
@ Template
We are parsing a template declaration.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ Compatible
Compatible - the types are compatible according to the standard.
CastKind
CastKind - The kind of operation required for a conversion.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Expr * IgnoreParensSingleStep(Expr *E)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
U cast(CodeGen::Address addr)
ConstructorInfo getConstructorInfo(NamedDecl *ND)
ActionResult< Expr * > ExprResult
@ Braces
New-expression has a C++11 list-initializer.
CheckedConversionKind
The kind of conversion being performed.
@ Implicit
An implicit conversion.
@ CStyleCast
A C-style cast.
@ OtherCast
A cast other than a C-style cast.
@ FunctionalCast
A functional-style cast.
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 int64_t
CXXConstructorDecl * Constructor
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
bool HadMultipleCandidates
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
unsigned FailureKind
FailureKind - The reason why this candidate is not viable.
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
unsigned Viable
Viable - True to indicate that this overload candidate is viable.
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.