[llvm] r279560 - Update coding standards for include style.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 23 13:07:32 PDT 2016


Author: zturner
Date: Tue Aug 23 15:07:32 2016
New Revision: 279560

URL: http://llvm.org/viewvc/llvm-project?rev=279560&view=rev
Log:
Update coding standards for include style.

Reviewed By: lattner
Differential Revision: https://reviews.llvm.org/D23591

Modified:
    llvm/trunk/docs/CodingStandards.rst

Modified: llvm/trunk/docs/CodingStandards.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodingStandards.rst?rev=279560&r1=279559&r2=279560&view=diff
==============================================================================
--- llvm/trunk/docs/CodingStandards.rst (original)
+++ llvm/trunk/docs/CodingStandards.rst Tue Aug 23 15:07:32 2016
@@ -453,7 +453,7 @@ listed.  We prefer these ``#include``\s
 
 #. 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.
@@ -466,6 +466,16 @@ that the header does not have any hidden
 ``#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




More information about the llvm-commits mailing list