From: Bill Wendling Date: Sun, 17 Dec 2006 11:40:40 +0000 (+0000) Subject: Added example of how to code print() methods so that they will disappear X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b0a9d1b9bc3180e7f5e7ca3c0c1a798414e942e8;p=oota-llvm.git Added example of how to code print() methods so that they will disappear from the code if "cnull" is passed into them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32641 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index 5b65fbc637c..97e21fa65cc 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -509,7 +509,7 @@ library. There are two problems with this:

more pressure on the VM system on low-memory machines. - +
@@ -520,8 +520,10 @@ library. There are two problems with this:

- - + + @@ -535,6 +537,12 @@ library. There are two problems with this:

+ + + + @@ -552,9 +560,14 @@ library. There are two problems with this:

// ... print(std::cerr); - +print(llvm::cerr); + + +
Old Way
#include "llvm/Support/Streams.h"
DEBUG(std::cerr << ...);
DOUT << ...;
DEBUG(std::cerr << ...);
+DEBUG(dump(std::cerr));
DOUT << ...;
+dump(DOUT);
std::cerr << "Hello world\n";
std::cin >> Var;
llvm::cin >> Var;
N/A
llvm::cnull >> Var;
+
    N.B. Eats up argument Var outputting + nothing.
std::ostream
llvm::OStream
void print(std::ostream &Out);
+void print(std::ostream *Out) { if (Out) print(*Out) }
 // ...
-print(*llvm::cerr.stream());