From a20d7d482113a5eba59bd7a51857c9403e75d7fd Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 3 May 2016 09:20:42 -0400 Subject: [PATCH 1/5] Tests: Fix Plugin test include order Fix the order accidentally broken by commit e1c77472 (Format include directive blocks and ordering with clang-format, 2016-04-29). Include the KWSys header first in its own block so that it is not moved by tools that re-order includes. It must be included first to define large file support macros consistently. --- Tests/Plugin/src/example_exe.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx index 393bb680c..fd23e8f3c 100644 --- a/Tests/Plugin/src/example_exe.cxx +++ b/Tests/Plugin/src/example_exe.cxx @@ -1,9 +1,10 @@ +#include + #include #include #include -#include #include #include From 5e871f708907d0d70cf3f0f68da6b9cc617f376e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 2 May 2016 15:09:33 -0400 Subject: [PATCH 2/5] Tests: Sort includes of sys/types.h as clang-format would --- Tests/TestsWorkingDirectory/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/TestsWorkingDirectory/main.c b/Tests/TestsWorkingDirectory/main.c index 3616f8e34..d4b760c2f 100644 --- a/Tests/TestsWorkingDirectory/main.c +++ b/Tests/TestsWorkingDirectory/main.c @@ -38,8 +38,8 @@ static const char* Getcwd(char* buf, unsigned int len) } #else -#include #include +#include #include static const char* Getcwd(char* buf, unsigned int len) From be14fe4857299ccd5918e6b1f8db0f0587db2850 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 2 May 2016 15:03:45 -0400 Subject: [PATCH 3/5] Source: Stabilize include order of sys/types.h before sys/stat.h Include the two headers in an isolated block with a comment separating them so that tools that re-order includes do not re-order these. --- Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 1 + Source/CPack/cmCPackDebGenerator.cxx | 1 + Source/CPack/cmCPackSTGZGenerator.cxx | 4 +++- Source/cmFileCommand.cxx | 4 +++- Source/cmTimestamp.cxx | 3 ++- Source/cmWriteFileCommand.cxx | 1 + Source/cmake.cxx | 3 ++- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index 446ce9639..2833d53df 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -17,6 +17,7 @@ #include #include +// include sys/stat.h after sys/types.h #include cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 9e17bc836..794955f18 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -761,6 +761,7 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( */ #include +// include sys/stat.h after sys/types.h #include #include diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 8a83666fa..4a8754e53 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -18,8 +18,10 @@ #include "cmSystemTools.h" #include "cmake.h" -#include #include + +#include +// include sys/stat.h after sys/types.h #include //---------------------------------------------------------------------- diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 035b97ff9..575051e61 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -28,8 +28,10 @@ #endif #undef GetCurrentDirectory -#include #include + +#include +// include sys/stat.h after sys/types.h #include #include diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 7d1ba3231..b5c9d8e78 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -13,9 +13,10 @@ #include #include +#include #include -#include +// include sys/stat.h after sys/types.h #include //---------------------------------------------------------------------------- diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index d52d6b5d6..c4468f334 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -14,6 +14,7 @@ #include #include +// include sys/stat.h after sys/types.h #include // cmLibraryCommand diff --git a/Source/cmake.cxx b/Source/cmake.cxx index da6e59e36..f176cc10d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -99,11 +99,12 @@ # include "cmGlobalXCodeGenerator.h" # define CMAKE_USE_XCODE 1 # endif -# include # include # include #endif +#include +// include sys/stat.h after sys/types.h #include // struct stat #include From 7b6ffa59b12aaa11f435578cb67e59570bef0453 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 2 May 2016 15:05:39 -0400 Subject: [PATCH 4/5] Source: Sort includes of sys/types.h as clang-format would When this header is included in blocks where order does not matter, just place it in lexicographic order as clang-format would by default. --- Source/CTest/cmCTestGIT.cxx | 2 +- Source/CTest/cmCTestP4.cxx | 2 +- Source/cmGeneratorExpressionEvaluationFile.h | 2 +- Source/cmSystemTools.cxx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 3ff12c18f..19d869c37 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -19,8 +19,8 @@ #include #include -#include #include +#include #include //---------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index f7c960c53..b801cfc16 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -17,8 +17,8 @@ #include #include -#include #include +#include #include //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index f34dadc66..b8c824b6b 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -14,8 +14,8 @@ #include "cmGeneratorExpression.h" -#include #include +#include class cmLocalGenerator; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3177a84f9..68c1eb892 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -42,8 +42,8 @@ // include wincrypt.h after windows.h # include #else -# include # include +# include # include # include # include From 54f71cd72cb6e50ca72004aba80ff1d94f4a6a5a Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 2 May 2016 15:42:32 -0400 Subject: [PATCH 5/5] Source: Sort includes the way clang-format would Re-apply the approach from commit e1c77472 (Format include directive blocks and ordering with clang-format, 2016-04-29) but this time be more careful about exclusion of parser generator sources: $ git ls-files -z -- \ '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' | egrep -z -v '^Source/cmCommandArgumentLexer\.' | egrep -z -v '^Source/cmCommandArgumentParser\.' | egrep -z -v '^Source/cmDependsJavaLexer\.' | egrep -z -v '^Source/cmDependsJavaParser\.' | egrep -z -v '^Source/cmExprLexer\.' | egrep -z -v '^Source/cmExprParser\.' | egrep -z -v '^Source/cmFortranLexer\.' | egrep -z -v '^Source/cmFortranParser\.' | egrep -z -v '^Source/cmListFileLexer\.' | egrep -z -v '^Source/cm_sha2' | egrep -z -v '^Source/(kwsys|CursesDialog/form)/' | egrep -z -v '^Utilities/(KW|cm).*/' | egrep -z -v '^Tests/Module/GenerateExportHeader' | egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' | xargs -0 clang-format -i Also drop use of custom sorting for `sys/types.h`. --- Source/CPack/WiX/cmWIXPatchParser.h | 2 +- Source/cmCommandArgumentParserHelper.cxx | 4 ++-- Source/cmDependsJavaParserHelper.cxx | 2 +- Source/cmExprParserHelper.cxx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h index 42c0787f8..8ce4026ba 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -17,8 +17,8 @@ #include -#include #include +#include struct cmWIXPatchNode { diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 15ab74609..0b2fd81eb 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -11,10 +11,10 @@ ============================================================================*/ #include "cmCommandArgumentParserHelper.h" -#include "cmSystemTools.h" #include "cmMakefile.h" -#include "cmState.h" #include "cmOutputConverter.h" +#include "cmState.h" +#include "cmSystemTools.h" #include "cmCommandArgumentLexer.h" diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 3c0232574..51a1cb4c5 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -11,8 +11,8 @@ ============================================================================*/ #include "cmDependsJavaParserHelper.h" -#include "cmSystemTools.h" #include "cmDependsJavaLexer.h" +#include "cmSystemTools.h" #include int cmDependsJava_yyparse( yyscan_t yyscanner ); diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index 6016c4cce..c5ecde422 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -11,8 +11,8 @@ ============================================================================*/ #include "cmExprParserHelper.h" -#include "cmSystemTools.h" #include "cmMakefile.h" +#include "cmSystemTools.h" #include "cmExprLexer.h"