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 wrote:
> Why are you matching on `ends`.
> That manipulator just inserts a null character to the stream(akin to doing 
> `std::cout << '\0';`)
> More to the point changing replacing this call with `std::cout << '\n'` 
> changes behaviour and will likely cause UB as this modifier is meant for 
> null-terminating character buffers to pass to `C` functions.
> 
> Double side note the point I made before about how you can turn `<< "World" 
> << endl` into `<< "World\n"` also wouldn't work here as `<< "World\0"` does 
> the same thing as `<< "World"` due to "World" already being a null terminated 
> string.
Good point, so maybe lets get rid `std::ends`, probably that could be covered 
in different check. I personalty for my project got ends and endl on forbidd 
list, but thats more to avoid control characters in logs, we can probably 
create new check for that case, and don't change this one.

Sorry for confusion...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148318/new/

https://reviews.llvm.org/D148318

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to