[PATCH] D44764: [clangd] Use operator<< to prevent printers issues in Gtest

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 29 11:42:44 PDT 2018


sammccall added inline comments.


================
Comment at: clangd/Protocol.h:673
 json::Expr toJSON(const CompletionItem &);
+std::ostream &operator<<(std::ostream &, const CompletionItem &);
 
----------------
I think raw_ostream should work fine here, it's what we've done elsewhere.
Is there a reason to use std::ostream?

(llvm's gtest is specially modified so raw_ostream printers can be used)


================
Comment at: unittests/clangd/JSONExprTests.cpp:19
-void PrintTo(const Expr &E, std::ostream *OS) {
-  llvm::raw_os_ostream(*OS) << llvm::formatv("{0:2}", E);
-}
----------------
malaperle wrote:
> This one I couldn't change to operator<< because there was already one defined with raw_ostream. But this just means losing indentation so perhaps that's not too bad?
yeah, I think this is fine.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44764





More information about the cfe-commits mailing list