X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FCodingStandards.html;h=8566e670f20b0f150cbb25d6dd1b149167f7cf5c;hb=3d87b42bf98f630c07733dc15c143c0653095331;hp=489e47694c7b9f0b63b35b3799d8c014ae0e834b;hpb=a9a090b483d1909638417e89a3015c685540618f;p=oota-llvm.git diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index 489e47694c7..8566e670f20 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -37,6 +37,7 @@
  1. Assert Liberally
  2. Prefer Preincrement +
  3. Avoid endl
  4. Exploit C++ to its Fullest
  • Writing Iterators @@ -262,7 +263,7 @@ To further assist with debugging, make sure to put some kind of error message in
       inline Value *getOperand(unsigned i) { 
    -    assert(i < Operands.size() && "getOperand() out of range!");
    +    assert(i < Operands.size() && "getOperand() out of range!");
         return Operands[i]; 
       }
     
    @@ -270,15 +271,15 @@ To further assist with debugging, make sure to put some kind of error message in Here are some examples:
    -  assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
    +  assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
     
       assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
     
    -  assert(idx < getNumSuccessors() && "Successor # out of range!");
    +  assert(idx < getNumSuccessors() && "Successor # out of range!");
     
       assert(V1.getType() == V2.getType() && "Constant types must be identical!");
     
    -  assert(Succ->front()->isPHINode() && "Only works on PHId BBs!");
    +  assert(isa<PHINode>(Succ->front()) && "Only works on PHId BBs!");
     

    You get the idea...

    @@ -292,6 +293,19 @@ Hard fast rule: Preincrement (++X) may be no slower than postincrement (X++) and The semantics of postincrement include making a copy of the value being incremented, returning it, and then preincrementing the "work value". For primitive types, this isn't a big deal... but for iterators, it can be a huge issue (for example, some iterators contains stack and set objects in them... copying an iterator could invoke the copy ctor's of these as well). In general, get in the habit of always using preincrement, and you won't have a problem.

    + +


    Avoid endl


    Exploit C++ to its Fullest