|
| 1 | +--- |
| 2 | +applyTo: lldb/**/* |
| 3 | +--- |
| 4 | + |
| 5 | +When reviewing code, focus on: |
| 6 | + |
| 7 | +## Language, Libraries & Standards |
| 8 | + |
| 9 | +- Target C++17 and avoid vendor-specific extensions. |
| 10 | +- For Python scripts, follow PEP 8. |
| 11 | +- Prefer standard library or LLVM support libraries instead of reinventing data structures. |
| 12 | + |
| 13 | +## Comments & Documentation |
| 14 | + |
| 15 | +- Each source file should include the standard LLVM file header. |
| 16 | +- Header files must have proper header guards. |
| 17 | +- Non-trivial classes and public methods should have Doxygen documentation. |
| 18 | +- Use `//` or `///` comments normally; avoid block comments unless necessary. |
| 19 | +- Non-trivial code should have comments explaining what it does and why. Avoid comments that explain how it does it at a micro level. |
| 20 | + |
| 21 | +## Language & Compiler Issues |
| 22 | + |
| 23 | +- Write portable code; wrap non-portable code in interfaces. |
| 24 | +- Do not use RTTI or exceptions. |
| 25 | +- Prefer C++-style casts over C-style casts. |
| 26 | +- Do not use static constructors. |
| 27 | +- Use `class` or `struct` consistently; `struct` only for all-public data. |
| 28 | +- When then same class is declared or defined multiple times, make sure it's consistently done using either `class` or `struct`. |
| 29 | + |
| 30 | +## Headers & Library Layering |
| 31 | + |
| 32 | +- Include order: module header → local/private headers → project headers → system headers. |
| 33 | +- Headers must compile standalone (include all dependencies). |
| 34 | +- Maintain proper library layering; avoid circular dependencies. |
| 35 | +- Include minimally; use forward declarations where possible. |
| 36 | +- Keep internal headers private to modules. |
| 37 | +- Use full namespace qualifiers for out-of-line definitions. |
| 38 | + |
| 39 | +## Control Flow & Structure |
| 40 | + |
| 41 | +- Prefer early exits over deep nesting. |
| 42 | +- Do not use `else` after `return`, `continue`, `break`, or `goto`. |
| 43 | +- Encapsulate loops that compute predicates into helper functions. |
| 44 | + |
| 45 | +## Naming |
| 46 | + |
| 47 | +- LLDB's code style differs from LLVM's coding style. |
| 48 | +- Variables are `snake_case`. |
| 49 | +- Functions and methods are `UpperCamelCase`. |
| 50 | +- Static, global and member variables have `s_`, `g_` and `m_` prefixes respectively. |
| 51 | + |
| 52 | +## General Guidelines |
| 53 | + |
| 54 | +- Use `assert` liberally; prefer `llvm_unreachable` for unreachable states. |
| 55 | +- Do not use `using namespace std;` in headers. |
| 56 | +- Provide a virtual method anchor for classes defined in headers. |
| 57 | +- Do not use default labels in fully covered switches over enumerations. |
| 58 | +- Use range-based for loops wherever possible. |
| 59 | +- Capture `end()` outside loops if not using range-based iteration. |
| 60 | +- Including `<iostream>` is forbidded. Use LLVM’s `raw_ostream` instead. |
| 61 | +- Don’t use `inline` when defining a function in a class definition. |
| 62 | + |
| 63 | +## Microscopic Details |
| 64 | + |
| 65 | +- Preserve existing style in modified code. |
| 66 | +- Prefer pre-increment (`++i`) when value is unused. |
| 67 | +- Use `private`, `protected`, or `public` keyword as appropriate to restrict class member visibility. |
| 68 | +- Omit braces for single-statement `if`, `else`, `while`, `for` unless needed. |
| 69 | + |
| 70 | +## Review Style |
| 71 | + |
| 72 | +- Be specific and actionable in feedback. |
| 73 | +- Explain the "why" behind recommendations. |
| 74 | +- Link back to the LLVM Coding Standards: https://llvm.org/docs/CodingStandards.html. |
| 75 | +- Ask clarifying questions when code intent is unclear. |
| 76 | + |
| 77 | +Ignore formatting and assume that's handled by external tools like `clang-format` and `black`. |
| 78 | +Remember that these standards are **guidelines**. |
| 79 | +Always prioritize consistency with the style that is already being used by the surrounding code. |
0 commit comments