Commit Graph

35 Commits

Author SHA1 Message Date
Brad King b5ec5b0901 Avoid using KWSys auto_ptr by adopting it ourselves
Replace use of cmsys::auto_ptr with a CM_AUTO_PTR macro that maps to
our own implementation adopted from the KWSys auto_ptr implementation.
Later we may be able to map CM_AUTO_PTR to std::auto_ptr on compilers
that do not warn about it.

Automate the client site conversions:

    git grep -l auto_ptr -- Source/ | grep -v Source/kwsys/ | xargs sed -i \
      's|cmsys::auto_ptr|CM_AUTO_PTR|;s|cmsys/auto_ptr.hxx|cm_auto_ptr.hxx|'
2016-06-29 09:47:58 -04:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Daniel Pfeifer 7647f6afa4 Add CM_OVERRIDE to some functions
Run clang-tidy's modernize-use-override checker.  This checker must have
issues in version 3.8.  It has way too little matches.  And it adds
override to destructors.  Revert the changes on the destructors and
change override to CM_OVERRIDE.
2016-06-27 10:37:41 -04:00
Daniel Pfeifer 7f6b8d3399 Simplify boolean expressions
Use clang-tidy's readability-simplify-boolean-expr checker.
After applying the fix-its, revise all changes *very* carefully.
Be aware of false positives and invalid changes.
2016-06-02 08:24:04 -04: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 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 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 036b6ef7c4 Port CMake from cmIML to KWIML
KWIML no longer uses a configured prefix.
2015-12-18 10:02:07 -05:00
Brad King d462ac27d8 cmELF: Use KWIML ABI.h header to get endian-ness
Port away from KWSys CPU header.
2015-12-09 11:38:10 -05:00
Ty Smith f5cd92a826 cmELF: Avoid divide by zero if there are no dynamic section entries 2015-11-19 13:20:21 -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
Rolf Eike Beer 3022f2a1ef cmELF: fix signedness warning on OpenBSD
OpenBSD defines Elf64_Dyn::d_tag to be of an unsigned type, which differs from
what most other platforms do and what is the case for 32 bit. To have the tag
as unsigned makes sense, but this causes a compilation warning:

/.../CMake/Source/cmELF.cxx: In member function 'const cmELF::StringEntry* cmELFInternalImpl<Types>::GetDynamicSectionString(int) [with Types = cmELFTypes64]':
/.../CMake/Source/cmELF.cxx:945:   instantiated from here
/.../CMake/Source/cmELF.cxx:668: warning: comparison between signed and unsigned integer expressions

Add an explicit typedef to cast the value to for 32 and 64 bit. That type is
unsigned and has the proper length for both platforms so no information is
lost. Explicitely cast both arguments before comparing them to avoid the
warning in all situations.
2014-04-14 20:43:10 +02:00
Adrien Destugues 84603d804c Haiku: Enable CMake builtin ELF editor
Co-Author: Brad King <brad.king@kitware.com>
2014-03-21 08:19:09 -04:00
Ryo ONODERA 172d8d94f4 cmELF: Fix typo in comment, 32-bit => 64-bit (#14799) 2014-03-10 11:05:26 -04:00
Clinton Stimpson 5730710c86 Use cmsys::[io]fstream instead of cmsys_ios::[io]fstream.
Also use SystemTools::Fopen() instead of fopen().
This is to eventually support utf-8 filenames.
2014-01-07 09:27:44 -05:00
David Coppa 480e924dae OpenBSD: Enable ELF parsing and editing (#14241)
OpenBSD provides ELF ABI declarations in

 #include <stdint.h>
 #include <elf_abi.h>

Teach the platform check and cmELF implementation to use these.
2013-06-21 08:27:40 -04:00
Brad King 9d21281b7d Fix line-too-long style errors 2010-09-10 14:42:09 -04:00
Brad King 6fc4cd8680 Fix or cast integer conversions in cmake
These were revealed by GCC's -Wconversion option.  Fix types where it is
easy to do so.  Cast in cases we know the integer will not be truncated.
2010-06-25 09:05:15 -04:00
Bill Hoffman f2d18d6e99 Try to remove some warnings. 2010-05-12 10:41:06 -04:00
Brad King d4ef3bcf59 Use explicit conversion to avoid warnings in cmELF 2009-10-06 08:33:05 -04:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King 0c20967a6b BUG: Fix operator precedence error in cmELF
When attempting to load the RPATH out of a non-ELF file cmELF would
crash because the check for a valid file was done with in correct
operator precedence.  See bug#7392.
2008-08-04 09:38:38 -04:00
Brad King 9eee4149ec BUG: When byte order is not known at compile time make sure NeedSwap in cmELF is still initialized. 2008-05-13 10:34:24 -04:00
Brad King d707719d57 ENH: In cmELF it is okay if the byte order is not known at compile time.
- We perform a runtime check of the input file anyway.
2008-05-13 10:24:23 -04:00
Brad King cf3e180f14 COMP: Fix signed/unsigned comparison warning in cmELF. 2008-04-15 09:00:20 -04:00
Brad King 3ff5404cca ENH: Added cmELF methods to get information about DYNAMIC section entries. 2008-04-14 15:02:24 -04:00
Brad King e98ee8cf70 COMP: Fix cmELF to build when ET_LOOS, ET_HIOS, ET_LOPROC, ET_HIPROC may not be defined. 2008-03-03 08:48:37 -05:00
Brad King 78d27ce7a6 BUG: Fix bug introduced by workaround to warning. 2008-03-02 16:31:06 -05:00
Brad King f42c3de1d7 BUG: A few more corrections for cmELF
- Add os-specific and processor-specific file types
  - Add more error strings for invalid files.
  - Byte order of header fields does not always match encoding
2008-03-02 16:19:40 -05:00
Brad King 61178a0682 ENH: Add Size member to cmELF::StringEntry to return the amount of space in the string entry. 2008-03-01 12:50:42 -05:00
Brad King 03ef00bc93 ENH: Make cmELF parser more general and powerful
- Add support to get RPATH and RUNPATH entries.
  - Add support to get file offsets to strings.
  - Add more DT_* tags to byte swapping.
2008-02-29 11:12:59 -05:00
Brad King d404c6bff6 COMP: cmELF needs to include sys/link.h to get dynamic section structures on the Sun. 2008-02-28 08:43:10 -05:00
Brad King fcad490654 COMP: Fix warnings in cmELF. 2008-02-28 08:32:05 -05:00
Brad King 4c137bad6b ENH: Add ELF file parsing
- Enabled when system provides elf.h
  - Introduce cmELF class to parse ELF files
  - Use in cmSystemTools::GuessLibrarySOName to really get soname
2008-02-27 16:26:35 -05:00