-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix more C++ modernize lints #3353
Merged
Merged
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4723ecf
Fix NOLINT usage
bernardnormier d69b4f3
modernize-use-nullptr, modernize-use-emplace
bernardnormier 77242b0
Remove modernize-use-default-member-init
bernardnormier 1d62849
modernize-use-auto
bernardnormier 6b3cc66
modernize-loop-convert
bernardnormier dbd9d34
Fix test
bernardnormier b5117fb
Fix IceGrid
bernardnormier 4cd2e36
Complete modernize-loop-convert
bernardnormier 845d960
Reformat
bernardnormier 911b301
Fix names
bernardnormier 24d11c4
More name fix
bernardnormier e36d1ae
Fix Windows build
bernardnormier 97ab8f7
Use const auto& instead of auto& in range-based for loops (tests)
bernardnormier c49f230
More const auto&
bernardnormier 9e90646
More const auto& fixes
bernardnormier bc876e2
Use range-based for loops in header files
bernardnormier c192fa6
More fixes
bernardnormier 12e8317
Fix ConnectionFactory
bernardnormier 85ae821
Fix Linux build
bernardnormier a4b5be7
Fix more const auto& range-based for loops
bernardnormier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,12 +125,9 @@ namespace IceInternal | |
~EntryT() | ||
{ | ||
assert(_object->total > 0); | ||
for (typename std::map<std::string, std::pair<MetricsMapIPtr, SubMapMember>>::const_iterator p = | ||
_subMaps.begin(); | ||
p != _subMaps.end(); | ||
++p) | ||
for (const auto& subMap : _subMaps) | ||
{ | ||
p->second.first->destroy(); // Break cyclic reference counts. | ||
subMap.second.first->destroy(); // Break cyclic reference counts. | ||
} | ||
} | ||
|
||
|
@@ -148,8 +145,7 @@ namespace IceInternal | |
MetricsMapIPtr m; | ||
{ | ||
std::lock_guard lock(_map->_mutex); | ||
typename std::map<std::string, std::pair<MetricsMapIPtr, SubMapMember>>::iterator p = | ||
_subMaps.find(mapName); | ||
auto p = _subMaps.find(mapName); | ||
if (p == _subMaps.end()) | ||
{ | ||
std::pair<MetricsMapIPtr, SubMapMember> map = _map->createSubMap(mapName); | ||
|
@@ -200,10 +196,7 @@ namespace IceInternal | |
[[nodiscard]] IceMX::MetricsPtr clone() const | ||
{ | ||
TPtr metrics = std::dynamic_pointer_cast<T>(_object->ice_clone()); | ||
for (typename std::map<std::string, std::pair<MetricsMapIPtr, SubMapMember>>::const_iterator p = | ||
_subMaps.begin(); | ||
p != _subMaps.end(); | ||
++p) | ||
for (auto p = _subMaps.begin(); p != _subMaps.end(); ++p) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why -fix didn't convert this code in a loop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, in this case, I prefer to leave it alone as the syntax is hard to decipher. |
||
{ | ||
metrics.get()->*p->second.second = p->second.first->getMetrics(); | ||
} | ||
|
@@ -278,10 +271,9 @@ namespace IceInternal | |
IceMX::MetricsMap objects; | ||
|
||
std::lock_guard lock(_mutex); | ||
for (typename std::map<std::string, EntryTPtr>::const_iterator p = _objects.begin(); p != _objects.end(); | ||
++p) | ||
for (const auto& object : _objects) | ||
{ | ||
objects.push_back(p->second->clone()); | ||
objects.push_back(object.second->clone()); | ||
} | ||
return objects; | ||
} | ||
|
@@ -291,10 +283,9 @@ namespace IceInternal | |
IceMX::MetricsFailuresSeq failures; | ||
|
||
std::lock_guard lock(_mutex); | ||
for (typename std::map<std::string, EntryTPtr>::const_iterator p = _objects.begin(); p != _objects.end(); | ||
++p) | ||
for (const auto& object : _objects) | ||
{ | ||
IceMX::MetricsFailures f = p->second->getFailures(); | ||
IceMX::MetricsFailures f = object.second->getFailures(); | ||
if (!f.failures.empty()) | ||
{ | ||
failures.push_back(f); | ||
|
@@ -306,7 +297,7 @@ namespace IceInternal | |
IceMX::MetricsFailures getFailures(const std::string& id) override | ||
{ | ||
std::lock_guard lock(_mutex); | ||
typename std::map<std::string, EntryTPtr>::const_iterator p = _objects.find(id); | ||
auto p = _objects.find(id); | ||
if (p != _objects.end()) | ||
{ | ||
return p->second->getFailures(); | ||
|
@@ -316,8 +307,7 @@ namespace IceInternal | |
|
||
std::pair<MetricsMapIPtr, SubMapMember> createSubMap(const std::string& subMapName) | ||
{ | ||
typename std::map<std::string, std::pair<SubMapMember, MetricsMapIPtr>>::const_iterator p = | ||
_subMaps.find(subMapName); | ||
auto p = _subMaps.find(subMapName); | ||
if (p != _subMaps.end()) | ||
{ | ||
return std::pair<MetricsMapIPtr, SubMapMember>( | ||
|
@@ -332,17 +322,17 @@ namespace IceInternal | |
// | ||
// Check the accept and reject filters. | ||
// | ||
for (std::vector<RegExpPtr>::const_iterator p = _accept.begin(); p != _accept.end(); ++p) | ||
for (const auto& filter : _accept) | ||
{ | ||
if (!(*p)->match(helper, false)) | ||
if (!filter->match(helper, false)) | ||
{ | ||
return nullptr; | ||
} | ||
} | ||
|
||
for (std::vector<RegExpPtr>::const_iterator p = _reject.begin(); p != _reject.end(); ++p) | ||
for (const auto& filter : _reject) | ||
{ | ||
if ((*p)->match(helper, true)) | ||
if (filter->match(helper, true)) | ||
{ | ||
return nullptr; | ||
} | ||
|
@@ -361,10 +351,8 @@ namespace IceInternal | |
else | ||
{ | ||
std::ostringstream os; | ||
std::vector<std::string>::const_iterator q = _groupBySeparators.begin(); | ||
for (std::vector<std::string>::const_iterator p = _groupByAttributes.begin(); | ||
p != _groupByAttributes.end(); | ||
++p) | ||
auto q = _groupBySeparators.begin(); | ||
for (auto p = _groupByAttributes.begin(); p != _groupByAttributes.end(); ++p) | ||
{ | ||
os << helper(*p); | ||
if (q != _groupBySeparators.end()) | ||
|
@@ -395,7 +383,7 @@ namespace IceInternal | |
return previous; | ||
} | ||
|
||
typename std::map<std::string, EntryTPtr>::const_iterator p = _objects.find(key); | ||
auto p = _objects.find(key); | ||
if (p == _objects.end()) | ||
{ | ||
TPtr t = std::make_shared<T>(); | ||
|
@@ -443,7 +431,7 @@ namespace IceInternal | |
if (static_cast<int>(_detachedQueue.size()) == _retain) | ||
{ | ||
// Remove entries which are no longer detached | ||
typename std::list<EntryTPtr>::iterator p = _detachedQueue.begin(); | ||
auto p = _detachedQueue.begin(); | ||
while (p != _detachedQueue.end()) | ||
{ | ||
if (!(*p)->isDetached()) | ||
|
@@ -563,7 +551,7 @@ namespace IceInternal | |
std::shared_ptr<MetricsMapFactoryT<MetricsType>> factory; | ||
{ | ||
std::lock_guard lock(_mutex); | ||
std::map<std::string, MetricsMapFactoryPtr>::const_iterator p = _factories.find(map); | ||
auto p = _factories.find(map); | ||
if (p == _factories.end()) | ||
{ | ||
return; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppressed for now as -fix doesn't deal well with macro conditionals and produces incorrect code.