Commit Graph

95 Commits

Author SHA1 Message Date
Brad King f1ad71d7f8 cmMakefile: Restore nested error logic use of cmExecutionStatus
Since commit 14a8d61f (cmMakefile: Port nested error logic away from
cmExecutionStatus) we fail to continue processing function and macro
bodies after non-fatal errors.  A non-fatal error should not stop
foreach loops, macro bodies, nested bodies, or the outer script.
Add a test covering these cases, and revert the change to fix them.

Also revert commit 2af853de (cmMakefile: Simplify IssueMessage
implementation) because the assertion it added (which was removed by the
above commit and is restored by reverting it) is incorrect.  We do have
code paths that call cmMakefile::IssueMessage with an empty execution
stack, such as in CheckForUnusedVariables's LogUnused call.
2016-09-06 16:20:39 -04:00
Stephen Kelly 14a8d61fd4 cmMakefile: Port nested error logic away from cmExecutionStatus
It is no longer needed.
2016-08-25 09:47:26 -04:00
Daniel Pfeifer a7a9239096 mark functions with CM_OVERRIDE 2016-06-27 23:24:38 +02:00
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 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
Milian Wolff ad9394f4fd Remove temporary allocations in cmMacroHelper::InvokeInitialPass.
This code used to convert std::string's to raw C strings only to
put that back into a std::string. This patch thus removes ~70k
temporary allocations when running the CMake daemon on KDevelop.

This hotspot was found with heaptrack.
2016-01-20 21:20:55 +01:00
Stephen Kelly 8ea0b81d20 cmAlgorithms: Rename cmRange to cmMakeRange. 2015-07-22 10:58:19 -04:00
Stephen Kelly 41bb831fc9 cmMakefile: Remove special handling of MACROS property. 2015-07-19 16:01:39 +02:00
Stephen Kelly 238aac2351 cmListFile: Remove FilePath member from cmListFileContext.
There is no need to store the FilePath for every function, as it is
known by other means.
2015-07-06 11:22:41 -04:00
Stephen Kelly 6361f68056 cmState: Store execution context.
Extend snapshot creation API to store the file being executed and the
entry point to get to that context.
2015-07-06 01:37:15 +02:00
Stephen Kelly 782657db48 cmListFileArgument: Remove FilePath member.
It is now unused.
2015-06-21 20:57:26 +02:00
Stephen Kelly 076760a63c cmMakefile: Add filename context to ExpandArguments.
The cmListFileArgument currently stores a FilePath for use in this
method.  The filename is the same as the CMAKE_CURRENT_LIST_FILE,
except if executing a macro or function defined in another file.

