[PATCH] D118247: [clang] NFC: Use flush() idiomatically

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 26 06:59:49 PST 2022


kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
kbobyrev requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Using both `raw_ostream::flush()` and `raw_ostream::str()` consecutively is
redundant. The alternatives are:

- Use `raw_ostream::str()` without `raw_ostream::flush()`
- Use `raw_ostream::flush()` and then use the destination for `raw_ostream` writer

The latter is more idiomatic, so the fix resolves this particular case in its
favor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118247

Files:
  clang/lib/AST/DeclPrinter.cpp


Index: clang/lib/AST/DeclPrinter.cpp
===================================================================
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -588,7 +588,7 @@
   }
   EOut << " ";
   EOut.flush();
-  Out << EOut.str();
+  Out << Proto;
 }
 
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118247.403252.patch
Type: text/x-patch
Size: 331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220126/0727ff88/attachment.bin>


More information about the cfe-commits mailing list