llvm.org GIT mirror llvm / 34ccf03
Add raw_null_ostream and llvm::nulls(), a raw_ostream that discards output. - No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76103 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
2 changed file(s) with 33 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
326326 /// Use it like: errs() << "foo" << "bar";
327327 raw_ostream &errs();
328328
329 /// nulls() - This returns a reference to a raw_ostream which simply discards
330 /// output.
331 raw_ostream &nulls();
329332
330333 //===----------------------------------------------------------------------===//
331334 // Output Stream Adaptors
398401 uint64_t tell();
399402 };
400403
404 /// raw_null_ostream - A raw_ostream that discards all output.
405 class raw_null_ostream : public raw_ostream {
406 /// write_impl - See raw_ostream::write_impl.
407 virtual void write_impl(const char *Ptr, size_t size);
408
409 /// current_pos - Return the current position within the stream, not
410 /// counting the bytes currently in the buffer.
411 virtual uint64_t current_pos();
412
413 public:
414 explicit raw_null_ostream() {}
415 };
416
401417 } // end llvm namespace
402418
403419 #endif
374374 return S;
375375 }
376376
377 /// nulls() - This returns a reference to a raw_ostream which discards output.
378 raw_ostream &llvm::nulls() {
379 static raw_null_ostream S;
380 return S;
381 }
382
377383 //===----------------------------------------------------------------------===//
378384 // raw_os_ostream
379385 //===----------------------------------------------------------------------===//
421427 uint64_t raw_svector_ostream::tell() {
422428 return OS.size() + GetNumBytesInBuffer();
423429 }
430
431 //===----------------------------------------------------------------------===//
432 // raw_null_ostream
433 //===----------------------------------------------------------------------===//
434
435 void raw_null_ostream::write_impl(const char *Ptr, size_t Size) {
436 }
437
438 uint64_t raw_null_ostream::current_pos() {
439 return 0;
440 }