================ @@ -164,6 +164,33 @@ void UseRangesCheck::registerMatchers(MatchFinder *Finder) { static void removeFunctionArgs(DiagnosticBuilder &Diag, const CallExpr &Call, ArrayRef<unsigned> Indexes, const ASTContext &Ctx) { + auto GetCommaLoc = + [&](SourceLocation BeginLoc, + SourceLocation EndLoc) -> std::optional<CharSourceRange> { + auto Invalid = false; + auto SourceText = Lexer::getSourceText( ---------------- 5chmidti wrote:
Doing all of this with strings is error-prone, which is why you are removing the comma inside a comment by accident, as you've noted. Instead, use the Lexer through one of the utility functions here: https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/utils/LexerUtils.h This can probably look something like: ```c++ auto RemovalRange = Arg->getSourceRange(); if (/*not first arg*/) { // so we can extend the range backward to the preceeding comma RemovalRange.setBegin(utils::lexer::findPreviousAnyTokenKind(RemovalRange.getBegin(), SM, LO, tok::TokenKind::comma)); } else if (/*not the only arg*/) { // so we can extend the range forwards to the next comma RemovalRange.setEnd(findNextAnyTokenKind(RemovalRange.getEnd(), SM, LO, tok::TokenKind::comma)); } ``` 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