This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd893308b5d4: [clang-tidy] Add `performance-avoid-endl`
check (authored by AMS21, committed by PiotrZSL).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
AMS21 added a comment.
If someone could be so kind as to push this on my behalf, it would be greatly
appreciated
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.
More or less looks good.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
AMS21 added inline comments.
Comment at: clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp:48-51
+const CharSourceRange TokenRange =
+CharSourceRange::getTokenRange(Expression->getSourceRange());
+const StringRef SourceText = Lexer::getSourceText(
+
AMS21 updated this revision to Diff 515283.
AMS21 marked 12 inline comments as done.
AMS21 added a comment.
Implement suggested changes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
Files:
PiotrZSL added a comment.
Overall looks good, didn't found any bugs, just some potential improvements.
Comment at: clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp:23
+void AvoidEndlCheck::registerMatchers(MatchFinder *Finder) {
+ Finder->addMatcher(
+
AMS21 updated this revision to Diff 514908.
AMS21 added a comment.
Minor code cleanup
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
Files:
clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
AMS21 updated this revision to Diff 514367.
AMS21 added a comment.
Fix docs
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
Files:
clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
AMS21 updated this revision to Diff 514366.
AMS21 added a comment.
Handle the function calling case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
Files:
AMS21 added a comment.
I've also notices that we don't handle this case
std::endl(std::cout);
Although a rather unusual thing to use, its still valid and has the same
problems.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
AMS21 updated this revision to Diff 514118.
AMS21 added a comment.
Remove std::ends from the check
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
Files:
PiotrZSL added inline comments.
Comment at: clang-tools-extra/clang-tidy/performance/AvoidEndlEndsCheck.cpp:28
+ declRefExpr(
+ to(namedDecl(hasAnyName("endl", "ends")).bind("decl")))
+ .bind("expr",
njames93
njames93 added inline comments.
Comment at: clang-tools-extra/clang-tidy/performance/AvoidEndlEndsCheck.cpp:28
+ declRefExpr(
+ to(namedDecl(hasAnyName("endl", "ends")).bind("decl")))
+ .bind("expr",
Why are you
AMS21 added inline comments.
Comment at:
clang-tools-extra/test/clang-tidy/checkers/performance/avoid-endl.cpp:46
+void bad() {
+ std::cout << "World" << std::endl;
+ // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not use std::endl with
iostreams; use '\n' instead
AMS21 updated this revision to Diff 513878.
AMS21 marked 12 inline comments as done.
AMS21 added a comment.
Implement suggested fixes
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
Files:
njames93 added a comment.
For what its worth, there typically isn't any performance gain using `\n` over
`std::endl` when writing to `std::cerr` or `std::clog` (or their wide string
counterparts) as every write operation on those implicitly calls flush.
However If the fix was changed to convert
PiotrZSL added inline comments.
Comment at: clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp:1
+//===--- AvoidEndlCheck.cpp - clang-tidy ===//
+//
rename script got problem with this comment, you may need to align it
PiotrZSL added a comment.
Consider extending this check to suport also std::ends, maybe name it
performance-avoid-endl-ends.
Comment at: clang-tools-extra/clang-tidy/performance/DontUseEndlCheck.cpp:26
+ callee(cxxMethodDecl(ofClass(
+
carlosgalvezp added inline comments.
Comment at:
clang-tools-extra/test/clang-tidy/checkers/performance/avoid-endl.cpp:47
+ std::cout << "World" << std::endl;
+ // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not use std::endl with
iostreams; use '\n' instead
+ std::cerr <<
carlosgalvezp added a comment.
Thank you for the contribution! Looks good in general, have minor comments.
Comment at:
clang-tools-extra/docs/clang-tidy/checks/performance/avoid-endl.rst:1
+.. title:: clang-tidy - performance-avoid-endl
+
Please wrap file to
20 matches
Mail list logo