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