mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
source: Pass small and trivially copyable types by value
This commit is contained in:

committed by
Brad King

parent
7829ea76ad
commit
b1fdab3cc1
@@ -10,7 +10,6 @@ export CLAZY_CHECKS="level2\
|
||||
,no-copyable-polymorphic\
|
||||
,no-ctor-missing-parent-argument\
|
||||
,no-function-args-by-ref\
|
||||
,no-function-args-by-value\
|
||||
,no-missing-qobject-macro\
|
||||
,no-non-pod-global-static\
|
||||
,no-old-style-connect\
|
||||
|
@@ -530,7 +530,7 @@ bool cmCTestTestHandler::ProcessOptions()
|
||||
|
||||
void cmCTestTestHandler::LogTestSummary(std::vector<std::string> const& passed,
|
||||
std::vector<std::string> const& failed,
|
||||
cmDuration const& durationInSecs)
|
||||
cmDuration durationInSecs)
|
||||
{
|
||||
std::size_t total = passed.size() + failed.size();
|
||||
|
||||
|
@@ -242,7 +242,7 @@ protected:
|
||||
bool ProcessOptions();
|
||||
void LogTestSummary(std::vector<std::string> const& passed,
|
||||
std::vector<std::string> const& failed,
|
||||
cmDuration const& durationInSecs);
|
||||
cmDuration durationInSecs);
|
||||
void LogDisabledTests(std::vector<cmCTestTestResult> const& disabledTests);
|
||||
void LogFailedTests(std::vector<std::string> const& failed,
|
||||
SetOfTests const& resultsSet);
|
||||
|
@@ -779,7 +779,7 @@ cmComputeLinkDepends::AllocateLinkEntry(cmLinkItem const& item)
|
||||
}
|
||||
|
||||
std::pair<size_t, bool> cmComputeLinkDepends::AddLinkEntry(
|
||||
cmLinkItem const& item, cm::optional<size_t> const& groupIndex)
|
||||
cmLinkItem const& item, cm::optional<size_t> groupIndex)
|
||||
{
|
||||
// Allocate a spot for the item entry.
|
||||
auto lei = this->AllocateLinkEntry(item);
|
||||
@@ -950,7 +950,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
|
||||
}
|
||||
|
||||
void cmComputeLinkDepends::AddVarLinkEntries(
|
||||
cm::optional<size_t> const& depender_index, char const* value)
|
||||
cm::optional<size_t> depender_index, char const* value)
|
||||
{
|
||||
// This is called to add the dependencies named by
|
||||
// <item>_LIB_DEPENDS. The variable contains a semicolon-separated
|
||||
@@ -1020,8 +1020,8 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void cmComputeLinkDepends::AddLinkEntries(
|
||||
cm::optional<size_t> const& depender_index, std::vector<T> const& libs)
|
||||
void cmComputeLinkDepends::AddLinkEntries(cm::optional<size_t> depender_index,
|
||||
std::vector<T> const& libs)
|
||||
{
|
||||
// Track inferred dependency sets implied by this list.
|
||||
std::map<size_t, DependSet> dependSets;
|
||||
@@ -1305,7 +1305,7 @@ void cmComputeLinkDepends::AddLinkObjects(std::vector<cmLinkItem> const& objs)
|
||||
}
|
||||
|
||||
cmLinkItem cmComputeLinkDepends::ResolveLinkItem(
|
||||
cm::optional<size_t> const& depender_index, std::string const& name)
|
||||
cm::optional<size_t> depender_index, std::string const& name)
|
||||
{
|
||||
// Look for a target in the scope of the depender.
|
||||
cmGeneratorTarget const* from = this->Target;
|
||||
|
@@ -106,16 +106,16 @@ private:
|
||||
std::pair<std::map<cmLinkItem, size_t>::iterator, bool> AllocateLinkEntry(
|
||||
cmLinkItem const& item);
|
||||
std::pair<size_t, bool> AddLinkEntry(cmLinkItem const& item,
|
||||
cm::optional<size_t> const& groupIndex);
|
||||
cm::optional<size_t> groupIndex);
|
||||
void AddLinkObject(cmLinkItem const& item);
|
||||
void AddVarLinkEntries(cm::optional<size_t> const& depender_index,
|
||||
void AddVarLinkEntries(cm::optional<size_t> depender_index,
|
||||
char const* value);
|
||||
void AddDirectLinkEntries();
|
||||
template <typename T>
|
||||
void AddLinkEntries(cm::optional<size_t> const& depender_index,
|
||||
void AddLinkEntries(cm::optional<size_t> depender_index,
|
||||
std::vector<T> const& libs);
|
||||
void AddLinkObjects(std::vector<cmLinkItem> const& objs);
|
||||
cmLinkItem ResolveLinkItem(cm::optional<size_t> const& depender_index,
|
||||
cmLinkItem ResolveLinkItem(cm::optional<size_t> depender_index,
|
||||
std::string const& name);
|
||||
|
||||
// One entry for each unique item.
|
||||
|
@@ -394,7 +394,7 @@ void cmDebuggerAdapter::OnBeginFunctionCall(cmMakefile* mf,
|
||||
dap::array<dap::integer> hitBreakpoints;
|
||||
hitBreakpoints.resize(hits.size());
|
||||
std::transform(hits.begin(), hits.end(), hitBreakpoints.begin(),
|
||||
[&](int64_t const& id) { return dap::integer(id); });
|
||||
[&](int64_t id) { return dap::integer(id); });
|
||||
stoppedEvent.reason = "breakpoint";
|
||||
stoppedEvent.hitBreakpointIds = hitBreakpoints;
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ int64_t cmDebuggerBreakpointManager::FindFunctionStartLine(
|
||||
auto location =
|
||||
find_if(ListFileFunctionLines[sourcePath].begin(),
|
||||
ListFileFunctionLines[sourcePath].end(),
|
||||
[=](cmDebuggerFunctionLocation const& loc) {
|
||||
[=](cmDebuggerFunctionLocation loc) {
|
||||
return loc.StartLine <= line && loc.EndLine >= line;
|
||||
});
|
||||
|
||||
@@ -47,11 +47,10 @@ int64_t cmDebuggerBreakpointManager::FindFunctionStartLine(
|
||||
int64_t cmDebuggerBreakpointManager::CalibrateBreakpointLine(
|
||||
std::string const& sourcePath, int64_t line)
|
||||
{
|
||||
auto location = find_if(ListFileFunctionLines[sourcePath].begin(),
|
||||
ListFileFunctionLines[sourcePath].end(),
|
||||
[=](cmDebuggerFunctionLocation const& loc) {
|
||||
return loc.StartLine >= line;
|
||||
});
|
||||
auto location = find_if(
|
||||
ListFileFunctionLines[sourcePath].begin(),
|
||||
ListFileFunctionLines[sourcePath].end(),
|
||||
[=](cmDebuggerFunctionLocation loc) { return loc.StartLine >= line; });
|
||||
|
||||
if (location != ListFileFunctionLines[sourcePath].end()) {
|
||||
return location->StartLine;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include "cmDuration.h"
|
||||
|
||||
template <typename T>
|
||||
T cmDurationTo(cmDuration const& duration)
|
||||
T cmDurationTo(cmDuration duration)
|
||||
{
|
||||
/* This works because the comparison operators for duration rely on
|
||||
* std::common_type.
|
||||
@@ -23,5 +23,5 @@ T cmDurationTo(cmDuration const& duration)
|
||||
.count();
|
||||
}
|
||||
|
||||
template int cmDurationTo<int>(cmDuration const&);
|
||||
template unsigned int cmDurationTo<unsigned int>(cmDuration const&);
|
||||
template int cmDurationTo<int>(cmDuration);
|
||||
template unsigned int cmDurationTo<unsigned int>(cmDuration);
|
||||
|
@@ -16,9 +16,9 @@ using cmDuration = std::chrono::duration<double, std::ratio<1>>;
|
||||
* the permissible valid values for T.
|
||||
*/
|
||||
template <typename T>
|
||||
T cmDurationTo(cmDuration const& duration);
|
||||
T cmDurationTo(cmDuration duration);
|
||||
|
||||
#ifndef CMDURATION_CPP
|
||||
extern template int cmDurationTo<int>(cmDuration const&);
|
||||
extern template unsigned int cmDurationTo<unsigned int>(cmDuration const&);
|
||||
extern template int cmDurationTo<int>(cmDuration);
|
||||
extern template unsigned int cmDurationTo<unsigned int>(cmDuration);
|
||||
#endif
|
||||
|
@@ -3848,7 +3848,7 @@ bool ValidateAndConvertPermissions(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetPermissions(std::string const& filename, mode_t const& perms,
|
||||
bool SetPermissions(std::string const& filename, mode_t perms,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (!cmSystemTools::SetPermissions(filename, perms)) {
|
||||
@@ -3953,8 +3953,7 @@ bool HandleChmodCommandImpl(std::vector<std::string> const& args, bool recurse,
|
||||
|
||||
if (cmSystemTools::FileExists(i, true)) {
|
||||
bool success = true;
|
||||
mode_t const& filePermissions =
|
||||
parsedArgs.FilePermissions ? fperms : perms;
|
||||
mode_t filePermissions = parsedArgs.FilePermissions ? fperms : perms;
|
||||
if (filePermissions) {
|
||||
success = SetPermissions(i, filePermissions, status);
|
||||
}
|
||||
@@ -3965,7 +3964,7 @@ bool HandleChmodCommandImpl(std::vector<std::string> const& args, bool recurse,
|
||||
|
||||
else if (cmSystemTools::FileIsDirectory(i)) {
|
||||
bool success = true;
|
||||
mode_t const& directoryPermissions =
|
||||
mode_t directoryPermissions =
|
||||
parsedArgs.DirectoryPermissions ? dperms : perms;
|
||||
if (directoryPermissions) {
|
||||
success = SetPermissions(i, directoryPermissions, status);
|
||||
|
@@ -702,7 +702,7 @@ bool CheckPathParametersEx(cmGeneratorExpressionContext* ctx,
|
||||
}
|
||||
bool CheckPathParameters(cmGeneratorExpressionContext* ctx,
|
||||
GeneratorExpressionContent const* cnt,
|
||||
cm::string_view option, Arguments const& args,
|
||||
cm::string_view option, Arguments args,
|
||||
int required = 1)
|
||||
{
|
||||
return CheckPathParametersEx(ctx, cnt, option, args.size(), required);
|
||||
@@ -1190,7 +1190,7 @@ inline bool CheckListParametersEx(cmGeneratorExpressionContext* ctx,
|
||||
}
|
||||
inline bool CheckListParameters(cmGeneratorExpressionContext* ctx,
|
||||
GeneratorExpressionContent const* cnt,
|
||||
cm::string_view option, Arguments const& args,
|
||||
cm::string_view option, Arguments args,
|
||||
int required = 1)
|
||||
{
|
||||
return CheckListParametersEx(ctx, cnt, option, args.size(), required);
|
||||
@@ -1225,7 +1225,7 @@ bool GetNumericArgument(std::string const& arg, cmList::index_type& value)
|
||||
|
||||
bool GetNumericArguments(
|
||||
cmGeneratorExpressionContext* ctx, GeneratorExpressionContent const* cnt,
|
||||
Arguments const& args, std::vector<cmList::index_type>& indexes,
|
||||
Arguments args, std::vector<cmList::index_type>& indexes,
|
||||
cmList::ExpandElements expandElements = cmList::ExpandElements::No)
|
||||
{
|
||||
using IndexRange = cmRange<Arguments::const_iterator>;
|
||||
|
@@ -134,7 +134,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
StringSorter(cmList::SortConfiguration const& config)
|
||||
StringSorter(cmList::SortConfiguration config)
|
||||
: Filters{ this->GetCompareFilter(config.Compare),
|
||||
this->GetCaseFilter(config.Case) }
|
||||
, SortMethod(this->GetComparisonFunction(config.Compare))
|
||||
@@ -175,7 +175,7 @@ private:
|
||||
|
||||
cmList::SortConfiguration::SortConfiguration() = default;
|
||||
|
||||
cmList& cmList::sort(SortConfiguration const& cfg)
|
||||
cmList& cmList::sort(SortConfiguration cfg)
|
||||
{
|
||||
SortConfiguration config{ cfg };
|
||||
|
||||
@@ -910,7 +910,7 @@ cmList& cmList::RemoveItems(std::vector<index_type>&& indexes)
|
||||
// compute all indexes
|
||||
std::vector<size_type> idx(indexes.size());
|
||||
std::transform(indexes.cbegin(), indexes.cend(), idx.begin(),
|
||||
[this](index_type const& index) -> size_type {
|
||||
[this](index_type index) -> size_type {
|
||||
return this->ComputeIndex(index);
|
||||
});
|
||||
|
||||
|
@@ -863,7 +863,7 @@ public:
|
||||
{
|
||||
}
|
||||
};
|
||||
cmList& sort(SortConfiguration const& config = SortConfiguration{});
|
||||
cmList& sort(SortConfiguration config = SortConfiguration{});
|
||||
|
||||
// exception raised on error during transform operations
|
||||
class transform_error : public std::runtime_error
|
||||
|
@@ -58,7 +58,7 @@ void cmOSXBundleGenerator::CreateAppBundle(std::string const& targetName,
|
||||
|
||||
void cmOSXBundleGenerator::CreateFramework(
|
||||
std::string const& targetName, std::string const& outpath,
|
||||
std::string const& config, cmOSXBundleGenerator::SkipParts const& skipParts)
|
||||
std::string const& config, cmOSXBundleGenerator::SkipParts skipParts)
|
||||
{
|
||||
if (this->MustSkip()) {
|
||||
return;
|
||||
|
@@ -34,7 +34,7 @@ public:
|
||||
// create a framework at a given root
|
||||
void CreateFramework(std::string const& targetName, std::string const& root,
|
||||
std::string const& config,
|
||||
SkipParts const& skipParts = SkipParts{});
|
||||
SkipParts skipParts = SkipParts{});
|
||||
|
||||
// create a cf bundle at a given root
|
||||
void CreateCFBundle(std::string const& targetName, std::string const& root,
|
||||
|
@@ -180,7 +180,7 @@ std::string DeterminePrefix(std::string const& filepath,
|
||||
}
|
||||
|
||||
// Extract key name from value iterator as string_view.
|
||||
cm::string_view IterKey(Json::Value::const_iterator const& iter)
|
||||
cm::string_view IterKey(Json::Value::const_iterator iter)
|
||||
{
|
||||
char const* end;
|
||||
char const* const start = iter.memberName(&end);
|
||||
|
@@ -325,8 +325,8 @@ cmQtAutoGen::ConfigStrings<std::vector<std::string>> generateListOptions(
|
||||
|
||||
cmQtAutoGenInitializer::cmQtAutoGenInitializer(
|
||||
cmQtAutoGenGlobalInitializer* globalInitializer,
|
||||
cmGeneratorTarget* genTarget, IntegerVersion const& qtVersion,
|
||||
bool mocEnabled, bool uicEnabled, bool rccEnabled, bool globalAutogenTarget,
|
||||
cmGeneratorTarget* genTarget, IntegerVersion qtVersion, bool mocEnabled,
|
||||
bool uicEnabled, bool rccEnabled, bool globalAutogenTarget,
|
||||
bool globalAutoRccTarget)
|
||||
: GlobalInitializer(globalInitializer)
|
||||
, GenTarget(genTarget)
|
||||
|
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer,
|
||||
cmGeneratorTarget* genTarget,
|
||||
IntegerVersion const& qtVersion, bool mocEnabled,
|
||||
IntegerVersion qtVersion, bool mocEnabled,
|
||||
bool uicEnabled, bool rccEnabled,
|
||||
bool globalAutogenTarget, bool globalAutoRccTarget);
|
||||
|
||||
|
@@ -37,7 +37,7 @@ bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
|
||||
};
|
||||
|
||||
auto isAPropertyKeyword =
|
||||
[](std::vector<std::string>::const_iterator const& arg_it) {
|
||||
[](std::vector<std::string>::const_iterator arg_it) {
|
||||
return std::any_of(
|
||||
std::begin(prop_names), std::end(prop_names),
|
||||
[&arg_it](cm::string_view prop_name) { return *arg_it == prop_name; });
|
||||
|
@@ -14,7 +14,7 @@ public:
|
||||
{
|
||||
}
|
||||
size_t Index() const { return index_; }
|
||||
friend bool operator<(cmStandardLevel const& l, cmStandardLevel const& r)
|
||||
friend bool operator<(cmStandardLevel l, cmStandardLevel r)
|
||||
{
|
||||
return l.index_ < r.index_;
|
||||
}
|
||||
|
@@ -542,7 +542,7 @@ std::string cmStandardLevelResolver::GetEffectiveStandard(
|
||||
}
|
||||
|
||||
std::string cmStandardLevelResolver::GetLevelString(
|
||||
std::string const& lang, cmStandardLevel const& level) const
|
||||
std::string const& lang, cmStandardLevel level) const
|
||||
{
|
||||
auto mapping = StandardComputerMapping.find(lang);
|
||||
if (mapping == StandardComputerMapping.end()) {
|
||||
|
@@ -30,7 +30,7 @@ public:
|
||||
std::string const& config) const;
|
||||
|
||||
std::string GetLevelString(std::string const& lang,
|
||||
cmStandardLevel const& level) const;
|
||||
cmStandardLevel level) const;
|
||||
|
||||
bool AddRequiredTargetFeature(cmTarget* target, std::string const& feature,
|
||||
std::string* error = nullptr) const;
|
||||
|
@@ -524,7 +524,7 @@ namespace std {
|
||||
template <>
|
||||
struct hash<cmWindowsRegistry::View>
|
||||
{
|
||||
size_t operator()(cmWindowsRegistry::View const& v) const noexcept
|
||||
size_t operator()(cmWindowsRegistry::View v) const noexcept
|
||||
{
|
||||
return static_cast<
|
||||
typename underlying_type<cmWindowsRegistry::View>::type>(v);
|
||||
|
@@ -108,8 +108,7 @@ private:
|
||||
* Therefore we must assume it is an arbitrary point in time. Instead of this
|
||||
* method, it is recommended to convert it by means of the to_time_t method.
|
||||
*/
|
||||
static std::time_t SafeContent(
|
||||
std::chrono::system_clock::time_point const& value)
|
||||
static std::time_t SafeContent(std::chrono::system_clock::time_point value)
|
||||
{
|
||||
return std::chrono::system_clock::to_time_t(value);
|
||||
}
|
||||
|
@@ -455,8 +455,8 @@ void cmake::CleanupCommandsAndMacros()
|
||||
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
void cmake::SetWarningFromPreset(std::string const& name,
|
||||
cm::optional<bool> const& warning,
|
||||
cm::optional<bool> const& error)
|
||||
cm::optional<bool> warning,
|
||||
cm::optional<bool> error)
|
||||
{
|
||||
if (warning) {
|
||||
if (*warning) {
|
||||
|
@@ -388,8 +388,8 @@ public:
|
||||
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
void SetWarningFromPreset(std::string const& name,
|
||||
cm::optional<bool> const& warning,
|
||||
cm::optional<bool> const& error);
|
||||
cm::optional<bool> warning,
|
||||
cm::optional<bool> error);
|
||||
void ProcessPresetVariables();
|
||||
void PrintPresetVariables();
|
||||
void ProcessPresetEnvironment();
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
inline int runTests(std::initializer_list<std::function<bool()>> const& tests,
|
||||
inline int runTests(std::initializer_list<std::function<bool()>> tests,
|
||||
bool const fail_fast = true)
|
||||
{
|
||||
int result = 0;
|
||||
|
Reference in New Issue
Block a user