From 6c772ac40b2aa9ac14b64bc4ffec7d8432c87491 Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Thu, 12 Apr 2018 12:23:20 -0700 Subject: [PATCH] [flang] Improve include file sorting. Includes like "../dir/file.h" should sort after local includes. This change fixes that and applies the new formatting. Now the order (in reverse) is: - system includes - includes from llvm or clang (this is from the default IncludeCategories) - includes of ../something - everything else Original-commit: flang-compiler/f18@324643d63a1842ddfea9ea2a70ebb363f9ced8cc Reviewed-on: https://github.com/flang-compiler/f18/pull/52 --- flang/.clang-format | 9 +++++++++ flang/lib/semantics/LabelTable.h | 2 +- flang/lib/semantics/ParseTreeDump.h | 5 ++--- flang/lib/semantics/attr.cc | 2 +- flang/lib/semantics/attr.h | 2 +- flang/lib/semantics/make-types.cc | 1 - flang/lib/semantics/resolve-names.cc | 6 +++--- flang/lib/semantics/scope.h | 4 ++-- flang/lib/semantics/symbol.cc | 2 +- flang/lib/semantics/type.h | 2 +- flang/tools/f18/f18.cc | 8 ++++---- flang/tools/f18/test-sema.cc | 2 +- 12 files changed, 26 insertions(+), 19 deletions(-) diff --git a/flang/.clang-format b/flang/.clang-format index 1a7f13d..f622194 100644 --- a/flang/.clang-format +++ b/flang/.clang-format @@ -12,6 +12,15 @@ AlignTrailingComments: false ConstructorInitializerIndentWidth: 2 SpaceAfterTemplateKeyword: false SpacesBeforeTrailingComments: 2 +IncludeCategories: + - Regex: '^<' + Priority: 4 + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 3 + - Regex: '^"\.\./' + Priority: 2 + - Regex: '.*' + Priority: 1 ... # vim:set filetype=yaml: diff --git a/flang/lib/semantics/LabelTable.h b/flang/lib/semantics/LabelTable.h index 0c3fd8f..f27d2fd 100644 --- a/flang/lib/semantics/LabelTable.h +++ b/flang/lib/semantics/LabelTable.h @@ -1,8 +1,8 @@ #ifndef FORTRAN_LABEL_TABLE_H_ #define FORTRAN_LABEL_TABLE_H_ -#include #include +#include namespace Fortran::semantics { diff --git a/flang/lib/semantics/ParseTreeDump.h b/flang/lib/semantics/ParseTreeDump.h index 8c19d27..949ccce 100644 --- a/flang/lib/semantics/ParseTreeDump.h +++ b/flang/lib/semantics/ParseTreeDump.h @@ -7,11 +7,10 @@ #include "../parser/parse-tree-visitor.h" #include "../parser/parse-tree.h" - -#include #include -#include #include +#include +#include namespace Fortran::semantics { diff --git a/flang/lib/semantics/attr.cc b/flang/lib/semantics/attr.cc index d926c87..a3babe8 100644 --- a/flang/lib/semantics/attr.cc +++ b/flang/lib/semantics/attr.cc @@ -1,5 +1,5 @@ -#include "../parser/idioms.h" #include "attr.h" +#include "../parser/idioms.h" #include namespace Fortran { diff --git a/flang/lib/semantics/attr.h b/flang/lib/semantics/attr.h index 074fed7..456dec1 100644 --- a/flang/lib/semantics/attr.h +++ b/flang/lib/semantics/attr.h @@ -1,8 +1,8 @@ #ifndef FORTRAN_ATTR_H_ #define FORTRAN_ATTR_H_ -#include "../parser/idioms.h" #include "enum-set.h" +#include "../parser/idioms.h" #include #include #include diff --git a/flang/lib/semantics/make-types.cc b/flang/lib/semantics/make-types.cc index a4c05c8..9cf190b 100644 --- a/flang/lib/semantics/make-types.cc +++ b/flang/lib/semantics/make-types.cc @@ -1,7 +1,6 @@ #include "make-types.h" #include "attr.h" #include "type.h" - #include "../parser/idioms.h" #include "../parser/parse-tree-visitor.h" #include "../parser/parse-tree.h" diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc index c9f4f96..4dae821 100644 --- a/flang/lib/semantics/resolve-names.cc +++ b/flang/lib/semantics/resolve-names.cc @@ -1,10 +1,10 @@ -#include "../parser/indirection.h" -#include "../parser/parse-tree-visitor.h" -#include "../parser/parse-tree.h" #include "attr.h" #include "scope.h" #include "symbol.h" #include "type.h" +#include "../parser/indirection.h" +#include "../parser/parse-tree-visitor.h" +#include "../parser/parse-tree.h" #include #include #include diff --git a/flang/lib/semantics/scope.h b/flang/lib/semantics/scope.h index f40002d..fcecc36 100644 --- a/flang/lib/semantics/scope.h +++ b/flang/lib/semantics/scope.h @@ -1,10 +1,10 @@ #ifndef FORTRAN_SEMANTICS_SCOPE_H_ #define FORTRAN_SEMANTICS_SCOPE_H_ -#include "../parser/idioms.h" -#include "../parser/parse-tree.h" #include "attr.h" #include "symbol.h" +#include "../parser/idioms.h" +#include "../parser/parse-tree.h" #include #include #include diff --git a/flang/lib/semantics/symbol.cc b/flang/lib/semantics/symbol.cc index bd25699..7217cd0 100644 --- a/flang/lib/semantics/symbol.cc +++ b/flang/lib/semantics/symbol.cc @@ -1,6 +1,6 @@ #include "symbol.h" -#include "../parser/idioms.h" #include "scope.h" +#include "../parser/idioms.h" #include namespace Fortran::semantics { diff --git a/flang/lib/semantics/type.h b/flang/lib/semantics/type.h index 62aedd5..84c6163 100644 --- a/flang/lib/semantics/type.h +++ b/flang/lib/semantics/type.h @@ -1,9 +1,9 @@ #ifndef FORTRAN_TYPE_H_ #define FORTRAN_TYPE_H_ +#include "attr.h" #include "../parser/idioms.h" #include "../parser/parse-tree.h" -#include "attr.h" #include #include #include diff --git a/flang/tools/f18/f18.cc b/flang/tools/f18/f18.cc index 2089443..fec8f67 100644 --- a/flang/tools/f18/f18.cc +++ b/flang/tools/f18/f18.cc @@ -2,8 +2,8 @@ #include "../../lib/parser/characters.h" #include "../../lib/parser/message.h" -#include "../../lib/parser/parse-tree.h" #include "../../lib/parser/parse-tree-visitor.h" +#include "../../lib/parser/parse-tree.h" #include "../../lib/parser/parsing.h" #include "../../lib/parser/provenance.h" #include "../../lib/parser/unparse.h" @@ -15,11 +15,11 @@ #include #include #include -#include -#include #include -#include +#include #include +#include +#include static std::list argList(int argc, char *const argv[]) { std::list result; diff --git a/flang/tools/f18/test-sema.cc b/flang/tools/f18/test-sema.cc index 1ec522a..f1e4081 100644 --- a/flang/tools/f18/test-sema.cc +++ b/flang/tools/f18/test-sema.cc @@ -6,8 +6,8 @@ #include #include #include -#include #include +#include using namespace Fortran; using namespace parser; -- 2.7.4