From: Bill Wendling Date: Sat, 9 Dec 2006 01:20:34 +0000 (+0000) Subject: Add documentation for how to use the new LLVM streams. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7f564c02cf46e4b29e7d3594036c5535e2f5cc52;p=oota-llvm.git Add documentation for how to use the new LLVM streams. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32390 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index cec26fa67c6..40d08383a83 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -41,12 +41,15 @@
  • #include as Little as Possible
  • Keep "internal" Headers Private
  • +
  • #include <iostream> is + forbidden
  • The Low Level Issues
    1. Assert Liberally
    2. Do not use 'using namespace std'
    3. -
    4. Provide a virtual method anchor for clases in headers
    5. +
    6. Provide a virtual method anchor for + clases in headers
    7. Prefer Preincrement
    8. Avoid std::endl
  • @@ -55,7 +58,8 @@
    -

    Written by Chris Lattner

    +

    Written by Chris Lattner and + Bill Wendling

    @@ -482,6 +486,73 @@ class itself... just make them private (or protected), and all is well.

    + +
    + #include <iostream> is forbidden +
    + +
    + +

    The use of #include <iostream> in library files is +hereby forbidden. The primary reason for doing this is to +support clients using LLVM libraries as part of larger systems. In particular, +we statically link LLVM into some dynamic libraries. Even if LLVM isn't used, +the static c'tors are run whenever an application start up that uses the dynamic +library. There are two problems with this:

    + +
      +
    1. The time to run the static c'tors impacts startup time of + applications—a critical time for gui apps.
    2. +
    3. The static c'tors cause the app to pull many extra pages of memory off the + disk: both the code for the static c'tors in each .o file and the small + amount of data that gets touched. In addition, touched/dirty pages put + more pressure on the VM system on low-memory machines.
    4. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Old WayNew Way
    #include <iostream>
    #include "llvm/Support/Streams.h"
    DEBUG(std::cerr << ...);
    DOUT << ...;
    std::cerr << "Hello world\n";
    llvm::cerr << "Hello world\n";
    std::cout << "Hello world\n";
    llvm::cout << "Hello world\n";
    std::cin >> Var;
    llvm::cin >> Var;
    std::ostream
    llvm::OStream
    std::istream
    llvm::IStream
    std::stringstream
    llvm::StringStream
    + +
    + +
    The Low Level Issues @@ -631,6 +702,7 @@ it's better to use a literal '\n'.

    +
    See Also