diff options
author | Stephen Kelly <steveire@gmail.com> | 2018-08-09 21:08:08 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2018-08-09 21:08:08 +0000 |
commit | f2ceec4811c3587056344dd5ef8d819261e256ad (patch) | |
tree | e3d713a6806e8f9b334df4a7083d82dfc5c06d79 /clang/lib/Sema/SemaInit.cpp | |
parent | a6e4358f071e18aa969c0ae820745510b3581aff (diff) | |
download | bcm5719-llvm-f2ceec4811c3587056344dd5ef8d819261e256ad.tar.gz bcm5719-llvm-f2ceec4811c3587056344dd5ef8d819261e256ad.zip |
Port getLocStart -> getBeginLoc
Reviewers: teemperor!
Subscribers: jholewinski, whisperity, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D50350
llvm-svn: 339385
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 298 |
1 files changed, 140 insertions, 158 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 01ef86c656b..8bab240cef7 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -194,15 +194,15 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, // [dcl.init.string]p2 if (StrLength > CAT->getSize().getZExtValue()) - S.Diag(Str->getLocStart(), + S.Diag(Str->getBeginLoc(), diag::err_initializer_string_for_char_array_too_long) - << Str->getSourceRange(); + << Str->getSourceRange(); } else { // C99 6.7.8p14. if (StrLength-1 > CAT->getSize().getZExtValue()) - S.Diag(Str->getLocStart(), + S.Diag(Str->getBeginLoc(), diag::ext_initializer_string_for_char_array_too_long) - << Str->getSourceRange(); + << Str->getSourceRange(); } // Set the type to the actual size that we are initializing. If we have @@ -917,7 +917,7 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity, if (maxElements == 0) { if (!VerifyOnly) - SemaRef.Diag(ParentIList->getInit(Index)->getLocStart(), + SemaRef.Diag(ParentIList->getInit(Index)->getBeginLoc(), diag::err_implicit_empty_initializer); ++Index; hadError = true; @@ -925,11 +925,10 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity, } // Build a structured initializer list corresponding to this subobject. - InitListExpr *StructuredSubobjectInitList - = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList, - StructuredIndex, - SourceRange(ParentIList->getInit(Index)->getLocStart(), - ParentIList->getSourceRange().getEnd())); + InitListExpr *StructuredSubobjectInitList = getStructuredSubobjectInit( + ParentIList, Index, T, StructuredList, StructuredIndex, + SourceRange(ParentIList->getInit(Index)->getBeginLoc(), + ParentIList->getSourceRange().getEnd())); unsigned StructuredSubobjectInitIndex = 0; // Check the element types and build the structural subobject. @@ -956,11 +955,11 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity, if ((T->isArrayType() || T->isRecordType()) && !ParentIList->isIdiomaticZeroInitializer(SemaRef.getLangOpts()) && !isIdiomaticBraceElisionEntity(Entity)) { - SemaRef.Diag(StructuredSubobjectInitList->getLocStart(), + SemaRef.Diag(StructuredSubobjectInitList->getBeginLoc(), diag::warn_missing_braces) << StructuredSubobjectInitList->getSourceRange() << FixItHint::CreateInsertion( - StructuredSubobjectInitList->getLocStart(), "{") + StructuredSubobjectInitList->getBeginLoc(), "{") << FixItHint::CreateInsertion( SemaRef.getLocForEndOfToken( StructuredSubobjectInitList->getLocEnd()), @@ -1080,8 +1079,8 @@ void InitListChecker::CheckExplicitInitList(const InitializedEntity &Entity, hadError = true; } // Special-case - SemaRef.Diag(IList->getInit(Index)->getLocStart(), DK) - << IList->getInit(Index)->getSourceRange(); + SemaRef.Diag(IList->getInit(Index)->getBeginLoc(), DK) + << IList->getInit(Index)->getSourceRange(); } else if (!T->isIncompleteType()) { // Don't complain for incomplete types, since we'll get an error // elsewhere @@ -1103,8 +1102,8 @@ void InitListChecker::CheckExplicitInitList(const InitializedEntity &Entity, hadError = true; } - SemaRef.Diag(IList->getInit(Index)->getLocStart(), DK) - << initKind << IList->getInit(Index)->getSourceRange(); + SemaRef.Diag(IList->getInit(Index)->getBeginLoc(), DK) + << initKind << IList->getInit(Index)->getSourceRange(); } } @@ -1155,21 +1154,20 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity, // This type is invalid, issue a diagnostic. ++Index; if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), diag::err_illegal_initializer_type) - << DeclType; + SemaRef.Diag(IList->getBeginLoc(), diag::err_illegal_initializer_type) + << DeclType; hadError = true; } else if (DeclType->isReferenceType()) { CheckReferenceType(Entity, IList, DeclType, Index, StructuredList, StructuredIndex); } else if (DeclType->isObjCObjectType()) { if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), diag::err_init_objc_class) - << DeclType; + SemaRef.Diag(IList->getBeginLoc(), diag::err_init_objc_class) << DeclType; hadError = true; } else { if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), diag::err_illegal_initializer_type) - << DeclType; + SemaRef.Diag(IList->getBeginLoc(), diag::err_illegal_initializer_type) + << DeclType; hadError = true; } } @@ -1232,7 +1230,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, // FIXME: Better EqualLoc? InitializationKind Kind = - InitializationKind::CreateCopy(expr->getLocStart(), SourceLocation()); + InitializationKind::CreateCopy(expr->getBeginLoc(), SourceLocation()); InitializationSequence Seq(SemaRef, Entity, Kind, expr, /*TopLevelOfInitList*/ true); @@ -1356,8 +1354,8 @@ void InitListChecker::CheckComplexType(const InitializedEntity &Entity, // This is an extension in C. (The builtin _Complex type does not exist // in the C++ standard.) if (!SemaRef.getLangOpts().CPlusPlus && !VerifyOnly) - SemaRef.Diag(IList->getLocStart(), diag::ext_complex_component_init) - << IList->getSourceRange(); + SemaRef.Diag(IList->getBeginLoc(), diag::ext_complex_component_init) + << IList->getSourceRange(); // Initialize the complex number. QualType elementType = DeclType->getAs<ComplexType>()->getElementType(); @@ -1378,11 +1376,11 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, unsigned &StructuredIndex) { if (Index >= IList->getNumInits()) { if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), - SemaRef.getLangOpts().CPlusPlus11 ? - diag::warn_cxx98_compat_empty_scalar_initializer : - diag::err_empty_scalar_initializer) - << IList->getSourceRange(); + SemaRef.Diag(IList->getBeginLoc(), + SemaRef.getLangOpts().CPlusPlus11 + ? diag::warn_cxx98_compat_empty_scalar_initializer + : diag::err_empty_scalar_initializer) + << IList->getSourceRange(); hadError = !SemaRef.getLangOpts().CPlusPlus11; ++Index; ++StructuredIndex; @@ -1394,18 +1392,17 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, // FIXME: This is invalid, and accepting it causes overload resolution // to pick the wrong overload in some corner cases. if (!VerifyOnly) - SemaRef.Diag(SubIList->getLocStart(), + SemaRef.Diag(SubIList->getBeginLoc(), diag::ext_many_braces_around_scalar_init) - << SubIList->getSourceRange(); + << SubIList->getSourceRange(); CheckScalarType(Entity, SubIList, DeclType, Index, StructuredList, StructuredIndex); return; } else if (isa<DesignatedInitExpr>(expr)) { if (!VerifyOnly) - SemaRef.Diag(expr->getLocStart(), - diag::err_designator_for_scalar_init) - << DeclType << expr->getSourceRange(); + SemaRef.Diag(expr->getBeginLoc(), diag::err_designator_for_scalar_init) + << DeclType << expr->getSourceRange(); hadError = true; ++Index; ++StructuredIndex; @@ -1420,8 +1417,8 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, } ExprResult Result = - SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), expr, - /*TopLevelOfInitList=*/true); + SemaRef.PerformCopyInitialization(Entity, expr->getBeginLoc(), expr, + /*TopLevelOfInitList=*/true); Expr *ResultExpr = nullptr; @@ -1453,10 +1450,9 @@ void InitListChecker::CheckReferenceType(const InitializedEntity &Entity, // so that we know the location (or decl) of the "current object" being // initialized. if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), - diag::err_init_reference_member_uninitialized) - << DeclType - << IList->getSourceRange(); + SemaRef.Diag(IList->getBeginLoc(), + diag::err_init_reference_member_uninitialized) + << DeclType << IList->getSourceRange(); hadError = true; ++Index; ++StructuredIndex; @@ -1466,8 +1462,8 @@ void InitListChecker::CheckReferenceType(const InitializedEntity &Entity, Expr *expr = IList->getInit(Index); if (isa<InitListExpr>(expr) && !SemaRef.getLangOpts().CPlusPlus11) { if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), diag::err_init_non_aggr_init_list) - << DeclType << IList->getSourceRange(); + SemaRef.Diag(IList->getBeginLoc(), diag::err_init_non_aggr_init_list) + << DeclType << IList->getSourceRange(); hadError = true; ++Index; ++StructuredIndex; @@ -1482,7 +1478,7 @@ void InitListChecker::CheckReferenceType(const InitializedEntity &Entity, } ExprResult Result = - SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), expr, + SemaRef.PerformCopyInitialization(Entity, expr->getBeginLoc(), expr, /*TopLevelOfInitList=*/true); if (Result.isInvalid()) @@ -1529,9 +1525,9 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, return; } - ExprResult Result = - SemaRef.PerformCopyInitialization(Entity, Init->getLocStart(), Init, - /*TopLevelOfInitList=*/true); + ExprResult Result = + SemaRef.PerformCopyInitialization(Entity, Init->getBeginLoc(), Init, + /*TopLevelOfInitList=*/true); Expr *ResultExpr = nullptr; if (Result.isInvalid()) @@ -1586,7 +1582,7 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, // // Because of this, explicitly call out that it is non-portable. // - SemaRef.Diag(IList->getLocStart(), + SemaRef.Diag(IList->getBeginLoc(), diag::warn_neon_vector_initializer_non_portable); const char *typeCode; @@ -1601,11 +1597,11 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, else llvm_unreachable("Invalid element type!"); - SemaRef.Diag(IList->getLocStart(), - SemaRef.Context.getTypeSize(VT) > 64 ? - diag::note_neon_vector_initializer_non_portable_q : - diag::note_neon_vector_initializer_non_portable) - << typeCode << typeSize; + SemaRef.Diag(IList->getBeginLoc(), + SemaRef.Context.getTypeSize(VT) > 64 + ? diag::note_neon_vector_initializer_non_portable_q + : diag::note_neon_vector_initializer_non_portable) + << typeCode << typeSize; } return; @@ -1646,9 +1642,9 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, // OpenCL requires all elements to be initialized. if (numEltsInit != maxElements) { if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), + SemaRef.Diag(IList->getBeginLoc(), diag::err_vector_incorrect_num_initializers) - << (numEltsInit < maxElements) << maxElements << numEltsInit; + << (numEltsInit < maxElements) << maxElements << numEltsInit; hadError = true; } } @@ -1686,9 +1682,9 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity, // earlier, but I don't know where clang accepts VLAs (gcc accepts // them in all sorts of strange places). if (!VerifyOnly) - SemaRef.Diag(VAT->getSizeExpr()->getLocStart(), - diag::err_variable_object_no_init) - << VAT->getSizeExpr()->getSourceRange(); + SemaRef.Diag(VAT->getSizeExpr()->getBeginLoc(), + diag::err_variable_object_no_init) + << VAT->getSizeExpr()->getSourceRange(); hadError = true; ++Index; ++StructuredIndex; @@ -1765,8 +1761,7 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity, if (maxElements == Zero && !Entity.isVariableLengthArrayNew()) { // Sizing an array implicitly to zero is not allowed by ISO C, // but is supported by GNU. - SemaRef.Diag(IList->getLocStart(), - diag::ext_typecheck_zero_array_size); + SemaRef.Diag(IList->getBeginLoc(), diag::ext_typecheck_zero_array_size); } DeclType = SemaRef.Context.getConstantArrayType(elementType, maxElements, @@ -1815,9 +1810,8 @@ bool InitListChecker::CheckFlexibleArrayInit(const InitializedEntity &Entity, } if (!VerifyOnly) { - SemaRef.Diag(InitExpr->getLocStart(), - FlexArrayDiag) - << InitExpr->getLocStart(); + SemaRef.Diag(InitExpr->getBeginLoc(), FlexArrayDiag) + << InitExpr->getBeginLoc(); SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member) << Field; } @@ -1881,7 +1875,7 @@ void InitListChecker::CheckStructUnionTypes( // If we have any base classes, they are initialized prior to the fields. for (auto &Base : Bases) { Expr *Init = Index < IList->getNumInits() ? IList->getInit(Index) : nullptr; - SourceLocation InitLoc = Init ? Init->getLocStart() : IList->getLocEnd(); + SourceLocation InitLoc = Init ? Init->getBeginLoc() : IList->getLocEnd(); // Designated inits always initialize fields, so if we see one, all // remaining base classes have no explicit initializer. @@ -1958,8 +1952,8 @@ void InitListChecker::CheckStructUnionTypes( if (VerifyOnly) InvalidUse = !SemaRef.CanUseDecl(*Field, TreatUnavailableAsInvalid); else - InvalidUse = SemaRef.DiagnoseUseOfDecl(*Field, - IList->getInit(Index)->getLocStart()); + InvalidUse = SemaRef.DiagnoseUseOfDecl( + *Field, IList->getInit(Index)->getBeginLoc()); if (InvalidUse) { ++Index; ++Field; @@ -2182,11 +2176,9 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, ExistingInit = StructuredList->getArrayFiller(); if (!ExistingInit) - StructuredList = - getStructuredSubobjectInit(IList, Index, CurrentObjectType, - StructuredList, StructuredIndex, - SourceRange(D->getLocStart(), - DIE->getLocEnd())); + StructuredList = getStructuredSubobjectInit( + IList, Index, CurrentObjectType, StructuredList, StructuredIndex, + SourceRange(D->getBeginLoc(), DIE->getLocEnd())); else if (InitListExpr *Result = dyn_cast<InitListExpr>(ExistingInit)) StructuredList = Result; else { @@ -2194,10 +2186,9 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, dyn_cast<DesignatedInitUpdateExpr>(ExistingInit)) StructuredList = E->getUpdater(); else { - DesignatedInitUpdateExpr *DIUE = - new (SemaRef.Context) DesignatedInitUpdateExpr(SemaRef.Context, - D->getLocStart(), ExistingInit, - DIE->getLocEnd()); + DesignatedInitUpdateExpr *DIUE = new (SemaRef.Context) + DesignatedInitUpdateExpr(SemaRef.Context, D->getBeginLoc(), + ExistingInit, DIE->getLocEnd()); StructuredList->updateInit(SemaRef.Context, StructuredIndex, DIUE); StructuredList = DIUE->getUpdater(); } @@ -2222,14 +2213,13 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // Here, xs[0].a == 0 and xs[0].b == 3, since the second, // designated initializer re-initializes the whole // subobject [0], overwriting previous initializers. - SemaRef.Diag(D->getLocStart(), + SemaRef.Diag(D->getBeginLoc(), diag::warn_subobject_initializer_overrides) - << SourceRange(D->getLocStart(), DIE->getLocEnd()); + << SourceRange(D->getBeginLoc(), DIE->getLocEnd()); - SemaRef.Diag(ExistingInit->getLocStart(), + SemaRef.Diag(ExistingInit->getBeginLoc(), diag::note_previous_initializer) - << /*FIXME:has side effects=*/0 - << ExistingInit->getSourceRange(); + << /*FIXME:has side effects=*/0 << ExistingInit->getSourceRange(); } } } @@ -2350,10 +2340,10 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, SemaRef.Diag(D->getFieldLoc(), diag::warn_initializer_overrides) << D->getSourceRange(); - SemaRef.Diag(ExistingInit->getLocStart(), + SemaRef.Diag(ExistingInit->getBeginLoc(), diag::note_previous_initializer) - << /*FIXME:has side effects=*/0 - << ExistingInit->getSourceRange(); + << /*FIXME:has side effects=*/0 + << ExistingInit->getSourceRange(); } // remove existing initializer @@ -2395,10 +2385,9 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, if (!VerifyOnly) { DesignatedInitExpr::Designator *NextD = DIE->getDesignator(DesigIdx + 1); - SemaRef.Diag(NextD->getLocStart(), - diag::err_designator_into_flexible_array_member) - << SourceRange(NextD->getLocStart(), - DIE->getLocEnd()); + SemaRef.Diag(NextD->getBeginLoc(), + diag::err_designator_into_flexible_array_member) + << SourceRange(NextD->getBeginLoc(), DIE->getLocEnd()); SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member) << *Field; } @@ -2409,9 +2398,9 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, !isa<StringLiteral>(DIE->getInit())) { // The initializer is not an initializer list. if (!VerifyOnly) { - SemaRef.Diag(DIE->getInit()->getLocStart(), - diag::err_flexible_array_init_needs_braces) - << DIE->getInit()->getSourceRange(); + SemaRef.Diag(DIE->getInit()->getBeginLoc(), + diag::err_flexible_array_init_needs_braces) + << DIE->getInit()->getSourceRange(); SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member) << *Field; } @@ -2553,10 +2542,10 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned()); if (DesignatedEndIndex >= MaxElements) { if (!VerifyOnly) - SemaRef.Diag(IndexExpr->getLocStart(), - diag::err_array_designator_too_large) - << DesignatedEndIndex.toString(10) << MaxElements.toString(10) - << IndexExpr->getSourceRange(); + SemaRef.Diag(IndexExpr->getBeginLoc(), + diag::err_array_designator_too_large) + << DesignatedEndIndex.toString(10) << MaxElements.toString(10) + << IndexExpr->getSourceRange(); ++Index; return true; } @@ -2728,10 +2717,8 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index, SemaRef.Diag(InitRange.getBegin(), diag::warn_subobject_initializer_overrides) << InitRange; - SemaRef.Diag(ExistingInit->getLocStart(), - diag::note_previous_initializer) - << /*FIXME:has side effects=*/0 - << ExistingInit->getSourceRange(); + SemaRef.Diag(ExistingInit->getBeginLoc(), diag::note_previous_initializer) + << /*FIXME:has side effects=*/0 << ExistingInit->getSourceRange(); } InitListExpr *Result @@ -2810,14 +2797,11 @@ void InitListChecker::UpdateStructuredListElement(InitListExpr *StructuredList, // There is an overwrite taking place because the first braced initializer // list "{ .a = 2 }' already provides value for .p.b (which is zero). if (PrevInit->getSourceRange().isValid()) { - SemaRef.Diag(expr->getLocStart(), - diag::warn_initializer_overrides) - << expr->getSourceRange(); + SemaRef.Diag(expr->getBeginLoc(), diag::warn_initializer_overrides) + << expr->getSourceRange(); - SemaRef.Diag(PrevInit->getLocStart(), - diag::note_previous_initializer) - << /*FIXME:has side effects=*/0 - << PrevInit->getSourceRange(); + SemaRef.Diag(PrevInit->getBeginLoc(), diag::note_previous_initializer) + << /*FIXME:has side effects=*/0 << PrevInit->getSourceRange(); } } @@ -2833,7 +2817,7 @@ void InitListChecker::UpdateStructuredListElement(InitListExpr *StructuredList, /// value of the constant expression. static ExprResult CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value) { - SourceLocation Loc = Index->getLocStart(); + SourceLocation Loc = Index->getBeginLoc(); // Make sure this is an integer constant expression. ExprResult Result = S.VerifyIntegerConstantExpression(Index, &Value); @@ -2941,8 +2925,8 @@ ExprResult Sema::ActOnDesignatedInitializer(Designation &Desig, Init.getAs<Expr>()); if (!getLangOpts().C99) - Diag(DIE->getLocStart(), diag::ext_designated_init) - << DIE->getSourceRange(); + Diag(DIE->getBeginLoc(), diag::ext_designated_init) + << DIE->getSourceRange(); return DIE; } @@ -3583,7 +3567,7 @@ static bool TryInitializerListConstruction(Sema &S, InitializedEntity HiddenArray = InitializedEntity::InitializeTemporary(ArrayType); InitializationKind Kind = InitializationKind::CreateDirectList( - List->getExprLoc(), List->getLocStart(), List->getLocEnd()); + List->getExprLoc(), List->getBeginLoc(), List->getLocEnd()); TryListInitialization(S, HiddenArray, Kind, List, Sequence, TreatUnavailableAsInvalid); if (Sequence) @@ -3974,7 +3958,7 @@ static void TryReferenceListInitialization(Sema &S, T1, Sequence)) return; - SourceLocation DeclLoc = Initializer->getLocStart(); + SourceLocation DeclLoc = Initializer->getBeginLoc(); bool dummy1, dummy2, dummy3; Sema::ReferenceCompareResult RefRelationship = S.CompareReferenceRelationship(DeclLoc, cv1T1, cv2T2, dummy1, @@ -4031,7 +4015,7 @@ static void TryListInitialization(Sema &S, } if (DestType->isRecordType() && - !S.isCompleteType(InitList->getLocStart(), DestType)) { + !S.isCompleteType(InitList->getBeginLoc(), DestType)) { Sequence.setIncompleteTypeFailure(DestType); return; } @@ -4051,7 +4035,7 @@ static void TryListInitialization(Sema &S, if (DestType->isRecordType()) { QualType InitType = InitList->getInit(0)->getType(); if (S.Context.hasSameUnqualifiedType(InitType, DestType) || - S.IsDerivedFrom(InitList->getLocStart(), InitType, DestType)) { + S.IsDerivedFrom(InitList->getBeginLoc(), InitType, DestType)) { Expr *InitListAsExpr = InitList; TryConstructorInitialization(S, Entity, Kind, InitListAsExpr, DestType, DestType, Sequence, @@ -4218,9 +4202,8 @@ static OverloadingResult TryRefInitWithConversionFunction( bool DerivedToBase; bool ObjCConversion; bool ObjCLifetimeConversion; - assert(!S.CompareReferenceRelationship(Initializer->getLocStart(), - T1, T2, DerivedToBase, - ObjCConversion, + assert(!S.CompareReferenceRelationship(Initializer->getBeginLoc(), T1, T2, + DerivedToBase, ObjCConversion, ObjCLifetimeConversion) && "Must have incompatible references when binding via conversion"); (void)DerivedToBase; @@ -4313,7 +4296,7 @@ static OverloadingResult TryRefInitWithConversionFunction( if (T2RecordType && T2RecordType->getDecl()->isInvalidDecl()) return OR_No_Viable_Function; - SourceLocation DeclLoc = Initializer->getLocStart(); + SourceLocation DeclLoc = Initializer->getBeginLoc(); // Perform overload resolution. If it fails, return the failed result. OverloadCandidateSet::iterator Best; @@ -4439,7 +4422,7 @@ static void TryReferenceInitializationCore(Sema &S, Qualifiers T2Quals, InitializationSequence &Sequence) { QualType DestType = Entity.getType(); - SourceLocation DeclLoc = Initializer->getLocStart(); + SourceLocation DeclLoc = Initializer->getBeginLoc(); // Compute some basic properties of the types and the initializer. bool isLValueRef = DestType->isLValueReferenceType(); bool isRValueRef = !isLValueRef; @@ -4867,7 +4850,7 @@ static void TryUserDefinedConversion(Sema &S, } } - SourceLocation DeclLoc = Initializer->getLocStart(); + SourceLocation DeclLoc = Initializer->getBeginLoc(); if (const RecordType *SourceRecordType = SourceType->getAs<RecordType>()) { // The type we're converting from is a class type, enumerate its conversion @@ -5310,7 +5293,7 @@ void InitializationSequence::InitializeFrom(Sema &S, if (Args.size() == 1) { Initializer = Args[0]; if (S.getLangOpts().ObjC1) { - if (S.CheckObjCBridgeRelatedConversions(Initializer->getLocStart(), + if (S.CheckObjCBridgeRelatedConversions(Initializer->getBeginLoc(), DestType, Initializer->getType(), Initializer) || S.ConversionToObjCStringLiteralCheck(DestType, Initializer)) @@ -5501,7 +5484,7 @@ void InitializationSequence::InitializeFrom(Sema &S, if (Kind.getKind() == InitializationKind::IK_Direct || (Kind.getKind() == InitializationKind::IK_Copy && (Context.hasSameUnqualifiedType(SourceType, DestType) || - S.IsDerivedFrom(Initializer->getLocStart(), SourceType, DestType)))) + S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType)))) TryConstructorInitialization(S, Entity, Kind, Args, DestType, DestType, *this); // - Otherwise (i.e., for the remaining copy-initialization cases), @@ -5535,7 +5518,7 @@ void InitializationSequence::InitializeFrom(Sema &S, bool NeedAtomicConversion = false; if (const AtomicType *Atomic = DestType->getAs<AtomicType>()) { if (Context.hasSameUnqualifiedType(SourceType, Atomic->getValueType()) || - S.IsDerivedFrom(Initializer->getLocStart(), SourceType, + S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, Atomic->getValueType())) { DestType = Atomic->getValueType(); NeedAtomicConversion = true; @@ -5758,7 +5741,7 @@ static SourceLocation getInitializationLoc(const InitializedEntity &Entity, case InitializedEntity::EK_LambdaToBlockConversionBlockElement: case InitializedEntity::EK_CompoundLiteralInit: case InitializedEntity::EK_RelatedResult: - return Initializer->getLocStart(); + return Initializer->getBeginLoc(); } llvm_unreachable("missed an InitializedEntity kind?"); } @@ -7067,18 +7050,18 @@ static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, return; } - S.Diag(CE->getLocStart(), DiagID); + S.Diag(CE->getBeginLoc(), DiagID); // Get all the locations for a fix-it. Don't emit the fix-it if any location // is within a macro. - SourceLocation CallBegin = CE->getCallee()->getLocStart(); + SourceLocation CallBegin = CE->getCallee()->getBeginLoc(); if (CallBegin.isMacroID()) return; SourceLocation RParen = CE->getRParenLoc(); if (RParen.isMacroID()) return; SourceLocation LParen; - SourceLocation ArgLoc = Arg->getLocStart(); + SourceLocation ArgLoc = Arg->getBeginLoc(); // Special testing for the argument location. Since the fix-it needs the // location right before the argument, the argument location can be in a @@ -7093,7 +7076,7 @@ static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr, LParen = ArgLoc.getLocWithOffset(-1); - S.Diag(CE->getLocStart(), diag::note_remove_move) + S.Diag(CE->getBeginLoc(), diag::note_remove_move) << FixItHint::CreateRemoval(SourceRange(CallBegin, LParen)) << FixItHint::CreateRemoval(SourceRange(RParen, RParen)); } @@ -7235,8 +7218,8 @@ InitializationSequence::Perform(Sema &S, // from an initializer list. For parameters, we produce a better warning // elsewhere. Expr *Init = Args[0]; - S.Diag(Init->getLocStart(), diag::warn_cxx98_compat_reference_list_init) - << Init->getSourceRange(); + S.Diag(Init->getBeginLoc(), diag::warn_cxx98_compat_reference_list_init) + << Init->getSourceRange(); } // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope @@ -7248,8 +7231,9 @@ InitializationSequence::Perform(Sema &S, if (S.getLangOpts().OpenCLVersion >= 200 && ETy->isAtomicType() && !HasGlobalAS && Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) { - S.Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << 1 << - SourceRange(Entity.getDecl()->getLocStart(), Args[0]->getLocEnd()); + S.Diag(Args[0]->getBeginLoc(), diag::err_opencl_atomic_init) + << 1 + << SourceRange(Entity.getDecl()->getBeginLoc(), Args[0]->getLocEnd()); return ExprError(); } @@ -7365,10 +7349,9 @@ InitializationSequence::Perform(Sema &S, // Casts to inaccessible base classes are allowed with C-style casts. bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast(); - if (S.CheckDerivedToBaseConversion(SourceType, Step->Type, - CurInit.get()->getLocStart(), - CurInit.get()->getSourceRange(), - &BasePath, IgnoreBaseAccess)) + if (S.CheckDerivedToBaseConversion( + SourceType, Step->Type, CurInit.get()->getBeginLoc(), + CurInit.get()->getSourceRange(), &BasePath, IgnoreBaseAccess)) return ExprError(); ExprValueKind VK = @@ -7397,7 +7380,7 @@ InitializationSequence::Perform(Sema &S, if (auto *DRE = dyn_cast<DeclRefExpr>(CurInit.get()->IgnoreParens())) { if (auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) { if (!S.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true, - DRE->getLocStart())) + DRE->getBeginLoc())) return ExprError(); } } @@ -7458,7 +7441,7 @@ InitializationSequence::Perform(Sema &S, if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Fn)) { // Build a call to the selected constructor. SmallVector<Expr*, 8> ConstructorArgs; - SourceLocation Loc = CurInit.get()->getLocStart(); + SourceLocation Loc = CurInit.get()->getBeginLoc(); // Determine the arguments required to actually perform the constructor // call. @@ -7525,10 +7508,10 @@ InitializationSequence::Perform(Sema &S, if (const RecordType *Record = T->getAs<RecordType>()) { CXXDestructorDecl *Destructor = S.LookupDestructor(cast<CXXRecordDecl>(Record->getDecl())); - S.CheckDestructorAccess(CurInit.get()->getLocStart(), Destructor, + S.CheckDestructorAccess(CurInit.get()->getBeginLoc(), Destructor, S.PDiag(diag::err_access_dtor_temp) << T); - S.MarkFunctionReferenced(CurInit.get()->getLocStart(), Destructor); - if (S.DiagnoseUseOfDecl(Destructor, CurInit.get()->getLocStart())) + S.MarkFunctionReferenced(CurInit.get()->getBeginLoc(), Destructor); + if (S.DiagnoseUseOfDecl(Destructor, CurInit.get()->getBeginLoc())) return ExprError(); } } @@ -8023,7 +8006,7 @@ static bool DiagnoseUninitializedReference(Sema &S, SourceLocation Loc, } for (const auto &BI : RD->bases()) { - if (DiagnoseUninitializedReference(S, BI.getLocStart(), BI.getType())) { + if (DiagnoseUninitializedReference(S, BI.getBeginLoc(), BI.getType())) { S.Diag(Loc, diag::note_value_initialization_here) << RD; return true; } @@ -8078,7 +8061,7 @@ static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, // inner initialization failed. QualType T = DestType->getAs<ReferenceType>()->getPointeeType(); diagnoseListInit(S, InitializedEntity::InitializeTemporary(T), InitList); - SourceLocation Loc = InitList->getLocStart(); + SourceLocation Loc = InitList->getBeginLoc(); if (auto *D = Entity.getDecl()) Loc = D->getLocation(); S.Diag(Loc, diag::note_in_reference_temporary_list_initializer) << T; @@ -8128,7 +8111,7 @@ bool InitializationSequence::Diagnose(Sema &S, (void)Diagnosed; } else // FIXME: diagnostic below could be better! S.Diag(Kind.getLocation(), diag::err_reference_has_multiple_inits) - << SourceRange(Args.front()->getLocStart(), Args.back()->getLocEnd()); + << SourceRange(Args.front()->getBeginLoc(), Args.back()->getLocEnd()); break; case FK_ParenthesizedListInitForReference: S.Diag(Kind.getLocation(), diag::err_list_init_in_parens) @@ -8157,9 +8140,9 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_PlainStringIntoUTF8Char: S.Diag(Kind.getLocation(), diag::err_array_init_plain_string_into_char8_t); - S.Diag(Args.front()->getLocStart(), + S.Diag(Args.front()->getBeginLoc(), diag::note_array_init_plain_string_into_char8_t) - << FixItHint::CreateInsertion(Args.front()->getLocStart(), "u8"); + << FixItHint::CreateInsertion(Args.front()->getBeginLoc(), "u8"); break; case FK_UTF8StringIntoPlainChar: S.Diag(Kind.getLocation(), @@ -8193,7 +8176,7 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_AddressOfUnaddressableFunction: { auto *FD = cast<FunctionDecl>(cast<DeclRefExpr>(OnlyArg)->getDecl()); S.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true, - OnlyArg->getLocStart()); + OnlyArg->getBeginLoc()); break; } @@ -8374,8 +8357,8 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_ConstructorOverloadFailed: { SourceRange ArgsRange; if (Args.size()) - ArgsRange = SourceRange(Args.front()->getLocStart(), - Args.back()->getLocEnd()); + ArgsRange = + SourceRange(Args.front()->getBeginLoc(), Args.back()->getLocEnd()); if (Failure == FK_ListConstructorOverloadFailed) { assert(Args.size() == 1 && @@ -8910,7 +8893,7 @@ static void DiagnoseNarrowingInInitList(Sema &S, // This was a floating-to-integer conversion, which is always considered a // narrowing conversion even if the value is a constant and can be // represented exactly as an integer. - S.Diag(PostInit->getLocStart(), NarrowingErrs(S.getLangOpts()) + S.Diag(PostInit->getBeginLoc(), NarrowingErrs(S.getLangOpts()) ? diag::ext_init_list_type_narrowing : diag::warn_init_list_type_narrowing) << PostInit->getSourceRange() @@ -8920,7 +8903,7 @@ static void DiagnoseNarrowingInInitList(Sema &S, case NK_Constant_Narrowing: // A constant value was narrowed. - S.Diag(PostInit->getLocStart(), + S.Diag(PostInit->getBeginLoc(), NarrowingErrs(S.getLangOpts()) ? diag::ext_init_list_constant_narrowing : diag::warn_init_list_constant_narrowing) @@ -8931,7 +8914,7 @@ static void DiagnoseNarrowingInInitList(Sema &S, case NK_Variable_Narrowing: // A variable's value may have been narrowed. - S.Diag(PostInit->getLocStart(), + S.Diag(PostInit->getBeginLoc(), NarrowingErrs(S.getLangOpts()) ? diag::ext_init_list_variable_narrowing : diag::warn_init_list_variable_narrowing) @@ -8959,9 +8942,9 @@ static void DiagnoseNarrowingInInitList(Sema &S, return; } OS << ">("; - S.Diag(PostInit->getLocStart(), diag::note_init_list_narrowing_silence) + S.Diag(PostInit->getBeginLoc(), diag::note_init_list_narrowing_silence) << PostInit->getSourceRange() - << FixItHint::CreateInsertion(PostInit->getLocStart(), OS.str()) + << FixItHint::CreateInsertion(PostInit->getBeginLoc(), OS.str()) << FixItHint::CreateInsertion( S.getLocForEndOfToken(PostInit->getLocEnd()), ")"); } @@ -8978,8 +8961,8 @@ Sema::CanPerformCopyInitialization(const InitializedEntity &Entity, Expr *InitE = Init.get(); assert(InitE && "No initialization expression"); - InitializationKind Kind - = InitializationKind::CreateCopy(InitE->getLocStart(), SourceLocation()); + InitializationKind Kind = + InitializationKind::CreateCopy(InitE->getBeginLoc(), SourceLocation()); InitializationSequence Seq(*this, Entity, Kind, InitE); return !Seq.Failed(); } @@ -8997,11 +8980,10 @@ Sema::PerformCopyInitialization(const InitializedEntity &Entity, assert(InitE && "No initialization expression?"); if (EqualLoc.isInvalid()) - EqualLoc = InitE->getLocStart(); + EqualLoc = InitE->getBeginLoc(); - InitializationKind Kind = InitializationKind::CreateCopy(InitE->getLocStart(), - EqualLoc, - AllowExplicit); + InitializationKind Kind = InitializationKind::CreateCopy( + InitE->getBeginLoc(), EqualLoc, AllowExplicit); InitializationSequence Seq(*this, Entity, Kind, InitE, TopLevelOfInitList); // Prevent infinite recursion when performing parameter copy-initialization. |