[clang-tools-extra] [clang-tidy] Add modernize-use-std-format check (PR #90397)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 28 08:39:11 PDT 2024


================
@@ -627,7 +628,8 @@ void FormatStringConverter::finalizeFormatText() {
 
   // It's clearer to convert printf("Hello\r\n"); to std::print("Hello\r\n")
   // than to std::println("Hello\r");
-  if (StringRef(StandardFormatString).ends_with("\\n") &&
+  if (Config.AllowTrailingNewlineRemoval &&
+      StringRef(StandardFormatString).ends_with("\\n") &&
       !StringRef(StandardFormatString).ends_with("\\\\n") &&
       !StringRef(StandardFormatString).ends_with("\\r\\n")) {
----------------
PiotrZSL wrote:

Avoid constructing StringRef multiple times.

https://github.com/llvm/llvm-project/pull/90397


More information about the cfe-commits mailing list