Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrCai0907 committed Sep 12, 2024
1 parent 89313a2 commit f0cdfb4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) {
TokenRange, *Result.SourceManager, Result.Context->getLangOpts());
if (SourceText.empty())
SourceText = "std::endl";
diag(Expression->getBeginLoc(),
"do not use '%0' with streams; use '\\n' instead")
<< SourceText << FixItHint::CreateReplacement(TokenRange, "'\\n'");
auto Builder = diag(Expression->getBeginLoc(),
"do not use '%0' with streams; use '\\n' instead");
if (TokenRange.isValid())
Builder << SourceText
<< FixItHint::CreateReplacement(TokenRange, "'\\n'");
} else {
// Handle the less common function call 'std::endl(...)' case
const auto *CallExpression = llvm::cast<CallExpr>(Expression);
Expand Down

0 comments on commit f0cdfb4

Please sign in to comment.