diff options
| author | Marc-Andre Laperle <marc-andre.laperle@ericsson.com> | 2018-04-10 17:34:46 +0000 |
|---|---|---|
| committer | Marc-Andre Laperle <marc-andre.laperle@ericsson.com> | 2018-04-10 17:34:46 +0000 |
| commit | 90a937e3e11efc202865c86e008d9dca08eb5535 (patch) | |
| tree | 5852b90ea7e3d9956f8a56b5a5f50c17fda7b607 /clang-tools-extra/unittests/clangd/JSONExprTests.cpp | |
| parent | 3dca0bedbb769565787ca6bb120ea6cfb39aec19 (diff) | |
| download | bcm5719-llvm-90a937e3e11efc202865c86e008d9dca08eb5535.tar.gz bcm5719-llvm-90a937e3e11efc202865c86e008d9dca08eb5535.zip | |
[clangd] Use operator<< to prevent printers issues in Gtest
Summary:
It is possible that there will be two different instantiations of
the printer template for a given type and some tests could end up calling the
wrong (default) one. For example, it was seen in CodeCompleteTests.cpp when
printing CompletionItems that it would use the wrong printer because the default
is also instantiated in ClangdTests.cpp.
With this change, objects that were previously printed with a custom Printer now
get printed through the operator<< which is declared alongside the class.
This rule of the thumb should make it less error-prone.
Reviewers: simark, ilya-biryukov, sammccall
Reviewed By: simark, ilya-biryukov, sammccall
Subscribers: bkramer, hokein, sammccall, klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits
Differential Revision: https://reviews.llvm.org/D44764
llvm-svn: 329725
Diffstat (limited to 'clang-tools-extra/unittests/clangd/JSONExprTests.cpp')
| -rw-r--r-- | clang-tools-extra/unittests/clangd/JSONExprTests.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/clang-tools-extra/unittests/clangd/JSONExprTests.cpp b/clang-tools-extra/unittests/clangd/JSONExprTests.cpp index 2c5cab29ca4..1e24e0988e2 100644 --- a/clang-tools-extra/unittests/clangd/JSONExprTests.cpp +++ b/clang-tools-extra/unittests/clangd/JSONExprTests.cpp @@ -15,9 +15,7 @@ namespace clang { namespace clangd { namespace json { -void PrintTo(const Expr &E, std::ostream *OS) { - llvm::raw_os_ostream(*OS) << llvm::formatv("{0:2}", E); -} + namespace { std::string s(const Expr &E) { return llvm::formatv("{0}", E).str(); } |

