This is an archive of the discontinued LLVM Phabricator instance.

Replace uses of std::iterator with explicit using
ClosedPublic

Authored by hamzasood on Sep 14 2019, 9:25 AM.

Details

Summary

This patch removes all uses of std::iterator, which was deprecated in C++17.
While this isn't currently an issue while compiling LLVM, it's useful for those using LLVM as a library.

For some reason there're a few places that were seemingly able to use std functions unqualified, which no longer works after this patch. I've updated those places, but I'm not really sure why it worked in the first place.

Diff Detail

Event Timeline

hamzasood created this revision.Sep 14 2019, 9:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2019, 9:25 AM

I just realised that the unqualified calls worked because a base class of type std::iterator means that functions in namespace std will be found by ADL. So you can ignore the last paragraph in the patch summary.

MaskRay accepted this revision.Sep 24 2019, 10:56 PM

Looks good!

// P0174
Update from Jacksonville, 2016:

Poll: Deprecate iterator for C++17??

SF	F	N	A	SA
6	10	1	0	0

I just realised that the unqualified calls worked because a base class of type std::iterator means that functions in namespace std will be found by ADL. So you can ignore the last paragraph in the patch summary.

You can edit the summary to mention that due to the loss of ADL you have to prepend std:: in a few places.

Have you done a check-all (llvm,clang,lldb,lld,etc) to ensure nothing else breaks?

This revision is now accepted and ready to land.Sep 24 2019, 10:56 PM
MaskRay retitled this revision from Replace uses of std::iterator with explicit typedefs to Replace uses of std::iterator with explicit using.Sep 24 2019, 10:58 PM

Hey, anything that needs to be done before this PR can be merged (rebase, etc.)? I'd be willing to give it a shot if so 🙂

Otherwise, it'd be nice to be merged...

This comment was removed by 1whatleytay.

Hey, anything that needs to be done before this PR can be merged (rebase, etc.)? I'd be willing to give it a shot if so 🙂

Otherwise, it'd be nice to be merged...

Hi @1whatleytay,

The process is usually for the patch author to commit it themselves, once they have commit access. If you don't have commit access, you need to ask one of the people who reviewed your patch (or indeed any other person with commit access), to submit it on your behalf. In order for them to be able to, you'll need to provide them with your email and name for the git log. Once you've contributed a few patches, you can request access for yourself. For full details, see https://llvm.org/docs/Contributing.html#how-to-submit-a-patch

As this patch is quite old, it would likely also be helpful to the person who eventually pushes if you rebase this on the latest main branch.

hamzasood updated this revision to Diff 336673.Apr 11 2021, 9:05 AM

I had no idea that this was left incomplete. I've rebased the patch and applied the same process to some new classes that were added in the meantime.

I don't have commit access anymore after the move to Git, so I'd appreciate it if someone could commit this on my behalf.

I had no idea that this was left incomplete. I've rebased the patch and applied the same process to some new classes that were added in the meantime.

I don't have commit access anymore after the move to Git, so I'd appreciate it if someone could commit this on my behalf.

I made clang-format fixes. I am testing and will push it on your behalf. Thanks!

This revision was landed with ongoing or failed builds.Apr 12 2021, 10:47 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2021, 10:47 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript