diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index 8d460009457..2068c0f2c5a 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -631,7 +631,7 @@ be a big understandability win.
It is very common to write inline functions that just compute a boolean +
It is very common to write small loops that just compute a boolean value. There are a number of ways that people commonly write these, but an example of this sort of thing is:
@@ -653,8 +653,8 @@ be a big understandability win.This sort of code is awkward to write, and is almost always a bad sign. Instead of this sort of loop, we strongly prefer to use a predicate function (which may be static) that uses -early exits to compute the predicate. Code like -this would be preferred: +early exits to compute the predicate. We prefer +the code to be structured like this:
@@ -1050,21 +1050,27 @@ example:-/// SomeCrazyThing - This namespace contains flags for ... -namespace SomeCrazyThing { - enum foo { - /// X - This is the X flag, which is ... - X = 1, - - /// Y - This is the Y flag, which is ... - Y = 2, - - /// Z - This is the Z flag, which is ... - Z = 4, - - /// ALL_FLAGS - This is the union of all flags. - ALL_FLAGS = 7 - }; +namespace llvm { + namespace X86 { + /// RelocationType - An enum for the x86 relocation codes. Note that + /// the terminology here doesn't follow x86 convention - word means + /// 32-bit and dword means 64-bit. + enum RelocationType { + /// reloc_pcrel_word - PC relative relocation, add the relocated value to + /// the value already in memory, after we adjust it for where the PC is. + reloc_pcrel_word = 0, + + /// reloc_picrel_word - PIC base relative relocation, add the relocated + /// value to the value already in memory, after we adjust it for where the + /// PIC base is. + reloc_picrel_word = 1, + + /// reloc_absolute_word, reloc_absolute_dword - Absolute relocation, just + /// add the relocated value to the value already in memory. + reloc_absolute_word = 2, + reloc_absolute_dword = 3 + }; + } }
A common topic after talking about namespaces is anonymous namespaces. +
After talking about namespaces in general, you may be wondering about +anonymous namespaces in particular. Anonymous namespaces are a great language feature that tells the C++ compiler that the contents of the namespace are only visible within the current translation unit, allowing more aggressive optimization and eliminating the @@ -1186,7 +1193,7 @@ bool StringSort::operator<(const char *RHS) const { of a large C++ file, that you have no immediate way to tell if it is local to the file. When it is marked static explicitly, this is immediately obvious. Also, there is no reason to enclose the definition of "operator<" in the -namespace since it was declared there. +namespace just because it was declared there.