Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | Compiler Coding Style |
| 2 | ===================== |
| 3 | |
| 4 | Coding style for the TurboFan compiler generally follows the Google C++ Style |
| 5 | Guide and the Chromium Coding Style. The notes below are usually just extensions |
| 6 | beyond what the Google style guide already says. If this document doesn't |
| 7 | mention a rule, follow the Google C++ style. |
| 8 | |
| 9 | |
| 10 | TODOs |
| 11 | ----- |
| 12 | We use the following convention for putting TODOs into the code: |
| 13 | |
| 14 | * A TODO(turbofan) implies a performance improvement opportunity. |
| 15 | * A TODO(name) implies an incomplete implementation. |
| 16 | |
| 17 | |
| 18 | Use of C++11 auto keyword |
| 19 | ------------------------- |
| 20 | Use auto to avoid type names that are just clutter. Continue to use manifest |
| 21 | type declarations when it helps readability, and never use auto for anything |
| 22 | but local variables, in particular auto should only be used where it is obvious |
| 23 | from context what the type is: |
| 24 | |
| 25 | for (auto block : x->blocks()) // clearly a Block of some kind |
| 26 | for (auto instr : x->instructions()) // clearly an Instruction of some kind |
| 27 | |
| 28 | for (auto b : x->predecessors()) // less clear, better to make it explicit |
| 29 | for (BasicBlock* b : x->predecessors()) // now clear |