1 //===--------------------------- StreamWrapper.cpp ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "StreamWrapper.h"
10 #include "llvm/Support/raw_ostream.h"
11 #include <cassert>
12 #include <memory>
13 
14 namespace __llvm_libc {
15 namespace testutils {
16 
17 StreamWrapper outs() { return {std::addressof(llvm::outs())}; }
18 
19 template <typename T> StreamWrapper &StreamWrapper::operator<<(T t) {
20   assert(OS);
21   llvm::raw_ostream &Stream = *reinterpret_cast<llvm::raw_ostream *>(OS);
22   Stream << t;
23   return *this;
24 }
25 
26 template StreamWrapper &StreamWrapper::operator<<<void *>(void *t);
27 template StreamWrapper &StreamWrapper::operator<<<const char *>(const char *t);
28 template StreamWrapper &StreamWrapper::operator<<<char *>(char *t);
29 template StreamWrapper &StreamWrapper::operator<<<char>(char t);
30 template StreamWrapper &StreamWrapper::operator<<<short>(short t);
31 template StreamWrapper &StreamWrapper::operator<<<int>(int t);
32 template StreamWrapper &StreamWrapper::operator<<<long>(long t);
33 template StreamWrapper &StreamWrapper::operator<<<long long>(long long t);
34 template StreamWrapper &
35     StreamWrapper::operator<<<unsigned char>(unsigned char t);
36 template StreamWrapper &
37     StreamWrapper::operator<<<unsigned short>(unsigned short t);
38 template StreamWrapper &StreamWrapper::operator<<<unsigned int>(unsigned int t);
39 template StreamWrapper &
40     StreamWrapper::operator<<<unsigned long>(unsigned long t);
41 template StreamWrapper &
42     StreamWrapper::operator<<<unsigned long long>(unsigned long long t);
43 template StreamWrapper &StreamWrapper::operator<<<bool>(bool t);
44 
45 } // namespace testutils
46 } // namespace __llvm_libc
47