diff options
author | Stephen Kelly <steveire@gmail.com> | 2018-08-09 22:42:26 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2018-08-09 22:42:26 +0000 |
commit | 43465bf3fd6cca715187ee7286c881cb210fc3c4 (patch) | |
tree | c2aad6e9cadd0b7164c476722704660c4b84b5e5 /clang-tools-extra/clang-tidy | |
parent | d54b7f059290102b0ff007843ecf0668e833c118 (diff) | |
download | llvm-43465bf3fd6cca715187ee7286c881cb210fc3c4.zip llvm-43465bf3fd6cca715187ee7286c881cb210fc3c4.tar.gz llvm-43465bf3fd6cca715187ee7286c881cb210fc3c4.tar.bz2 |
Port getLocStart -> getBeginLoc
Reviewers: javed.absar
Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D50354
llvm-svn: 339400
Diffstat (limited to 'clang-tools-extra/clang-tidy')
115 files changed, 280 insertions, 280 deletions
diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp index 7a94c10..2701c24 100644 --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp @@ -71,7 +71,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) { ->getImplicitObjectArgument(); assert(Haystack != nullptr); - if (ComparisonExpr->getLocStart().isMacroID()) + if (ComparisonExpr->getBeginLoc().isMacroID()) return; // Get the source code blocks (as characters) for both the string object @@ -94,7 +94,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) { // Create the warning message and a FixIt hint replacing the original expr. auto Diagnostic = - diag(ComparisonExpr->getLocStart(), + diag(ComparisonExpr->getBeginLoc(), (StringRef("use ") + StartswithStr + " instead of find() " + ComparisonExpr->getOpcodeStr() + " 0") .str()); @@ -107,7 +107,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) { // Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks // whether this already exists). auto IncludeHint = IncludeInserter->CreateIncludeInsertion( - Source.getFileID(ComparisonExpr->getLocStart()), AbseilStringsMatchHeader, + Source.getFileID(ComparisonExpr->getBeginLoc()), AbseilStringsMatchHeader, false); if (IncludeHint) { Diagnostic << *IncludeHint; diff --git a/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp index 8473f1a..686c749 100644 --- a/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp +++ b/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp @@ -25,7 +25,7 @@ namespace { // end of the string. Else, add <Mode>. std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager &SM, const LangOptions &LangOpts, char Mode) { - if (Arg->getLocStart().isMacroID()) + if (Arg->getBeginLoc().isMacroID()) return (Lexer::getSourceText( CharSourceRange::getTokenRange(Arg->getSourceRange()), SM, LangOpts) + @@ -75,7 +75,7 @@ void CloexecCheck::insertMacroFlag(const MatchFinder::MatchResult &Result, void CloexecCheck::replaceFunc(const MatchFinder::MatchResult &Result, StringRef WarningMsg, StringRef FixMsg) { const auto *MatchedCall = Result.Nodes.getNodeAs<CallExpr>(FuncBindingStr); - diag(MatchedCall->getLocStart(), WarningMsg) + diag(MatchedCall->getBeginLoc(), WarningMsg) << FixItHint::CreateReplacement(MatchedCall->getSourceRange(), FixMsg); } @@ -94,7 +94,7 @@ void CloexecCheck::insertStringFlag( const std::string &ReplacementText = buildFixMsgForStringFlag( ModeArg, *Result.SourceManager, Result.Context->getLangOpts(), Mode); - diag(ModeArg->getLocStart(), "use %0 mode '%1' to set O_CLOEXEC") + diag(ModeArg->getBeginLoc(), "use %0 mode '%1' to set O_CLOEXEC") << FD << std::string(1, Mode) << FixItHint::CreateReplacement(ModeArg->getSourceRange(), ReplacementText); diff --git a/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp b/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp index 49db53a..a98eb8c 100644 --- a/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp +++ b/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp @@ -21,15 +21,15 @@ namespace android { namespace { AST_MATCHER(BinaryOperator, isRHSATempFailureRetryArg) { - if (!Node.getLocStart().isMacroID()) + if (!Node.getBeginLoc().isMacroID()) return false; const SourceManager &SM = Finder->getASTContext().getSourceManager(); - if (!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getLocStart())) + if (!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getBeginLoc())) return false; const LangOptions &Opts = Finder->getASTContext().getLangOpts(); - SourceLocation LocStart = Node.getLocStart(); + SourceLocation LocStart = Node.getBeginLoc(); while (LocStart.isMacroID()) { SourceLocation Invocation = SM.getImmediateMacroCallerLoc(LocStart); Token Tok; diff --git a/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp b/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp index 1775440..259f3df 100644 --- a/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp +++ b/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp @@ -56,7 +56,7 @@ void UseToStringCheck::check(const MatchFinder::MatchResult &Result) { else return; - auto Loc = Call->getLocStart(); + auto Loc = Call->getBeginLoc(); auto Diag = diag(Loc, "use std::to_%0 instead of boost::lexical_cast<std::%0>") << StringType; @@ -65,8 +65,8 @@ void UseToStringCheck::check(const MatchFinder::MatchResult &Result) { return; Diag << FixItHint::CreateReplacement( - CharSourceRange::getCharRange(Call->getLocStart(), - Call->getArg(0)->getLocStart()), + CharSourceRange::getCharRange(Call->getBeginLoc(), + Call->getArg(0)->getBeginLoc()), (llvm::Twine("std::to_") + StringType + "(").str()); } diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp index a8da703..34d1712 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp @@ -242,7 +242,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx, } CharSourceRange BeforeArgument = - makeFileCharRange(ArgBeginLoc, Args[I]->getLocStart()); + makeFileCharRange(ArgBeginLoc, Args[I]->getBeginLoc()); ArgBeginLoc = Args[I]->getLocEnd(); std::vector<std::pair<SourceLocation, StringRef>> Comments; @@ -251,7 +251,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx, } else { // Fall back to parsing back from the start of the argument. CharSourceRange ArgsRange = makeFileCharRange( - Args[I]->getLocStart(), Args[NumArgs - 1]->getLocEnd()); + Args[I]->getBeginLoc(), Args[NumArgs - 1]->getLocEnd()); Comments = getCommentsBeforeLoc(Ctx, ArgsRange.getBegin()); } diff --git a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp index 244e755..c747980 100644 --- a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp @@ -102,7 +102,7 @@ void AssertSideEffectCheck::registerMatchers(MatchFinder *Finder) { void AssertSideEffectCheck::check(const MatchFinder::MatchResult &Result) { const SourceManager &SM = *Result.SourceManager; const LangOptions LangOpts = getLangOpts(); - SourceLocation Loc = Result.Nodes.getNodeAs<Stmt>("condStmt")->getLocStart(); + SourceLocation Loc = Result.Nodes.getNodeAs<Stmt>("condStmt")->getBeginLoc(); StringRef AssertMacroName; while (Loc.isValid() && Loc.isMacroID()) { diff --git a/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp index ed2c2db..5f33697 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp @@ -36,7 +36,7 @@ void BoolPointerImplicitConversionCheck::check( auto *Var = Result.Nodes.getNodeAs<DeclRefExpr>("expr"); // Ignore macros. - if (Var->getLocStart().isMacroID()) + if (Var->getBeginLoc().isMacroID()) return; // Only allow variable accesses for now, no function calls or member exprs. @@ -63,9 +63,9 @@ void BoolPointerImplicitConversionCheck::check( .empty()) return; - diag(Var->getLocStart(), "dubious check of 'bool *' against 'nullptr', did " + diag(Var->getBeginLoc(), "dubious check of 'bool *' against 'nullptr', did " "you mean to dereference it?") - << FixItHint::CreateInsertion(Var->getLocStart(), "*"); + << FixItHint::CreateInsertion(Var->getBeginLoc(), "*"); } } // namespace bugprone diff --git a/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp index 151e56c..170ce452 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp @@ -104,7 +104,7 @@ void CopyConstructorInitCheck::check(const MatchFinder::MatchResult &Result) { SourceLocation FixItLoc; // There is no initialization list in this constructor. if (!HasWrittenInitializer) { - FixItLoc = Ctor->getBody()->getLocStart(); + FixItLoc = Ctor->getBody()->getBeginLoc(); FixItMsg = " : " + FixItMsg; } else { // We apply the missing ctors at the beginning of the initialization list. diff --git a/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp index a22dcad..81b799e 100644 --- a/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp @@ -178,7 +178,7 @@ void DanglingHandleCheck::registerMatchers(MatchFinder *Finder) { void DanglingHandleCheck::check(const MatchFinder::MatchResult &Result) { auto *Handle = Result.Nodes.getNodeAs<CXXRecordDecl>("handle"); - diag(Result.Nodes.getNodeAs<Stmt>("bad_stmt")->getLocStart(), + diag(Result.Nodes.getNodeAs<Stmt>("bad_stmt")->getBeginLoc(), "%0 outlives its value") << Handle->getQualifiedNameAsString(); } diff --git a/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp index cf1be0e..02d23c4 100644 --- a/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp @@ -57,7 +57,7 @@ void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) { Result.Nodes.getNodeAs<CXXMemberCallExpr>("erase"); const auto *EndExpr = Result.Nodes.getNodeAs<CXXMemberCallExpr>("end"); - const SourceLocation Loc = MemberCall->getLocStart(); + const SourceLocation Loc = MemberCall->getBeginLoc(); FixItHint Hint; diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp index ab7b28d..549799f 100644 --- a/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp @@ -61,7 +61,7 @@ void IncorrectRoundingsCheck::registerMatchers(MatchFinder *MatchFinder) { void IncorrectRoundingsCheck::check(const MatchFinder::MatchResult &Result) { const auto *CastExpr = Result.Nodes.getNodeAs<ImplicitCastExpr>("CastExpr"); - diag(CastExpr->getLocStart(), + diag(CastExpr->getBeginLoc(), "casting (double + 0.5) to integer leads to incorrect rounding; " "consider using lround (#include <cmath>) instead"); } diff --git a/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp index 1b4eaea..094d991 100644 --- a/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp @@ -48,7 +48,7 @@ void IntegerDivisionCheck::registerMatchers(MatchFinder *Finder) { void IntegerDivisionCheck::check(const MatchFinder::MatchResult &Result) { const auto *IntDiv = Result.Nodes.getNodeAs<BinaryOperator>("IntDiv"); - diag(IntDiv->getLocStart(), "result of integer division used in a floating " + diag(IntDiv->getBeginLoc(), "result of integer division used in a floating " "point context; possible loss of precision"); } diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp index f8db0b3..25544a5 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp @@ -102,9 +102,10 @@ void MisplacedOperatorInStrlenInAllocCheck::check( StrLen->getSourceRange(), (StrLenBegin + LHSText + StrLenEnd + " + " + RHSText).str()); - diag(Alloc->getLocStart(), + diag(Alloc->getBeginLoc(), "addition operator is applied to the argument of %0 instead of its " - "result") << StrLen->getDirectCallee()->getName() << Hint; + "result") + << StrLen->getDirectCallee()->getName() << Hint; } } // namespace bugprone diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp index e263366..b9cbfeb 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp @@ -185,11 +185,11 @@ void MisplacedWideningCastCheck::check(const MatchFinder::MatchResult &Result) { const auto *Cast = Result.Nodes.getNodeAs<CastExpr>("Cast"); if (!CheckImplicitCasts && isa<ImplicitCastExpr>(Cast)) return; - if (Cast->getLocStart().isMacroID()) + if (Cast->getBeginLoc().isMacroID()) return; const auto *Calc = Result.Nodes.getNodeAs<Expr>("Calc"); - if (Calc->getLocStart().isMacroID()) + if (Calc->getBeginLoc().isMacroID()) return; if (Cast->isTypeDependent() || Cast->isValueDependent() || @@ -223,7 +223,7 @@ void MisplacedWideningCastCheck::check(const MatchFinder::MatchResult &Result) { if (Context.getIntWidth(CalcType) >= getMaxCalculationWidth(Context, Calc)) return; - diag(Cast->getLocStart(), "either cast from %0 to %1 is ineffective, or " + diag(Cast->getBeginLoc(), "either cast from %0 to %1 is ineffective, or " "there is loss of precision before the conversion") << CalcType << CastType; } diff --git a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp index 516ee19..9699250 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp @@ -29,7 +29,7 @@ static void replaceMoveWithForward(const UnresolvedLookupExpr *Callee, CharSourceRange CallRange = Lexer::makeFileCharRange(CharSourceRange::getTokenRange( - Callee->getLocStart(), Callee->getLocEnd()), + Callee->getBeginLoc(), Callee->getLocEnd()), SM, LangOpts); if (CallRange.isValid()) { diff --git a/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp index 942c875..5c49821 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp @@ -19,7 +19,7 @@ namespace bugprone { namespace { -AST_MATCHER(Expr, isInMacro) { return Node.getLocStart().isMacroID(); } +AST_MATCHER(Expr, isInMacro) { return Node.getBeginLoc().isMacroID(); } /// \brief Find the next statement after `S`. const Stmt *nextStmt(const MatchFinder::MatchResult &Result, const Stmt *S) { @@ -73,13 +73,13 @@ void MultipleStatementMacroCheck::check( if (!Next) return; - SourceLocation OuterLoc = Outer->getLocStart(); + SourceLocation OuterLoc = Outer->getBeginLoc(); if (Result.Nodes.getNodeAs<Stmt>("else")) OuterLoc = cast<IfStmt>(Outer)->getElseLoc(); - auto InnerRanges = getExpansionRanges(Inner->getLocStart(), Result); + auto InnerRanges = getExpansionRanges(Inner->getBeginLoc(), Result); auto OuterRanges = getExpansionRanges(OuterLoc, Result); - auto NextRanges = getExpansionRanges(Next->getLocStart(), Result); + auto NextRanges = getExpansionRanges(Next->getBeginLoc(), Result); // Remove all the common ranges, starting from the top (the last ones in the // list). diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp index b4a019e..f7d63b1 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp @@ -40,7 +40,7 @@ void SizeofContainerCheck::check(const MatchFinder::MatchResult &Result) { Result.Nodes.getNodeAs<UnaryExprOrTypeTraitExpr>("sizeof"); auto Diag = - diag(SizeOf->getLocStart(), "sizeof() doesn't return the size of the " + diag(SizeOf->getBeginLoc(), "sizeof() doesn't return the size of the " "container; did you mean .size()?"); } diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp index f05a900..d662657 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -216,29 +216,29 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { const ASTContext &Ctx = *Result.Context; if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-constant")) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(K)'; did you mean 'K'?"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-integer-call")) { - diag(E->getLocStart(), "suspicious usage of 'sizeof()' on an expression " + diag(E->getBeginLoc(), "suspicious usage of 'sizeof()' on an expression " "that results in an integer"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-this")) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(this)'; did you mean 'sizeof(*this)'"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-charp")) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(char*)'; do you mean 'strlen'?"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-pointer-to-aggregate")) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(A*)'; pointer to aggregate"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-compare-constant")) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious comparison of 'sizeof(expr)' to a constant"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-comma-expr")) { - diag(E->getLocStart(), "suspicious usage of 'sizeof(..., ...)'"); + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(..., ...)'"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-divide-expr")) { const auto *NumTy = Result.Nodes.getNodeAs<Type>("num-type"); @@ -252,30 +252,30 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { if (DenominatorSize > CharUnits::Zero() && !NumeratorSize.isMultipleOf(DenominatorSize)) { - diag(E->getLocStart(), "suspicious usage of 'sizeof(...)/sizeof(...)';" + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(...)/sizeof(...)';" " numerator is not a multiple of denominator"); } else if (ElementSize > CharUnits::Zero() && DenominatorSize > CharUnits::Zero() && ElementSize != DenominatorSize) { - diag(E->getLocStart(), "suspicious usage of 'sizeof(...)/sizeof(...)';" + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(...)/sizeof(...)';" " numerator is not a multiple of denominator"); } else if (NumTy && DenomTy && NumTy == DenomTy) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'"); } else if (PointedTy && DenomTy && PointedTy == DenomTy) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'"); } else if (NumTy && DenomTy && NumTy->isPointerType() && DenomTy->isPointerType()) { - diag(E->getLocStart(), + diag(E->getBeginLoc(), "suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'"); } } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-sizeof-expr")) { - diag(E->getLocStart(), "suspicious usage of 'sizeof(sizeof(...))'"); + diag(E->getBeginLoc(), "suspicious usage of 'sizeof(sizeof(...))'"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-multiply-sizeof")) { - diag(E->getLocStart(), "suspicious 'sizeof' by 'sizeof' multiplication"); + diag(E->getBeginLoc(), "suspicious 'sizeof' by 'sizeof' multiplication"); } } diff --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp index 420428f..d888230 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp @@ -106,7 +106,7 @@ void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) { const ASTContext &Ctx = *Result.Context; const auto *E = Result.Nodes.getNodeAs<CXXConstructExpr>("constructor"); assert(E && "missing constructor expression"); - SourceLocation Loc = E->getLocStart(); + SourceLocation Loc = E->getBeginLoc(); if (Result.Nodes.getNodeAs<Expr>("swapped-parameter")) { const Expr *P0 = E->getArg(0); diff --git a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp index f373648..1481cc3 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp @@ -39,7 +39,7 @@ void StringIntegerAssignmentCheck::registerMatchers(MatchFinder *Finder) { void StringIntegerAssignmentCheck::check( const MatchFinder::MatchResult &Result) { const auto *Argument = Result.Nodes.getNodeAs<Expr>("expr"); - SourceLocation Loc = Argument->getLocStart(); + SourceLocation Loc = Argument->getBeginLoc(); auto Diag = diag(Loc, "an integer is interpreted as a character code when assigning " diff --git a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp index eaa610f..b440b61 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp @@ -68,14 +68,14 @@ void StringLiteralWithEmbeddedNulCheck::check( SL->getCodeUnit(Offset + 1) == 'x' && isDigit(SL->getCodeUnit(Offset + 2)) && isDigit(SL->getCodeUnit(Offset + 3))) { - diag(SL->getLocStart(), "suspicious embedded NUL character"); + diag(SL->getBeginLoc(), "suspicious embedded NUL character"); return; } } } if (const auto *SL = Result.Nodes.getNodeAs<StringLiteral>("truncated")) { - diag(SL->getLocStart(), + diag(SL->getBeginLoc(), "truncated string literal with embedded NUL character"); } } diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp index 8e11a43..2e0a46c 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp @@ -61,7 +61,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) { SourceRange CharRange = CharZeroFill->getSourceRange(); auto Diag = - diag(CharZeroFill->getLocStart(), "memset fill value is char '0', " + diag(CharZeroFill->getBeginLoc(), "memset fill value is char '0', " "potentially mistaken for int 0"); // Only suggest a fix if no macros are involved. @@ -82,7 +82,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) { (NumValue >= 0 && NumValue <= UCharMax)) return; - diag(NumFill->getLocStart(), "memset fill value is out of unsigned " + diag(NumFill->getBeginLoc(), "memset fill value is out of unsigned " "character range, gets truncated"); } @@ -110,7 +110,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) { // `byte_count` is known to be zero at compile time, and `fill_char` is // either not known or known to be a positive integer. Emit a warning // and fix-its to swap the arguments. - auto D = diag(Call->getLocStart(), + auto D = diag(Call->getBeginLoc(), "memset of size zero, potentially swapped arguments"); StringRef RHSString = tooling::fixit::getText(*ByteCount, *Result.Context); StringRef LHSString = tooling::fixit::getText(*FillChar, *Result.Context); diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp index 3831dc3..a66cf43 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp @@ -120,7 +120,7 @@ void SuspiciousMissingCommaCheck::check( if (double(Count) / Size > RatioThreshold) return; - diag(ConcatenatedLiteral->getLocStart(), + diag(ConcatenatedLiteral->getBeginLoc(), "suspicious string literal, probably missing a comma"); } diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp index d7f51d0..f4e1496 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp @@ -34,7 +34,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) { return; const auto *Semicolon = Result.Nodes.getNodeAs<NullStmt>("semi"); - SourceLocation LocStart = Semicolon->getLocStart(); + SourceLocation LocStart = Semicolon->getBeginLoc(); if (LocStart.isMacroID()) return; @@ -60,7 +60,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) { if (Lexer.LexFromRawLexer(Token)) return; - unsigned BaseIndent = SM.getSpellingColumnNumber(Statement->getLocStart()); + unsigned BaseIndent = SM.getSpellingColumnNumber(Statement->getBeginLoc()); unsigned NewTokenIndent = SM.getSpellingColumnNumber(Token.getLocation()); unsigned NewTokenLine = SM.getSpellingLineNumber(Token.getLocation()); diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp index 0cc6215..a16da4a 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp @@ -177,7 +177,7 @@ void SuspiciousStringCompareCheck::check( Call->getRParenLoc(), 0, Result.Context->getSourceManager(), getLangOpts()); - diag(Call->getLocStart(), + diag(Call->getBeginLoc(), "function %0 is called without explicitly comparing result") << Decl << FixItHint::CreateInsertion(EndLoc, " != 0"); } @@ -186,29 +186,30 @@ void SuspiciousStringCompareCheck::check( SourceLocation EndLoc = Lexer::getLocForEndOfToken( Call->getRParenLoc(), 0, Result.Context->getSourceManager(), getLangOpts()); - SourceLocation NotLoc = E->getLocStart(); + SourceLocation NotLoc = E->getBeginLoc(); - diag(Call->getLocStart(), + diag(Call->getBeginLoc(), "function %0 is compared using logical not operator") - << Decl << FixItHint::CreateRemoval( - CharSourceRange::getTokenRange(NotLoc, NotLoc)) + << Decl + << FixItHint::CreateRemoval( + CharSourceRange::getTokenRange(NotLoc, NotLoc)) << FixItHint::CreateInsertion(EndLoc, " == 0"); } if (Result.Nodes.getNodeAs<Stmt>("invalid-comparison")) { - diag(Call->getLocStart(), + diag(Call->getBeginLoc(), "function %0 is compared to a suspicious constant") << Decl; } if (const auto *BinOp = Result.Nodes.getNodeAs<BinaryOperator>("suspicious-operator")) { - diag(Call->getLocStart(), "results of function %0 used by operator '%1'") + diag(Call->getBeginLoc(), "results of function %0 used by operator '%1'") << Decl << BinOp->getOpcodeStr(); } if (Result.Nodes.getNodeAs<Stmt>("invalid-conversion")) { - diag(Call->getLocStart(), "function %0 has suspicious implicit cast") + diag(Call->getBeginLoc(), "function %0 has suspicious implicit cast") << Decl; } } diff --git a/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp index 64d3eaf..c1550f6 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp @@ -84,7 +84,7 @@ void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) { continue; // Emit a warning and fix-its that swap the arguments. - diag(Call->getLocStart(), "argument with implicit conversion from %0 " + diag(Call->getBeginLoc(), "argument with implicit conversion from %0 " "to %1 followed by argument converted from " "%2 to %3, potentially swapped arguments.") << LHS->getType() << LHSFrom->getType() << RHS->getType() diff --git a/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp index 3e11e06..e41fc1f 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp @@ -39,7 +39,7 @@ void TerminatingContinueCheck::check(const MatchFinder::MatchResult &Result) { const auto *ContStmt = Result.Nodes.getNodeAs<ContinueStmt>("continue"); auto Diag = - diag(ContStmt->getLocStart(), + diag(ContStmt->getBeginLoc(), "'continue' in loop with false condition is equivalent to 'break'") << tooling::fixit::createReplacement(*ContStmt, "break"); } diff --git a/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp index 350cf3b..695d9c5 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp @@ -42,7 +42,7 @@ void ThrowKeywordMissingCheck::check(const MatchFinder::MatchResult &Result) { const auto *TemporaryExpr = Result.Nodes.getNodeAs<Expr>("temporary-exception-not-thrown"); - diag(TemporaryExpr->getLocStart(), "suspicious exception object created but " + diag(TemporaryExpr->getBeginLoc(), "suspicious exception object created but " "not thrown; did you mean 'throw %0'?") << TemporaryExpr->getType().getBaseTypeIdentifier()->getName(); } diff --git a/clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp index ebfe517..0665e08 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp @@ -52,7 +52,7 @@ void UndefinedMemoryManipulationCheck::check( QualType DestType = Call->getArg(0)->IgnoreImplicit()->getType(); if (!DestType->getPointeeType().isNull()) DestType = DestType->getPointeeType(); - diag(Call->getLocStart(), "undefined behavior, destination object type %0 " + diag(Call->getBeginLoc(), "undefined behavior, destination object type %0 " "is not TriviallyCopyable") << DestType; } @@ -60,7 +60,7 @@ void UndefinedMemoryManipulationCheck::check( QualType SourceType = Call->getArg(1)->IgnoreImplicit()->getType(); if (!SourceType->getPointeeType().isNull()) SourceType = SourceType->getPointeeType(); - diag(Call->getLocStart(), + diag(Call->getBeginLoc(), "undefined behavior, source object type %0 is not TriviallyCopyable") << SourceType; } diff --git a/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp index f47ad7e..90c07b9 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp @@ -75,7 +75,7 @@ void UndelegatedConstructorCheck::registerMatchers(MatchFinder *Finder) { void UndelegatedConstructorCheck::check( const MatchFinder::MatchResult &Result) { const auto *E = Result.Nodes.getNodeAs<CXXConstructExpr>("construct"); - diag(E->getLocStart(), "did you intend to call a delegated constructor? " + diag(E->getBeginLoc(), "did you intend to call a delegated constructor? " "A temporary object is created here instead"); } diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp index e2882f3..e58f166 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp @@ -52,7 +52,7 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) { // We ignore code expanded from macros to reduce the number of false // positives. - if (E->getLocStart().isMacroID()) + if (E->getBeginLoc().isMacroID()) return; // Don't emit a warning for the last statement in the surrounding compund @@ -62,7 +62,7 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) { return; // Emit a warning. - auto D = diag(E->getLocStart(), "object destroyed immediately after " + auto D = diag(E->getBeginLoc(), "object destroyed immediately after " "creation; did you mean to name the object?"); const char *Replacement = " give_me_a_name"; diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp index d0c5885..b8de045 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp @@ -86,10 +86,10 @@ void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) { void UnusedReturnValueCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *Matched = Result.Nodes.getNodeAs<CallExpr>("match")) { - diag(Matched->getLocStart(), + diag(Matched->getBeginLoc(), "the value returned by this function should be used") << Matched->getSourceRange(); - diag(Matched->getLocStart(), + diag(Matched->getBeginLoc(), "cast the expression to void to silence this warning", DiagnosticIDs::Note); } diff --git a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp index bb9c9b6..ede1bf33 100644 --- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp @@ -257,7 +257,7 @@ void VirtualNearMissCheck::check(const MatchFinder::MatchResult &Result) { bool ApplyFix = !BaseMD->isTemplateInstantiation() && !DerivedMD->isTemplateInstantiation(); auto Diag = - diag(DerivedMD->getLocStart(), + diag(DerivedMD->getBeginLoc(), "method '%0' has a similar name and the same signature as " "virtual method '%1'; did you mean to override it?") << DerivedMD->getQualifiedNameAsString() diff --git a/clang-tools-extra/clang-tidy/cert/LimitedRandomnessCheck.cpp b/clang-tools-extra/clang-tidy/cert/LimitedRandomnessCheck.cpp index f319f9f..3f6f948 100644 --- a/clang-tools-extra/clang-tidy/cert/LimitedRandomnessCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/LimitedRandomnessCheck.cpp @@ -30,7 +30,7 @@ void LimitedRandomnessCheck::check(const MatchFinder::MatchResult &Result) { msg = "; use C++11 random library instead"; const auto *MatchedDecl = Result.Nodes.getNodeAs<CallExpr>("randomGenerator"); - diag(MatchedDecl->getLocStart(), "rand() has limited randomness" + msg); + diag(MatchedDecl->getBeginLoc(), "rand() has limited randomness" + msg); } } // namespace cert diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp index 3e800cd..eaed15f 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp @@ -19,7 +19,7 @@ namespace cppcoreguidelines { namespace { AST_MATCHER(GotoStmt, isForwardJumping) { - return Node.getLocStart() < Node.getLabel()->getLocStart(); + return Node.getBeginLoc() < Node.getLabel()->getBeginLoc(); } } // namespace @@ -49,7 +49,7 @@ void AvoidGotoCheck::check(const MatchFinder::MatchResult &Result) { diag(Goto->getGotoLoc(), "avoid using 'goto' for flow control") << Goto->getSourceRange(); - diag(Goto->getLabel()->getLocStart(), "label defined here", + diag(Goto->getLabel()->getBeginLoc(), "label defined here", DiagnosticIDs::Note); } } // namespace cppcoreguidelines diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp index 2c5676e..3a22c1e 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp @@ -52,14 +52,14 @@ void NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) { void NarrowingConversionsCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *Op = Result.Nodes.getNodeAs<BinaryOperator>("op")) { - if (Op->getLocStart().isMacroID()) + if (Op->getBeginLoc().isMacroID()) return; diag(Op->getOperatorLoc(), "narrowing conversion from %0 to %1") << Op->getRHS()->getType() << Op->getLHS()->getType(); return; } const auto *Cast = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast"); - if (Cast->getLocStart().isMacroID()) + if (Cast->getBeginLoc().isMacroID()) return; diag(Cast->getExprLoc(), "narrowing conversion from %0 to %1") << Cast->getSubExpr()->getType() << Cast->getType(); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp index 5a2b882..cc33468 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp @@ -73,8 +73,8 @@ void NoMallocCheck::check(const MatchFinder::MatchResult &Result) { assert(Call && "Unhandled binding in the Matcher"); - diag(Call->getLocStart(), "do not manage memory manually; %0") - << Recommendation << SourceRange(Call->getLocStart(), Call->getLocEnd()); + diag(Call->getBeginLoc(), "do not manage memory manually; %0") + << Recommendation << SourceRange(Call->getBeginLoc(), Call->getLocEnd()); } } // namespace cppcoreguidelines diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp index 6c86e05..ebebfda 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp @@ -203,7 +203,7 @@ bool OwningMemoryCheck::handleDeletion(const BoundNodes &Nodes) { // Deletion of non-owners, with `delete variable;` if (DeleteStmt) { - diag(DeleteStmt->getLocStart(), + diag(DeleteStmt->getBeginLoc(), "deleting a pointer through a type that is " "not marked 'gsl::owner<>'; consider using a " "smart pointer instead") @@ -212,7 +212,7 @@ bool OwningMemoryCheck::handleDeletion(const BoundNodes &Nodes) { // FIXME: The declaration of the variable that was deleted can be // rewritten. const ValueDecl *Decl = DeletedVariable->getDecl(); - diag(Decl->getLocStart(), "variable declared here", DiagnosticIDs::Note) + diag(Decl->getBeginLoc(), "variable declared here", DiagnosticIDs::Note) << Decl->getSourceRange(); return true; @@ -228,7 +228,7 @@ bool OwningMemoryCheck::handleLegacyConsumers(const BoundNodes &Nodes) { // as a pointer, which should not be an owner. The argument that is an owner // is known and the false positive coming from the filename can be avoided. if (LegacyConsumer) { - diag(LegacyConsumer->getLocStart(), + diag(LegacyConsumer->getBeginLoc(), "calling legacy resource function without passing a 'gsl::owner<>'") << LegacyConsumer->getSourceRange(); return true; @@ -242,7 +242,7 @@ bool OwningMemoryCheck::handleExpectedOwner(const BoundNodes &Nodes) { // Expected function argument to be owner. if (ExpectedOwner) { - diag(ExpectedOwner->getLocStart(), + diag(ExpectedOwner->getBeginLoc(), "expected argument of type 'gsl::owner<>'; got %0") << ExpectedOwner->getType() << ExpectedOwner->getSourceRange(); return true; @@ -261,7 +261,7 @@ bool OwningMemoryCheck::handleAssignmentAndInit(const BoundNodes &Nodes) { // Assignments to owners. if (OwnerAssignment) { - diag(OwnerAssignment->getLocStart(), + diag(OwnerAssignment->getBeginLoc(), "expected assignment source to be of type 'gsl::owner<>'; got %0") << OwnerAssignment->getRHS()->getType() << OwnerAssignment->getSourceRange(); @@ -270,7 +270,7 @@ bool OwningMemoryCheck::handleAssignmentAndInit(const BoundNodes &Nodes) { // Initialization of owners. if (OwnerInitialization) { - diag(OwnerInitialization->getLocStart(), + diag(OwnerInitialization->getBeginLoc(), "expected initialization with value of type 'gsl::owner<>'; got %0") << OwnerInitialization->getAnyInitializer()->getType() << OwnerInitialization->getSourceRange(); @@ -306,7 +306,7 @@ bool OwningMemoryCheck::handleAssignmentFromNewOwner(const BoundNodes &Nodes) { // Bad assignments to non-owners, where the RHS is a newly created owner. if (BadOwnerAssignment) { - diag(BadOwnerAssignment->getLocStart(), + diag(BadOwnerAssignment->getBeginLoc(), "assigning newly created 'gsl::owner<>' to non-owner %0") << BadOwnerAssignment->getLHS()->getType() << BadOwnerAssignment->getSourceRange(); @@ -315,7 +315,7 @@ bool OwningMemoryCheck::handleAssignmentFromNewOwner(const BoundNodes &Nodes) { // Bad initialization of non-owners, where the RHS is a newly created owner. if (BadOwnerInitialization) { - diag(BadOwnerInitialization->getLocStart(), + diag(BadOwnerInitialization->getBeginLoc(), "initializing non-owner %0 with a newly created 'gsl::owner<>'") << BadOwnerInitialization->getType() << BadOwnerInitialization->getSourceRange(); @@ -326,7 +326,7 @@ bool OwningMemoryCheck::handleAssignmentFromNewOwner(const BoundNodes &Nodes) { // If the type of the variable was deduced, the wrapping owner typedef is // eliminated, therefore the check emits a special note for that case. if (Nodes.getNodeAs<AutoType>("deduced_type")) { - diag(BadOwnerInitialization->getLocStart(), + diag(BadOwnerInitialization->getBeginLoc(), "type deduction did not result in an owner", DiagnosticIDs::Note); } return true; @@ -337,7 +337,7 @@ bool OwningMemoryCheck::handleAssignmentFromNewOwner(const BoundNodes &Nodes) { if (BadOwnerArgument) { assert(BadOwnerParameter && "parameter for the problematic argument not found"); - diag(BadOwnerArgument->getLocStart(), "initializing non-owner argument of " + diag(BadOwnerArgument->getBeginLoc(), "initializing non-owner argument of " "type %0 with a newly created " "'gsl::owner<>'") << BadOwnerParameter->getType() << BadOwnerArgument->getSourceRange(); @@ -356,7 +356,7 @@ bool OwningMemoryCheck::handleReturnValues(const BoundNodes &Nodes) { if (BadReturnType) { // The returned value is a resource or variable that was not annotated with // owner<> and the function return type is not owner<>. - diag(BadReturnType->getLocStart(), + diag(BadReturnType->getBeginLoc(), "returning a newly created resource of " "type %0 or 'gsl::owner<>' from a " "function whose return type is not 'gsl::owner<>'") @@ -380,7 +380,7 @@ bool OwningMemoryCheck::handleOwnerMembers(const BoundNodes &Nodes) { assert(DeclaredOwnerMember && "match on class with bad destructor but without a declared owner"); - diag(DeclaredOwnerMember->getLocStart(), + diag(DeclaredOwnerMember->getBeginLoc(), "member variable of type 'gsl::owner<>' requires the class %0 to " "implement a destructor to release the owned resource") << BadClass; diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp index 52156ad..8a43a81 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp @@ -46,7 +46,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) { MatchedCast->getCastKind() == CK_IntegralToPointer || MatchedCast->getCastKind() == CK_PointerToIntegral || MatchedCast->getCastKind() == CK_ReinterpretMemberPointer) { - diag(MatchedCast->getLocStart(), + diag(MatchedCast->getBeginLoc(), "do not use C-style cast to convert between unrelated types"); return; } @@ -71,7 +71,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) { *Result.SourceManager, getLangOpts()); auto diag_builder = diag( - MatchedCast->getLocStart(), + MatchedCast->getBeginLoc(), "do not use C-style cast to downcast from a base to a derived class; " "use dynamic_cast instead"); @@ -90,7 +90,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) { diag_builder << FixItHint::CreateReplacement(ParenRange, CastText); } else { diag( - MatchedCast->getLocStart(), + MatchedCast->getBeginLoc(), "do not use C-style cast to downcast from a base to a derived class"); } return; @@ -98,7 +98,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) { if (MatchedCast->getCastKind() == CK_NoOp && needsConstCast(SourceType, MatchedCast->getType())) { - diag(MatchedCast->getLocStart(), + diag(MatchedCast->getBeginLoc(), "do not use C-style cast to cast away constness"); } } diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index 4d9be81..142ac2e 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -120,7 +120,7 @@ struct IntializerInsertion { switch (Placement) { case InitializerPlacement::New: Location = utils::lexer::getPreviousToken( - Context, Constructor.getBody()->getLocStart()) + Context, Constructor.getBody()->getBeginLoc()) .getLocation(); break; case InitializerPlacement::Before: @@ -230,7 +230,7 @@ void fixInitializerList(const ASTContext &Context, DiagnosticBuilder &Diag, const CXXConstructorDecl *Ctor, const SmallPtrSetImpl<const T *> &DeclsToInit) { // Do not propose fixes in macros since we cannot place them correctly. - if (Ctor->getLocStart().isMacroID()) + if (Ctor->getBeginLoc().isMacroID()) return; SmallVector<const NamedDecl *, 16> OrderedDecls; @@ -384,7 +384,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer( return; DiagnosticBuilder Diag = - diag(Ctor ? Ctor->getLocStart() : ClassDecl.getLocation(), + diag(Ctor ? Ctor->getBeginLoc() : ClassDecl.getLocation(), IsUnion ? "union constructor should initialize one of these fields: %0" : "constructor does not initialize these fields: %0") @@ -392,7 +392,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer( // Do not propose fixes for constructors in macros since we cannot place them // correctly. - if (Ctor && Ctor->getLocStart().isMacroID()) + if (Ctor && Ctor->getBeginLoc().isMacroID()) return; // Collect all fields but only suggest a fix for the first member of unions, @@ -462,7 +462,7 @@ void ProTypeMemberInitCheck::checkMissingBaseClassInitializer( return; DiagnosticBuilder Diag = - diag(Ctor ? Ctor->getLocStart() : ClassDecl.getLocation(), + diag(Ctor ? Ctor->getBeginLoc() : ClassDecl.getLocation(), "constructor does not initialize these bases: %0") << toCommaSeparatedString(AllBases, BasesToInit); @@ -473,7 +473,7 @@ void ProTypeMemberInitCheck::checkMissingBaseClassInitializer( void ProTypeMemberInitCheck::checkUninitializedTrivialType( const ASTContext &Context, const VarDecl *Var) { DiagnosticBuilder Diag = - diag(Var->getLocStart(), "uninitialized record type: %0") << Var; + diag(Var->getBeginLoc(), "uninitialized record type: %0") << Var; Diag << FixItHint::CreateInsertion( getLocationForEndOfToken(Context, Var->getSourceRange().getEnd()), diff --git a/clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp index 493ce9a..f6c64ce 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp @@ -27,8 +27,7 @@ void DefaultArgumentsCheck::check(const MatchFinder::MatchResult &Result) { Result.Nodes.getNodeAs<CXXDefaultArgExpr>("stmt")) { diag(S->getUsedLocation(), "calling a function that uses a default argument is disallowed"); - diag(S->getParam()->getLocStart(), - "default parameter was declared here", + diag(S->getParam()->getBeginLoc(), "default parameter was declared here", DiagnosticIDs::Note); } else if (const ParmVarDecl *D = Result.Nodes.getNodeAs<ParmVarDecl>("decl")) { @@ -37,11 +36,11 @@ void DefaultArgumentsCheck::check(const MatchFinder::MatchResult &Result) { if (DefaultArgRange.getEnd() != D->getLocEnd()) { return; } else if (DefaultArgRange.getBegin().isMacroID()) { - diag(D->getLocStart(), + diag(D->getBeginLoc(), "declaring a parameter with a default argument is disallowed"); } else { - SourceLocation StartLocation = D->getName().empty() ? - D->getLocStart() : D->getLocation(); + SourceLocation StartLocation = + D->getName().empty() ? D->getBeginLoc() : D->getLocation(); SourceRange RemovalRange(Lexer::getLocForEndOfToken( StartLocation, 0, @@ -51,10 +50,9 @@ void DefaultArgumentsCheck::check(const MatchFinder::MatchResult &Result) { DefaultArgRange.getEnd() ); - diag(D->getLocStart(), - "declaring a parameter with a default argument is disallowed") - << D - << FixItHint::CreateRemoval(RemovalRange); + diag(D->getBeginLoc(), + "declaring a parameter with a default argument is disallowed") + << D << FixItHint::CreateRemoval(RemovalRange); } } } diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp index 35504c9..a49c952 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp @@ -120,9 +120,8 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) { } if (NumConcrete > 1) { - diag(D->getLocStart(), - "inheriting mulitple classes that aren't " - "pure virtual is discouraged"); + diag(D->getBeginLoc(), "inheriting mulitple classes that aren't " + "pure virtual is discouraged"); } } } diff --git a/clang-tools-extra/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp index 847f7635..8e6c74f 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp @@ -34,8 +34,8 @@ void OverloadedOperatorCheck::registerMatchers(MatchFinder *Finder) { void OverloadedOperatorCheck::check(const MatchFinder::MatchResult &Result) { const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl"); assert(D && "No FunctionDecl captured!"); - - SourceLocation Loc = D->getLocStart(); + + SourceLocation Loc = D->getBeginLoc(); if (Loc.isValid()) diag(Loc, "overloading %0 is disallowed") << D; } diff --git a/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp index 16a534b..e33f90a 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp @@ -51,7 +51,7 @@ void StaticallyConstructedObjectsCheck::registerMatchers(MatchFinder *Finder) { void StaticallyConstructedObjectsCheck::check( const MatchFinder::MatchResult &Result) { if (const auto *D = Result.Nodes.getNodeAs<VarDecl>("decl")) - diag(D->getLocStart(), "static objects are disallowed; if possible, use a " + diag(D->getBeginLoc(), "static objects are disallowed; if possible, use a " "constexpr constructor instead"); } diff --git a/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp index 7af0c9c..4ffa3f7 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp @@ -43,7 +43,7 @@ void TrailingReturnCheck::registerMatchers(MatchFinder *Finder) { void TrailingReturnCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *D = Result.Nodes.getNodeAs<Decl>("decl")) - diag(D->getLocStart(), + diag(D->getBeginLoc(), "a trailing return type is disallowed for this type of declaration"); } diff --git a/clang-tools-extra/clang-tidy/fuchsia/VirtualInheritanceCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/VirtualInheritanceCheck.cpp index f3da2b6..82f4410 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/VirtualInheritanceCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/VirtualInheritanceCheck.cpp @@ -35,7 +35,7 @@ void VirtualInheritanceCheck::registerMatchers(MatchFinder *Finder) { void VirtualInheritanceCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *D = Result.Nodes.getNodeAs<CXXRecordDecl>("decl")) - diag(D->getLocStart(), "direct virtual inheritance is disallowed"); + diag(D->getBeginLoc(), "direct virtual inheritance is disallowed"); } } // namespace fuchsia diff --git a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp index 4c7c164..ffcfe11 100644 --- a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp @@ -82,7 +82,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { const QualType DestType = DestTypeAsWritten.getCanonicalType(); auto ReplaceRange = CharSourceRange::getCharRange( - CastExpr->getLParenLoc(), CastExpr->getSubExprAsWritten()->getLocStart()); + CastExpr->getLParenLoc(), CastExpr->getSubExprAsWritten()->getBeginLoc()); bool FnToFnCast = isFunction(SourceTypeAsWritten) && isFunction(DestTypeAsWritten); @@ -93,7 +93,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { // in this case. Don't emit "redundant cast" warnings for function // pointer/reference types. if (SourceTypeAsWritten == DestTypeAsWritten) { - diag(CastExpr->getLocStart(), "redundant cast to the same type") + diag(CastExpr->getBeginLoc(), "redundant cast to the same type") << FixItHint::CreateRemoval(ReplaceRange); return; } @@ -116,7 +116,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { // Ignore code in .c files #included in other files (which shouldn't be done, // but people still do this for test and other purposes). - if (SM.getFilename(SM.getSpellingLoc(CastExpr->getLocStart())).endswith(".c")) + if (SM.getFilename(SM.getSpellingLoc(CastExpr->getBeginLoc())).endswith(".c")) return; // Leave type spelling exactly as it was (unlike @@ -128,7 +128,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { SM, getLangOpts()); auto Diag = - diag(CastExpr->getLocStart(), "C-style casts are discouraged; use %0"); + diag(CastExpr->getBeginLoc(), "C-style casts are discouraged; use %0"); auto ReplaceWithCast = [&](std::string CastText) { const Expr *SubExpr = CastExpr->getSubExprAsWritten()->IgnoreImpCasts(); diff --git a/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp b/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp index 6c2f0a3..7e82751 100644 --- a/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp @@ -60,12 +60,12 @@ void ExplicitMakePairCheck::check(const MatchFinder::MatchResult &Result) { // make_pair. if (Arg0->getType() != Call->getArg(0)->getType() || Arg1->getType() != Call->getArg(1)->getType()) { - diag(Call->getLocStart(), "for C++11-compatibility, use pair directly") + diag(Call->getBeginLoc(), "for C++11-compatibility, use pair directly") << FixItHint::CreateReplacement( - SourceRange(DeclRef->getLocStart(), DeclRef->getLAngleLoc()), + SourceRange(DeclRef->getBeginLoc(), DeclRef->getLAngleLoc()), "std::pair<"); } else { - diag(Call->getLocStart(), + diag(Call->getBeginLoc(), "for C++11-compatibility, omit template arguments from make_pair") << FixItHint::CreateRemoval( SourceRange(DeclRef->getLAngleLoc(), DeclRef->getRAngleLoc())); diff --git a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp index 45c5b70..9f03f7d 100644 --- a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp @@ -48,15 +48,15 @@ void GlobalNamesInHeadersCheck::registerMatchers( void GlobalNamesInHeadersCheck::check(const MatchFinder::MatchResult &Result) { const auto *D = Result.Nodes.getNodeAs<Decl>("using_decl"); // If it comes from a macro, we'll assume it is fine. - if (D->getLocStart().isMacroID()) + if (D->getBeginLoc().isMacroID()) return; // Ignore if it comes from the "main" file ... if (Result.SourceManager->isInMainFile( - Result.SourceManager->getExpansionLoc(D->getLocStart()))) { + Result.SourceManager->getExpansionLoc(D->getBeginLoc()))) { // unless that file is a header. if (!utils::isSpellingLocInHeaderFile( - D->getLocStart(), *Result.SourceManager, HeaderFileExtensions)) + D->getBeginLoc(), *Result.SourceManager, HeaderFileExtensions)) return; } @@ -70,7 +70,7 @@ void GlobalNamesInHeadersCheck::check(const MatchFinder::MatchResult &Result) { } } - diag(D->getLocStart(), + diag(D->getBeginLoc(), "using declarations in the global namespace in headers are prohibited"); } diff --git a/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp b/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp index 7f0b765..07ee081 100644 --- a/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp @@ -72,7 +72,7 @@ void IntegerTypesCheck::registerMatchers(MatchFinder *Finder) { void IntegerTypesCheck::check(const MatchFinder::MatchResult &Result) { auto TL = *Result.Nodes.getNodeAs<TypeLoc>("tl"); - SourceLocation Loc = TL.getLocStart(); + SourceLocation Loc = TL.getBeginLoc(); if (Loc.isInvalid() || Loc.isMacroID()) return; diff --git a/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp b/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp index 84abb5f..ff67b53 100644 --- a/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp @@ -43,7 +43,7 @@ void OverloadedUnaryAndCheck::registerMatchers( void OverloadedUnaryAndCheck::check(const MatchFinder::MatchResult &Result) { const auto *Decl = Result.Nodes.getNodeAs<FunctionDecl>("overload"); - diag(Decl->getLocStart(), + diag(Decl->getBeginLoc(), "do not overload unary operator&, it is dangerous."); } diff --git a/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp b/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp index 32ff6e0..94e1729 100644 --- a/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp @@ -48,7 +48,7 @@ void UnnamedNamespaceInHeaderCheck::registerMatchers( void UnnamedNamespaceInHeaderCheck::check( const MatchFinder::MatchResult &Result) { const auto *N = Result.Nodes.getNodeAs<NamespaceDecl>("anonymousNamespace"); - SourceLocation Loc = N->getLocStart(); + SourceLocation Loc = N->getBeginLoc(); if (!Loc.isValid()) return; diff --git a/clang-tools-extra/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp b/clang-tools-extra/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp index 60a46f8..7490f02 100644 --- a/clang-tools-extra/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp @@ -30,7 +30,7 @@ void UsingNamespaceDirectiveCheck::registerMatchers( void UsingNamespaceDirectiveCheck::check( const MatchFinder::MatchResult &Result) { const auto *U = Result.Nodes.getNodeAs<UsingDirectiveDecl>("usingNamespace"); - SourceLocation Loc = U->getLocStart(); + SourceLocation Loc = U->getBeginLoc(); if (U->isImplicit() || !Loc.isValid()) return; diff --git a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp index 298759f..3ea56d2 100644 --- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp @@ -35,14 +35,14 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) { void ExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) { const auto *BadThrow = Result.Nodes.getNodeAs<CXXThrowExpr>("bad_throw"); - diag(BadThrow->getSubExpr()->getLocStart(), "throwing an exception whose " + diag(BadThrow->getSubExpr()->getBeginLoc(), "throwing an exception whose " "type %0 is not derived from " "'std::exception'") << BadThrow->getSubExpr()->getType() << BadThrow->getSourceRange(); const auto *TypeDecl = Result.Nodes.getNodeAs<NamedDecl>("decl"); if (TypeDecl != nullptr) - diag(TypeDecl->getLocStart(), "type defined here", DiagnosticIDs::Note); + diag(TypeDecl->getBeginLoc(), "type defined here", DiagnosticIDs::Note); } } // namespace hicpp diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp index 68ae54e..f4cad2e 100644 --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -94,7 +94,7 @@ static std::size_t getNumberOfPossibleValues(QualType T, void MultiwayPathsCoveredCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *ElseIfWithoutElse = Result.Nodes.getNodeAs<IfStmt>("else-if")) { - diag(ElseIfWithoutElse->getLocStart(), + diag(ElseIfWithoutElse->getBeginLoc(), "potentially uncovered codepath; add an ending else statement"); return; } @@ -120,7 +120,7 @@ void MultiwayPathsCoveredCheck::check(const MatchFinder::MatchResult &Result) { // FIXME: Evaluate, if emitting a fix-it to simplify that statement is // reasonable. if (!SwitchHasDefault && SwitchCaseCount == 0) { - diag(Switch->getLocStart(), + diag(Switch->getBeginLoc(), "switch statement without labels has no effect"); return; } @@ -132,7 +132,7 @@ void MultiwayPathsCoveredCheck::handleSwitchWithDefault( assert(CaseCount > 0 && "Switch statement with supposedly one default " "branch did not contain any case labels"); if (CaseCount == 1 || CaseCount == 2) - diag(Switch->getLocStart(), + diag(Switch->getBeginLoc(), CaseCount == 1 ? "degenerated switch with default label only" : "switch could be better written as an if/else statement"); @@ -172,7 +172,7 @@ void MultiwayPathsCoveredCheck::handleSwitchWithoutDefault( // FIXME: Transform the 'switch' into an 'if' for CaseCount == 1. if (CaseCount < MaxPathsPossible) - diag(Switch->getLocStart(), + diag(Switch->getBeginLoc(), CaseCount == 1 ? "switch with only one case; use an if statement" : "potential uncovered code path; add a default label"); } diff --git a/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp index 03900527..5c76b8e 100644 --- a/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp @@ -75,14 +75,14 @@ void SignedBitwiseCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *UnaryOp = N.getNodeAs<UnaryOperator>("unary-signed")) { IsUnary = true; - Location = UnaryOp->getLocStart(); + Location = UnaryOp->getBeginLoc(); } else { if (const auto *BinaryOp = N.getNodeAs<BinaryOperator>("binary-no-sign-interference")) - Location = BinaryOp->getLocStart(); + Location = BinaryOp->getBeginLoc(); else if (const auto *BinaryOp = N.getNodeAs<BinaryOperator>("binary-sign-interference")) - Location = BinaryOp->getLocStart(); + Location = BinaryOp->getBeginLoc(); else llvm_unreachable("unexpected matcher result"); } diff --git a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp index 67c85a6..915a51db 100644 --- a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp @@ -50,7 +50,7 @@ void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) { SourceLocation EndLoc = Lexer::getLocForEndOfToken( VD->getInit()->getLocEnd(), 0, *Result.SourceManager, getLangOpts()); Diag << FixItHint::CreateReplacement(TypeRange, "std::string") - << FixItHint::CreateInsertion(VD->getInit()->getLocStart(), "(") + << FixItHint::CreateInsertion(VD->getInit()->getBeginLoc(), "(") << FixItHint::CreateInsertion(EndLoc, ").str()"); } else { // Just an implicit conversion. Insert the real type. diff --git a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp index 69ef3ef..f4dab397 100644 --- a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp @@ -22,7 +22,7 @@ namespace { AST_MATCHER_P(NamedDecl, usesHeaderFileExtension, utils::HeaderFileExtensionsSet, HeaderFileExtensions) { return utils::isExpansionLocInHeaderFile( - Node.getLocStart(), Finder->getASTContext().getSourceManager(), + Node.getBeginLoc(), Finder->getASTContext().getSourceManager(), HeaderFileExtensions); } diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp index e259b6b..5f055d1 100644 --- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp @@ -884,7 +884,7 @@ void RedundantExpressionCheck::checkBitwiseExpr( if (exprEvaluatesToZero(Opcode, Value)) { diag(Loc, "expression always evaluates to 0"); } else if (exprEvaluatesToBitwiseNegatedZero(Opcode, Value)) { - SourceRange ConstExprRange(ConstExpr->getLocStart(), + SourceRange ConstExprRange(ConstExpr->getBeginLoc(), ConstExpr->getLocEnd()); StringRef ConstExprText = Lexer::getSourceText( CharSourceRange::getTokenRange(ConstExprRange), *Result.SourceManager, @@ -893,7 +893,7 @@ void RedundantExpressionCheck::checkBitwiseExpr( diag(Loc, "expression always evaluates to '%0'") << ConstExprText; } else if (exprEvaluatesToSymbolic(Opcode, Value)) { - SourceRange SymExprRange(Sym->getLocStart(), Sym->getLocEnd()); + SourceRange SymExprRange(Sym->getBeginLoc(), Sym->getLocEnd()); StringRef ExprText = Lexer::getSourceText( CharSourceRange::getTokenRange(SymExprRange), *Result.SourceManager, diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index 77fb58d..1d0d88d 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp @@ -88,7 +88,7 @@ void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) { const auto *AssertExprRoot = Result.Nodes.getNodeAs<BinaryOperator>("assertExprRoot"); const auto *CastExpr = Result.Nodes.getNodeAs<CStyleCastExpr>("castExpr"); - SourceLocation AssertExpansionLoc = CondStmt->getLocStart(); + SourceLocation AssertExpansionLoc = CondStmt->getBeginLoc(); if (!AssertExpansionLoc.isValid() || !AssertExpansionLoc.isMacroID()) return; @@ -129,7 +129,7 @@ void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) { FixItHints.push_back(FixItHint::CreateRemoval( SourceRange(AssertExprRoot->getOperatorLoc()))); FixItHints.push_back(FixItHint::CreateRemoval( - SourceRange(AssertMSG->getLocStart(), AssertMSG->getLocEnd()))); + SourceRange(AssertMSG->getBeginLoc(), AssertMSG->getLocEnd()))); StaticAssertMSG = (Twine(", \"") + AssertMSG->getString() + "\"").str(); } diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp index 90398cc..759c3f0 100644 --- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp @@ -81,7 +81,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations( if (declRef && isCatchVariable(declRef)) { return; } - diag(subExpr->getLocStart(), "throw expression throws a pointer; it should " + diag(subExpr->getBeginLoc(), "throw expression throws a pointer; it should " "throw a non-pointer value instead"); } // If the throw statement does not throw by pointer then it throws by value @@ -124,7 +124,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations( } } if (emit) - diag(subExpr->getLocStart(), + diag(subExpr->getBeginLoc(), "throw expression should throw anonymous temporary values instead"); } } @@ -144,7 +144,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations( // We do not diagnose when catching pointer to strings since we also allow // throwing string literals. if (!PT->getPointeeType()->isAnyCharacterType()) - diag(varDecl->getLocStart(), diagMsgCatchReference); + diag(varDecl->getBeginLoc(), diagMsgCatchReference); } else if (!caughtType->isReferenceType()) { const char *diagMsgCatchReference = "catch handler catches by value; " "should catch by reference instead"; @@ -152,7 +152,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations( // value". In this case we should emit a diagnosis message unless the type // is trivial. if (!caughtType.isTrivialType(context)) - diag(varDecl->getLocStart(), diagMsgCatchReference); + diag(varDecl->getBeginLoc(), diagMsgCatchReference); } } diff --git a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp index 0fd7e77..84dd410 100644 --- a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp @@ -72,7 +72,7 @@ void UnconventionalAssignOperatorCheck::registerMatchers( void UnconventionalAssignOperatorCheck::check( const MatchFinder::MatchResult &Result) { if (const auto *RetStmt = Result.Nodes.getNodeAs<ReturnStmt>("returnStmt")) { - diag(RetStmt->getLocStart(), "operator=() should always return '*this'"); + diag(RetStmt->getBeginLoc(), "operator=() should always return '*this'"); } else { static const char *const Messages[][2] = { {"ReturnType", "operator=() should return '%0&'"}, @@ -82,7 +82,7 @@ void UnconventionalAssignOperatorCheck::check( const auto *Method = Result.Nodes.getNodeAs<CXXMethodDecl>("method"); for (const auto &Message : Messages) { if (Result.Nodes.getNodeAs<Decl>(Message[0])) - diag(Method->getLocStart(), Message[1]) + diag(Method->getBeginLoc(), Message[1]) << Method->getParent()->getName() << (Method->isConst() ? "const" : "virtual"); } diff --git a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp index 07165d6..3ef5b20 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp @@ -34,7 +34,7 @@ void UnusedAliasDeclsCheck::registerMatchers(MatchFinder *Finder) { void UnusedAliasDeclsCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *AliasDecl = Result.Nodes.getNodeAs<NamedDecl>("alias")) { FoundDecls[AliasDecl] = CharSourceRange::getCharRange( - AliasDecl->getLocStart(), + AliasDecl->getBeginLoc(), Lexer::findLocationAfterToken( AliasDecl->getLocEnd(), tok::semi, *Result.SourceManager, getLangOpts(), diff --git a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp index 1e342d1..a5dae81 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp @@ -41,8 +41,8 @@ static CharSourceRange removeNode(const MatchFinder::MatchResult &Result, const T *PrevNode, const T *Node, const T *NextNode) { if (NextNode) - return CharSourceRange::getCharRange(Node->getLocStart(), - NextNode->getLocStart()); + return CharSourceRange::getCharRange(Node->getBeginLoc(), + NextNode->getBeginLoc()); if (PrevNode) return CharSourceRange::getTokenRange( diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp index b3eabdc..da27047 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp @@ -68,7 +68,7 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) { UsingDeclContext Context(Using); Context.UsingDeclRange = CharSourceRange::getCharRange( - Using->getLocStart(), + Using->getBeginLoc(), Lexer::findLocationAfterToken( Using->getLocEnd(), tok::semi, *Result.SourceManager, getLangOpts(), /*SkipTrailingWhitespaceAndNewLine=*/true)); diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp index 7cdbb66..e0bdd86 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp @@ -59,7 +59,7 @@ buildBindArguments(const MatchFinder::MatchResult &Result, const CallExpr *C) { } B.Tokens = Lexer::getSourceText( - CharSourceRange::getTokenRange(E->getLocStart(), E->getLocEnd()), + CharSourceRange::getTokenRange(E->getBeginLoc(), E->getLocEnd()), *Result.SourceManager, Result.Context->getLangOpts()); SmallVector<StringRef, 2> Matches; @@ -131,7 +131,7 @@ void AvoidBindCheck::registerMatchers(MatchFinder *Finder) { void AvoidBindCheck::check(const MatchFinder::MatchResult &Result) { const auto *MatchedDecl = Result.Nodes.getNodeAs<CallExpr>("bind"); - auto Diag = diag(MatchedDecl->getLocStart(), "prefer a lambda to std::bind"); + auto Diag = diag(MatchedDecl->getBeginLoc(), "prefer a lambda to std::bind"); const auto Args = buildBindArguments(Result, MatchedDecl); diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp index 8deaa83..6f3cb1f 100644 --- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp @@ -199,7 +199,7 @@ void MakeSmartPtrCheck::checkReset(SourceManager &SM, const auto *Expr = cast<MemberExpr>(Reset->getCallee()); SourceLocation OperatorLoc = Expr->getOperatorLoc(); SourceLocation ResetCallStart = Reset->getExprLoc(); - SourceLocation ExprStart = Expr->getLocStart(); + SourceLocation ExprStart = Expr->getBeginLoc(); SourceLocation ExprEnd = Lexer::getLocForEndOfToken(Expr->getLocEnd(), 0, SM, getLangOpts()); @@ -353,7 +353,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag, // Has to be replaced with: // smart_ptr<Pair>(Pair{first, second}); InitRange = SourceRange( - New->getAllocatedTypeSourceInfo()->getTypeLoc().getLocStart(), + New->getAllocatedTypeSourceInfo()->getTypeLoc().getBeginLoc(), New->getInitializer()->getSourceRange().getEnd()); } Diag << FixItHint::CreateRemoval( diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp index 1ab73d5..c4f10a3 100644 --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -194,7 +194,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) { *Result.Context)) return; - auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use std::move"); + auto Diag = diag(ParamDecl->getBeginLoc(), "pass by value and use std::move"); // Iterate over all declarations of the constructor. for (const ParmVarDecl *ParmDecl : collectParamDecls(Ctor, ParamDecl)) { @@ -206,7 +206,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) { continue; TypeLoc ValueTL = RefTL.getPointeeLoc(); - auto TypeRange = CharSourceRange::getTokenRange(ParmDecl->getLocStart(), + auto TypeRange = CharSourceRange::getTokenRange(ParmDecl->getBeginLoc(), ParamTL.getLocEnd()); std::string ValueStr = Lexer::getSourceText(CharSourceRange::getTokenRange( ValueTL.getSourceRange()), diff --git a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp index 868c5c7..a4aef41 100644 --- a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -129,14 +129,14 @@ void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) { void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) { const auto *Literal = Result.Nodes.getNodeAs<StringLiteral>("lit"); - if (Literal->getLocStart().isMacroID()) + if (Literal->getBeginLoc().isMacroID()) return; if (containsEscapedCharacters(Result, Literal, DisallowedChars)) { std::string Replacement = asRawStringLiteral(Literal, DelimiterStem); if (ReplaceShorterLiterals || Replacement.length() <= - Lexer::MeasureTokenLength(Literal->getLocStart(), + Lexer::MeasureTokenLength(Literal->getBeginLoc(), *Result.SourceManager, getLangOpts())) replaceWithRawStringLiteral(Result, Literal, Replacement); } @@ -148,7 +148,7 @@ void RawStringLiteralCheck::replaceWithRawStringLiteral( CharSourceRange CharRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(Literal->getSourceRange()), *Result.SourceManager, getLangOpts()); - diag(Literal->getLocStart(), + diag(Literal->getBeginLoc(), "escaped string literal can be written as a raw string literal") << FixItHint::CreateReplacement(CharRange, Replacement); } diff --git a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp index 6701fa4..a68033e 100644 --- a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp @@ -103,9 +103,9 @@ void RedundantVoidArgCheck::processFunctionDecl( const MatchFinder::MatchResult &Result, const FunctionDecl *Function) { if (Function->isThisDeclarationADefinition()) { const Stmt *Body = Function->getBody(); - SourceLocation Start = Function->getLocStart(); + SourceLocation Start = Function->getBeginLoc(); SourceLocation End = - Body ? Body->getLocStart().getLocWithOffset(-1) : Function->getLocEnd(); + Body ? Body->getBeginLoc().getLocWithOffset(-1) : Function->getLocEnd(); removeVoidArgumentTokens(Result, SourceRange(Start, End), "function definition"); } else { @@ -198,10 +198,10 @@ void RedundantVoidArgCheck::processFieldDecl( void RedundantVoidArgCheck::processVarDecl( const MatchFinder::MatchResult &Result, const VarDecl *Var) { if (protoTypeHasNoParms(Var->getType())) { - SourceLocation Begin = Var->getLocStart(); + SourceLocation Begin = Var->getBeginLoc(); if (Var->hasInit()) { SourceLocation InitStart = - Result.SourceManager->getExpansionLoc(Var->getInit()->getLocStart()) + Result.SourceManager->getExpansionLoc(Var->getInit()->getBeginLoc()) .getLocWithOffset(-1); removeVoidArgumentTokens(Result, SourceRange(Begin, InitStart), "variable declaration with initializer"); @@ -237,7 +237,7 @@ void RedundantVoidArgCheck::processLambdaExpr( Lambda->hasExplicitParameters()) { SourceLocation Begin = Lambda->getIntroducerRange().getEnd().getLocWithOffset(1); - SourceLocation End = Lambda->getBody()->getLocStart().getLocWithOffset(-1); + SourceLocation End = Lambda->getBody()->getBeginLoc().getLocWithOffset(-1); removeVoidArgumentTokens(Result, SourceRange(Begin, End), "lambda expression"); } diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp index cd9aa11..9a71569 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp @@ -62,13 +62,13 @@ void ReplaceRandomShuffleCheck::check(const MatchFinder::MatchResult &Result) { const auto *MatchedArgumentThree = Result.Nodes.getNodeAs<Expr>("randomFunc"); const auto *MatchedCallExpr = Result.Nodes.getNodeAs<CallExpr>("match"); - if (MatchedCallExpr->getLocStart().isMacroID()) + if (MatchedCallExpr->getBeginLoc().isMacroID()) return; auto Diag = [&] { if (MatchedCallExpr->getNumArgs() == 3) { auto DiagL = - diag(MatchedCallExpr->getLocStart(), + diag(MatchedCallExpr->getBeginLoc(), "'std::random_shuffle' has been removed in C++17; use " "'std::shuffle' and an alternative random mechanism instead"); DiagL << FixItHint::CreateReplacement( @@ -76,7 +76,7 @@ void ReplaceRandomShuffleCheck::check(const MatchFinder::MatchResult &Result) { "std::mt19937(std::random_device()())"); return DiagL; } else { - auto DiagL = diag(MatchedCallExpr->getLocStart(), + auto DiagL = diag(MatchedCallExpr->getBeginLoc(), "'std::random_shuffle' has been removed in C++17; use " "'std::shuffle' instead"); DiagL << FixItHint::CreateInsertion( @@ -94,12 +94,12 @@ void ReplaceRandomShuffleCheck::check(const MatchFinder::MatchResult &Result) { NewName = "std::" + NewName; Diag << FixItHint::CreateRemoval(MatchedDecl->getSourceRange()); - Diag << FixItHint::CreateInsertion(MatchedDecl->getLocStart(), NewName); + Diag << FixItHint::CreateInsertion(MatchedDecl->getBeginLoc(), NewName); if (Optional<FixItHint> IncludeFixit = IncludeInserter->CreateIncludeInsertion( Result.Context->getSourceManager().getFileID( - MatchedCallExpr->getLocStart()), + MatchedCallExpr->getBeginLoc()), "random", /*IsAngled=*/true)) Diag << IncludeFixit.getValue(); } diff --git a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp index f197399..bc0749b 100644 --- a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp @@ -59,7 +59,7 @@ void ShrinkToFitCheck::check(const MatchFinder::MatchResult &Result) { const auto *Container = Result.Nodes.getNodeAs<Expr>("ContainerToShrink"); FixItHint Hint; - if (!MemberCall->getLocStart().isMacroID()) { + if (!MemberCall->getBeginLoc().isMacroID()) { const LangOptions &Opts = getLangOpts(); std::string ReplacementText; if (const auto *UnaryOp = llvm::dyn_cast<UnaryOperator>(Container)) { @@ -79,7 +79,7 @@ void ShrinkToFitCheck::check(const MatchFinder::MatchResult &Result) { ReplacementText); } - diag(MemberCall->getLocStart(), "the shrink_to_fit method should be used " + diag(MemberCall->getBeginLoc(), "the shrink_to_fit method should be used " "to reduce the capacity of a shrinkable " "container") << Hint; diff --git a/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp index 67c0063..5ddbb93 100644 --- a/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp @@ -32,7 +32,7 @@ void UnaryStaticAssertCheck::check(const MatchFinder::MatchResult &Result) { SourceLocation Loc = MatchedDecl->getLocation(); if (!AssertMessage || AssertMessage->getLength() || - AssertMessage->getLocStart().isMacroID() || Loc.isMacroID()) + AssertMessage->getBeginLoc().isMacroID() || Loc.isMacroID()) return; diag(Loc, diff --git a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp index ece8cd5..13afbb4 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp @@ -57,7 +57,7 @@ void UseBoolLiteralsCheck::check(const MatchFinder::MatchResult &Result) { const Expr *Expression = Cast ? Cast : Literal; - bool InMacro = Expression->getLocStart().isMacroID(); + bool InMacro = Expression->getBeginLoc().isMacroID(); if (InMacro && IgnoreMacros) return; diff --git a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp index c14c685..374fcb3 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp @@ -202,7 +202,7 @@ void UseDefaultMemberInitCheck::checkDefaultInit( const MatchFinder::MatchResult &Result, const CXXCtorInitializer *Init) { const FieldDecl *Field = Init->getAnyMember(); - SourceLocation StartLoc = Field->getLocStart(); + SourceLocation StartLoc = Field->getBeginLoc(); if (StartLoc.isMacroID() && IgnoreMacros) return; diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp index 88f4485..d67bb79 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -298,7 +298,7 @@ void UseEqualsDefaultCheck::check(const MatchFinder::MatchResult &Result) { // expansion locations are reported. SourceLocation Location = SpecialFunctionDecl->getLocation(); if (Location.isMacroID()) - Location = Body->getLocStart(); + Location = Body->getBeginLoc(); auto Diag = diag(Location, "use '= default' to define a trivial " + SpecialFunctionName); diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp index 476c549..5f5ee71 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp @@ -125,7 +125,7 @@ public: } bool VisitStmt(Stmt *S) { - if (SM.getFileLoc(S->getLocStart()) != CastLoc) + if (SM.getFileLoc(S->getBeginLoc()) != CastLoc) return true; Visited = true; @@ -214,7 +214,7 @@ public: return true; } - SourceLocation StartLoc = FirstSubExpr->getLocStart(); + SourceLocation StartLoc = FirstSubExpr->getBeginLoc(); SourceLocation EndLoc = FirstSubExpr->getLocEnd(); // If the location comes from a macro arg expansion, *all* uses of that @@ -269,7 +269,7 @@ private: /// \brief Tests that all expansions of a macro arg, one of which expands to /// result in \p CE, yield NullTo(Member)Pointer casts. bool allArgUsesValid(const CastExpr *CE) { - SourceLocation CastLoc = CE->getLocStart(); + SourceLocation CastLoc = CE->getBeginLoc(); // Step 1: Get location of macro arg and location of the macro the arg was // provided to. @@ -437,9 +437,9 @@ private: SourceLocation Loc; if (const auto *D = Parent.get<Decl>()) - Loc = D->getLocStart(); + Loc = D->getBeginLoc(); else if (const auto *S = Parent.get<Stmt>()) - Loc = S->getLocStart(); + Loc = S->getBeginLoc(); // TypeLoc and NestedNameSpecifierLoc are members of the parent map. Skip // them and keep going up. diff --git a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp index 7f59200..0389a5e 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp @@ -85,8 +85,8 @@ void UseTransparentFunctorsCheck::check( Result.Nodes.getNodeAs<ClassTemplateSpecializationDecl>("FunctorClass"); if (const auto *FuncInst = Result.Nodes.getNodeAs<CXXConstructExpr>("FuncInst")) { - diag(FuncInst->getLocStart(), Message) - << (FuncClass->getName() + "<>").str(); + diag(FuncInst->getBeginLoc(), Message) + << (FuncClass->getName() + "<>").str(); return; } diff --git a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp index 9ac6e1d..8a659b7 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp @@ -57,14 +57,14 @@ void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) { bool WarnOnly = false; if (C) { - BeginLoc = C->getLocStart(); + BeginLoc = C->getBeginLoc(); EndLoc = C->getLocEnd(); } else if (const auto *E = Result.Nodes.getNodeAs<CallExpr>("call_expr")) { - BeginLoc = E->getLocStart(); + BeginLoc = E->getBeginLoc(); EndLoc = E->getLocEnd(); } else if (const auto *D = Result.Nodes.getNodeAs<DeclRefExpr>("decl_ref_expr")) { - BeginLoc = D->getLocStart(); + BeginLoc = D->getBeginLoc(); EndLoc = D->getLocEnd(); WarnOnly = true; } else { diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp index cc6d77d..5244aa6 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp @@ -83,7 +83,7 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) { auto &Context = *Result.Context; auto &SM = *Result.SourceManager; - SourceLocation StartLoc = MatchedDecl->getLocStart(); + SourceLocation StartLoc = MatchedDecl->getBeginLoc(); if (StartLoc.isMacroID() && IgnoreMacros) return; diff --git a/clang-tools-extra/clang-tidy/objc/AvoidNSErrorInitCheck.cpp b/clang-tools-extra/clang-tidy/objc/AvoidNSErrorInitCheck.cpp index 86c4656..a4dc48e 100644 --- a/clang-tools-extra/clang-tidy/objc/AvoidNSErrorInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/objc/AvoidNSErrorInitCheck.cpp @@ -31,7 +31,7 @@ void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) { void AvoidNSErrorInitCheck::check(const MatchFinder::MatchResult &Result) { const auto *MatchedExpr = Result.Nodes.getNodeAs<ObjCMessageExpr>("nserrorInit"); - diag(MatchedExpr->getLocStart(), + diag(MatchedExpr->getBeginLoc(), "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to " "create a new NSError"); } diff --git a/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp b/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp index 21ec364..319d945 100644 --- a/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp +++ b/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp @@ -27,7 +27,7 @@ void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) { void AvoidSpinlockCheck::check(const MatchFinder::MatchResult &Result) { const auto *MatchedExpr = Result.Nodes.getNodeAs<CallExpr>("spinlock"); - diag(MatchedExpr->getLocStart(), + diag(MatchedExpr->getBeginLoc(), "use os_unfair_lock_lock() or dispatch queue APIs instead of the " "deprecated OSSpinLock"); } diff --git a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp index eddc52b..71e5e40 100644 --- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp @@ -90,13 +90,14 @@ void FasterStringFindCheck::check(const MatchFinder::MatchResult &Result) { if (!Replacement) return; - diag(Literal->getLocStart(), "%0 called with a string literal consisting of " + diag(Literal->getBeginLoc(), "%0 called with a string literal consisting of " "a single character; consider using the more " "effective overload accepting a character") - << FindFunc << FixItHint::CreateReplacement( - CharSourceRange::getTokenRange(Literal->getLocStart(), - Literal->getLocEnd()), - *Replacement); + << FindFunc + << FixItHint::CreateReplacement( + CharSourceRange::getTokenRange(Literal->getBeginLoc(), + Literal->getLocEnd()), + *Replacement); } } // namespace performance diff --git a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp index 2358aac..c8c9063 100644 --- a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp @@ -41,7 +41,7 @@ void ForRangeCopyCheck::registerMatchers(MatchFinder *Finder) { void ForRangeCopyCheck::check(const MatchFinder::MatchResult &Result) { const auto *Var = Result.Nodes.getNodeAs<VarDecl>("loopVar"); // Ignore code in macros since we can't place the fixes correctly. - if (Var->getLocStart().isMacroID()) + if (Var->getBeginLoc().isMacroID()) return; if (handleConstValueCopy(*Var, *Result.Context)) return; diff --git a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp index 1a5605f..6e73119 100644 --- a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp @@ -96,7 +96,7 @@ void ImplicitConversionInLoopCheck::ReportAndFix( "change the type to the matching one (%1 but 'const auto&' is always a " "valid option) or remove the reference to make it explicit that you are " "creating a new value"; - diag(VD->getLocStart(), Message) << VD << ConstRefType; + diag(VD->getBeginLoc(), Message) << VD << ConstRefType; } } // namespace performance diff --git a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp index 4471d07..8cee281 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp @@ -99,7 +99,7 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) { .getUnqualifiedType() .getCanonicalType(); if (AlgCmp != ContainerCmp) { - diag(Arg->getLocStart(), + diag(Arg->getBeginLoc(), "different comparers used in the algorithm and the container"); return; } @@ -153,7 +153,7 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) { Hint = FixItHint::CreateReplacement(CallRange, ReplacementText); } - diag(AlgCall->getLocStart(), + diag(AlgCall->getBeginLoc(), "this STL algorithm call should be replaced with a container method") << Hint; } diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp index 33c68f0..5b08376 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp @@ -168,7 +168,7 @@ void InefficientVectorOperationCheck::check( // FIXME: make it more intelligent to identify the pre-allocating operations // before the for loop. if (SM.isBeforeInTranslationUnit(Ref->getLocation(), - LoopStmt->getLocStart())) { + LoopStmt->getBeginLoc())) { return; } } @@ -200,13 +200,13 @@ void InefficientVectorOperationCheck::check( } auto Diag = - diag(VectorAppendCall->getLocStart(), + diag(VectorAppendCall->getBeginLoc(), "%0 is called inside a loop; " "consider pre-allocating the vector capacity before the loop") << VectorAppendCall->getMethodDecl()->getDeclName(); if (!ReserveStmt.empty()) - Diag << FixItHint::CreateInsertion(LoopStmt->getLocStart(), ReserveStmt); + Diag << FixItHint::CreateInsertion(LoopStmt->getBeginLoc(), ReserveStmt); } } // namespace performance diff --git a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp index 8d49480..c9c7be1 100644 --- a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp @@ -23,7 +23,7 @@ static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag, const Expr *Arg = Call->getArg(0); CharSourceRange BeforeArgumentsRange = Lexer::makeFileCharRange( - CharSourceRange::getCharRange(Call->getLocStart(), Arg->getLocStart()), + CharSourceRange::getCharRange(Call->getBeginLoc(), Arg->getBeginLoc()), SM, LangOpts); CharSourceRange AfterArgumentsRange = Lexer::makeFileCharRange( CharSourceRange::getCharRange(Call->getLocEnd(), diff --git a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp index 441bad3..8ff31a0 100644 --- a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp @@ -195,7 +195,7 @@ void TypePromotionInMathFnCheck::check(const MatchFinder::MatchResult &Result) { // declared in <math.h>. if (FnInCmath) if (auto IncludeFixit = IncludeInserter->CreateIncludeInsertion( - Result.Context->getSourceManager().getFileID(Call->getLocStart()), + Result.Context->getSourceManager().getFileID(Call->getBeginLoc()), "cmath", /*IsAngled=*/true)) Diag << *IncludeFixit; } diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp index 588a298..8c9259c 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -156,7 +156,7 @@ void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult &Result) { // compilation unit as the signature change could introduce build errors. // 4. the function is an explicit template specialization. const auto *Method = llvm::dyn_cast<CXXMethodDecl>(Function); - if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()) || + if (Param->getBeginLoc().isMacroID() || (Method && Method->isVirtual()) || isReferencedOutsideOfCallExpr(*Function, *Result.Context) || isExplicitTemplateSpecialization(*Function)) return; @@ -189,20 +189,20 @@ void UnnecessaryValueParamCheck::storeOptions( void UnnecessaryValueParamCheck::handleMoveFix(const ParmVarDecl &Var, const DeclRefExpr &CopyArgument, const ASTContext &Context) { - auto Diag = diag(CopyArgument.getLocStart(), + auto Diag = diag(CopyArgument.getBeginLoc(), "parameter %0 is passed by value and only copied once; " "consider moving it to avoid unnecessary copies") << &Var; // Do not propose fixes in macros since we cannot place them correctly. - if (CopyArgument.getLocStart().isMacroID()) + if (CopyArgument.getBeginLoc().isMacroID()) return; const auto &SM = Context.getSourceManager(); auto EndLoc = Lexer::getLocForEndOfToken(CopyArgument.getLocation(), 0, SM, Context.getLangOpts()); - Diag << FixItHint::CreateInsertion(CopyArgument.getLocStart(), "std::move(") + Diag << FixItHint::CreateInsertion(CopyArgument.getBeginLoc(), "std::move(") << FixItHint::CreateInsertion(EndLoc, ")"); if (auto IncludeFixit = Inserter->CreateIncludeInsertion( - SM.getFileID(CopyArgument.getLocStart()), "utility", + SM.getFileID(CopyArgument.getBeginLoc()), "utility", /*IsAngled=*/true)) Diag << *IncludeFixit; } diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp index 70329e83..8b22188 100644 --- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp +++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp @@ -22,7 +22,7 @@ namespace { SourceRange getTypeRange(const ParmVarDecl &Param) { if (Param.getIdentifier() != nullptr) - return SourceRange(Param.getLocStart(), + return SourceRange(Param.getBeginLoc(), Param.getLocEnd().getLocWithOffset(-1)); return Param.getSourceRange(); } @@ -82,7 +82,7 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) { if (!Param->getType().isLocalConstQualified()) return; - auto Diag = diag(Param->getLocStart(), + auto Diag = diag(Param->getBeginLoc(), "parameter %0 is const-qualified in the function " "declaration; const-qualification of parameters only has an " "effect in function definitions"); @@ -97,7 +97,7 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) { Diag << Param; } - if (Param->getLocStart().isMacroID() != Param->getLocEnd().isMacroID()) { + if (Param->getBeginLoc().isMacroID() != Param->getLocEnd().isMacroID()) { // Do not offer a suggestion if the part of the variable declaration comes // from a macro. return; diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp index 1bff668..a29e68a 100644 --- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp @@ -174,7 +174,7 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S, const SourceManager &SM, const ASTContext *Context) { // Skip macros. - if (S->getLocStart().isMacroID()) + if (S->getBeginLoc().isMacroID()) return SourceLocation(); SourceLocation CondEndLoc = S->getCond()->getLocEnd(); @@ -232,7 +232,7 @@ bool BracesAroundStatementsCheck::checkStmt( // level as the start of the statement. We also need file locations for // Lexer::getLocForEndOfToken working properly. InitialLoc = Lexer::makeFileCharRange( - CharSourceRange::getCharRange(InitialLoc, S->getLocStart()), + CharSourceRange::getCharRange(InitialLoc, S->getBeginLoc()), SM, Context->getLangOpts()) .getBegin(); if (InitialLoc.isInvalid()) diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp index 5604354..60a153a 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp @@ -201,12 +201,12 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) { } if (MemberCall) { - diag(MemberCall->getLocStart(), + diag(MemberCall->getBeginLoc(), "the 'empty' method should be used to check " "for emptiness instead of 'size'") << Hint; } else { - diag(BinCmp->getLocStart(), + diag(BinCmp->getBeginLoc(), "the 'empty' method should be used to check " "for emptiness instead of comparing to an empty object") << Hint; diff --git a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp index 766dfda..4d3188c 100644 --- a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp @@ -55,14 +55,14 @@ void DeleteNullPointerCheck::check(const MatchFinder::MatchResult &Result) { const auto *Compound = Result.Nodes.getNodeAs<CompoundStmt>("compound"); auto Diag = diag( - IfWithDelete->getLocStart(), + IfWithDelete->getBeginLoc(), "'if' statement is unnecessary; deleting null pointer has no effect"); if (IfWithDelete->getElse()) return; // FIXME: generate fixit for this case. Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange( - IfWithDelete->getLocStart(), + IfWithDelete->getBeginLoc(), Lexer::getLocForEndOfToken(IfWithDelete->getCond()->getLocEnd(), 0, *Result.SourceManager, Result.Context->getLangOpts()))); diff --git a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp b/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp index a197e8d..e99ca83 100644 --- a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp @@ -41,7 +41,7 @@ void DeletedDefaultCheck::check(const MatchFinder::MatchResult &Result) { "either be removed or explicitly deleted"; if (const auto *Constructor = Result.Nodes.getNodeAs<CXXConstructorDecl>("constructor")) { - auto Diag = diag(Constructor->getLocStart(), Message); + auto Diag = diag(Constructor->getBeginLoc(), Message); if (Constructor->isDefaultConstructor()) { Diag << "default constructor" << "a non-static data member or a base class is lacking a default " @@ -56,7 +56,7 @@ void DeletedDefaultCheck::check(const MatchFinder::MatchResult &Result) { } } else if (const auto *Assignment = Result.Nodes.getNodeAs<CXXMethodDecl>("method-decl")) { - diag(Assignment->getLocStart(), Message) + diag(Assignment->getBeginLoc(), Message) << (Assignment->isCopyAssignmentOperator() ? "copy assignment operator" : "move assignment operator") << "a base class or a non-static data member is not assignable, e.g. " diff --git a/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp b/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp index 8ed6b90..b1ceea1 100644 --- a/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp @@ -73,7 +73,7 @@ public: // is already nested NestingThreshold levels deep, record the start location // of this new compound statement. if (CurrentNestingLevel == Info.NestingThreshold) - Info.NestingThresholders.push_back(Node->getLocStart()); + Info.NestingThresholders.push_back(Node->getBeginLoc()); ++CurrentNestingLevel; Base::TraverseCompoundStmt(Node); @@ -162,9 +162,9 @@ void FunctionSizeCheck::check(const MatchFinder::MatchResult &Result) { // Count the lines including whitespace and comments. Really simple. if (const Stmt *Body = Func->getBody()) { SourceManager *SM = Result.SourceManager; - if (SM->isWrittenInSameFile(Body->getLocStart(), Body->getLocEnd())) { + if (SM->isWrittenInSameFile(Body->getBeginLoc(), Body->getLocEnd())) { FI.Lines = SM->getSpellingLineNumber(Body->getLocEnd()) - - SM->getSpellingLineNumber(Body->getLocStart()); + SM->getSpellingLineNumber(Body->getBeginLoc()); } } diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 46919d3..90c34b3 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -841,7 +841,7 @@ void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) { if (StringRef(Fixup).equals(Name)) { if (!IgnoreFailedSplit) { LLVM_DEBUG(llvm::dbgs() - << Decl->getLocStart().printToString(*Result.SourceManager) + << Decl->getBeginLoc().printToString(*Result.SourceManager) << llvm::format(": unable to split words for %s '%s'\n", KindName.c_str(), Name.str().c_str())); } diff --git a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp index 79022d4..2a449ff 100644 --- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp @@ -24,14 +24,14 @@ namespace { AST_MATCHER(Stmt, isMacroExpansion) { SourceManager &SM = Finder->getASTContext().getSourceManager(); - SourceLocation Loc = Node.getLocStart(); + SourceLocation Loc = Node.getBeginLoc(); return SM.isMacroBodyExpansion(Loc) || SM.isMacroArgExpansion(Loc); } bool isNULLMacroExpansion(const Stmt *Statement, ASTContext &Context) { SourceManager &SM = Context.getSourceManager(); const LangOptions &LO = Context.getLangOpts(); - SourceLocation Loc = Statement->getLocStart(); + SourceLocation Loc = Statement->getBeginLoc(); return SM.isMacroBodyExpansion(Loc) && Lexer::getImmediateMacroName(Loc, SM, LO) == "NULL"; } @@ -97,9 +97,9 @@ void fixGenericExprCastToBool(DiagnosticBuilder &Diag, bool InvertComparison = Parent != nullptr && isUnaryLogicalNotOperator(Parent); if (InvertComparison) { - SourceLocation ParentStartLoc = Parent->getLocStart(); + SourceLocation ParentStartLoc = Parent->getBeginLoc(); SourceLocation ParentEndLoc = - cast<UnaryOperator>(Parent)->getSubExpr()->getLocStart(); + cast<UnaryOperator>(Parent)->getSubExpr()->getBeginLoc(); Diag << FixItHint::CreateRemoval( CharSourceRange::getCharRange(ParentStartLoc, ParentEndLoc)); @@ -122,7 +122,7 @@ void fixGenericExprCastToBool(DiagnosticBuilder &Diag, } if (!StartLocInsertion.empty()) { - Diag << FixItHint::CreateInsertion(Cast->getLocStart(), StartLocInsertion); + Diag << FixItHint::CreateInsertion(Cast->getBeginLoc(), StartLocInsertion); } std::string EndLocInsertion; @@ -183,7 +183,7 @@ void fixGenericExprCastFromBool(DiagnosticBuilder &Diag, bool NeedParens = !isa<ParenExpr>(SubExpr); Diag << FixItHint::CreateInsertion( - Cast->getLocStart(), + Cast->getBeginLoc(), (Twine("static_cast<") + OtherType + ">" + (NeedParens ? "(" : "")) .str()); @@ -354,7 +354,7 @@ void ImplicitBoolConversionCheck::handleCastToBool(const ImplicitCastExpr *Cast, return; } - auto Diag = diag(Cast->getLocStart(), "implicit conversion %0 -> bool") + auto Diag = diag(Cast->getBeginLoc(), "implicit conversion %0 -> bool") << Cast->getSubExpr()->getType(); StringRef EquivalentLiteral = @@ -371,7 +371,7 @@ void ImplicitBoolConversionCheck::handleCastFromBool( ASTContext &Context) { QualType DestType = NextImplicitCast ? NextImplicitCast->getType() : Cast->getType(); - auto Diag = diag(Cast->getLocStart(), "implicit conversion bool -> %0") + auto Diag = diag(Cast->getBeginLoc(), "implicit conversion bool -> %0") << DestType; if (const auto *BoolLiteral = diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp index f1d0036..280c354 100644 --- a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp @@ -324,7 +324,7 @@ void InconsistentDeclarationParameterNameCheck::check( return; } - SourceLocation StartLoc = OriginalDeclaration->getLocStart(); + SourceLocation StartLoc = OriginalDeclaration->getBeginLoc(); if (StartLoc.isMacroID() && IgnoreMacros) { markRedeclarationsAsVisited(OriginalDeclaration); return; diff --git a/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp b/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp index 8a6c8c4..5abace5 100644 --- a/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp @@ -79,15 +79,15 @@ void MisleadingIndentationCheck::missingBracesCheck(const SourceManager &SM, if (isa<CompoundStmt>(Inner)) continue; - SourceLocation InnerLoc = Inner->getLocStart(); - SourceLocation OuterLoc = CurrentStmt->getLocStart(); + SourceLocation InnerLoc = Inner->getBeginLoc(); + SourceLocation OuterLoc = CurrentStmt->getBeginLoc(); if (SM.getExpansionLineNumber(InnerLoc) == SM.getExpansionLineNumber(OuterLoc)) continue; const Stmt *NextStmt = CStmt->body_begin()[i + 1]; - SourceLocation NextLoc = NextStmt->getLocStart(); + SourceLocation NextLoc = NextStmt->getBeginLoc(); if (InnerLoc.isMacroID() || OuterLoc.isMacroID() || NextLoc.isMacroID()) continue; diff --git a/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp b/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp index f5e09fa..3d1971b 100644 --- a/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp @@ -30,7 +30,7 @@ void MisplacedArrayIndexCheck::check(const MatchFinder::MatchResult &Result) { const auto *ArraySubscriptE = Result.Nodes.getNodeAs<ArraySubscriptExpr>("expr"); - auto Diag = diag(ArraySubscriptE->getLocStart(), "confusing array subscript " + auto Diag = diag(ArraySubscriptE->getBeginLoc(), "confusing array subscript " "expression, usually the " "index is inside the []"); diff --git a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp index ffdc813..6fa9e68 100644 --- a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp @@ -59,7 +59,7 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) { // Sanity check the source locations. if (!Parm->getLocation().isValid() || Parm->getLocation().isMacroID() || - !SM.isWrittenInSameFile(Parm->getLocStart(), Parm->getLocation())) + !SM.isWrittenInSameFile(Parm->getBeginLoc(), Parm->getLocation())) continue; // Skip gmock testing::Unused parameters. @@ -73,7 +73,7 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) { // Look for comments. We explicitly want to allow idioms like // void foo(int /*unused*/) - const char *Begin = SM.getCharacterData(Parm->getLocStart()); + const char *Begin = SM.getCharacterData(Parm->getBeginLoc()); const char *End = SM.getCharacterData(Parm->getLocation()); StringRef Data(Begin, End - Begin); if (Data.find("/*") != StringRef::npos) diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp index 409aba9..229cc626 100644 --- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp @@ -69,12 +69,12 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) { const auto *ND = Result.Nodes.getNodeAs<NamespaceDecl>("namespace"); const SourceManager &Sources = *Result.SourceManager; - if (!locationsInSameFile(Sources, ND->getLocStart(), ND->getRBraceLoc())) + if (!locationsInSameFile(Sources, ND->getBeginLoc(), ND->getRBraceLoc())) return; // Don't require closing comments for namespaces spanning less than certain // number of lines. - unsigned StartLine = Sources.getSpellingLineNumber(ND->getLocStart()); + unsigned StartLine = Sources.getSpellingLineNumber(ND->getBeginLoc()); unsigned EndLine = Sources.getSpellingLineNumber(ND->getRBraceLoc()); if (EndLine - StartLine + 1 <= ShortNamespaceLines) return; diff --git a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp index bc6507c..e33191c 100644 --- a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp @@ -146,7 +146,7 @@ void NonConstParameterCheck::diagnoseNonConstParameters() { unsigned Index = Par->getFunctionScopeIndex(); for (FunctionDecl *FnDecl : Function->redecls()) Fixes.push_back(FixItHint::CreateInsertion( - FnDecl->getParamDecl(Index)->getLocStart(), "const ")); + FnDecl->getParamDecl(Index)->getBeginLoc(), "const ")); diag(Par->getLocation(), "pointer parameter '%0' can be pointer to const") << Par->getName() << Fixes; diff --git a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp index 1df3f05..c5b6cc3 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp @@ -59,7 +59,7 @@ void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *VD = dyn_cast<VarDecl>(D)) { // Is this a multivariable declaration? for (const auto Other : VD->getDeclContext()->decls()) { - if (Other != D && Other->getLocStart() == VD->getLocStart()) { + if (Other != D && Other->getBeginLoc() == VD->getBeginLoc()) { MultiVar = true; break; } diff --git a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp index 1abd70b..b03b546 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp @@ -138,7 +138,7 @@ void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) { *Result.SourceManager, getLangOpts()); // Replace foo->get() with *foo, and foo.get() with foo. std::string Replacement = Twine(IsPtrToPtr ? "*" : "", SmartptrText).str(); - diag(GetCall->getLocStart(), "redundant get() call on smart pointer") + diag(GetCall->getBeginLoc(), "redundant get() call on smart pointer") << FixItHint::CreateReplacement(GetCall->getSourceRange(), Replacement); } diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp index 21f4a8a..f0c378f 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp @@ -189,7 +189,7 @@ void RedundantStringCStrCheck::check(const MatchFinder::MatchResult &Result) { if (ArgText.empty()) return; - diag(Call->getLocStart(), "redundant call to %0") + diag(Call->getBeginLoc(), "redundant call to %0") << Member->getMemberDecl() << FixItHint::CreateReplacement(Call->getSourceRange(), ArgText); } diff --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp index ba8e5b4..97243a9 100644 --- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -62,7 +62,7 @@ const char SimplifyConditionalReturnDiagnostic[] = const CXXBoolLiteralExpr *getBoolLiteral(const MatchFinder::MatchResult &Result, StringRef Id) { const auto *Literal = Result.Nodes.getNodeAs<CXXBoolLiteralExpr>(Id); - return (Literal && Literal->getLocStart().isMacroID()) ? nullptr : Literal; + return (Literal && Literal->getBeginLoc().isMacroID()) ? nullptr : Literal; } internal::Matcher<Stmt> returnsBool(bool Value, StringRef Id = "ignored") { @@ -372,7 +372,7 @@ void SimplifyBooleanExprCheck::reportBinOp( else return; - if (Bool->getLocStart().isMacroID()) + if (Bool->getBeginLoc().isMacroID()) return; // FIXME: why do we need this? @@ -385,8 +385,8 @@ void SimplifyBooleanExprCheck::reportBinOp( const Expr *ReplaceWith, bool Negated) { std::string Replacement = replacementExpression(Result, Negated, ReplaceWith); - SourceRange Range(LHS->getLocStart(), RHS->getLocEnd()); - issueDiag(Result, Bool->getLocStart(), SimplifyOperatorDiagnostic, Range, + SourceRange Range(LHS->getBeginLoc(), RHS->getLocEnd()); + issueDiag(Result, Bool->getBeginLoc(), SimplifyOperatorDiagnostic, Range, Replacement); }; @@ -577,7 +577,7 @@ void SimplifyBooleanExprCheck::replaceWithThenStatement( const MatchFinder::MatchResult &Result, const CXXBoolLiteralExpr *TrueConditionRemoved) { const auto *IfStatement = Result.Nodes.getNodeAs<IfStmt>(IfStmtId); - issueDiag(Result, TrueConditionRemoved->getLocStart(), + issueDiag(Result, TrueConditionRemoved->getBeginLoc(), SimplifyConditionDiagnostic, IfStatement->getSourceRange(), getText(Result, *IfStatement->getThen())); } @@ -587,7 +587,7 @@ void SimplifyBooleanExprCheck::replaceWithElseStatement( const CXXBoolLiteralExpr *FalseConditionRemoved) { const auto *IfStatement = Result.Nodes.getNodeAs<IfStmt>(IfStmtId); const Stmt *ElseStatement = IfStatement->getElse(); - issueDiag(Result, FalseConditionRemoved->getLocStart(), + issueDiag(Result, FalseConditionRemoved->getBeginLoc(), SimplifyConditionDiagnostic, IfStatement->getSourceRange(), ElseStatement ? getText(Result, *ElseStatement) : ""); } @@ -597,7 +597,7 @@ void SimplifyBooleanExprCheck::replaceWithCondition( bool Negated) { std::string Replacement = replacementExpression(Result, Negated, Ternary->getCond()); - issueDiag(Result, Ternary->getTrueExpr()->getLocStart(), + issueDiag(Result, Ternary->getTrueExpr()->getBeginLoc(), "redundant boolean literal in ternary expression result", Ternary->getSourceRange(), Replacement); } @@ -608,7 +608,7 @@ void SimplifyBooleanExprCheck::replaceWithReturnCondition( std::string Condition = replacementExpression(Result, Negated, If->getCond()); std::string Replacement = ("return " + Condition + Terminator).str(); SourceLocation Start = - Result.Nodes.getNodeAs<CXXBoolLiteralExpr>(ThenLiteralId)->getLocStart(); + Result.Nodes.getNodeAs<CXXBoolLiteralExpr>(ThenLiteralId)->getBeginLoc(); issueDiag(Result, Start, SimplifyConditionalReturnDiagnostic, If->getSourceRange(), Replacement); } @@ -640,8 +640,8 @@ void SimplifyBooleanExprCheck::replaceCompoundReturnWithCondition( std::string Replacement = "return " + replacementExpression(Result, Negated, Condition); issueDiag( - Result, Lit->getLocStart(), SimplifyConditionalReturnDiagnostic, - SourceRange(If->getLocStart(), Ret->getLocEnd()), Replacement); + Result, Lit->getBeginLoc(), SimplifyConditionalReturnDiagnostic, + SourceRange(If->getBeginLoc(), Ret->getLocEnd()), Replacement); return; } @@ -665,7 +665,7 @@ void SimplifyBooleanExprCheck::replaceWithAssignment( std::string Replacement = (VariableName + " = " + Condition + Terminator).str(); SourceLocation Location = - Result.Nodes.getNodeAs<CXXBoolLiteralExpr>(IfAssignLocId)->getLocStart(); + Result.Nodes.getNodeAs<CXXBoolLiteralExpr>(IfAssignLocId)->getBeginLoc(); issueDiag(Result, Location, "redundant boolean literal in conditional assignment", Range, Replacement); diff --git a/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp index 28cc576..036489f 100644 --- a/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp @@ -60,7 +60,7 @@ void SimplifySubscriptExprCheck::check(const MatchFinder::MatchResult &Result) { "accessing an element of the container does not require a call to " "'data()'; did you mean to use 'operator[]'?"); if (Member->isArrow()) - DiagBuilder << FixItHint::CreateInsertion(Member->getLocStart(), "(*") + DiagBuilder << FixItHint::CreateInsertion(Member->getBeginLoc(), "(*") << FixItHint::CreateInsertion(Member->getOperatorLoc(), ")"); DiagBuilder << FixItHint::CreateRemoval( {Member->getOperatorLoc(), Call->getLocEnd()}); diff --git a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp index b136577..92d78796 100644 --- a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp @@ -51,7 +51,7 @@ void StaticAccessedThroughInstanceCheck::check( const auto *MemberExpression = Result.Nodes.getNodeAs<MemberExpr>("memberExpression"); - if (MemberExpression->getLocStart().isMacroID()) + if (MemberExpression->getBeginLoc().isMacroID()) return; const Expr *BaseExpr = MemberExpression->getBase(); @@ -71,7 +71,7 @@ void StaticAccessedThroughInstanceCheck::check( std::string BaseTypeName = BaseType.getAsString(PrintingPolicyWithSupressedTag); - SourceLocation MemberExprStartLoc = MemberExpression->getLocStart(); + SourceLocation MemberExprStartLoc = MemberExpression->getBeginLoc(); auto Diag = diag(MemberExprStartLoc, "static member accessed through instance"); diff --git a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp index e75e80b..38ac43f 100644 --- a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp @@ -51,7 +51,7 @@ void StringCompareCheck::registerMatchers(MatchFinder *Finder) { void StringCompareCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *Matched = Result.Nodes.getNodeAs<Stmt>("match1")) { - diag(Matched->getLocStart(), CompareMessage); + diag(Matched->getBeginLoc(), CompareMessage); return; } @@ -63,10 +63,10 @@ void StringCompareCheck::check(const MatchFinder::MatchResult &Result) { const auto *Str2 = Result.Nodes.getNodeAs<Stmt>("str2"); const auto *Compare = Result.Nodes.getNodeAs<Stmt>("compare"); - auto Diag = diag(Matched->getLocStart(), CompareMessage); + auto Diag = diag(Matched->getBeginLoc(), CompareMessage); if (Str1->isArrow()) - Diag << FixItHint::CreateInsertion(Str1->getLocStart(), "*"); + Diag << FixItHint::CreateInsertion(Str1->getBeginLoc(), "*"); Diag << tooling::fixit::createReplacement(*Zero, *Str2, Ctx) << tooling::fixit::createReplacement(*Compare, *Str1->getBase(), diff --git a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp index 3ad346c..4476f37 100644 --- a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp @@ -42,7 +42,7 @@ void UniqueptrDeleteReleaseCheck::check( const auto *PtrExpr = Result.Nodes.getNodeAs<Expr>("uptr"); const auto *DeleteExpr = Result.Nodes.getNodeAs<Expr>("delete"); - if (PtrExpr->getLocStart().isMacroID()) + if (PtrExpr->getBeginLoc().isMacroID()) return; // Ignore dependent types. @@ -54,11 +54,11 @@ void UniqueptrDeleteReleaseCheck::check( SourceLocation AfterPtr = Lexer::getLocForEndOfToken( PtrExpr->getLocEnd(), 0, *Result.SourceManager, getLangOpts()); - diag(DeleteExpr->getLocStart(), + diag(DeleteExpr->getBeginLoc(), "prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> " "objects") << FixItHint::CreateRemoval(CharSourceRange::getCharRange( - DeleteExpr->getLocStart(), PtrExpr->getLocStart())) + DeleteExpr->getBeginLoc(), PtrExpr->getBeginLoc())) << FixItHint::CreateReplacement( CharSourceRange::getTokenRange(AfterPtr, DeleteExpr->getLocEnd()), " = nullptr"); diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp index ab6077a..5c6b984 100644 --- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp @@ -45,8 +45,8 @@ bool exprHasBitFlagWithSpelling(const Expr *Flags, const SourceManager &SM, StringRef FlagName) { // If the Flag is an integer constant, check it. if (isa<IntegerLiteral>(Flags)) { - if (!SM.isMacroBodyExpansion(Flags->getLocStart()) && - !SM.isMacroArgExpansion(Flags->getLocStart())) + if (!SM.isMacroBodyExpansion(Flags->getBeginLoc()) && + !SM.isMacroArgExpansion(Flags->getBeginLoc())) return false; // Get the macro name. diff --git a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp index 1a5120d..2518230 100644 --- a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp +++ b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp @@ -70,7 +70,7 @@ NamespaceAliaser::createAlias(ASTContext &Context, const Stmt &Statement, (llvm::Twine("\nnamespace ") + Abbreviation + " = " + Namespace + ";") .str(); SourceLocation Loc = - Lexer::getLocForEndOfToken(Function->getBody()->getLocStart(), 0, + Lexer::getLocForEndOfToken(Function->getBody()->getBeginLoc(), 0, SourceMgr, Context.getLangOpts()); AddedAliases[Function][Namespace.str()] = Abbreviation; return FixItHint::CreateInsertion(Loc, Declaration); diff --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp index e7200c9..e479d59 100644 --- a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp +++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp @@ -41,7 +41,7 @@ Optional<FixItHint> UsingInserter::createUsingDeclaration( return None; SourceLocation InsertLoc = Lexer::getLocForEndOfToken( - Function->getBody()->getLocStart(), 0, SourceMgr, Context.getLangOpts()); + Function->getBody()->getBeginLoc(), 0, SourceMgr, Context.getLangOpts()); // Only use using declarations in the main file, not in includes. if (SourceMgr.getFileID(InsertLoc) != SourceMgr.getMainFileID()) |