1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-10 23:23:43 +08:00

233 Commits

Author SHA1 Message Date
Nikita Nemkin
637a0f7ed4 cmCacheManager: Prevent corruption from multiline help strings
Corruption happens when a multiline help string starts with
a newline. This causes an overflow in substr() and the whole,
unescaped help string is written to the cache file.

Multiline strings are escaped line by line. The fix is to start
searching for line break points from position 1. A break point
at zero, which triggers the overflow, could only produce
a redundant empty line.

Fixes: #9098
2025-02-05 01:26:11 +05:00
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* 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.

Issue: #26123
2025-01-23 13:09:50 -05:00
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Vitaly Stakhovsky
822203dd65 Source: Rename SetProperty(nullptr_t) to RemoveProperty()
Avoid assignment to NULL semantics.
2023-08-15 12:13:56 -04:00
Marc Chevrier
4fc322bab4 AddCacheEntry: Suppress raw pointer usage 2023-05-30 16:41:59 +02:00
Marc Chevrier
aa5fed5052 SetProperty: suppress raw pointer usage 2023-05-26 14:48:22 +02:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Marc Chevrier
f84193292c Use new AddCacheEntry signatures 2021-09-10 15:46:21 +02:00
Marc Chevrier
3c2e58eeb8 AddCacheEntry accept cmProp or std::string 2021-09-10 15:45:51 +02:00
Marc Chevrier
e5cd39ca80 cmProp: refactoring: transform alias in class
To handle safely the values used by CMake variables and properties,
introduce the class cmProp as a replacement from the simple pointer
to std::string instance.
2021-08-08 16:19:08 +02:00
Ben Boeckel
cdfc4e3195 clang-tidy: fix readability-qualified-auto warnings 2021-01-27 08:45:45 -05:00
Kyle Edwards
b7d7eca66d CMakePresets.json: Rework how --preset argument is handled
If a path argument with no -S or -B leads to a cache directory,
use that directory as the binary directory. Otherwise, use the
binary directory from the preset.

Fixes: #21311
2020-10-26 22:32:45 +11:00
Vitaly Stakhovsky
7156911242 cmIsOn: add overload accepting const std::string* 2020-07-14 08:22:24 -04:00
Tushar Maheshwari
80d8b20351 cmCacheManager: Cleanup CacheIterator interface
- Expose required functionality from CacheEntry.
- Modify usage in cmState member functions.
- Remove cmState access to CacheEntry members.
2020-04-18 18:35:57 +05:30
Brad King
d6119e2305 Merge topic 'cleanup-endls-1'
3fdd8db3aa Refactor: Avoid `std::endl` where it's not necessary (part 1)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4513
2020-03-27 07:51:27 -04:00
Brad King
577fc3ef19 Merge topic 'string-prefix'
ec7928ef26 use _s to construct static string_views at several places
94de927cab VS10Generator: avoid many string allocations
8ca2504a4d use string_views to avoid memory allocations
761f1adcae check for a valid URL scheme before starting to do any splitting
ef778d77e0 replace std::string::substr() with operations that do not allocate memory
77616f4681 pass cm::string_view to cmVisualStudioSlnParser::ParseTag()
ada6a3226f use cm::string_view for language extension lookups
48adc29721 replace "std::string::find(x) == 0" with cmHasPrefix()
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4501
2020-03-26 09:15:41 -04:00
Alex Turbov
3fdd8db3aa Refactor: Avoid std::endl where it's not necessary (part 1)
The `std::endl` manupulator, except inserting `\n` character, also
performs `os.flush()`, which may leads to undesired effects (like
disk I/O in the middle of forming data strings). For the
`std::stringstream` it also has no meaning.
2020-03-26 11:36:57 +08:00
Rolf Eike Beer
48adc29721 replace "std::string::find(x) == 0" with cmHasPrefix() 2020-03-23 22:41:43 +01:00
Vitaly Stakhovsky
0bf0e35e59 cmCacheManager::GetProperty: return cmProp 2020-03-19 08:18:42 -04:00
Vitaly Stakhovsky
60f57d0dcc cmPropertyMap: Introduce cmProp as return type for GetProperty() functions
Currently properties are usually stored internally as `std::string`.
However, family of GetProperty() functions return them as `const char *` using `c_str()`.
The proposed `cmProp`, typedef'ed as `const std::string *` will expose properties
more naturally.
2020-03-13 13:32:17 -04:00
Vitaly Stakhovsky
1398517f31 AppendProperty: convert value param to std::string 2020-01-25 10:37:00 -05:00
Vitaly Stakhovsky
93e9d10c7f cmCacheManager: more members use std::string 2020-01-06 00:26:28 -05:00
Vitaly Stakhovsky
232d5bc333 cmState: more members will use std::string 2020-01-02 07:56:34 -05:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Regina Pfeifer
d25a5a7ec9 clang-tidy: modernize-use-auto
Set the MinTypeNameLength option to an impossibly high value in order
to limit the diagnostics to iterators.  Leave new expressions and cast
expressions for later.
2019-09-10 22:21:41 +02:00
Regina Pfeifer
d63c1e4e6e clang-tidy: modernize-return-braced-init-list 2019-09-06 22:27:39 +02:00
Sebastian Holtermann
aaf59120bf Source sweep: Replace cmExpandList with the shorter cmExpandedList
This replaces the code pattern
```
std::vector<std::string> args;
cmExpandList(valueStr, args, ...)
```
with
```
std::vector<std::string> args = cmExpandedList(valueStr, ...)
```
2019-08-23 17:07:49 +02:00
Sebastian Holtermann
9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00
Brad King
5f7386dd19 Merge topic 'string-literal-append'
da26b3be89 avoid adding multiple consecutive string literals to std::string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3698
2019-08-19 15:06:47 -04:00
Rolf Eike Beer
da26b3be89 avoid adding multiple consecutive string literals to std::string
While at it change some single character additions to be of type char.
2019-08-18 14:22:11 +02:00
Sebastian Holtermann
20e580be01 Source sweep: Use cmIsOn instead of cmSystemTools::IsOn
This replaces invocations of

