diff options
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 97c178ef42b..c170d74ca5e 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -918,8 +918,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // Check the unconverted value is within the range of possible values of // the switch expression. - checkCaseValue(*this, Lo->getLocStart(), LoVal, - CondWidthBeforePromotion, CondIsSignedBeforePromotion); + checkCaseValue(*this, Lo->getBeginLoc(), LoVal, CondWidthBeforePromotion, + CondIsSignedBeforePromotion); // FIXME: This duplicates the check performed for warn_not_in_enum below. checkEnumTypesInSwitchStmt(*this, CondExprBeforePromotion, @@ -979,17 +979,17 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, CaseVals[i-1].first.toString(CaseValStr); if (PrevString == CurrString) - Diag(CaseVals[i].second->getLHS()->getLocStart(), - diag::err_duplicate_case) << - (PrevString.empty() ? StringRef(CaseValStr) : PrevString); + Diag(CaseVals[i].second->getLHS()->getBeginLoc(), + diag::err_duplicate_case) + << (PrevString.empty() ? StringRef(CaseValStr) : PrevString); else - Diag(CaseVals[i].second->getLHS()->getLocStart(), - diag::err_duplicate_case_differing_expr) << - (PrevString.empty() ? StringRef(CaseValStr) : PrevString) << - (CurrString.empty() ? StringRef(CaseValStr) : CurrString) << - CaseValStr; + Diag(CaseVals[i].second->getLHS()->getBeginLoc(), + diag::err_duplicate_case_differing_expr) + << (PrevString.empty() ? StringRef(CaseValStr) : PrevString) + << (CurrString.empty() ? StringRef(CaseValStr) : CurrString) + << CaseValStr; - Diag(CaseVals[i-1].second->getLHS()->getLocStart(), + Diag(CaseVals[i - 1].second->getLHS()->getBeginLoc(), diag::note_duplicate_case_prev); // FIXME: We really want to remove the bogus case stmt from the // substmt, but we have no way to do this right now. @@ -1018,7 +1018,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // Check the unconverted value is within the range of possible values of // the switch expression. - checkCaseValue(*this, Hi->getLocStart(), HiVal, + checkCaseValue(*this, Hi->getBeginLoc(), HiVal, CondWidthBeforePromotion, CondIsSignedBeforePromotion); // Convert the value to the same width/sign as the condition. @@ -1026,9 +1026,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // If the low value is bigger than the high value, the case is empty. if (LoVal > HiVal) { - Diag(CR->getLHS()->getLocStart(), diag::warn_case_empty_range) - << SourceRange(CR->getLHS()->getLocStart(), - Hi->getLocEnd()); + Diag(CR->getLHS()->getBeginLoc(), diag::warn_case_empty_range) + << SourceRange(CR->getLHS()->getBeginLoc(), Hi->getLocEnd()); CaseRanges.erase(CaseRanges.begin()+i); --i; --e; @@ -1082,9 +1081,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, if (OverlapStmt) { // If we have a duplicate, report it. - Diag(CR->getLHS()->getLocStart(), diag::err_duplicate_case) - << OverlapVal.toString(10); - Diag(OverlapStmt->getLHS()->getLocStart(), + Diag(CR->getLHS()->getBeginLoc(), diag::err_duplicate_case) + << OverlapVal.toString(10); + Diag(OverlapStmt->getLHS()->getBeginLoc(), diag::note_duplicate_case_prev); // FIXME: We really want to remove the bogus case stmt from the // substmt, but we have no way to do this right now. @@ -1492,7 +1491,7 @@ namespace { if (!Second) return; if (S.Diags.isIgnored(diag::warn_variables_not_in_loop_body, - Second->getLocStart())) + Second->getBeginLoc())) return; PartialDiagnostic PDiag = S.PDiag(diag::warn_variables_not_in_loop_body); @@ -1668,7 +1667,7 @@ namespace { if (!Body || !Third) return; if (S.Diags.isIgnored(diag::warn_redundant_loop_iteration, - Third->getLocStart())) + Third->getBeginLoc())) return; // Get the last statement from the loop body. @@ -1914,9 +1913,9 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, } else { Expr *FirstE = cast<Expr>(First); if (!FirstE->isTypeDependent() && !FirstE->isLValue()) - return StmtError(Diag(First->getLocStart(), - diag::err_selector_element_not_lvalue) - << First->getSourceRange()); + return StmtError( + Diag(First->getBeginLoc(), diag::err_selector_element_not_lvalue) + << First->getSourceRange()); FirstType = static_cast<Expr*>(First)->getType(); if (FirstType.isConstQualified()) @@ -2087,7 +2086,7 @@ StmtResult Sema::ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, // Build auto && __range = range-init // Divide by 2, since the variables are in the inner scope (loop body). const auto DepthStr = std::to_string(S->getDepth() / 2); - SourceLocation RangeLoc = Range->getLocStart(); + SourceLocation RangeLoc = Range->getBeginLoc(); VarDecl *RangeVar = BuildForRangeVarDecl(*this, RangeLoc, Context.getAutoRRefDeductType(), std::string("__range") + DepthStr); @@ -2169,7 +2168,7 @@ BuildNonArrayForRange(Sema &SemaRef, Expr *BeginRange, Expr *EndRange, if (RangeStatus != Sema::FRS_Success) { if (RangeStatus == Sema::FRS_DiagnosticIssued) - SemaRef.Diag(BeginRange->getLocStart(), diag::note_in_for_range) + SemaRef.Diag(BeginRange->getBeginLoc(), diag::note_in_for_range) << ColonLoc << BEF_begin << BeginRange->getType(); return RangeStatus; } @@ -2195,7 +2194,7 @@ BuildNonArrayForRange(Sema &SemaRef, Expr *BeginRange, Expr *EndRange, EndRange, EndExpr); if (RangeStatus != Sema::FRS_Success) { if (RangeStatus == Sema::FRS_DiagnosticIssued) - SemaRef.Diag(EndRange->getLocStart(), diag::note_in_for_range) + SemaRef.Diag(EndRange->getBeginLoc(), diag::note_in_for_range) << ColonLoc << BEF_end << EndRange->getType(); return RangeStatus; } @@ -2451,8 +2450,8 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, QualType ArrayTy = PVD->getOriginalType(); QualType PointerTy = PVD->getType(); if (PointerTy->isPointerType() && ArrayTy->isArrayType()) { - Diag(Range->getLocStart(), diag::err_range_on_array_parameter) - << RangeLoc << PVD << ArrayTy << PointerTy; + Diag(Range->getBeginLoc(), diag::err_range_on_array_parameter) + << RangeLoc << PVD << ArrayTy << PointerTy; Diag(PVD->getLocation(), diag::note_declared_at); return StmtError(); } @@ -2473,7 +2472,7 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, // Otherwise, emit diagnostics if we haven't already. if (RangeStatus == FRS_NoViableFunction) { Expr *Range = BEFFailure ? EndRangeRef.get() : BeginRangeRef.get(); - Diag(Range->getLocStart(), diag::err_for_range_invalid) + Diag(Range->getBeginLoc(), diag::err_for_range_invalid) << RangeLoc << Range->getType() << BEFFailure; CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Range); } @@ -2660,7 +2659,7 @@ static void DiagnoseForRangeReferenceVariableCopies(Sema &SemaRef, NonReferenceType.removeLocalConst(); QualType NewReferenceType = SemaRef.Context.getLValueReferenceType(E->getType().withConst()); - SemaRef.Diag(VD->getLocStart(), diag::note_use_type_or_non_reference) + SemaRef.Diag(VD->getBeginLoc(), diag::note_use_type_or_non_reference) << NonReferenceType << NewReferenceType << VD->getSourceRange(); } else { // The range always returns a copy, so a temporary is always created. @@ -2669,7 +2668,7 @@ static void DiagnoseForRangeReferenceVariableCopies(Sema &SemaRef, << VD << RangeInitType; QualType NonReferenceType = VariableType.getNonReferenceType(); NonReferenceType.removeLocalConst(); - SemaRef.Diag(VD->getLocStart(), diag::note_use_non_reference_type) + SemaRef.Diag(VD->getBeginLoc(), diag::note_use_non_reference_type) << NonReferenceType << VD->getSourceRange(); } } @@ -2705,7 +2704,7 @@ static void DiagnoseForRangeConstVariableCopies(Sema &SemaRef, // if doing so will prevent a copy. SemaRef.Diag(VD->getLocation(), diag::warn_for_range_copy) << VD << VariableType << InitExpr->getType(); - SemaRef.Diag(VD->getLocStart(), diag::note_use_reference_type) + SemaRef.Diag(VD->getBeginLoc(), diag::note_use_reference_type) << SemaRef.Context.getLValueReferenceType(VariableType) << VD->getSourceRange(); } @@ -2721,11 +2720,11 @@ static void DiagnoseForRangeConstVariableCopies(Sema &SemaRef, static void DiagnoseForRangeVariableCopies(Sema &SemaRef, const CXXForRangeStmt *ForStmt) { if (SemaRef.Diags.isIgnored(diag::warn_for_range_const_reference_copy, - ForStmt->getLocStart()) && + ForStmt->getBeginLoc()) && SemaRef.Diags.isIgnored(diag::warn_for_range_variable_always_copy, - ForStmt->getLocStart()) && + ForStmt->getBeginLoc()) && SemaRef.Diags.isIgnored(diag::warn_for_range_copy, - ForStmt->getLocStart())) { + ForStmt->getBeginLoc())) { return; } @@ -2951,7 +2950,7 @@ static void TryMoveInitialization(Sema& S, Expr *InitExpr = &AsRvalue; InitializationKind Kind = InitializationKind::CreateCopy( - Value->getLocStart(), Value->getLocStart()); + Value->getBeginLoc(), Value->getBeginLoc()); InitializationSequence Seq(S, Entity, Kind, InitExpr); @@ -3969,7 +3968,7 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, // declarations that are invalid, since we can't usefully report on them. if (!H->getExceptionDecl()) { if (i < NumHandlers - 1) - return StmtError(Diag(H->getLocStart(), diag::err_early_catch_all)); + return StmtError(Diag(H->getBeginLoc(), diag::err_early_catch_all)); continue; } else if (H->getExceptionDecl()->isInvalidDecl()) continue; |