[PATCH] D23591: Update coding standards for include style

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 16:51:49 PDT 2016


zturner created this revision.
zturner added a reviewer: lattner.
zturner added a subscriber: llvm-commits.

Per discussion on lldb-dev mailing list the other day.

https://reviews.llvm.org/D23591

Files:
  docs/CodingStandards.rst

Index: docs/CodingStandards.rst
===================================================================
--- docs/CodingStandards.rst
+++ docs/CodingStandards.rst
@@ -451,7 +451,7 @@
 
 #. Main Module Header
 #. Local/Private Headers
-#. ``llvm/...``
+#. LLVM project/subproject headers (``clang/...``, ``lldb/...``, ``llvm/...``, etc)
 #. System ``#include``\s
 
 and each category should be sorted lexicographically by the full path.
@@ -464,6 +464,16 @@
 ``#include``\d in the header, but should be. It is also a form of documentation
 in the ``.cpp`` file to indicate where the interfaces it implements are defined.
 
+LLVM project and subproject headers should be grouped from most specific to least
+specific, for the same reasons described above.  For example, LLDB depends on
+both clang and LLVM, and clang depends on LLVM.  So an LLDB source file should
+include ``lldb`` headers first, followed by ``clang`` headers, followed by
+``llvm`` headers, to reduce the possibility (for example) of an LLDB header
+accidentally picking up a missing include due to the previous inclusion of that
+header in the main source file or some earlier header file.  clang should
+similarly include its own headers before including llvm headers.  This rule
+applies to all LLVM subprojects.
+
 .. _fit into 80 columns:
 
 Source Code Width


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23591.68287.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160816/e151e5d6/attachment.bin>


More information about the llvm-commits mailing list