From f99445facd3750217fc10227c8bd12b22546bf8a Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 23 Aug 2016 20:07:32 +0000 Subject: [PATCH] Update coding standards for include style. Reviewed By: lattner Differential Revision: https://reviews.llvm.org/D23591 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279560 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CodingStandards.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/CodingStandards.rst b/docs/CodingStandards.rst index d9fde5490f8..e14f63525fc 100644 --- a/docs/CodingStandards.rst +++ b/docs/CodingStandards.rst @@ -453,7 +453,7 @@ listed. We prefer these ``#include``\s to be listed in this order: #. 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 dependencies which are not explicitly ``#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 -- 2.11.0