[PATCH] D148318: [clang-tidy] Add `performance-dont-use-endl` check
André Schackier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 14 03:19:13 PDT 2023
AMS21 added a comment.
This check is mostly working. Added notes about problems I know about.
================
Comment at: clang-tools-extra/clang-tidy/performance/DontUseEndlCheck.cpp:44
+ Diag << FixItHint::CreateReplacement(
+ CharSourceRange::getCharRange(EndlCall->getSourceRange()), "'\\n'");
+}
----------------
This doesn't quite work and I'm not sure why or what would work. Any help would be appreciated.
Report for this like
```cpp
std::cout << std::endl;
```
looks like this:
```
std::cout << std::endl;
^~~~~
'\n'
```
So the start location is correct but the end is not.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/performance/dont-use-endl.cpp:45-71
+void bad() {
+ std::cout << "World" << std::endl;
+ // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not use std::endl with iostreams; use '\n' instead
+ std::cerr << "World" << std::endl;
+ // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not use std::endl with iostreams; use '\n' instead
+}
+
----------------
All these test are missing checks for the fixit. See comment above why they are missing.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148318/new/
https://reviews.llvm.org/D148318
More information about the cfe-commits
mailing list