Skip to content

[Basic] Include SmallVector.h for Clang <= 5 #60426

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

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Aug 6, 2022

Clang 5 (possibly earlier) has a bug where it does not merge default
template arguments properly for forwarded declarations. Include
SmallVector.h directly in this case. This will slightly increase
compile times, but only for very old compilers and only for files that
don't already include SmallVector.h (of which there's currently only
23).

Clang 5 (possibly earlier) has a bug where it does not merge default
template arguments properly for forwarded declarations. Include
`SmallVector.h` directly in this case. This will slightly increase
compile times, but only for very old compilers and only for files that
don't already include `SmallVector.h` (of which there's currently only
23).
@bnbarham
Copy link
Contributor Author

bnbarham commented Aug 6, 2022

I found the reverted cases by grepping the log for SmallVector. I'm pretty positive there's been others but... good enough for now 🤷

@bnbarham
Copy link
Contributor Author

bnbarham commented Aug 6, 2022

@swift-ci please test

@bnbarham bnbarham requested a review from aschwaighofer August 6, 2022 00:33
@@ -449,7 +449,7 @@ int main(int argc, char *argv[]) {
return 1;
}

SmallVector<std::unique_ptr<SourceEditConsumer>, 32> Consumers;
Copy link
Contributor

Choose a reason for hiding this comment

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

The default here would be quite a bit smaller, if it matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the only place it's added to is below. So technically this could be 2 if we really cared, but given this is just a testing tool and not even remotely hot 🤷

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Sema changes look good, thank you!

@bnbarham
Copy link
Contributor Author

bnbarham commented Aug 6, 2022

Sema changes look good, thank you!

Just to be clear, the only changes I made were reverts where there was a "added default size"-like commit after the initial commit. There's likely many places the default size is preferable but I figure this is okay for a starting point 😅

With the change to include `SmallVector.h` directly in `LLVM.h` rather
than forward declaring in the only case it matters (ie. Clang <= 5),
these fixes are no longer needed. Since defaulted version is preferred
when there's no better choice (which is presumably the case if that's
how they were originally added), use it instead. Some uses were instead
changed to add `llvm::` so remove that too.
@bnbarham
Copy link
Contributor Author

bnbarham commented Aug 6, 2022

@swift-ci please test

@xedin
Copy link
Contributor

xedin commented Aug 6, 2022

@bnbarham Yes, that’s totally fine!

@gottesmm
Copy link
Contributor

gottesmm commented Aug 6, 2022

@bnbarham this seems to change behavior no? Wouldn't it just make sense to get rid of SmallVector<T, N> if N is the default value? These seem to be different values of N.

@bnbarham
Copy link
Contributor Author

bnbarham commented Aug 8, 2022

Yes, but I'm not convinced the old default values were chosen for any particular reason @gottesmm. All these were from commits that came in after a failure on CentOS 7 (and 2 in the last week). Are there any in particular you're concerned about?

@gottesmm
Copy link
Contributor

gottesmm commented Aug 9, 2022

As long as that is what they are, I am fine. Thanks!

@bnbarham
Copy link
Contributor Author

I went through them all to double check, they all definitely existed as the default-arg case initially and then were fixed in PRs either referencing the linux failure or on "fix rebranch" PRs (I wonder if CentOS 7 was initially brought up on rebranch?). Going to go ahead and merge.

@bnbarham bnbarham merged commit a59fa46 into swiftlang:main Aug 10, 2022
@bnbarham bnbarham deleted the include-smallvec branch August 10, 2022 22:54
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.

5 participants