[llvm-commits] CVS: llvm/docs/CodingStandards.html
Bill Wendling
isanbard at gmail.com
Sun Dec 17 03:40:55 PST 2006
Changes in directory llvm/docs:
CodingStandards.html updated: 1.32 -> 1.33
---
Log message:
Added example of how to code print() methods so that they will disappear
from the code if "cnull" is passed into them.
---
Diffs of the changes: (+19 -6)
CodingStandards.html | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
Index: llvm/docs/CodingStandards.html
diff -u llvm/docs/CodingStandards.html:1.32 llvm/docs/CodingStandards.html:1.33
--- llvm/docs/CodingStandards.html:1.32 Fri Dec 8 19:35:43 2006
+++ llvm/docs/CodingStandards.html Sun Dec 17 05:40:40 2006
@@ -509,7 +509,7 @@
more pressure on the VM system on low-memory machines.</li>
</ol>
-<table>
+<table align="center">
<tbody>
<tr>
<th>Old Way</th>
@@ -520,8 +520,10 @@
<td align="left"><pre>#include "llvm/Support/Streams.h"</pre></td>
</tr>
<tr>
- <td align="left"><pre>DEBUG(std::cerr << ...);</pre></td>
- <td align="left"><pre>DOUT << ...;</pre></td>
+ <td align="left"><pre>DEBUG(std::cerr << ...);
+DEBUG(dump(std::cerr));</pre></td>
+ <td align="left"><pre>DOUT << ...;
+dump(DOUT);</pre></td>
</tr>
<tr>
<td align="left"><pre>std::cerr << "Hello world\n";</pre></td>
@@ -536,6 +538,12 @@
<td align="left"><pre>llvm::cin >> Var;</pre></td>
</tr>
<tr>
+ <td align="left"><em>N/A</em></td>
+ <td align="left"><pre>llvm::cnull >> Var;</pre>
+ <ul><i>N.B.</i> Eats up argument <tt>Var</tt> outputting
+ nothing.</ul></td>
+ </tr>
+ <tr>
<td align="left"><pre>std::ostream</pre></td>
<td align="left"><pre>llvm::OStream</pre></td>
</tr>
@@ -552,9 +560,14 @@
// ...
print(std::cerr);</pre></td>
<td align="left"><pre>void print(std::ostream &Out);
+void print(std::ostream *Out) { if (Out) print(*Out) }
// ...
-print(*llvm::cerr.stream());</pre></td>
- </tbody>
+print(llvm::cerr);</pre>
+
+<ul><i>N.B.</i> The second <tt>print</tt> method is called by the <tt>print</tt>
+expression. It prevents the execution of the first <tt>print</tt> method if the
+stream is <tt>cnull</tt>.</ul></td>
+ </tbody>
</table>
</div>
@@ -752,7 +765,7 @@
<a href="mailto:sabre at nondot.org">Chris Lattner</a><br>
<a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
- Last modified: $Date: 2006/12/09 01:35:43 $
+ Last modified: $Date: 2006/12/17 11:40:40 $
</address>
</body>
More information about the llvm-commits
mailing list