Commit Graph

48 Commits

Author SHA1 Message Date
Kitware Robot d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Brad King 0ac18d40c8 Remove `//------...` horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King 64b5520346 Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.

Find blocks of the form

    os <<
      "...\n"
      "...\n"
      ;

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'

Find blocks of the form

    os << "...\n"
       << "...\n"
       << "...\n";

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'

Surround such blocks with the pair

    /* clang-format off */
    ...
    /* clang-format on */

in order to protect them from update by clang-format.  Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
2016-05-06 14:25:55 -04:00
Brad King e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      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

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Brad King 180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Brad King 2fd5fd1f4d Merge topic 'minor-cleanups'
13a37f5f cmMakefile: Fix typo in comment
958508bb cmMakefile: Fix style
91a829c1 Makefiles: Remove unused variable
e0213882 cmTarget: Remove obsolete member
0554c2c9 cmTarget: Fix style
b22e5d0a Remove some obsolete declarations
ce43ed2c Use LocalGenerator when possible
d90c9738 Makefiles: Remove some unneeded casts
331023ae Export: Remove unused variable
a03f3d0e cmFunctionBlocker: Constify method
d50c4220 Xcode: Fix typo in comment
803f1901 Xcode: Remove trailing semicolon
2015-10-28 08:48:08 -04:00
Stephen Kelly b22e5d0ab7 Remove some obsolete declarations
Ensure that cmStandardIncludes.h is included before any platform header
in cmGeneratorExpressionEvaluator.h.  That file needs to change as
a result of removal of the cmMakefile.h header from
cmGeneratorExpressionNode.h, affecting the compilation of
cmGeneratorExpressionNode.cxx.

On AIX we need to include our own headers first to get large file
support macros defined consistently within system headers.  The old
order in this header worked only because it was always included after
other headers.
2015-10-27 21:52:47 +01:00
Stephen Kelly b397eae82e cmGeneratorTarget: Move LinkLanguagePropagatesToDependents from cmTarget 2015-10-27 07:44:21 +01:00
Stephen Kelly 4c6374bcc5 Genex: use cmGeneratorTarget policy API 2015-10-27 07:44:21 +01:00
Stephen Kelly 7d409f500e cmLocalGenerator: Add GetPolicyStatus API 2015-10-27 07:44:21 +01:00
Stephen Kelly 6d94078e62 cmGeneratorTarget: Move IsDLLPlatform from cmTarget. 2015-10-21 00:52:22 +02:00
Stephen Kelly 8e20ea6ef2 cmGeneratorTarget: Move IsLinkable from cmTarget. 2015-10-19 20:27:40 +02:00
Stephen Kelly fb4fca0b5e cmGeneratorTarget: Access global state through LocalGenerator. 2015-10-16 20:24:43 +02:00
Brad King dfd371dc01 Merge topic 'genex-consumers-generator-targets'
c4ae1578 Genex: Port some access API to cmGeneratorTarget.
6d27a3db Genex: Port implementation to cmGeneratorTarget.
2015-10-16 09:35:37 -04:00
Stephen Kelly c4ae157865 Genex: Port some access API to cmGeneratorTarget. 2015-10-15 22:40:56 +02:00
Stephen Kelly 6d27a3dbfb Genex: Port implementation to cmGeneratorTarget. 2015-10-15 22:40:55 +02:00
Stephen Kelly 38df5c36d6 Remove now-obsolete casts. 2015-10-15 00:41:40 +02:00
Stephen Kelly eac15298a8 cmState: Move TargetType enum from cmTarget.
Mostly automated:

 values=( "EXECUTABLE" "STATIC_LIBRARY" "SHARED_LIBRARY" "MODULE_LIBRARY" "OBJECT_LIBRARY" "UTILITY" "GLOBAL_TARGET" "INTERFACE_LIBRARY" "UNKNOWN_LIBRARY" "TargetType")
 for i in "${values[@]}"; do     git grep -l cmTarget::$i | xargs sed -i "s|cmTarget::$i|cmState::$i|g"; done