Set the context filename when expanding the arguments of macros and
functions using the filename recorded when defining the prototype.
2015-06-21 20:57:25 +02:00
Stephen Kelly f971ab04cf cmMacroCommand: Store the FilePath when creating the prototype.
Instead of setting it each time the macro is invoked.
2015-06-21 20:31:27 +02:00
Stephen Kelly ca140c2e89 cmMakefile: Create a unified raii for macro scopes. 2015-06-04 22:08:23 +02:00
Stephen Kelly 0aec491328 Port cmCommand consumers to cmState. 2015-04-15 11:43:49 -04:00
Stephen Kelly 7916d7bac6 Include cmAlgorithms where it is used. 2015-03-11 00:17:29 +01:00
Stephen Kelly c021f59c1f cmMakefile: Store macro list in a vector not in a map.
The signature was computed (incorrectly) and stored as the map
value, but never used.  Remove it now.
2015-02-21 11:25:47 +01:00
Stephen Kelly b5f98e5012 cmMacroCommand: Manipulate target string directly.
Avoid copying a string from the source, manipulating it, and then
copying it back.  Manipulate it in place instead.
2015-02-11 22:58:34 +01:00
Stephen Kelly 83414d5a07 cmMacroCommand: Move computation of ARGV%n names out of double loop. 2015-02-11 22:58:34 +01:00
Stephen Kelly 9a1f8f35f4 cmMacroCommand: Move ARGV replacement out of condition. 2015-02-11 22:58:34 +01:00
Stephen Kelly 4aa7bd2ac1 cmMacroCommand: Remove condition around ARGN replacement.
There is none for ARGC replacement, so no reason to conditionalize the
replacement.  The computation is already done.
2015-02-11 22:58:34 +01:00
Stephen Kelly 6774c92b58 cmMacroCommand: Declare tmps in the scope that it's used.
We don't particularly need to reuse the string memory here, and this
pattern is not common in CMake.
2015-02-11 22:58:34 +01:00
Stephen Kelly 2c4a7298fc cmMacroCommand: Declare arg in the scope that it is used.
It can make sense to declare objects outside of loops if
the size required by the object can grow (eg std::string when
using getline), but that is not the case here.
2015-02-11 22:58:34 +01:00
Stephen Kelly a551851ab3 cmMacroCommand: Inline variable computation. 2015-02-11 22:58:33 +01:00
Stephen Kelly f79c0f7697 cmMacroCommand: Compute variables outside of two loops.
Avoid computing them from scratch for each argument of each
function.
2015-02-11 22:58:33 +01:00
Stephen Kelly 8e0827b646 cmMacroCommand: Remove intermediate arg variables. 2015-02-11 22:58:33 +01:00
Stephen Kelly f2c49f59d8 cmMacroCommand: Remove condition around ARGN computation.
An empty string is appended if the condition is false, which is
ok for this commit.
2015-02-11 22:58:33 +01:00
Stephen Kelly 3250a7e535 cmMacroCommand: Remove conditional append of semicolon.
The conditions are never true.
2015-02-11 22:58:33 +01:00
Stephen Kelly 081a13f7c0 cmMacroCommand: Declare arg variables where used and initialized.
Make the initialization by population with the expanded* content
unconditional.
2015-02-11 22:58:33 +01:00
Stephen Kelly 17b5ebd383 cmMacroCommand: Join the args strings outside of the loops.
This means that we compute the strings even if not used in the macro
but this shouldn't be expensive and it simplifies the code.
2015-02-11 22:58:31 +01:00
Stephen Kelly 9380e85f86 Convert loops to cmJoin algorithm with cmRange. 2015-02-11 22:58:04 +01:00
Stephen Kelly 8910224950 Replace common loop pattern with cmJoin 2015-02-11 22:57:55 +01:00
Stephen Kelly 7b8725bf84 Convert loops populating maybe-empty content into the common pattern. 2015-02-11 22:57:53 +01:00
Stephen Kelly 0a4e5674ec cmMacroCommand: Remove counting variable.
Start iteration at correct starting point directly.
2015-02-11 22:57:38 +01:00
Stephen Kelly 11ecc31d0a cmMacroCommand: Execute loop only if it has an effect. 2015-02-11 20:51:06 +01:00
Stephen Kelly f95543f8a6 cmMacroCommand: Extract iteration starting point. 2015-02-11 20:51:06 +01:00
Stephen Kelly 9fe8f49353 cmMacroCommand: Replace a loop with cmJoin. 2015-02-11 20:51:06 +01:00
Stephen Kelly fd7b371293 Replace foo.size() pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly d92887efab Replace 'foo.size() > 0' pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Brad King b5a467262b Merge topic 'drop-ancient-workarounds'
0f7bdd61 Remove VS 6 special case.
5e92c826 Remove some obsolete stuff.
15e42bb2 cmStandardIncludes: Remove obsolete cmOStringStream.
931e055d Port all cmOStringStream to std::ostringstream.
f194a009 Remove unused cmIStringStream class.
3ec1bb15 cmStandardIncludes: Remove std namespace hack.
bb3bce70 cmStandardIncludes: Remove ANSI_FOR_SCOPE hack.
28fa4923 cmStandardIncludes: Remove iostreams workaround for obsolete Compaq compiler.
837a8a63 cmStandardIncludes: Drop Comeau-related workaround.
4030ddfd Remove Borland-related undef.
17d6a6fd cmStandardIncludes: Remove comment about Borland.
26fb5011 Drop SGI as a CMake host compiler.
2015-01-12 08:57:39 -05:00
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Stephen Kelly 238dd2fbab Use insert instead of a loop in some cases.
Limit this change to inserting into a vector from a vector.

A follow up change can use insert for inserting into a set.
2015-01-11 17:00:55 +01:00
Stephen Kelly 6c19024570 Remove extra semicolons from C++ code.
Clang based tools running over the code complain about these,
but clang has a fixit for removing them.
2014-04-03 21:53:14 +02:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Ben Boeckel 85fc9f26a7 stringapi: Command names 2014-03-08 13:05:39 -05:00
Brad King ccdf7e04d4 macro: Do not substitute for placeholders in bracket arguments
Fix the macro command implementation to avoid substituting macro
placeholders in bracket arguments recorded inside the macro block.
2013-10-30 19:13:33 -04:00
Brad King 999abb993e macro: Add extra indentation to placeholder substitution code
The next commit will make this block conditional so pre-indent it
to clarify the simplicity of the change.
2013-10-30 19:10:11 -04:00
Brad King e33d8d2d77 Drop builtin command documentation
Drop all GetTerseDocumentation and GetFullDocumentation methods from
commands.  The command documentation is now in Help/command/*.rst files.
2013-10-16 09:22:36 -04:00
Brad King 0546484e4b cmListFileArgument: Generalize 'Quoted' bool to 'Delimeter' enum
Replace the boolean value that indicates whether an argument is unquoted
or quoted with a generalized enumeration of possible argument types.
For now "Quoted" and "Unquoted" remain the only types.
2013-08-08 13:26:27 -04:00
Kitware Robot 7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04:00