20 callee(functionDecl(hasAnyName(
"remove",
"remove_if",
"unique"))),
21 hasArgument(1, optionally(cxxMemberCallExpr(
22 callee(cxxMethodDecl(hasName(
"end"))))
26 const auto DeclInStd = type(hasUnqualifiedDesugaredType(
27 tagType(hasDeclaration(decl(isInStdNamespace())))));
30 on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd)))),
31 callee(cxxMethodDecl(hasName(
"erase"))), argumentCountIs(1),
32 hasArgument(0, EndCall))
38 const auto *MemberCall = Result.Nodes.getNodeAs<CXXMemberCallExpr>(
"erase");
39 const auto *EndExpr = Result.Nodes.getNodeAs<CXXMemberCallExpr>(
"end");
40 const SourceLocation Loc = MemberCall->getBeginLoc();
44 if (!Loc.isMacroID() && EndExpr) {
45 const auto *AlgCall = Result.Nodes.getNodeAs<CallExpr>(
"alg");
46 std::string ReplacementText = std::string(Lexer::getSourceText(
47 CharSourceRange::getTokenRange(EndExpr->getSourceRange()),
48 *Result.SourceManager, getLangOpts()));
49 const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
50 AlgCall->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
51 Hint = FixItHint::CreateInsertion(EndLoc,
", " + ReplacementText);
54 diag(Loc,
"this call will remove at most one item even when multiple items "