2015-10-15 00:41:39 +02:00
Stephen Kelly 983c00f8f9 Generators: Use GetType from the cmGeneratorTarget. 2015-10-15 00:41:19 +02:00
Stephen Kelly 2293d43d00 cmLocalGenerator: Store cmGeneratorTargets.
Relieve cmMakefile of this responsibility.
2015-10-14 13:32:09 -04:00
Stephen Kelly 1583440509 cmGeneratorExpression: Port interface to cmGeneratorTarget. 2015-10-12 23:07:46 +02:00
Stephen Kelly 11165525ba cmGeneratorExpression: Port to cmLocalGenerator. 2015-10-12 23:07:46 +02:00
Stephen Kelly 1fdccff589 Genex: Port implementation detail to cmGeneratorTarget. 2015-10-12 18:39:59 +02:00
Stephen Kelly 526cc7dc52 cmGeneratorTarget: Move HasImportLibrary from cmTarget. 2015-10-12 18:39:59 +02:00
Stephen Kelly ceb35b63a7 cmLinkItem: Port to cmGeneratorTarget. 2015-10-12 18:39:58 +02:00
Stephen Kelly f539da126b cmGeneratorTarget: Port GetLinkInterfaceLibraries away from cmTarget. 2015-10-10 11:14:31 +02:00
Stephen Kelly 50dc9b4440 cmGeneratorTarget: Move GetPDBDirectory from cmTarget. 2015-10-09 01:04:37 +02:00
Stephen Kelly 8b0168863e cmGeneratorTarget: Move GetDirectory from cmTarget. 2015-10-09 01:04:37 +02:00
Stephen Kelly df42dbb355 cmGeneratorTarget: Move link implementation from cmTarget. 2015-10-08 23:41:29 +02:00
Stefan Kislinskiy ca6ba3fee5 Genex: Add a SHELL_PATH expression
Some commands on Windows do not understand forward slash paths and
require backslashes.  In order to help projects generate shell
invocations of such commands, provide a generator expression to convert
paths to the shell-preferred path format for the current generator.
This will allow custom commands to generate paths the same way CMake
does for compiler command invocations.
2015-09-28 10:37:33 -04:00
Stephen Kelly 0db9d92787 cmGeneratorTarget: Move GetLinkInterfaceLibraries from cmTarget. 2015-08-26 19:38:37 +02:00
Stephen Kelly d67584ccc4 cmTarget: Move link interface libraries struct out. 2015-08-26 19:35:45 +02:00
Brad King 6e5953e9a4 Merge topic 'use-generator-target'
29886ce7 cmTarget: Use a simpler delete algorithm.
197f4de1 cmTarget: Split storage of compile definitions from genexes.
44e071ae cmTarget: Split storage of compile features from genexes.
772ecef4 cmTarget: Split storage of compile options from genexes.
1f54bc1c cmTarget: Split storage of include directories from genexes.
7568199b cmTarget: Request only the link libraries where needed.
10040601 cmLinkImplementationLibraries: Move to namespace scope.
d9da6ee2 cmLinkItem: Split to separate file.
27252b24 cmComputeLinkInformation: Simplify generator object access.
2015-08-11 08:47:08 -04:00
Stephen Kelly 10040601a2 cmLinkImplementationLibraries: Move to namespace scope. 2015-08-07 00:51:49 +02:00
Brad King 35aab9df9f Reject TARGET_PDB_FILE for imported targets instead of crashing
Reported-by: Justin Borodinsky <justin.borodinsky@gmail.com>
2015-08-06 09:42:31 -04:00
Stephen Kelly 7c809fa2a6 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 2015-08-05 18:20:48 +02:00
Stephen Kelly 3df705681b cmGeneratorTarget: Move GetPDBName from cmTarget. 2015-08-05 18:20:46 +02:00
Stephen Kelly 5ff813c7a6 cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. 2015-08-05 18:20:45 +02:00
Stephen Kelly 244c5b5dcd cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. 2015-08-05 18:20:44 +02:00
Stephen Kelly 41abdc17df cmGeneratorTarget: Move GetSOName from cmTarget.. 2015-08-05 18:20:43 +02:00
Stephen Kelly a034dc0df4 cmGeneratorExpressionNode: Remove unused variable. 2015-07-28 20:07:46 +02:00
Stephen Kelly ec38e4c84f Move GetFullPath to cmGeneratorTarget 2015-07-27 21:59:02 +02:00
Stephen Kelly fc1c7cf85d Genex: Store a backtrace, not a pointer to one.
The storage of a pointer means that the ownership and lifetime are
externally determined, which is harder to reason about. It also imposes
API constraints, requiring APIs to return references to backtraces.

This pointer storage was introduced in commit v3.1.0-rc1~425^2~3 (genex:
remove the need for backtraces, 2014-05-23).  As backtraces are now cheap
to copy around, just do that instead.
2015-07-17 22:14:37 +02:00
Brad King 2c5a1bff23 Merge topic 'refactor-cmPolicies'
013ada80 cmPolicies: Implement PolicyMap in terms of bitset.
be6664c2 cmPolicies: Implement abstraction for PolicyMap.
de211686 Port to static cmPolicies API.
13981f20 cmPolicies: Make all API static.
23e2bcc8 cmPolicies: Remove unused DefinePolicy method.
5641ba4f cmPolicies: Remove unused cmPolicy class.
3de54497 cmPolicies: Loop over all policies using enum constants.
387aff20 cmPolicies: Trivialize GetPolicyStatus method.
dbf680d6 cmPolicies: Use more-direct ID access.
8c204133 cmPolicies: Implement in terms of public API.
e3a8c029 cmPolicies: Make private method file-static.
cb765af0 cmPolicies: Implement short description access with XMacros.
5df267fa cmPolicies: Implement version check with XMacro.
2235cfeb cmPolicies: Implement id to version with XMacro.
05d84388 cmPolicies: Implement id to string conversion with XMacro.
6eaade8a cmPolicies: Introduce XMacro table for policy data.
...
2015-05-05 09:35:30 -04:00
Stephen Kelly de21168612 Port to static cmPolicies API. 2015-05-04 22:32:20 +02:00
Stephen Kelly a0836ed978 Port to cmMakefile::GetGlobalGenerator. 2015-05-03 11:42:00 +02:00
Stephen Kelly 199b28ac3a Remove duplicate tag name. 2015-04-04 18:30:52 +02:00
Stephen Kelly 9df1f0fce1 Genex: Split cmGeneratorExpressionNode into own file. 2015-03-11 00:12:56 +01:00