diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 0bc50c5f308a28dca8849cab65f10d9dd39d901f..cc0213fca235d53c52abd8063efc7e9a7cee8032 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -965,10 +965,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, Base1->getType(), Base2->getType())) { Context.Diag2(D2->getLocation(), diag::warn_odr_tag_type_inconsistent) << Context.C2.getTypeDeclType(D2); - Context.Diag2(Base2->getSourceRange().getBegin(), diag::note_odr_base) + Context.Diag2(Base2->getLocStart(), diag::note_odr_base) << Base2->getType() << Base2->getSourceRange(); - Context.Diag1(Base1->getSourceRange().getBegin(), diag::note_odr_base) + Context.Diag1(Base1->getLocStart(), diag::note_odr_base) << Base1->getType() << Base1->getSourceRange(); return false; @@ -978,10 +978,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, if (Base1->isVirtual() != Base2->isVirtual()) { Context.Diag2(D2->getLocation(), diag::warn_odr_tag_type_inconsistent) << Context.C2.getTypeDeclType(D2); - Context.Diag2(Base2->getSourceRange().getBegin(), + Context.Diag2(Base2->getLocStart(), diag::note_odr_virtual_base) << Base2->isVirtual() << Base2->getSourceRange(); - Context.Diag1(Base1->getSourceRange().getBegin(), diag::note_odr_base) + Context.Diag1(Base1->getLocStart(), diag::note_odr_base) << Base1->isVirtual() << Base1->getSourceRange(); return false; @@ -991,7 +991,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, Context.Diag2(D2->getLocation(), diag::warn_odr_tag_type_inconsistent) << Context.C2.getTypeDeclType(D2); const CXXBaseSpecifier *Base1 = D1CXX->bases_begin(); - Context.Diag1(Base1->getSourceRange().getBegin(), diag::note_odr_base) + Context.Diag1(Base1->getLocStart(), diag::note_odr_base) << Base1->getType() << Base1->getSourceRange(); Context.Diag2(D2->getLocation(), diag::note_odr_missing_base); @@ -4171,7 +4171,7 @@ TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) { return 0; return ToContext.getTrivialTypeSourceInfo(T, - FromTSI->getTypeLoc().getSourceRange().getBegin()); + FromTSI->getTypeLoc().getLocStart()); } Decl *ASTImporter::Import(Decl *FromD) { diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 7907e565dde1d468208957b44aff11045062f197..6af20df4bebac15bb577ce526f0839fea5a2b671 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -693,9 +693,9 @@ void IfStmt::setConditionVariable(ASTContext &C, VarDecl *V) { return; } - SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), - V->getSourceRange().getBegin(), - V->getSourceRange().getEnd()); + SourceRange VarRange = V->getSourceRange(); + SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(), + VarRange.getEnd()); } ForStmt::ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, @@ -724,9 +724,9 @@ void ForStmt::setConditionVariable(ASTContext &C, VarDecl *V) { return; } - SubExprs[CONDVAR] = new (C) DeclStmt(DeclGroupRef(V), - V->getSourceRange().getBegin(), - V->getSourceRange().getEnd()); + SourceRange VarRange = V->getSourceRange(); + SubExprs[CONDVAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(), + VarRange.getEnd()); } SwitchStmt::SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond) @@ -751,9 +751,9 @@ void SwitchStmt::setConditionVariable(ASTContext &C, VarDecl *V) { return; } - SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), - V->getSourceRange().getBegin(), - V->getSourceRange().getEnd()); + SourceRange VarRange = V->getSourceRange(); + SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(), + VarRange.getEnd()); } Stmt *SwitchCase::getSubStmt() { @@ -784,10 +784,10 @@ void WhileStmt::setConditionVariable(ASTContext &C, VarDecl *V) { SubExprs[VAR] = 0; return; } - - SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), - V->getSourceRange().getBegin(), - V->getSourceRange().getEnd()); + + SourceRange VarRange = V->getSourceRange(); + SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(), + VarRange.getEnd()); } // IndirectGotoStmt diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 062e4aa38f84bcdfef2280620a5e28732d173deb..7957473a6babdf079f1ae567dfdaf0dac825c9b5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2423,7 +2423,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, Record->getDeclContext()->isRecord()) return BuildAnonymousStructOrUnion(S, DS, AS, Record); - Diag(DS.getSourceRange().getBegin(), diag::ext_no_declarators) + Diag(DS.getLocStart(), diag::ext_no_declarators) << DS.getSourceRange(); emittedWarning = true; } @@ -2441,7 +2441,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, if ((Record && Record->getDeclName() && !Record->isCompleteDefinition()) || (DS.getTypeSpecType() == DeclSpec::TST_typename && DS.getRepAsType().get()->isStructureType())) { - Diag(DS.getSourceRange().getBegin(), diag::ext_ms_anonymous_struct) + Diag(DS.getLocStart(), diag::ext_ms_anonymous_struct) << DS.getSourceRange(); return BuildMicrosoftCAnonymousStruct(S, DS, Record); } @@ -2465,12 +2465,12 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, // extension in both Microsoft and GNU. if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef && Tag && isa<EnumDecl>(Tag)) { - Diag(DS.getSourceRange().getBegin(), diag::ext_typedef_without_a_name) + Diag(DS.getLocStart(), diag::ext_typedef_without_a_name) << DS.getSourceRange(); return Tag; } - Diag(DS.getSourceRange().getBegin(), diag::ext_no_declarators) + Diag(DS.getLocStart(), diag::ext_no_declarators) << DS.getSourceRange(); emittedWarning = true; } @@ -2848,7 +2848,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, NamedDecl *Anon = 0; if (RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) { Anon = FieldDecl::Create(Context, OwningClass, - DS.getSourceRange().getBegin(), + DS.getLocStart(), Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), @@ -2875,7 +2875,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, = StorageClassSpecToVarDeclStorageClass(SCSpec); Anon = VarDecl::Create(Context, Owner, - DS.getSourceRange().getBegin(), + DS.getLocStart(), Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), TInfo, SC, SCAsWritten); @@ -2945,8 +2945,8 @@ Decl *Sema::BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, // Create a declaration for this anonymous struct. NamedDecl* Anon = FieldDecl::Create(Context, cast<RecordDecl>(CurContext), - DS.getSourceRange().getBegin(), - DS.getSourceRange().getBegin(), + DS.getLocStart(), + DS.getLocStart(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), TInfo, @@ -3242,7 +3242,7 @@ Decl *Sema::HandleDeclarator(Scope *S, Declarator &D, // one, the ParsedFreeStandingDeclSpec action should be used. if (!Name) { if (!D.isInvalidType()) // Reject this if we think it is valid. - Diag(D.getDeclSpec().getSourceRange().getBegin(), + Diag(D.getDeclSpec().getLocStart(), diag::err_declarator_need_ident) << D.getDeclSpec().getSourceRange() << D.getSourceRange(); return 0; @@ -3913,7 +3913,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, bool isExplicitSpecialization = false; VarDecl *NewVD; if (!getLangOptions().CPlusPlus) { - NewVD = VarDecl::Create(Context, DC, D.getSourceRange().getBegin(), + NewVD = VarDecl::Create(Context, DC, D.getLocStart(), D.getIdentifierLoc(), II, R, TInfo, SC, SCAsWritten); @@ -3957,7 +3957,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, bool Invalid = false; if (TemplateParameterList *TemplateParams = MatchTemplateParametersToScopeSpecifier( - D.getDeclSpec().getSourceRange().getBegin(), + D.getDeclSpec().getLocStart(), D.getIdentifierLoc(), D.getCXXScopeSpec(), TemplateParamLists.get(), @@ -3983,7 +3983,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, } } - NewVD = VarDecl::Create(Context, DC, D.getSourceRange().getBegin(), + NewVD = VarDecl::Create(Context, DC, D.getLocStart(), D.getIdentifierLoc(), II, R, TInfo, SC, SCAsWritten); @@ -4676,7 +4676,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, (!isa<FunctionType>(R.getTypePtr()) && R->isFunctionProtoType()); NewFD = FunctionDecl::Create(SemaRef.Context, DC, - D.getSourceRange().getBegin(), NameInfo, R, + D.getLocStart(), NameInfo, R, TInfo, SC, SCAsWritten, isInline, HasPrototype); if (D.isInvalidType()) @@ -4708,7 +4708,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, R = SemaRef.CheckConstructorDeclarator(D, R, SC); return CXXConstructorDecl::Create(SemaRef.Context, cast<CXXRecordDecl>(DC), - D.getSourceRange().getBegin(), NameInfo, + D.getLocStart(), NameInfo, R, TInfo, isExplicit, isInline, /*isImplicitlyDeclared=*/false, isConstexpr); @@ -4720,7 +4720,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, CXXRecordDecl *Record = cast<CXXRecordDecl>(DC); CXXDestructorDecl *NewDD = CXXDestructorDecl::Create( SemaRef.Context, Record, - D.getSourceRange().getBegin(), + D.getLocStart(), NameInfo, R, TInfo, isInline, /*isImplicitlyDeclared=*/false); @@ -4743,7 +4743,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, // Create a FunctionDecl to satisfy the function definition parsing // code path. return FunctionDecl::Create(SemaRef.Context, DC, - D.getSourceRange().getBegin(), + D.getLocStart(), D.getIdentifierLoc(), Name, R, TInfo, SC, SCAsWritten, isInline, /*hasPrototype=*/true, isConstexpr); @@ -4759,7 +4759,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, SemaRef.CheckConversionDeclarator(D, R, SC); IsVirtualOkay = true; return CXXConversionDecl::Create(SemaRef.Context, cast<CXXRecordDecl>(DC), - D.getSourceRange().getBegin(), NameInfo, + D.getLocStart(), NameInfo, R, TInfo, isInline, isExplicit, isConstexpr, SourceLocation()); @@ -4795,7 +4795,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, // This is a C++ method declaration. return CXXMethodDecl::Create(SemaRef.Context, cast<CXXRecordDecl>(DC), - D.getSourceRange().getBegin(), NameInfo, R, + D.getLocStart(), NameInfo, R, TInfo, isStatic, SCAsWritten, isInline, isConstexpr, SourceLocation()); @@ -4804,7 +4804,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, // prototype. This true when: // - we're in C++ (where every function has a prototype), return FunctionDecl::Create(SemaRef.Context, DC, - D.getSourceRange().getBegin(), + D.getLocStart(), NameInfo, R, TInfo, SC, SCAsWritten, isInline, true/*HasPrototype*/, isConstexpr); } @@ -4888,7 +4888,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, bool Invalid = false; if (TemplateParameterList *TemplateParams = MatchTemplateParametersToScopeSpecifier( - D.getDeclSpec().getSourceRange().getBegin(), + D.getDeclSpec().getLocStart(), D.getIdentifierLoc(), D.getCXXScopeSpec(), TemplateParamLists.get(), @@ -5317,7 +5317,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, Diag(D.getIdentifierLoc(), diag::err_template_spec_needs_header) << SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc) << FixItHint::CreateInsertion( - D.getDeclSpec().getSourceRange().getBegin(), + D.getDeclSpec().getLocStart(), "template<> "); isFunctionTemplateSpecialization = true; } else { @@ -6093,14 +6093,14 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, if (CXXDirectInit->getNumExprs() == 0) { // It isn't possible to write this directly, but it is possible to // end up in this situation with "auto x(some_pack...);" - Diag(CXXDirectInit->getSourceRange().getBegin(), + Diag(CXXDirectInit->getLocStart(), diag::err_auto_var_init_no_expression) << VDecl->getDeclName() << VDecl->getType() << VDecl->getSourceRange(); RealDecl->setInvalidDecl(); return; } else if (CXXDirectInit->getNumExprs() > 1) { - Diag(CXXDirectInit->getExpr(1)->getSourceRange().getBegin(), + Diag(CXXDirectInit->getExpr(1)->getLocStart(), diag::err_auto_var_init_multiple_expressions) << VDecl->getDeclName() << VDecl->getType() << VDecl->getSourceRange(); @@ -6917,7 +6917,7 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { // the enclosing context. This prevents them from accidentally // looking like class members in C++. ParmVarDecl *New = CheckParameter(Context.getTranslationUnitDecl(), - D.getSourceRange().getBegin(), + D.getLocStart(), D.getIdentifierLoc(), II, parmDeclType, TInfo, StorageClass, StorageClassAsWritten); @@ -7662,7 +7662,7 @@ TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T, // Scope manipulation handled by caller. TypedefDecl *NewTD = TypedefDecl::Create(Context, CurContext, - D.getSourceRange().getBegin(), + D.getLocStart(), D.getIdentifierLoc(), D.getIdentifier(), TInfo); @@ -8777,7 +8777,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, bool Mutable = (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_mutable); - SourceLocation TSSL = D.getSourceRange().getBegin(); + SourceLocation TSSL = D.getLocStart(); FieldDecl *NewFD = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, HasInit, TSSL, AS, PrevDecl, &D); @@ -9067,7 +9067,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { if (RD->hasUserDeclaredCopyAssignment()) { // FIXME: this should use the location of the copy // assignment, not the type. - SourceLocation TyLoc = RD->getSourceRange().getBegin(); + SourceLocation TyLoc = RD->getLocStart(); Diag(TyLoc, diag::note_nontrivial_user_defined) << QT << member; return; } @@ -9099,7 +9099,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { // so we just iterate through the direct bases. for (base_iter bi = RD->bases_begin(), be = RD->bases_end(); bi != be; ++bi) if (bi->isVirtual()) { - SourceLocation BaseLoc = bi->getSourceRange().getBegin(); + SourceLocation BaseLoc = bi->getLocStart(); Diag(BaseLoc, diag::note_nontrivial_has_virtual) << QT << 1; return; } @@ -9109,7 +9109,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { for (meth_iter mi = RD->method_begin(), me = RD->method_end(); mi != me; ++mi) { if (mi->isVirtual()) { - SourceLocation MLoc = mi->getSourceRange().getBegin(); + SourceLocation MLoc = mi->getLocStart(); Diag(MLoc, diag::note_nontrivial_has_virtual) << QT << 0; return; } @@ -9136,7 +9136,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { assert(BaseRT && "Don't know how to handle dependent bases"); CXXRecordDecl *BaseRecTy = cast<CXXRecordDecl>(BaseRT->getDecl()); if (!(BaseRecTy->*hasTrivial)()) { - SourceLocation BaseLoc = bi->getSourceRange().getBegin(); + SourceLocation BaseLoc = bi->getLocStart(); Diag(BaseLoc, diag::note_nontrivial_has_nontrivial) << QT << 1 << member; DiagnoseNontrivial(BaseRT, member); return; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 32284968c9087131bd6c093bd705698623f90c48..21a394f71543e9af30526af045b8b632f59f3b37 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -86,7 +86,7 @@ namespace { // evaluated. Parameters of a function declared before a default // argument expression are in scope and can hide namespace and // class member names. - return S->Diag(DRE->getSourceRange().getBegin(), + return S->Diag(DRE->getLocStart(), diag::err_param_default_argument_references_param) << Param->getDeclName() << DefaultArg->getSourceRange(); } else if (VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) { @@ -94,7 +94,7 @@ namespace { // Local variables shall not be used in default argument // expressions. if (VDecl->isLocalVarDecl()) - return S->Diag(DRE->getSourceRange().getBegin(), + return S->Diag(DRE->getLocStart(), diag::err_param_default_argument_references_local) << VDecl->getDeclName() << DefaultArg->getSourceRange(); } @@ -107,7 +107,7 @@ namespace { // C++ [dcl.fct.default]p8: // The keyword this shall not be used in a default argument of a // member function. - return S->Diag(ThisE->getSourceRange().getBegin(), + return S->Diag(ThisE->getLocStart(), diag::err_param_default_argument_references_this) << ThisE->getSourceRange(); } @@ -680,7 +680,7 @@ bool Sema::CheckConstexprFunctionDecl(const FunctionDecl *NewFD) { << RD->getNumVBases(); for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(), E = RD->vbases_end(); I != E; ++I) - Diag(I->getSourceRange().getBegin(), + Diag(I->getLocStart(), diag::note_constexpr_virtual_base_here) << I->getSourceRange(); return false; } @@ -1134,7 +1134,7 @@ bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases, // C++ [class.mi]p3: // A class shall not be specified as a direct base class of a // derived class more than once. - Diag(Bases[idx]->getSourceRange().getBegin(), + Diag(Bases[idx]->getLocStart(), diag::err_duplicate_base_class) << KnownBase->getType() << Bases[idx]->getSourceRange(); @@ -1442,7 +1442,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, // For anonymous bitfields, the location should point to the type. if (Loc.isInvalid()) - Loc = D.getSourceRange().getBegin(); + Loc = D.getLocStart(); Expr *BitWidth = static_cast<Expr*>(BW); @@ -1907,7 +1907,7 @@ Sema::BuildMemInitializer(Decl *ConstructorD, const CXXBaseSpecifier *BaseSpec = DirectBaseSpec? DirectBaseSpec : VirtualBaseSpec; - Diag(BaseSpec->getSourceRange().getBegin(), + Diag(BaseSpec->getLocStart(), diag::note_base_class_specified_here) << BaseSpec->getType() << BaseSpec->getSourceRange(); @@ -3333,7 +3333,7 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location, assert(Dtor && "No dtor found for BaseClassDecl!"); // FIXME: caret should be on the start of the class name - CheckDestructorAccess(Base->getSourceRange().getBegin(), Dtor, + CheckDestructorAccess(Base->getLocStart(), Dtor, PDiag(diag::err_access_dtor_base) << Base->getType() << Base->getSourceRange()); @@ -5863,7 +5863,7 @@ Decl *Sema::ActOnUsingDeclaration(Scope *S, case UnqualifiedId::IK_ConstructorName: case UnqualifiedId::IK_ConstructorTemplateId: // C++0x inherited constructors. - Diag(Name.getSourceRange().getBegin(), + Diag(Name.getLocStart(), getLangOptions().CPlusPlus0x ? diag::warn_cxx98_compat_using_decl_constructor : diag::err_using_decl_constructor) @@ -5874,12 +5874,12 @@ Decl *Sema::ActOnUsingDeclaration(Scope *S, return 0; case UnqualifiedId::IK_DestructorName: - Diag(Name.getSourceRange().getBegin(), diag::err_using_decl_destructor) + Diag(Name.getLocStart(), diag::err_using_decl_destructor) << SS.getRange(); return 0; case UnqualifiedId::IK_TemplateId: - Diag(Name.getSourceRange().getBegin(), diag::err_using_decl_template_id) + Diag(Name.getLocStart(), diag::err_using_decl_template_id) << SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc); return 0; } @@ -5894,7 +5894,7 @@ Decl *Sema::ActOnUsingDeclaration(Scope *S, // talk about access decls instead of using decls in the // diagnostics. if (!HasUsingKeyword) { - UsingLoc = Name.getSourceRange().getBegin(); + UsingLoc = Name.getLocStart(); Diag(UsingLoc, diag::warn_access_decl_deprecated) << FixItHint::CreateInsertion(SS.getRange().getBegin(), "using "); @@ -9615,7 +9615,7 @@ Decl *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) { } VarDecl *ExDecl = BuildExceptionDeclaration(S, TInfo, - D.getSourceRange().getBegin(), + D.getLocStart(), D.getIdentifierLoc(), D.getIdentifier()); if (Invalid) @@ -9871,7 +9871,7 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, /// template <> template <class T> friend class A<int>::B; Decl *Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TempParams) { - SourceLocation Loc = DS.getSourceRange().getBegin(); + SourceLocation Loc = DS.getLocStart(); assert(DS.isFriendSpecified()); assert(DS.getStorageClassSpec() == DeclSpec::SCS_unspecified); @@ -10344,7 +10344,7 @@ static void SearchForReturnInStmt(Sema &Self, Stmt *S) { if (!SubStmt) continue; if (isa<ReturnStmt>(SubStmt)) - Self.Diag(SubStmt->getSourceRange().getBegin(), + Self.Diag(SubStmt->getLocStart(), diag::err_return_in_constructor_handler); if (!isa<Expr>(SubStmt)) SearchForReturnInStmt(Self, SubStmt); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 2adce06ce0a073f6e7f83935d2da37d39fa10fce..85778e4a439a6a09fa4d44f7c29afa271eea74d5 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3297,7 +3297,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, = InitializedEntity::InitializeParameter(Context, Param); InitializationKind Kind = InitializationKind::CreateCopy(Param->getLocation(), - /*FIXME:EqualLoc*/UninstExpr->getSourceRange().getBegin()); + /*FIXME:EqualLoc*/UninstExpr->getLocStart()); Expr *ResultE = Result.takeAs<Expr>(); InitializationSequence InitSeq(*this, Entity, Kind, &ResultE, 1); @@ -3418,7 +3418,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, CallType = VariadicBlock; // Block else if (isa<MemberExpr>(Fn)) CallType = VariadicMethod; - Invalid = GatherArgumentsForCall(Call->getSourceRange().getBegin(), FDecl, + Invalid = GatherArgumentsForCall(Call->getLocStart(), FDecl, Proto, 0, Args, NumArgs, AllArgs, CallType); if (Invalid) return true; @@ -3453,7 +3453,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, if (ArgIx < NumArgs) { Arg = Args[ArgIx++]; - if (RequireCompleteType(Arg->getSourceRange().getBegin(), + if (RequireCompleteType(Arg->getLocStart(), ProtoArgType, PDiag(diag::err_call_incomplete_argument) << Arg->getSourceRange())) @@ -3840,7 +3840,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, // Check for a valid return type if (CheckCallReturnType(FuncT->getResultType(), - Fn->getSourceRange().getBegin(), TheCall, + Fn->getLocStart(), TheCall, FDecl)) return ExprError(); @@ -3899,7 +3899,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, Arg = ArgE.takeAs<Expr>(); } - if (RequireCompleteType(Arg->getSourceRange().getBegin(), + if (RequireCompleteType(Arg->getLocStart(), Arg->getType(), PDiag(diag::err_call_incomplete_argument) << Arg->getSourceRange())) @@ -8895,7 +8895,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { // Don't allow returning a objc interface by value. if (RetTy->isObjCObjectType()) { - Diag(ParamInfo.getSourceRange().getBegin(), + Diag(ParamInfo.getLocStart(), diag::err_object_cannot_be_passed_returned_by_value) << 0 << RetTy; return; } @@ -8930,7 +8930,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { I = Fn->arg_type_begin(), E = Fn->arg_type_end(); I != E; ++I) { ParmVarDecl *Param = BuildParmVarDeclForTypedef(CurBlock->TheDecl, - ParamInfo.getSourceRange().getBegin(), + ParamInfo.getLocStart(), *I); Params.push_back(Param); } @@ -9392,7 +9392,7 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, PartialDiagnostic NotIceDiag, bool AllowFold, PartialDiagnostic FoldDiag) { - SourceLocation DiagLoc = E->getSourceRange().getBegin(); + SourceLocation DiagLoc = E->getLocStart(); if (getLangOptions().CPlusPlus0x) { // C++11 [expr.const]p5: @@ -10641,7 +10641,7 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) { Diag(Loc, diagnostic) << E->getSourceRange(); - SourceLocation Open = E->getSourceRange().getBegin(); + SourceLocation Open = E->getLocStart(); SourceLocation Close = PP.getLocForEndOfToken(E->getSourceRange().getEnd()); Diag(Loc, diag::note_condition_assign_silence) << FixItHint::CreateInsertion(Open, "(") @@ -10675,9 +10675,10 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) { SourceLocation Loc = opE->getOperatorLoc(); Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange(); + SourceRange ParenERange = ParenE->getSourceRange(); Diag(Loc, diag::note_equality_comparison_silence) - << FixItHint::CreateRemoval(ParenE->getSourceRange().getBegin()) - << FixItHint::CreateRemoval(ParenE->getSourceRange().getEnd()); + << FixItHint::CreateRemoval(ParenERange.getBegin()) + << FixItHint::CreateRemoval(ParenERange.getEnd()); Diag(Loc, diag::note_equality_comparison_to_assign) << FixItHint::CreateReplacement(Loc, "="); } diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 6c7bdeb7422880e6fc610616e5404fa5b41e3fde..c7152196caa859c044aa943d87e1c2f3a23a379d 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1057,12 +1057,12 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, return ExprError(Diag(StartLoc, diag::err_auto_new_requires_ctor_arg) << AllocType << TypeRange); if (initStyle == CXXNewExpr::ListInit) - return ExprError(Diag(Inits[0]->getSourceRange().getBegin(), + return ExprError(Diag(Inits[0]->getLocStart(), diag::err_auto_new_requires_parens) << AllocType << TypeRange); if (NumInits > 1) { Expr *FirstBad = Inits[1]; - return ExprError(Diag(FirstBad->getSourceRange().getBegin(), + return ExprError(Diag(FirstBad->getLocStart(), diag::err_auto_new_ctor_multiple_expressions) << AllocType << TypeRange); } @@ -1157,11 +1157,11 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, llvm::APInt::getNullValue(Value.getBitWidth()), Value.isUnsigned())) { if (getLangOptions().CPlusPlus0x) - Diag(ArraySize->getSourceRange().getBegin(), + Diag(ArraySize->getLocStart(), diag::warn_typecheck_negative_array_new_size) << ArraySize->getSourceRange(); else - return ExprError(Diag(ArraySize->getSourceRange().getBegin(), + return ExprError(Diag(ArraySize->getLocStart(), diag::err_typecheck_negative_array_size) << ArraySize->getSourceRange()); } else if (!AllocType->isDependentType()) { @@ -1169,12 +1169,12 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, ConstantArrayType::getNumAddressingBits(Context, AllocType, Value); if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) { if (getLangOptions().CPlusPlus0x) - Diag(ArraySize->getSourceRange().getBegin(), + Diag(ArraySize->getLocStart(), diag::warn_array_new_too_large) << Value.toString(10) << ArraySize->getSourceRange(); else - return ExprError(Diag(ArraySize->getSourceRange().getBegin(), + return ExprError(Diag(ArraySize->getLocStart(), diag::err_array_too_large) << Value.toString(10) << ArraySize->getSourceRange()); @@ -2453,7 +2453,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, if (!Fn) return ExprError(); - if (DiagnoseUseOfDecl(Fn, From->getSourceRange().getBegin())) + if (DiagnoseUseOfDecl(Fn, From->getLocStart())) return ExprError(); From = FixOverloadedFunctionReference(From, Found, Fn); @@ -2562,12 +2562,12 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, if (SCS.IncompatibleObjC && Action != AA_Casting) { // Diagnose incompatible Objective-C conversions if (Action == AA_Initializing || Action == AA_Assigning) - Diag(From->getSourceRange().getBegin(), + Diag(From->getLocStart(), diag::ext_typecheck_convert_incompatible_pointer) << ToType << From->getType() << Action << From->getSourceRange() << 0; else - Diag(From->getSourceRange().getBegin(), + Diag(From->getLocStart(), diag::ext_typecheck_convert_incompatible_pointer) << From->getType() << ToType << Action << From->getSourceRange() << 0; @@ -2580,10 +2580,10 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, !CheckObjCARCUnavailableWeakConversion(ToType, From->getType())) { if (Action == AA_Initializing) - Diag(From->getSourceRange().getBegin(), + Diag(From->getLocStart(), diag::err_arc_weak_unavailable_assign); else - Diag(From->getSourceRange().getBegin(), + Diag(From->getLocStart(), diag::err_arc_convesion_of_weak_unavailable) << (Action == AA_Casting) << From->getType() << ToType << From->getSourceRange(); @@ -3280,7 +3280,7 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc, if (T->isObjectType() || T->isFunctionType()) T = S.Context.getRValueReferenceType(T); OpaqueArgExprs.push_back( - OpaqueValueExpr(Args[I]->getTypeLoc().getSourceRange().getBegin(), + OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(), T.getNonLValueExprType(S.Context), Expr::getValueKindForType(T))); ArgExprs.push_back(&OpaqueArgExprs.back()); @@ -4661,7 +4661,7 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { continue; if (CheckCallReturnType(Call->getCallReturnType(), - Call->getSourceRange().getBegin(), + Call->getLocStart(), Call, Call->getDirectCallee())) return ExprError(); } diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index fe4815c30f31399af4e11ae5a158406f786a1fb8..7c1de21385e02f754663a2032f63bdc4dea6cc2a 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -118,13 +118,13 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, // [dcl.init.string]p2 if (StrLength > CAT->getSize().getZExtValue()) - S.Diag(Str->getSourceRange().getBegin(), + S.Diag(Str->getLocStart(), diag::err_initializer_string_for_char_array_too_long) << Str->getSourceRange(); } else { // C99 6.7.8p14. if (StrLength-1 > CAT->getSize().getZExtValue()) - S.Diag(Str->getSourceRange().getBegin(), + S.Diag(Str->getLocStart(), diag::warn_initializer_string_for_char_array_too_long) << Str->getSourceRange(); } @@ -289,7 +289,7 @@ void InitListChecker::FillInValueInitForField(unsigned Init, FieldDecl *Field, const InitializedEntity &ParentEntity, InitListExpr *ILE, bool &RequiresSecondPass) { - SourceLocation Loc = ILE->getSourceRange().getBegin(); + SourceLocation Loc = ILE->getLocStart(); unsigned NumInits = ILE->getNumInits(); InitializedEntity MemberEntity = InitializedEntity::InitializeMember(Field, &ParentEntity); @@ -354,9 +354,9 @@ InitListChecker::FillInValueInitializations(const InitializedEntity &Entity, bool &RequiresSecondPass) { assert((ILE->getType() != SemaRef.Context.VoidTy) && "Should not have void type"); - SourceLocation Loc = ILE->getSourceRange().getBegin(); + SourceLocation Loc = ILE->getLocStart(); if (ILE->getSyntacticForm()) - Loc = ILE->getSyntacticForm()->getSourceRange().getBegin(); + Loc = ILE->getSyntacticForm()->getLocStart(); if (const RecordType *RType = ILE->getType()->getAs<RecordType>()) { if (RType->getDecl()->isUnion() && @@ -546,7 +546,7 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity, InitListExpr *StructuredSubobjectInitList = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList, StructuredIndex, - SourceRange(ParentIList->getInit(Index)->getSourceRange().getBegin(), + SourceRange(ParentIList->getInit(Index)->getLocStart(), ParentIList->getSourceRange().getEnd())); unsigned StructuredSubobjectInitIndex = 0; @@ -931,7 +931,7 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, return; } else if (isa<DesignatedInitExpr>(expr)) { if (!VerifyOnly) - SemaRef.Diag(expr->getSourceRange().getBegin(), + SemaRef.Diag(expr->getLocStart(), diag::err_designator_for_scalar_init) << DeclType << expr->getSourceRange(); hadError = true; @@ -1136,7 +1136,7 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, // OpenCL requires all elements to be initialized. if (numEltsInit != maxElements) { if (!VerifyOnly) - SemaRef.Diag(IList->getSourceRange().getBegin(), + SemaRef.Diag(IList->getLocStart(), diag::err_vector_incorrect_num_initializers) << (numEltsInit < maxElements) << maxElements << numEltsInit; hadError = true; @@ -1300,9 +1300,9 @@ bool InitListChecker::CheckFlexibleArrayInit(const InitializedEntity &Entity, } if (!VerifyOnly) { - SemaRef.Diag(InitExpr->getSourceRange().getBegin(), + SemaRef.Diag(InitExpr->getLocStart(), FlexArrayDiag) - << InitExpr->getSourceRange().getBegin(); + << InitExpr->getLocStart(); SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member) << Field; } @@ -1818,7 +1818,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, !isa<StringLiteral>(DIE->getInit())) { // The initializer is not an initializer list. if (!VerifyOnly) { - SemaRef.Diag(DIE->getInit()->getSourceRange().getBegin(), + SemaRef.Diag(DIE->getInit()->getLocStart(), diag::err_flexible_array_init_needs_braces) << DIE->getInit()->getSourceRange(); SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member) @@ -1959,7 +1959,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, DesignatedEndIndex.setIsUnsigned(MaxElements.isUnsigned()); if (DesignatedEndIndex >= MaxElements) { if (!VerifyOnly) - SemaRef.Diag(IndexExpr->getSourceRange().getBegin(), + SemaRef.Diag(IndexExpr->getLocStart(), diag::err_array_designator_too_large) << DesignatedEndIndex.toString(10) << MaxElements.toString(10) << IndexExpr->getSourceRange(); @@ -2068,7 +2068,7 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index, SemaRef.Diag(InitRange.getBegin(), diag::warn_subobject_initializer_overrides) << InitRange; - SemaRef.Diag(ExistingInit->getSourceRange().getBegin(), + SemaRef.Diag(ExistingInit->getLocStart(), diag::note_previous_initializer) << /*FIXME:has side effects=*/0 << ExistingInit->getSourceRange(); @@ -2144,10 +2144,10 @@ void InitListChecker::UpdateStructuredListElement(InitListExpr *StructuredList, if (Expr *PrevInit = StructuredList->updateInit(SemaRef.Context, StructuredIndex, expr)) { // This initializer overwrites a previous initializer. Warn. - SemaRef.Diag(expr->getSourceRange().getBegin(), + SemaRef.Diag(expr->getLocStart(), diag::warn_initializer_overrides) << expr->getSourceRange(); - SemaRef.Diag(PrevInit->getSourceRange().getBegin(), + SemaRef.Diag(PrevInit->getLocStart(), diag::note_previous_initializer) << /*FIXME:has side effects=*/0 << PrevInit->getSourceRange(); @@ -2165,7 +2165,7 @@ void InitListChecker::UpdateStructuredListElement(InitListExpr *StructuredList, /// value of the constant expression. static ExprResult CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value) { - SourceLocation Loc = Index->getSourceRange().getBegin(); + SourceLocation Loc = Index->getLocStart(); // Make sure this is an integer constant expression. ExprResult Result = S.VerifyIntegerConstantExpression(Index, &Value); diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index fac3b7f3839abfb58b98ca443a9e318b8557de30..7434f0f8d7477d59f7ad46eae70ae711ec4bc75b 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -3052,11 +3052,11 @@ Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) { IsUserDefinedConversion(*this, From, ToType, ICS.UserDefined, CandidateSet, false); if (OvResult == OR_Ambiguous) - Diag(From->getSourceRange().getBegin(), + Diag(From->getLocStart(), diag::err_typecheck_ambiguous_condition) << From->getType() << ToType << From->getSourceRange(); else if (OvResult == OR_No_Viable_Function && !CandidateSet.empty()) - Diag(From->getSourceRange().getBegin(), + Diag(From->getLocStart(), diag::err_typecheck_nonviable_condition) << From->getType() << ToType << From->getSourceRange(); else @@ -4603,7 +4603,7 @@ Sema::PerformObjectArgumentInitialization(Expr *From, Qualifiers ToQs = DestType.getQualifiers(); unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers(); if (CVR) { - Diag(From->getSourceRange().getBegin(), + Diag(From->getLocStart(), diag::err_member_function_call_bad_cvr) << Method->getDeclName() << FromRecordType << (CVR - 1) << From->getSourceRange(); @@ -4613,7 +4613,7 @@ Sema::PerformObjectArgumentInitialization(Expr *From, } } - return Diag(From->getSourceRange().getBegin(), + return Diag(From->getLocStart(), diag::err_implicit_object_parameter_init) << ImplicitParamRecordType << FromRecordType << From->getSourceRange(); } @@ -4657,7 +4657,7 @@ ExprResult Sema::PerformContextuallyConvertToBool(Expr *From) { return PerformImplicitConversion(From, Context.BoolTy, ICS, AA_Converting); if (!DiagnoseMultipleUserDefinedConversion(From, Context.BoolTy)) - return Diag(From->getSourceRange().getBegin(), + return Diag(From->getLocStart(), diag::err_typecheck_bool_condition) << From->getType() << From->getSourceRange(); return ExprError(); @@ -4745,7 +4745,7 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: if (!CheckConvertedConstantConversions(*this, ICS.Standard)) - return Diag(From->getSourceRange().getBegin(), + return Diag(From->getLocStart(), diag::err_typecheck_converted_constant_expression_disallowed) << From->getType() << From->getSourceRange() << T; SCS = &ICS.Standard; @@ -4754,7 +4754,7 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, // We are converting from class type to an integral or enumeration type, so // the Before sequence must be trivial. if (!CheckConvertedConstantConversions(*this, ICS.UserDefined.After)) - return Diag(From->getSourceRange().getBegin(), + return Diag(From->getLocStart(), diag::err_typecheck_converted_constant_expression_disallowed) << From->getType() << From->getSourceRange() << T; SCS = &ICS.UserDefined.After; @@ -4762,7 +4762,7 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, case ImplicitConversionSequence::AmbiguousConversion: case ImplicitConversionSequence::BadConversion: if (!DiagnoseMultipleUserDefinedConversion(From, T)) - return Diag(From->getSourceRange().getBegin(), + return Diag(From->getLocStart(), diag::err_typecheck_converted_constant_expression) << From->getType() << From->getSourceRange() << T; return ExprError(); @@ -4786,14 +4786,14 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, break; case NK_Constant_Narrowing: - Diag(From->getSourceRange().getBegin(), diag::err_cce_narrowing) + Diag(From->getLocStart(), diag::err_cce_narrowing) << CCE << /*Constant*/1 << PreNarrowingValue.getAsString(Context, QualType()) << T; Diagnosed = true; break; case NK_Type_Narrowing: - Diag(From->getSourceRange().getBegin(), diag::err_cce_narrowing) + Diag(From->getLocStart(), diag::err_cce_narrowing) << CCE << /*Constant*/0 << From->getType() << T; Diagnosed = true; break; @@ -4826,7 +4826,7 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) Diag(Notes[0].first, diag::err_expr_not_cce) << CCE; else { - Diag(From->getSourceRange().getBegin(), diag::err_expr_not_cce) + Diag(From->getLocStart(), diag::err_expr_not_cce) << CCE << From->getSourceRange(); for (unsigned I = 0; I < Notes.size(); ++I) Diag(Notes[I].first, Notes[I].second); @@ -9083,7 +9083,7 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization( ExprResult SingleFunctionExpression; if (FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization( ovl.Expression, /*complain*/ false, &found)) { - if (DiagnoseUseOfDecl(fn, SrcExpr.get()->getSourceRange().getBegin())) { + if (DiagnoseUseOfDecl(fn, SrcExpr.get()->getLocStart())) { SrcExpr = ExprError(); return true; } @@ -9558,7 +9558,7 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, if (!Recovery.isInvalid()) return Recovery; - Diag(Fn->getSourceRange().getBegin(), + Diag(Fn->getLocStart(), diag::err_ovl_no_viable_function_in_call) << ULE->getName() << Fn->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, @@ -9567,7 +9567,7 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, } case OR_Ambiguous: - Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_ambiguous_call) + Diag(Fn->getLocStart(), diag::err_ovl_ambiguous_call) << ULE->getName() << Fn->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, llvm::makeArrayRef(Args, NumArgs)); @@ -9575,7 +9575,7 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, case OR_Deleted: { - Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_deleted_call) + Diag(Fn->getLocStart(), diag::err_ovl_deleted_call) << Best->Function->isDeleted() << ULE->getName() << getDeletedOrUnavailableSuffix(Best->Function) @@ -10307,7 +10307,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, resultType, valueKind, RParenLoc); if (CheckCallReturnType(proto->getResultType(), - op->getRHS()->getSourceRange().getBegin(), + op->getRHS()->getLocStart(), call, 0)) return ExprError(); @@ -10601,11 +10601,11 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, case OR_No_Viable_Function: if (CandidateSet.empty()) - Diag(Object.get()->getSourceRange().getBegin(), diag::err_ovl_no_oper) + Diag(Object.get()->getLocStart(), diag::err_ovl_no_oper) << Object.get()->getType() << /*call*/ 1 << Object.get()->getSourceRange(); else - Diag(Object.get()->getSourceRange().getBegin(), + Diag(Object.get()->getLocStart(), diag::err_ovl_no_viable_object_call) << Object.get()->getType() << Object.get()->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, @@ -10613,7 +10613,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, break; case OR_Ambiguous: - Diag(Object.get()->getSourceRange().getBegin(), + Diag(Object.get()->getLocStart(), diag::err_ovl_ambiguous_object_call) << Object.get()->getType() << Object.get()->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, @@ -10621,7 +10621,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, break; case OR_Deleted: - Diag(Object.get()->getSourceRange().getBegin(), + Diag(Object.get()->getLocStart(), diag::err_ovl_deleted_object_call) << Best->Function->isDeleted() << Object.get()->getType() diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 986a4c808171ac9339e730de3d08c0f019ef5158..2952de369d2dfa3c70a266fd52c306a9b303fe6f 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -155,8 +155,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S, QualType ObjectType = ObjectTypePtr.get(); - LookupResult R(*this, TName, Name.getSourceRange().getBegin(), - LookupOrdinaryName); + LookupResult R(*this, TName, Name.getLocStart(), LookupOrdinaryName); LookupTemplateName(R, S, SS, ObjectType, EnteringContext, MemberOfUnknownSpecialization); if (R.empty()) return TNK_Non_template; @@ -684,7 +683,7 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, bool IsParameterPack = D.hasEllipsis(); NonTypeTemplateParmDecl *Param = NonTypeTemplateParmDecl::Create(Context, Context.getTranslationUnitDecl(), - D.getSourceRange().getBegin(), + D.getLocStart(), D.getIdentifierLoc(), Depth, Position, ParamName, T, IsParameterPack, TInfo); @@ -2333,7 +2332,7 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases())) { // This is a dependent template. Handle it below. } else if (TNK == TNK_Non_template) { - Diag(Name.getSourceRange().getBegin(), + Diag(Name.getLocStart(), diag::err_template_kw_refers_to_non_template) << GetNameFromUnqualifiedId(Name).getName() << Name.getSourceRange() @@ -2367,7 +2366,7 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, break; } - Diag(Name.getSourceRange().getBegin(), + Diag(Name.getLocStart(), diag::err_template_kw_refers_to_non_template) << GetNameFromUnqualifiedId(Name).getName() << Name.getSourceRange() @@ -3472,7 +3471,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, bool ExtraParens = false; while (ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) { if (!Invalid && !ExtraParens) { - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getLocStart(), S.getLangOptions().CPlusPlus0x ? diag::warn_cxx98_compat_template_arg_extra_parens : diag::ext_template_arg_extra_parens) @@ -3522,7 +3521,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, } if (!isa<ValueDecl>(DRE->getDecl())) { - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getLocStart(), diag::err_template_arg_not_object_or_func_form) << Arg->getSourceRange(); S.Diag(Param->getLocation(), diag::note_template_param_here); @@ -3533,7 +3532,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, // Cannot refer to non-static data members if (FieldDecl *Field = dyn_cast<FieldDecl>(DRE->getDecl())) { - S.Diag(Arg->getSourceRange().getBegin(), diag::err_template_arg_field) + S.Diag(Arg->getLocStart(), diag::err_template_arg_field) << Field << Arg->getSourceRange(); S.Diag(Param->getLocation(), diag::note_template_param_here); return true; @@ -3542,7 +3541,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, // Cannot refer to non-static member functions if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(DRE->getDecl())) if (!Method->isStatic()) { - S.Diag(Arg->getSourceRange().getBegin(), diag::err_template_arg_method) + S.Diag(Arg->getLocStart(), diag::err_template_arg_method) << Method << Arg->getSourceRange(); S.Diag(Param->getLocation(), diag::note_template_param_here); return true; @@ -3551,7 +3550,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, // Functions must have external linkage. if (FunctionDecl *Func = dyn_cast<FunctionDecl>(DRE->getDecl())) { if (!isExternalLinkage(Func->getLinkage())) { - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getLocStart(), diag::err_template_arg_function_not_extern) << Func << Arg->getSourceRange(); S.Diag(Func->getLocation(), diag::note_template_arg_internal_object) @@ -3586,7 +3585,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, } } else if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) { if (!isExternalLinkage(Var->getLinkage())) { - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getLocStart(), diag::err_template_arg_object_not_extern) << Var << Arg->getSourceRange(); S.Diag(Var->getLocation(), diag::note_template_arg_internal_object) @@ -3596,7 +3595,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, // A value of reference type is not an object. if (Var->getType()->isReferenceType()) { - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getLocStart(), diag::err_template_arg_reference_var) << Var->getType() << Arg->getSourceRange(); S.Diag(Param->getLocation(), diag::note_template_param_here); @@ -3653,7 +3652,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, } } else { // We found something else, but we don't know specifically what it is. - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getLocStart(), diag::err_template_arg_not_object_or_func) << Arg->getSourceRange(); S.Diag(DRE->getDecl()->getLocation(), diag::note_template_arg_refers_here); @@ -3683,7 +3682,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, unsigned ArgQuals = ArgType.getCVRQualifiers(); if ((ParamQuals | ArgQuals) != ParamQuals) { - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getLocStart(), diag::err_template_arg_ref_bind_ignores_quals) << ParamType << Arg->getType() << Arg->getSourceRange(); @@ -3739,7 +3738,7 @@ bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, bool ExtraParens = false; while (ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) { if (!Invalid && !ExtraParens) { - Diag(Arg->getSourceRange().getBegin(), + Diag(Arg->getLocStart(), getLangOptions().CPlusPlus0x ? diag::warn_cxx98_compat_template_arg_extra_parens : diag::ext_template_arg_extra_parens) @@ -3782,7 +3781,7 @@ bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, } if (!DRE) - return Diag(Arg->getSourceRange().getBegin(), + return Diag(Arg->getLocStart(), diag::err_template_arg_not_pointer_to_member_form) << Arg->getSourceRange(); @@ -3801,7 +3800,7 @@ bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, } // We found something else, but we don't know specifically what it is. - Diag(Arg->getSourceRange().getBegin(), + Diag(Arg->getLocStart(), diag::err_template_arg_not_pointer_to_member_form) << Arg->getSourceRange(); Diag(DRE->getDecl()->getLocation(), @@ -3821,7 +3820,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, QualType InstantiatedParamType, Expr *Arg, TemplateArgument &Converted, CheckTemplateArgumentKind CTAK) { - SourceLocation StartLoc = Arg->getSourceRange().getBegin(); + SourceLocation StartLoc = Arg->getLocStart(); // If either the parameter has a dependent type or the argument is // type-dependent, there's nothing we can check now. @@ -3918,7 +3917,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, SourceLocation NonConstantLoc; llvm::APSInt Value; if (!ArgType->isIntegralOrEnumerationType()) { - Diag(Arg->getSourceRange().getBegin(), + Diag(Arg->getLocStart(), diag::err_template_arg_not_integral_or_enumeral) << ArgType << Arg->getSourceRange(); Diag(Param->getLocation(), diag::note_template_param_here); @@ -3947,7 +3946,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).take(); } else { // We can't perform this conversion. - Diag(Arg->getSourceRange().getBegin(), + Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible) << Arg->getType() << InstantiatedParamType << Arg->getSourceRange(); Diag(Param->getLocation(), diag::note_template_param_here); @@ -3988,7 +3987,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // Complain if an unsigned parameter received a negative value. if (IntegerType->isUnsignedIntegerOrEnumerationType() && (OldValue.isSigned() && OldValue.isNegative())) { - Diag(Arg->getSourceRange().getBegin(), diag::warn_template_arg_negative) + Diag(Arg->getLocStart(), diag::warn_template_arg_negative) << OldValue.toString(10) << Value.toString(10) << Param->getType() << Arg->getSourceRange(); Diag(Param->getLocation(), diag::note_template_param_here); @@ -4003,7 +4002,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, else RequiredBits = OldValue.getMinSignedBits(); if (RequiredBits > AllowedBits) { - Diag(Arg->getSourceRange().getBegin(), + Diag(Arg->getLocStart(), diag::warn_template_arg_too_large) << OldValue.toString(10) << Value.toString(10) << Param->getType() << Arg->getSourceRange(); @@ -4066,7 +4065,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType, true, FoundResult)) { - if (DiagnoseUseOfDecl(Fn, Arg->getSourceRange().getBegin())) + if (DiagnoseUseOfDecl(Fn, Arg->getLocStart())) return ExprError(); Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn); @@ -4091,7 +4090,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, } else if (!Context.hasSameUnqualifiedType(ArgType, ParamType.getNonReferenceType())) { // We can't perform this conversion. - Diag(Arg->getSourceRange().getBegin(), + Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible) << Arg->getType() << InstantiatedParamType << Arg->getSourceRange(); Diag(Param->getLocation(), diag::note_template_param_here); @@ -4133,7 +4132,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ParamRefType->getPointeeType(), true, FoundResult)) { - if (DiagnoseUseOfDecl(Fn, Arg->getSourceRange().getBegin())) + if (DiagnoseUseOfDecl(Fn, Arg->getLocStart())) return ExprError(); Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn); @@ -4162,7 +4161,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, Arg->getValueKind()).take(); } else { // We can't perform this conversion. - Diag(Arg->getSourceRange().getBegin(), + Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible) << Arg->getType() << InstantiatedParamType << Arg->getSourceRange(); Diag(Param->getLocation(), diag::note_template_param_here); @@ -6313,7 +6312,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, DeclarationName Name = NameInfo.getName(); if (!Name) { if (!D.isInvalidType()) - Diag(D.getDeclSpec().getSourceRange().getBegin(), + Diag(D.getDeclSpec().getLocStart(), diag::err_explicit_instantiation_requires_name) << D.getDeclSpec().getSourceRange() << D.getSourceRange(); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index d7c54f7d0b8027e1c3c7c5dbaad59bf1063f11cc..505cc8f769c8d3b11d0d7de1a928df3f0efe2d0d 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -548,7 +548,7 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state, // faking up the function chunk is still the right thing to do. // Otherwise, we need to fake up a function declarator. - SourceLocation loc = declarator.getSourceRange().getBegin(); + SourceLocation loc = declarator.getLocStart(); // ...and *prepend* it to the declarator. declarator.AddInnermostTypeInfo(DeclaratorChunk::getFunction( @@ -584,7 +584,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { const DeclSpec &DS = declarator.getDeclSpec(); SourceLocation DeclLoc = declarator.getIdentifierLoc(); if (DeclLoc.isInvalid()) - DeclLoc = DS.getSourceRange().getBegin(); + DeclLoc = DS.getLocStart(); ASTContext &Context = S.Context; @@ -662,7 +662,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { if (DS.isEmpty()) { S.Diag(DeclLoc, diag::ext_missing_declspec) << DS.getSourceRange() - << FixItHint::CreateInsertion(DS.getSourceRange().getBegin(), "int"); + << FixItHint::CreateInsertion(DS.getLocStart(), "int"); } } else if (!DS.hasTypeSpecifier()) { // C99 and C++ require a type specifier. For example, C99 6.7.2p2 says: @@ -2492,7 +2492,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static) && !IsTypedefName && D.getContext() != Declarator::TemplateTypeArgContext) { - SourceLocation Loc = D.getSourceRange().getBegin(); + SourceLocation Loc = D.getLocStart(); SourceRange RemovalRange; unsigned I; if (D.isFunctionDeclarator(I)) { @@ -4282,7 +4282,7 @@ bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, << RD->isStruct() << RD->getNumVBases(); for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(), E = RD->vbases_end(); I != E; ++I) - Diag(I->getSourceRange().getBegin(), + Diag(I->getLocStart(), diag::note_constexpr_virtual_base_here) << I->getSourceRange(); } else if (!RD->isAggregate() && !RD->hasConstexprNonCopyMoveConstructor() && !RD->hasTrivialDefaultConstructor()) { @@ -4291,7 +4291,7 @@ bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), E = RD->bases_end(); I != E; ++I) { if (!I->getType()->isLiteralType()) { - Diag(I->getSourceRange().getBegin(), + Diag(I->getLocStart(), diag::note_non_literal_base_class) << RD << I->getType() << I->getSourceRange(); return true; diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 7e4a1ede74f0bef7b348c8e8c96dab5b487871f6..a91146c8b3fb6e5dca3382707275294a0e5680f7 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3702,7 +3702,7 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) { TSInfo->getTypeLoc().getBeginLoc()); return cxloc::translateSourceLocation(getCursorContext(C), - BaseSpec->getSourceRange().getBegin()); + BaseSpec->getLocStart()); } case CXCursor_LabelRef: { @@ -3908,10 +3908,10 @@ static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr) { SourceLocation StartLoc; if (const DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { if (TypeSourceInfo *TI = DD->getTypeSourceInfo()) - StartLoc = TI->getTypeLoc().getSourceRange().getBegin(); + StartLoc = TI->getTypeLoc().getLocStart(); } else if (TypedefDecl *Typedef = dyn_cast<TypedefDecl>(D)) { if (TypeSourceInfo *TI = Typedef->getTypeSourceInfo()) - StartLoc = TI->getTypeLoc().getSourceRange().getBegin(); + StartLoc = TI->getTypeLoc().getLocStart(); } if (StartLoc.isValid() && R.getBegin().isValid() && @@ -4845,10 +4845,10 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { SourceLocation StartLoc; if (const DeclaratorDecl *DD = dyn_cast_or_null<DeclaratorDecl>(D)) { if (TypeSourceInfo *TI = DD->getTypeSourceInfo()) - StartLoc = TI->getTypeLoc().getSourceRange().getBegin(); + StartLoc = TI->getTypeLoc().getLocStart(); } else if (TypedefDecl *Typedef = dyn_cast_or_null<TypedefDecl>(D)) { if (TypeSourceInfo *TI = Typedef->getTypeSourceInfo()) - StartLoc = TI->getTypeLoc().getSourceRange().getBegin(); + StartLoc = TI->getTypeLoc().getLocStart(); } if (StartLoc.isValid() && L.isValid() &&