Port getLocEnd -> getEndLoc

Subscribers: nemanjai, ioeric, kbarton, cfe-commits

Differential Revision: https://reviews.llvm.org/D50355

llvm-svn: 339401
This commit is contained in:
Stephen Kelly 2018-08-09 22:43:02 +00:00
parent 43465bf3fd
commit c09197e086
43 changed files with 59 additions and 59 deletions

View File

@ -710,7 +710,7 @@ void ChangeNamespaceTool::moveClassForwardDeclaration(
const ast_matchers::MatchFinder::MatchResult &Result,
const NamedDecl *FwdDecl) {
SourceLocation Start = FwdDecl->getBeginLoc();
SourceLocation End = FwdDecl->getLocEnd();
SourceLocation End = FwdDecl->getEndLoc();
const SourceManager &SM = *Result.SourceManager;
SourceLocation AfterSemi = Lexer::findLocationAfterToken(
End, tok::semi, SM, Result.Context->getLangOpts(),
@ -911,7 +911,7 @@ void ChangeNamespaceTool::fixUsingShadowDecl(
const ast_matchers::MatchFinder::MatchResult &Result,
const UsingDecl *UsingDeclaration) {
SourceLocation Start = UsingDeclaration->getBeginLoc();
SourceLocation End = UsingDeclaration->getLocEnd();
SourceLocation End = UsingDeclaration->getEndLoc();
if (Start.isInvalid() || End.isInvalid())
return;

View File

@ -292,7 +292,7 @@ getLocForEndOfDecl(const clang::Decl *D,
// If the expansion range is a character range, this is the location of
// the first character past the end. Otherwise it's the location of the
// first character in the final token in the range.
auto EndExpansionLoc = SM.getExpansionRange(D->getLocEnd()).getEnd();
auto EndExpansionLoc = SM.getExpansionRange(D->getEndLoc()).getEnd();
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(EndExpansionLoc);
// Try to load the file buffer.
bool InvalidTemp = false;
@ -327,8 +327,8 @@ getFullRange(const clang::Decl *D,
getLocForEndOfDecl(D));
// Expand to comments that are associated with the Decl.
if (const auto *Comment = D->getASTContext().getRawCommentForDeclNoCache(D)) {
if (SM.isBeforeInTranslationUnit(Full.getEnd(), Comment->getLocEnd()))
Full.setEnd(Comment->getLocEnd());
if (SM.isBeforeInTranslationUnit(Full.getEnd(), Comment->getEndLoc()))
Full.setEnd(Comment->getEndLoc());
// FIXME: Don't delete a preceding comment, if there are no other entities
// it could refer to.
if (SM.isBeforeInTranslationUnit(Comment->getBeginLoc(), Full.getBegin()))

View File

@ -64,7 +64,7 @@ void CloexecCheck::insertMacroFlag(const MatchFinder::MatchResult &Result,
return;
SourceLocation EndLoc =
Lexer::getLocForEndOfToken(SM.getFileLoc(FlagArg->getLocEnd()), 0, SM,
Lexer::getLocForEndOfToken(SM.getFileLoc(FlagArg->getEndLoc()), 0, SM,
Result.Context->getLangOpts());
diag(EndLoc, "%0 should use %1 where possible")

View File

@ -243,7 +243,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
CharSourceRange BeforeArgument =
makeFileCharRange(ArgBeginLoc, Args[I]->getBeginLoc());
ArgBeginLoc = Args[I]->getLocEnd();
ArgBeginLoc = Args[I]->getEndLoc();
std::vector<std::pair<SourceLocation, StringRef>> Comments;
if (BeforeArgument.isValid()) {
@ -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]->getBeginLoc(), Args[NumArgs - 1]->getLocEnd());
Args[I]->getBeginLoc(), Args[NumArgs - 1]->getEndLoc());
Comments = getCommentsBeforeLoc(Ctx, ArgsRange.getBegin());
}
@ -287,7 +287,7 @@ void ArgumentCommentCheck::check(const MatchFinder::MatchResult &Result) {
if (!Callee)
return;
checkCallArgs(Result.Context, Callee, Call->getCallee()->getLocEnd(),
checkCallArgs(Result.Context, Callee, Call->getCallee()->getEndLoc(),
llvm::makeArrayRef(Call->getArgs(), Call->getNumArgs()));
} else {
const auto *Construct = cast<CXXConstructExpr>(E);

View File

@ -81,7 +81,7 @@ void CopyConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
if (CtorInitIsWritten) {
if (!ParamName.empty())
SafeFixIts.push_back(
FixItHint::CreateInsertion(CExpr->getLocEnd(), ParamName));
FixItHint::CreateInsertion(CExpr->getEndLoc(), ParamName));
} else {
if (Init->getSourceLocation().isMacroID() ||
Ctor->getLocation().isMacroID() || ShouldNotDoFixit)

View File

@ -67,7 +67,7 @@ void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) {
CharSourceRange::getTokenRange(EndExpr->getSourceRange()),
*Result.SourceManager, getLangOpts());
const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
AlgCall->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
AlgCall->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
Hint = FixItHint::CreateInsertion(EndLoc, ", " + ReplacementText);
}

View File

@ -29,7 +29,7 @@ static void replaceMoveWithForward(const UnresolvedLookupExpr *Callee,
CharSourceRange CallRange =
Lexer::makeFileCharRange(CharSourceRange::getTokenRange(
Callee->getBeginLoc(), Callee->getLocEnd()),
Callee->getBeginLoc(), Callee->getEndLoc()),
SM, LangOpts);
if (CallRange.isValid()) {

View File

@ -62,7 +62,7 @@ void StringIntegerAssignmentCheck::check(
}
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Argument->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
Argument->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
if (IsOneDigit) {
Diag << FixItHint::CreateInsertion(Loc, IsWideCharType ? "L'" : "'")
<< FixItHint::CreateInsertion(EndLoc, "'");

View File

@ -51,7 +51,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) {
SM.getSpellingLineNumber(Token.getLocation()) != SemicolonLine)
return;
SourceLocation LocEnd = Semicolon->getLocEnd();
SourceLocation LocEnd = Semicolon->getEndLoc();
FileID FID = SM.getFileID(LocEnd);
llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd);
Lexer Lexer(SM.getLocForStartOfFile(FID), Ctxt.getLangOpts(),

View File

@ -84,7 +84,7 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) {
match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context);
const auto *TL = selectFirst<TypeLoc>("t", Matches);
D << FixItHint::CreateInsertion(
Lexer::getLocForEndOfToken(TL->getLocEnd(), 0, *Result.SourceManager,
Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
getLangOpts()),
Replacement);
}

View File

@ -74,7 +74,7 @@ void NoMallocCheck::check(const MatchFinder::MatchResult &Result) {
assert(Call && "Unhandled binding in the Matcher");
diag(Call->getBeginLoc(), "do not manage memory manually; %0")
<< Recommendation << SourceRange(Call->getBeginLoc(), Call->getLocEnd());
<< Recommendation << SourceRange(Call->getBeginLoc(), Call->getEndLoc());
}
} // namespace cppcoreguidelines

View File

@ -93,7 +93,7 @@ void ProBoundsConstantArrayIndexCheck::check(
SourceRange(BaseRange.getEnd().getLocWithOffset(1),
IndexRange.getBegin().getLocWithOffset(-1)),
", ")
<< FixItHint::CreateReplacement(Matched->getLocEnd(), ")");
<< FixItHint::CreateReplacement(Matched->getEndLoc(), ")");
Optional<FixItHint> Insertion = Inserter->CreateIncludeInsertion(
Result.SourceManager->getMainFileID(), GslHeader,

View File

@ -81,7 +81,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) {
if (!isa<ParenExpr>(SubExpr)) {
CastText.push_back('(');
diag_builder << FixItHint::CreateInsertion(
Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0,
Lexer::getLocForEndOfToken(SubExpr->getEndLoc(), 0,
*Result.SourceManager, getLangOpts()),
")");
}

View File

@ -33,7 +33,7 @@ void DefaultArgumentsCheck::check(const MatchFinder::MatchResult &Result) {
Result.Nodes.getNodeAs<ParmVarDecl>("decl")) {
SourceRange DefaultArgRange = D->getDefaultArgRange();
if (DefaultArgRange.getEnd() != D->getLocEnd()) {
if (DefaultArgRange.getEnd() != D->getEndLoc()) {
return;
} else if (DefaultArgRange.getBegin().isMacroID()) {
diag(D->getBeginLoc(),

View File

@ -135,7 +135,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) {
if (!isa<ParenExpr>(SubExpr)) {
CastText.push_back('(');
Diag << FixItHint::CreateInsertion(
Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, SM,
Lexer::getLocForEndOfToken(SubExpr->getEndLoc(), 0, SM,
getLangOpts()),
")");
}

View File

@ -118,7 +118,7 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
};
SourceRange ExplicitTokenRange =
FindToken(*Result.SourceManager, getLangOpts(),
Ctor->getOuterLocStart(), Ctor->getLocEnd(), isKWExplicit);
Ctor->getOuterLocStart(), Ctor->getEndLoc(), isKWExplicit);
StringRef ConstructorDescription;
if (Ctor->isMoveConstructor())
ConstructorDescription = "move";

View File

@ -48,7 +48,7 @@ void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {
if (VD->getType()->getCanonicalTypeUnqualified() ==
C->getType()->getCanonicalTypeUnqualified()) {
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
VD->getInit()->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
VD->getInit()->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
Diag << FixItHint::CreateReplacement(TypeRange, "std::string")
<< FixItHint::CreateInsertion(VD->getInit()->getBeginLoc(), "(")
<< FixItHint::CreateInsertion(EndLoc, ").str()");

View File

@ -885,7 +885,7 @@ void RedundantExpressionCheck::checkBitwiseExpr(
diag(Loc, "expression always evaluates to 0");
} else if (exprEvaluatesToBitwiseNegatedZero(Opcode, Value)) {
SourceRange ConstExprRange(ConstExpr->getBeginLoc(),
ConstExpr->getLocEnd());
ConstExpr->getEndLoc());
StringRef ConstExprText = Lexer::getSourceText(
CharSourceRange::getTokenRange(ConstExprRange), *Result.SourceManager,
Result.Context->getLangOpts());
@ -893,7 +893,7 @@ void RedundantExpressionCheck::checkBitwiseExpr(
diag(Loc, "expression always evaluates to '%0'") << ConstExprText;
} else if (exprEvaluatesToSymbolic(Opcode, Value)) {
SourceRange SymExprRange(Sym->getBeginLoc(), Sym->getLocEnd());
SourceRange SymExprRange(Sym->getBeginLoc(), Sym->getEndLoc());
StringRef ExprText = Lexer::getSourceText(
CharSourceRange::getTokenRange(SymExprRange), *Result.SourceManager,

View File

@ -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->getBeginLoc(), AssertMSG->getLocEnd())));
SourceRange(AssertMSG->getBeginLoc(), AssertMSG->getEndLoc())));
StaticAssertMSG = (Twine(", \"") + AssertMSG->getString() + "\"").str();
}

View File

@ -36,7 +36,7 @@ void UnusedAliasDeclsCheck::check(const MatchFinder::MatchResult &Result) {
FoundDecls[AliasDecl] = CharSourceRange::getCharRange(
AliasDecl->getBeginLoc(),
Lexer::findLocationAfterToken(
AliasDecl->getLocEnd(), tok::semi, *Result.SourceManager,
AliasDecl->getEndLoc(), tok::semi, *Result.SourceManager,
getLangOpts(),
/*SkipTrailingWhitespaceAndNewLine=*/true));
return;

View File

@ -46,10 +46,10 @@ static CharSourceRange removeNode(const MatchFinder::MatchResult &Result,
if (PrevNode)
return CharSourceRange::getTokenRange(
Lexer::getLocForEndOfToken(PrevNode->getLocEnd(), 0,
Lexer::getLocForEndOfToken(PrevNode->getEndLoc(), 0,
*Result.SourceManager,
Result.Context->getLangOpts()),
Node->getLocEnd());
Node->getEndLoc());
return CharSourceRange::getTokenRange(Node->getSourceRange());
}

View File

@ -70,7 +70,7 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
Context.UsingDeclRange = CharSourceRange::getCharRange(
Using->getBeginLoc(),
Lexer::findLocationAfterToken(
Using->getLocEnd(), tok::semi, *Result.SourceManager, getLangOpts(),
Using->getEndLoc(), tok::semi, *Result.SourceManager, getLangOpts(),
/*SkipTrailingWhitespaceAndNewLine=*/true));
for (const auto *UsingShadow : Using->shadows()) {
const auto *TargetDecl = UsingShadow->getTargetDecl()->getCanonicalDecl();

View File

@ -59,7 +59,7 @@ buildBindArguments(const MatchFinder::MatchResult &Result, const CallExpr *C) {
}
B.Tokens = Lexer::getSourceText(
CharSourceRange::getTokenRange(E->getBeginLoc(), E->getLocEnd()),
CharSourceRange::getTokenRange(E->getBeginLoc(), E->getEndLoc()),
*Result.SourceManager, Result.Context->getLangOpts());
SmallVector<StringRef, 2> Matches;

View File

@ -201,7 +201,7 @@ void MakeSmartPtrCheck::checkReset(SourceManager &SM,
SourceLocation ResetCallStart = Reset->getExprLoc();
SourceLocation ExprStart = Expr->getBeginLoc();
SourceLocation ExprEnd =
Lexer::getLocForEndOfToken(Expr->getLocEnd(), 0, SM, getLangOpts());
Lexer::getLocForEndOfToken(Expr->getEndLoc(), 0, SM, getLangOpts());
bool InMacro = ExprStart.isMacroID();

View File

@ -207,7 +207,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) {
TypeLoc ValueTL = RefTL.getPointeeLoc();
auto TypeRange = CharSourceRange::getTokenRange(ParmDecl->getBeginLoc(),
ParamTL.getLocEnd());
ParamTL.getEndLoc());
std::string ValueStr = Lexer::getSourceText(CharSourceRange::getTokenRange(
ValueTL.getSourceRange()),
SM, getLangOpts())

View File

@ -105,7 +105,7 @@ void RedundantVoidArgCheck::processFunctionDecl(
const Stmt *Body = Function->getBody();
SourceLocation Start = Function->getBeginLoc();
SourceLocation End =
Body ? Body->getBeginLoc().getLocWithOffset(-1) : Function->getLocEnd();
Body ? Body->getBeginLoc().getLocWithOffset(-1) : Function->getEndLoc();
removeVoidArgumentTokens(Result, SourceRange(Start, End),
"function definition");
} else {

View File

@ -141,7 +141,7 @@ void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) {
Diag << FixItHint::CreateReplacement(FunctionNameSourceRange, EmplacePrefix);
const SourceRange CallParensRange =
MakeCall ? SourceRange(MakeCall->getCallee()->getLocEnd(),
MakeCall ? SourceRange(MakeCall->getCallee()->getEndLoc(),
MakeCall->getRParenLoc())
: CtorCall->getParenOrBraceRange();

View File

@ -55,7 +55,7 @@ void UseEqualsDeleteCheck::check(const MatchFinder::MatchResult &Result) {
if (const auto *Func =
Result.Nodes.getNodeAs<CXXMethodDecl>(SpecialFunction)) {
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Func->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
Func->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
// FIXME: Improve FixItHint to make the method public.
diag(Func->getLocation(),

View File

@ -215,7 +215,7 @@ public:
}
SourceLocation StartLoc = FirstSubExpr->getBeginLoc();
SourceLocation EndLoc = FirstSubExpr->getLocEnd();
SourceLocation EndLoc = FirstSubExpr->getEndLoc();
// If the location comes from a macro arg expansion, *all* uses of that
// arg must be checked to result in NullTo(Member)Pointer casts.

View File

@ -58,14 +58,14 @@ void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) {
if (C) {
BeginLoc = C->getBeginLoc();
EndLoc = C->getLocEnd();
EndLoc = C->getEndLoc();
} else if (const auto *E = Result.Nodes.getNodeAs<CallExpr>("call_expr")) {
BeginLoc = E->getBeginLoc();
EndLoc = E->getLocEnd();
EndLoc = E->getEndLoc();
} else if (const auto *D =
Result.Nodes.getNodeAs<DeclRefExpr>("decl_ref_expr")) {
BeginLoc = D->getBeginLoc();
EndLoc = D->getLocEnd();
EndLoc = D->getEndLoc();
WarnOnly = true;
} else {
const auto *U = Result.Nodes.getNodeAs<UsingDecl>("using_decl");

View File

@ -96,7 +96,7 @@ void FasterStringFindCheck::check(const MatchFinder::MatchResult &Result) {
<< FindFunc
<< FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(Literal->getBeginLoc(),
Literal->getLocEnd()),
Literal->getEndLoc()),
*Replacement);
}

View File

@ -26,8 +26,8 @@ static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag,
CharSourceRange::getCharRange(Call->getBeginLoc(), Arg->getBeginLoc()),
SM, LangOpts);
CharSourceRange AfterArgumentsRange = Lexer::makeFileCharRange(
CharSourceRange::getCharRange(Call->getLocEnd(),
Call->getLocEnd().getLocWithOffset(1)),
CharSourceRange::getCharRange(Call->getEndLoc(),
Call->getEndLoc().getLocWithOffset(1)),
SM, LangOpts);
if (BeforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {

View File

@ -23,7 +23,7 @@ namespace {
SourceRange getTypeRange(const ParmVarDecl &Param) {
if (Param.getIdentifier() != nullptr)
return SourceRange(Param.getBeginLoc(),
Param.getLocEnd().getLocWithOffset(-1));
Param.getEndLoc().getLocWithOffset(-1));
return Param.getSourceRange();
}
@ -97,7 +97,7 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
Diag << Param;
}
if (Param->getBeginLoc().isMacroID() != Param->getLocEnd().isMacroID()) {
if (Param->getBeginLoc().isMacroID() != Param->getEndLoc().isMacroID()) {
// Do not offer a suggestion if the part of the variable declaration comes
// from a macro.
return;

View File

@ -177,9 +177,9 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S,
if (S->getBeginLoc().isMacroID())
return SourceLocation();
SourceLocation CondEndLoc = S->getCond()->getLocEnd();
SourceLocation CondEndLoc = S->getCond()->getEndLoc();
if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt())
CondEndLoc = CondVar->getLocEnd();
CondEndLoc = CondVar->getEndLoc();
if (!CondEndLoc.isValid()) {
return SourceLocation();

View File

@ -63,7 +63,7 @@ void DeleteNullPointerCheck::check(const MatchFinder::MatchResult &Result) {
Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
IfWithDelete->getBeginLoc(),
Lexer::getLocForEndOfToken(IfWithDelete->getCond()->getLocEnd(), 0,
Lexer::getLocForEndOfToken(IfWithDelete->getCond()->getEndLoc(), 0,
*Result.SourceManager,
Result.Context->getLangOpts())));
if (Compound) {

View File

@ -162,8 +162,8 @@ 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->getBeginLoc(), Body->getLocEnd())) {
FI.Lines = SM->getSpellingLineNumber(Body->getLocEnd()) -
if (SM->isWrittenInSameFile(Body->getBeginLoc(), Body->getEndLoc())) {
FI.Lines = SM->getSpellingLineNumber(Body->getEndLoc()) -
SM->getSpellingLineNumber(Body->getBeginLoc());
}
}

View File

@ -145,7 +145,7 @@ void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
}
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Cast->getLocEnd(), 0, Context.getSourceManager(), Context.getLangOpts());
Cast->getEndLoc(), 0, Context.getSourceManager(), Context.getLangOpts());
Diag << FixItHint::CreateInsertion(EndLoc, EndLocInsertion);
}
@ -189,7 +189,7 @@ void fixGenericExprCastFromBool(DiagnosticBuilder &Diag,
if (NeedParens) {
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Cast->getLocEnd(), 0, Context.getSourceManager(),
Cast->getEndLoc(), 0, Context.getSourceManager(),
Context.getLangOpts());
Diag << FixItHint::CreateInsertion(EndLoc, ")");

View File

@ -40,7 +40,7 @@ void MisleadingIndentationCheck::danglingElseCheck(const SourceManager &SM,
if (IfLoc.isMacroID() || ElseLoc.isMacroID())
return;
if (SM.getExpansionLineNumber(If->getThen()->getLocEnd()) ==
if (SM.getExpansionLineNumber(If->getThen()->getEndLoc()) ==
SM.getExpansionLineNumber(ElseLoc))
return;

View File

@ -81,7 +81,7 @@ void RedundantControlFlowCheck::issueDiagnostic(
SourceLocation Start;
if (Previous != Block->body_rend())
Start = Lexer::findLocationAfterToken(
dyn_cast<Stmt>(*Previous)->getLocEnd(), tok::semi, SM, getLangOpts(),
dyn_cast<Stmt>(*Previous)->getEndLoc(), tok::semi, SM, getLangOpts(),
/*SkipTrailingWhitespaceAndNewLine=*/true);
if (!Start.isValid())
Start = StmtRange.getBegin();

View File

@ -385,7 +385,7 @@ void SimplifyBooleanExprCheck::reportBinOp(
const Expr *ReplaceWith, bool Negated) {
std::string Replacement =
replacementExpression(Result, Negated, ReplaceWith);
SourceRange Range(LHS->getBeginLoc(), RHS->getLocEnd());
SourceRange Range(LHS->getBeginLoc(), RHS->getEndLoc());
issueDiag(Result, Bool->getBeginLoc(), SimplifyOperatorDiagnostic, Range,
Replacement);
};
@ -641,7 +641,7 @@ void SimplifyBooleanExprCheck::replaceCompoundReturnWithCondition(
"return " + replacementExpression(Result, Negated, Condition);
issueDiag(
Result, Lit->getBeginLoc(), SimplifyConditionalReturnDiagnostic,
SourceRange(If->getBeginLoc(), Ret->getLocEnd()), Replacement);
SourceRange(If->getBeginLoc(), Ret->getEndLoc()), Replacement);
return;
}

View File

@ -63,7 +63,7 @@ void SimplifySubscriptExprCheck::check(const MatchFinder::MatchResult &Result) {
DiagBuilder << FixItHint::CreateInsertion(Member->getBeginLoc(), "(*")
<< FixItHint::CreateInsertion(Member->getOperatorLoc(), ")");
DiagBuilder << FixItHint::CreateRemoval(
{Member->getOperatorLoc(), Call->getLocEnd()});
{Member->getOperatorLoc(), Call->getEndLoc()});
}
void SimplifySubscriptExprCheck::storeOptions(

View File

@ -52,7 +52,7 @@ void UniqueptrDeleteReleaseCheck::check(
return;
SourceLocation AfterPtr = Lexer::getLocForEndOfToken(
PtrExpr->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
PtrExpr->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
diag(DeleteExpr->getBeginLoc(),
"prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> "
@ -60,7 +60,7 @@ void UniqueptrDeleteReleaseCheck::check(
<< FixItHint::CreateRemoval(CharSourceRange::getCharRange(
DeleteExpr->getBeginLoc(), PtrExpr->getBeginLoc()))
<< FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(AfterPtr, DeleteExpr->getLocEnd()),
CharSourceRange::getTokenRange(AfterPtr, DeleteExpr->getEndLoc()),
" = nullptr");
}

View File

@ -52,7 +52,7 @@ public:
auto *Cond = If->getCond();
SourceRange Range = Cond->getSourceRange();
if (auto *D = If->getConditionVariable()) {
Range = SourceRange(D->getBeginLoc(), D->getLocEnd());
Range = SourceRange(D->getBeginLoc(), D->getEndLoc());
}
diag(Range.getBegin(), "the cake is a lie") << FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(Range), "false");