- `cmSystemTools::IsInternallyOn` with `cmIsInternallyOn`
- `cmSystemTools::IsNOTFOUND` with `cmIsNOTFOUND`
- `cmSystemTools::IsOn` with `cmIsOn`
- `cmSystemTools::IsOff` with `cmIsOff`
2019-08-17 12:14:14 +02:00
Sebastian Holtermann
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Sebastian Holtermann
9e64e617eb cmPropertyMap: Rename GetPropertyList method to GetKeys 2019-06-08 12:25:35 +02:00
Vitaly Stakhovsky
e884b1b693 cmSystemTools::Error(): remove const char* overload 2019-05-22 10:51:06 -04:00
Vitaly Stakhovsky
9dd255548d cmSystemTools::Error: consolidate parameters into single std::string 2019-02-20 11:18:11 -05:00
Brad King
40745ad35a Merge topic 'cmake-files-directory'
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h

Acked-by: Kitware Robot <kwrobot@kitware.com>
Rejected-by: vvs31415 <vstakhovsky@fastmail.com>
Merge-request: !2655
2019-01-25 08:01:26 -05:00
Vitaly Stakhovsky
99337d345b cmSystemTools::Error(): new overload accepting std::string 2019-01-23 10:19:30 -05:00
Bruno Manganelli
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h 2019-01-21 15:34:16 +00:00
Bruno Manganelli
cc2a5261f8 Factor out enum MessageType into dedicated header
Reduce the number of files relying on `cmake.h`.
2019-01-16 08:16:31 -05:00
Regina Pfeifer
3e60580784 clang-tidy: Fix readability-static-accessed-through-instance
Enable the check in .clang-tidy and fix all warnings.
2018-11-22 00:11:37 +01:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Vitaly Stakhovsky
46855d000f cmCacheManager::GetInitializedCacheValue(): Return as const std::string*
Expose std::string type used internally instead of const char*
2018-09-06 12:49:57 -04:00
Vitaly Stakhovsky
6f16be6a62 Remove unnecessary c_str() calls
Use the new IsOn(),IsOff() overloads.
2018-09-05 15:12:57 -04:00
Sebastian Holtermann
b6802cd506 cmGeneratedFileStream: clang-tidy applied to remove redundant `c_str` calls
After changing the ``cmGeneratedFileStream`` methods to accept
``std::string const&`` instead of ``const char*`` we don't
need to call ``std::string::c_str`` anymore when passing
a ``std::string`` to a ``cmGeneratedFileStream`` method.

This patch removes all redundant ``std::string::c_str``
calls when passing a string to a ``cmGeneratedFileStream`` method.

It was generated by building CMake with clang-tidy enabled using
the following options:

-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy-4.0;-checks=-*,readability-redundant-string-cstr;-fix;-fix-errors
2018-08-07 17:02:39 +02:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* 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.
2018-06-01 09:53:42 -04:00
jrp2014
acda926a04 Replace some uses of sprintf with std::to_string 2018-04-05 15:34:23 -04:00
Shane Parris
f93cc4158e Refactor cmCacheManager::LoadCache to use ostringstream 2018-02-28 09:34:47 -05:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00