[Lldb-commits] [lldb] [lldb][Docs] Document our major differences from the LLVM style (PR #66345)

via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 14 02:12:01 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb
            
<details>
<summary>Changes</summary>
Running:
$ clang-format -i $(find -regex "\./lldb/.*\.c") $(find -regex "\./lldb/.*\.cpp") $(find -regex "\./lldb/.*\.h")

Resulted in:
 1602 files changed, 25090 insertions(+), 25849 deletions(-)
(note: this includes tests which we wouldn't format, just using this as an example)

The vast majority of which were whitespace changes. So as far as formatting we're not deviating from llvm for any reason other than not churning old code.

Formatting aside, the major features of lldb (single line if, early return) are all reflected in llvm's stype. We differ mainly on variable naming (proposed to change in https://llvm.org/docs/Proposals/VariableNames.html anyway) and use of asserts. Which was already documented.
--
Full diff: https://github.com/llvm/llvm-project/pull/66345.diff

1 Files Affected:

- (modified) lldb/docs/resources/contributing.rst (+29-10) 


<pre>
diff --git a/lldb/docs/resources/contributing.rst b/lldb/docs/resources/contributing.rst
index 54917f1ce8175b3..9b133706a7fd160 100644
--- a/lldb/docs/resources/contributing.rst
+++ b/lldb/docs/resources/contributing.rst
@@ -18,19 +18,38 @@ Please refer to the `LLVM Developer Policy
 authoring and uploading a patch. LLDB differs from the LLVM Developer
 Policy in the following respects.
 
- - **Test infrastructure**: Like LLVM it is  important to submit tests with your
-   patches, but note that LLDB uses a different system for tests. Refer to the
-   `test documentation &lt;test.html&gt;`_ for more details and the ``lldb/test``
-   folder on disk for examples.
-
- - **Coding Style**: LLDB&#x27;s code style differs from
-   `LLVM&#x27;s coding style &lt;https://llvm.org/docs/CodingStandards.html&gt;`_.
-   Unfortunately there is no document describing the differences. Please be
-   consistent with the existing code.
-
 For anything not explicitly listed here, assume that LLDB follows the LLVM
 policy.
 
+Coding Style
+++++++++++++
+
+LLDB&#x27;s code style differs from `LLVM&#x27;s coding style &lt;https://llvm.org/docs/CodingStandards.html&gt;`_
+in a few ways. The 2 main ones are:
+
+* `Variable naming &lt;https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly&gt;`_:
+  LLDB prefers variables to be ``named_like_this`` and uses the ``m_`` prefix for
+  member variables.
+
+* `Use of asserts &lt;https://llvm.org/docs/CodingStandards.html#assert-liberally&gt;`_:
+  See the :ref:`section below&lt;Error Handling&gt;`.
+
+For any other contradications please follow the existing code&#x27;s style.
+
+Code in LLDB does aim to conform to clang-format but older code may not yet. As
+always, consider the `golden rule &lt;https://llvm.org/docs/CodingStandards.html#introduction&gt;`_
+when working with such code. Reformatting before starting work is one possible
+option.
+
+Test Infrastructure
++++++++++++++++++++
+
+Like LLVM it is  important to submit tests with your patches, but note that LLDB
+uses a different system for tests. Refer to the `test documentation &lt;test.html&gt;`_
+for more details and the `lldb/test &lt;https://github.com/llvm/llvm-project/tree/main/lldb/test&gt;`_
+folder for examples.
+
+.. _Error handling:
 
 Error handling and use of assertions in LLDB
 --------------------------------------------
</pre>
</details>


https://github.com/llvm/llvm-project/pull/66345


More information about the lldb-commits mailing list