Skip to content
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 20 commits into from
Jan 14, 2025
Merged

Conversation

bernardnormier
Copy link
Member

This PR fixes:

  • modernize-use-nullopt
  • modernize-use-emplace
  • modernize-use-auto
  • modernize-loop-convert

It also fixes the syntax for NOLINT.

It was mostly done using "-fix" ... but with additional fixes as "-fix" is not always correct/good.

@@ -8,6 +8,7 @@ Checks:
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-modernize-concat-nested-namespaces,
-modernize-use-default-member-init,
Copy link
Member Author

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.

cpp/include/Ice/Communicator.h Show resolved Hide resolved
_subMaps.begin();
p != _subMaps.end();
++p)
for (auto p = _subMaps.begin(); p != _subMaps.end(); ++p)
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

cpp/src/Ice/IPEndpointI.cpp Outdated Show resolved Hide resolved
cpp/src/Ice/MetricsAdminI.cpp Outdated Show resolved Hide resolved
cpp/src/Ice/SSL/SSLUtil.cpp Outdated Show resolved Hide resolved
cpp/src/Ice/SSL/SSLUtil.cpp Outdated Show resolved Hide resolved
cpp/src/IceGrid/Database.cpp Outdated Show resolved Hide resolved
cpp/src/IceGrid/Database.cpp Outdated Show resolved Hide resolved
cpp/src/IceGrid/Util.h Outdated Show resolved Hide resolved
Copy link
Member

@externl externl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think many loop still need to be fixed.

cpp/include/Ice/MetricsObserverI.h Outdated Show resolved Hide resolved
cpp/include/Ice/MetricsObserverI.h Show resolved Hide resolved
cpp/include/Ice/MetricsObserverI.h Outdated Show resolved Hide resolved
cpp/include/Ice/Communicator.h Show resolved Hide resolved
@@ -31,15 +31,15 @@ namespace Ice::SSL
bool
DistinguishedName::match(const DistinguishedName& other) const
{
for (list<pair<string, string>>::const_iterator p = other._unescaped.begin(); p != other._unescaped.end(); ++p)
for (const auto& p : other._unescaped)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to use a variable like name instead of p and q.

cpp/src/Ice/Communicator.cpp Outdated Show resolved Hide resolved
cpp/src/Ice/ConnectionFactory.cpp Outdated Show resolved Hide resolved
cpp/src/Ice/ConnectionFactory.cpp Outdated Show resolved Hide resolved
cpp/src/Ice/IPEndpointI.cpp Outdated Show resolved Hide resolved
cpp/src/Ice/Instance.cpp Outdated Show resolved Hide resolved
Copy link
Member

@InsertCreativityHere InsertCreativityHere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only through some of the files, it seems good so far,
although I think the tool is still missing some const auto& in for loops.

If you want to take a look: for\s*\(auto(?!&)

@bernardnormier bernardnormier merged commit bc36e5b into zeroc-ice:main Jan 14, 2025
23 checks passed
@bernardnormier bernardnormier deleted the clang-tidy4 branch January 21, 2025 19:01
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants