================ @@ -46,14 +46,15 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) { // Handle the more common streaming '... << std::endl' case const CharSourceRange TokenRange = CharSourceRange::getTokenRange(Expression->getSourceRange()); - const StringRef SourceText = Lexer::getSourceText( + StringRef SourceText = Lexer::getSourceText( TokenRange, *Result.SourceManager, Result.Context->getLangOpts()); - - auto Diag = diag(Expression->getBeginLoc(), - "do not use '%0' with streams; use '\\n' instead") - << SourceText; - - Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'"); + if (SourceText.empty()) + SourceText = "std::endl"; + auto Builder = diag(Expression->getBeginLoc(), + "do not use '%0' with streams; use '\\n' instead"); + if (TokenRange.isValid()) + Builder << SourceText ---------------- SimplyDanny wrote:
The `<< SourceText` part should always be added, shouldn't it? The tests seem to be fine though. 🤔 https://github.com/llvm/llvm-project/pull/107867 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits