clang-tidy: modernize-return-braced-init-list
This commit is contained in:
parent
ca8c3d64c8
commit
d63c1e4e6e
@ -15,7 +15,6 @@ misc-*,\
|
||||
modernize-*,\
|
||||
-modernize-avoid-c-arrays,\
|
||||
-modernize-deprecated-headers,\
|
||||
-modernize-return-braced-init-list,\
|
||||
-modernize-use-auto,\
|
||||
-modernize-use-nodiscard,\
|
||||
-modernize-use-noexcept,\
|
||||
|
@ -498,7 +498,7 @@ cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
|
||||
|
||||
cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key)
|
||||
{
|
||||
return CacheIterator(*this, key);
|
||||
return { *this, key };
|
||||
}
|
||||
|
||||
const std::string* cmCacheManager::GetInitializedCacheValue(
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
};
|
||||
|
||||
//! return an iterator to iterate through the cache map
|
||||
cmCacheManager::CacheIterator NewIterator() { return CacheIterator(*this); }
|
||||
cmCacheManager::CacheIterator NewIterator() { return { *this }; }
|
||||
|
||||
//! Load a cache for given makefile. Loads from path/CMakeCache.txt.
|
||||
bool LoadCache(const std::string& path, bool internal,
|
||||
|
@ -311,7 +311,7 @@ cmExportBuildFileGenerator::FindBuildExportInfo(cmGlobalGenerator* gg,
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(exportFiles, ns);
|
||||
return { exportFiles, ns };
|
||||
}
|
||||
|
||||
void cmExportBuildFileGenerator::ComplainAboutMissingTarget(
|
||||
|
@ -496,7 +496,7 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg,
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(exportFiles, ns);
|
||||
return { exportFiles, ns };
|
||||
}
|
||||
|
||||
void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define WINMSG_BUF_LEN (1024)
|
||||
cmFileLockResult cmFileLockResult::MakeOk()
|
||||
{
|
||||
return cmFileLockResult(OK, 0);
|
||||
return { OK, 0 };
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLockResult::MakeSystem()
|
||||
@ -18,27 +18,27 @@ cmFileLockResult cmFileLockResult::MakeSystem()
|
||||
#else
|
||||
const Error lastError = errno;
|
||||
#endif
|
||||
return cmFileLockResult(SYSTEM, lastError);
|
||||
return { SYSTEM, lastError };
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLockResult::MakeTimeout()
|
||||
{
|
||||
return cmFileLockResult(TIMEOUT, 0);
|
||||
return { TIMEOUT, 0 };
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLockResult::MakeAlreadyLocked()
|
||||
{
|
||||
return cmFileLockResult(ALREADY_LOCKED, 0);
|
||||
return { ALREADY_LOCKED, 0 };
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLockResult::MakeInternal()
|
||||
{
|
||||
return cmFileLockResult(INTERNAL, 0);
|
||||
return { INTERNAL, 0 };
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLockResult::MakeNoFunction()
|
||||
{
|
||||
return cmFileLockResult(NO_FUNCTION, 0);
|
||||
return { NO_FUNCTION, 0 };
|
||||
}
|
||||
|
||||
bool cmFileLockResult::IsOk() const
|
||||
|
@ -4778,21 +4778,21 @@ template <>
|
||||
std::pair<bool, bool> consistentProperty(bool lhs, bool rhs,
|
||||
CompatibleType /*unused*/)
|
||||
{
|
||||
return std::make_pair(lhs == rhs, lhs);
|
||||
return { lhs == rhs, lhs };
|
||||
}
|
||||
|
||||
std::pair<bool, const char*> consistentStringProperty(const char* lhs,
|
||||
const char* rhs)
|
||||
{
|
||||
const bool b = strcmp(lhs, rhs) == 0;
|
||||
return std::make_pair(b, b ? lhs : nullptr);
|
||||
return { b, b ? lhs : nullptr };
|
||||
}
|
||||
|
||||
std::pair<bool, std::string> consistentStringProperty(const std::string& lhs,
|
||||
const std::string& rhs)
|
||||
{
|
||||
const bool b = lhs == rhs;
|
||||
return std::make_pair(b, b ? lhs : valueAsString(nullptr));
|
||||
return { b, b ? lhs : valueAsString(nullptr) };
|
||||
}
|
||||
|
||||
std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
|
||||
@ -4801,22 +4801,21 @@ std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
|
||||
{
|
||||
char* pEnd;
|
||||
|
||||
const char* const null_ptr = nullptr;
|
||||
|
||||
long lnum = strtol(lhs, &pEnd, 0);
|
||||
if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
|
||||
return std::pair<bool, const char*>(false, null_ptr);
|
||||
return { false, nullptr };
|
||||
}
|
||||
|
||||
long rnum = strtol(rhs, &pEnd, 0);
|
||||
if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
|
||||
return std::pair<bool, const char*>(false, null_ptr);
|
||||
return { false, nullptr };
|
||||
}
|
||||
|
||||
if (t == NumberMaxType) {
|
||||
return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs);
|
||||
return { true, std::max(lnum, rnum) == lnum ? lhs : rhs };
|
||||
}
|
||||
return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs);
|
||||
|
||||
return { true, std::min(lnum, rnum) == lnum ? lhs : rhs };
|
||||
}
|
||||
|
||||
template <>
|
||||
@ -4825,21 +4824,19 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
|
||||
CompatibleType t)
|
||||
{
|
||||
if (!lhs && !rhs) {
|
||||
return std::make_pair(true, lhs);
|
||||
return { true, lhs };
|
||||
}
|
||||
if (!lhs) {
|
||||
return std::make_pair(true, rhs);
|
||||
return { true, rhs };
|
||||
}
|
||||
if (!rhs) {
|
||||
return std::make_pair(true, lhs);
|
||||
return { true, lhs };
|
||||
}
|
||||
|
||||
const char* const null_ptr = nullptr;
|
||||
|
||||
switch (t) {
|
||||
case BoolType: {
|
||||
bool same = cmIsOn(lhs) == cmIsOn(rhs);
|
||||
return std::make_pair(same, same ? lhs : nullptr);
|
||||
return { same, same ? lhs : nullptr };
|
||||
}
|
||||
case StringType:
|
||||
return consistentStringProperty(lhs, rhs);
|
||||
@ -4848,7 +4845,7 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
|
||||
return consistentNumberProperty(lhs, rhs, t);
|
||||
}
|
||||
assert(false && "Unreachable!");
|
||||
return std::pair<bool, const char*>(false, null_ptr);
|
||||
return { false, nullptr };
|
||||
}
|
||||
|
||||
std::pair<bool, std::string> consistentProperty(const std::string& lhs,
|
||||
@ -4858,31 +4855,31 @@ std::pair<bool, std::string> consistentProperty(const std::string& lhs,
|
||||
const std::string null_ptr = valueAsString(nullptr);
|
||||
|
||||
if (lhs == null_ptr && rhs == null_ptr) {
|
||||
return std::make_pair(true, lhs);
|
||||
return { true, lhs };
|
||||
}
|
||||
if (lhs == null_ptr) {
|
||||
return std::make_pair(true, rhs);
|
||||
return { true, rhs };
|
||||
}
|
||||
if (rhs == null_ptr) {
|
||||
return std::make_pair(true, lhs);
|
||||
return { true, lhs };
|
||||
}
|
||||
|
||||
switch (t) {
|
||||
case BoolType: {
|
||||
bool same = cmIsOn(lhs) == cmIsOn(rhs);
|
||||
return std::make_pair(same, same ? lhs : null_ptr);
|
||||
return { same, same ? lhs : null_ptr };
|
||||
}
|
||||
case StringType:
|
||||
return consistentStringProperty(lhs, rhs);
|
||||
case NumberMinType:
|
||||
case NumberMaxType: {
|
||||
auto value = consistentNumberProperty(lhs.c_str(), rhs.c_str(), t);
|
||||
return std::make_pair(
|
||||
value.first, value.first ? std::string(value.second) : null_ptr);
|
||||
return { value.first,
|
||||
value.first ? std::string(value.second) : null_ptr };
|
||||
}
|
||||
}
|
||||
assert(false && "Unreachable!");
|
||||
return std::pair<bool, std::string>(false, null_ptr);
|
||||
return { false, null_ptr };
|
||||
}
|
||||
|
||||
template <typename PropertyType>
|
||||
|
@ -228,7 +228,7 @@ public:
|
||||
return this->GG->ConvertToNinjaPath(path);
|
||||
}
|
||||
};
|
||||
MapToNinjaPathImpl MapToNinjaPath() { return MapToNinjaPathImpl(this); }
|
||||
MapToNinjaPathImpl MapToNinjaPath() { return { this }; }
|
||||
|
||||
// -- Additional clean files
|
||||
void AddAdditionalCleanFile(std::string fileName);
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
}
|
||||
cmScriptGeneratorIndent Next(int step = 2) const
|
||||
{
|
||||
return cmScriptGeneratorIndent(this->Level + step);
|
||||
return { this->Level + step };
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -167,7 +167,7 @@ bool cmServerProtocol::DoActivate(const cmServerRequest& /*request*/,
|
||||
|
||||
std::pair<int, int> cmServerProtocol1::ProtocolVersion() const
|
||||
{
|
||||
return std::make_pair(1, 2);
|
||||
return { 1, 2 };
|
||||
}
|
||||
|
||||
static void setErrorMessage(std::string* errorMessage, const std::string& text)
|
||||
|
@ -324,7 +324,7 @@ cmStateSnapshot cmState::Reset()
|
||||
this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::TARGET, "", "", true);
|
||||
this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::TARGET, "", "", true);
|
||||
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
void cmState::DefineProperty(const std::string& name,
|
||||
@ -789,7 +789,7 @@ cmStateSnapshot cmState::CreateBaseSnapshot()
|
||||
assert(pos->Vars.IsValid());
|
||||
pos->Parent = this->VarTree.Root();
|
||||
pos->Root = this->VarTree.Root();
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::CreateBuildsystemDirectorySnapshot(
|
||||
@ -842,7 +842,7 @@ cmStateSnapshot cmState::CreateFunctionCallSnapshot(
|
||||
cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
|
||||
pos->Parent = origin;
|
||||
pos->Vars = this->VarTree.Push(origin);
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::CreateMacroCallSnapshot(
|
||||
@ -857,7 +857,7 @@ cmStateSnapshot cmState::CreateMacroCallSnapshot(
|
||||
assert(originSnapshot.Position->Vars.IsValid());
|
||||
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
||||
pos->PolicyScope = originSnapshot.Position->Policies;
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::CreateIncludeFileSnapshot(
|
||||
@ -872,7 +872,7 @@ cmStateSnapshot cmState::CreateIncludeFileSnapshot(
|
||||
assert(originSnapshot.Position->Vars.IsValid());
|
||||
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
||||
pos->PolicyScope = originSnapshot.Position->Policies;
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::CreateVariableScopeSnapshot(
|
||||
@ -890,7 +890,7 @@ cmStateSnapshot cmState::CreateVariableScopeSnapshot(
|
||||
pos->Parent = origin;
|
||||
pos->Vars = this->VarTree.Push(origin);
|
||||
assert(pos->Vars.IsValid());
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::CreateInlineListFileSnapshot(
|
||||
@ -904,7 +904,7 @@ cmStateSnapshot cmState::CreateInlineListFileSnapshot(
|
||||
originSnapshot.Position->ExecutionListFile, fileName);
|
||||
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
||||
pos->PolicyScope = originSnapshot.Position->Policies;
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::CreatePolicyScopeSnapshot(
|
||||
@ -916,7 +916,7 @@ cmStateSnapshot cmState::CreatePolicyScopeSnapshot(
|
||||
pos->Keep = false;
|
||||
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
||||
pos->PolicyScope = originSnapshot.Position->Policies;
|
||||
return cmStateSnapshot(this, pos);
|
||||
return { this, pos };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot)
|
||||
@ -948,7 +948,7 @@ cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot)
|
||||
this->SnapshotData.Pop(pos);
|
||||
}
|
||||
|
||||
return cmStateSnapshot(this, prevPos);
|
||||
return { this, prevPos };
|
||||
}
|
||||
|
||||
static bool ParseEntryWithoutType(const std::string& entry, std::string& var,
|
||||
|
@ -66,8 +66,7 @@ bool cmStateSnapshot::IsValid() const
|
||||
|
||||
cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectory() const
|
||||
{
|
||||
return cmStateSnapshot(this->State,
|
||||
this->Position->BuildSystemDirectory->DirectoryEnd);
|
||||
return { this->State, this->Position->BuildSystemDirectory->DirectoryEnd };
|
||||
}
|
||||
|
||||
cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectoryParent() const
|
||||
@ -126,7 +125,7 @@ cmStateSnapshot cmStateSnapshot::GetCallStackBottom() const
|
||||
pos != this->State->SnapshotData.Root()) {
|
||||
++pos;
|
||||
}
|
||||
return cmStateSnapshot(this->State, pos);
|
||||
return { this->State, pos };
|
||||
}
|
||||
|
||||
void cmStateSnapshot::PushPolicy(cmPolicies::PolicyMap const& entry, bool weak)
|
||||
@ -426,7 +425,7 @@ cmState* cmStateSnapshot::GetState() const
|
||||
|
||||
cmStateDirectory cmStateSnapshot::GetDirectory() const
|
||||
{
|
||||
return cmStateDirectory(this->Position->BuildSystemDirectory, *this);
|
||||
return { this->Position->BuildSystemDirectory, *this };
|
||||
}
|
||||
|
||||
void cmStateSnapshot::SetProjectName(const std::string& name)
|
||||
|
@ -77,14 +77,11 @@ private:
|
||||
void CloseStartElement();
|
||||
|
||||
private:
|
||||
static cmXMLSafe SafeAttribute(const char* value)
|
||||
{
|
||||
return cmXMLSafe(value);
|
||||
}
|
||||
static cmXMLSafe SafeAttribute(const char* value) { return { value }; }
|
||||
|
||||
static cmXMLSafe SafeAttribute(std::string const& value)
|
||||
{
|
||||
return cmXMLSafe(value);
|
||||
return { value };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -1081,20 +1081,18 @@ createExtraGenerator(
|
||||
const std::vector<std::string> generators =
|
||||
i->GetSupportedGlobalGenerators();
|
||||
if (i->GetName() == name) { // Match aliases
|
||||
return std::make_pair(i->CreateExternalMakefileProjectGenerator(),
|
||||
generators.at(0));
|
||||
return { i->CreateExternalMakefileProjectGenerator(), generators.at(0) };
|
||||
}
|
||||
for (std::string const& g : generators) {
|
||||
const std::string fullName =
|
||||
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
|
||||
g, i->GetName());
|
||||
if (fullName == name) {
|
||||
return std::make_pair(i->CreateExternalMakefileProjectGenerator(), g);
|
||||
return { i->CreateExternalMakefileProjectGenerator(), g };
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::make_pair(
|
||||
static_cast<cmExternalMakefileProjectGenerator*>(nullptr), name);
|
||||
return { nullptr, name };
|
||||
}
|
||||
|
||||
cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
|
||||
|
Loading…
Reference in New Issue
Block a user