================ @@ -173,21 +174,21 @@ static void removeFunctionArgs(DiagnosticBuilder &Diag, const CallExpr &Call, for (unsigned Index : Sorted) { const Expr *Arg = Call.getArg(Index); if (Commas[Index]) { - if (Index >= Commas.size()) { - Diag << FixItHint::CreateRemoval(Arg->getSourceRange()); - } else { + if (Index + 1 < Call.getNumArgs()) { // Remove the next comma Commas[Index + 1] = true; + const Expr *NextArg = Call.getArg(Index + 1); Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange( - {Arg->getBeginLoc(), - Lexer::getLocForEndOfToken( - Arg->getEndLoc(), 0, Ctx.getSourceManager(), Ctx.getLangOpts()) - .getLocWithOffset(1)})); + {Arg->getBeginLoc(), NextArg->getBeginLoc().getLocWithOffset(-1)})); ---------------- chomosuke wrote:
My newest commit finds the exact location of `,` and removes it, so ```diff void f(int a, int b); void g() { - f(/*a*/0, /*b*/1); + f(/*a*/0 /*b*/); } ``` I think this is better than assuming the inline comment are parameter documentation. My code would fail though, in the case of a comment between the argument and the comma containing a comma in itself, something like ```diff void f(int a, int b); void g() { - f(/*a*/0 /*bla, bla*/, /*b*/1); + f(/*a*/0 /*bla bla*/, /*b*/); } ``` In this case the comma in the comment gets removed instead of the comma after the comment. I would appreciate if someone can point me to how to avoid that but I also think it's not a big deal since I don't people put their inline comment after an argument but before the comma like that very often. https://github.com/llvm/llvm-project/pull/118568 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits