[clang-tidy] Add `performance-avoid-endl` check
authorAMS21 <AMS21.github@gmail.com>
Sat, 22 Apr 2023 10:50:42 +0000 (10:50 +0000)
committerPiotr Zegar <me@piotrzegar.pl>
Sat, 22 Apr 2023 10:50:51 +0000 (10:50 +0000)
commitcd893308b5d4d058b8ec6a2c4b00843d89e25552
tree39559cbc1037e9b3573df575acf2efc1b8e0db9b
parenta79a6ea4a831facc564a36911d79d4472ad93cec
[clang-tidy] Add `performance-avoid-endl` check

This check flags uses of `std::endl` on streams and suggests using the newline character `'\n'` instead. `std::endl` performs two operations: it writes a newline character to the output stream and then flushes the stream buffer, which can be less efficient than writing a single newline character using `'\n'`.

This fixes llvm#35321

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D148318
clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.h [new file with mode: 0644]
clang-tools-extra/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/performance/avoid-endl.rst [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/checkers/performance/avoid-endl.cpp [new file with mode: 0644]