-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
[clang][Sema] Improve collectViableConversionCandidates
#97908
Merged
cor3ntin
merged 3 commits into
llvm:main
from
MagentaTreehouse:improve-collect-viable-conv
Sep 14, 2024
Merged
[clang][Sema] Improve collectViableConversionCandidates
#97908
cor3ntin
merged 3 commits into
llvm:main
from
MagentaTreehouse:improve-collect-viable-conv
Sep 14, 2024
Conversation
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
* Use range-based for * The value of `Conv` is not used when `ConvTemplate` is not null, so we do not need to compute it on that path
llvmbot
added
clang
Clang issues not falling into any other category
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
labels
Jul 6, 2024
@llvm/pr-subscribers-clang Author: None (MagentaTreehouse) Changes
Full diff: https://github.com/llvm/llvm-project/pull/97908.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5ea6b06121c7c..95c433dab4da4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6504,29 +6504,23 @@ static void
collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType,
UnresolvedSetImpl &ViableConversions,
OverloadCandidateSet &CandidateSet) {
- for (unsigned I = 0, N = ViableConversions.size(); I != N; ++I) {
- DeclAccessPair FoundDecl = ViableConversions[I];
+ for (DeclAccessPair FoundDecl : ViableConversions.pairs()) {
NamedDecl *D = FoundDecl.getDecl();
CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext());
if (isa<UsingShadowDecl>(D))
D = cast<UsingShadowDecl>(D)->getTargetDecl();
- CXXConversionDecl *Conv;
- FunctionTemplateDecl *ConvTemplate;
- if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
- Conv = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl());
- else
- Conv = cast<CXXConversionDecl>(D);
-
- if (ConvTemplate)
+ if (auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
SemaRef.AddTemplateConversionCandidate(
ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
- /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit*/ true);
- else
- SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From,
- ToType, CandidateSet,
- /*AllowObjCConversionOnExplicit=*/false,
- /*AllowExplicit*/ true);
+ /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit=*/true);
+ continue;
+ }
+ CXXConversionDecl *Conv = cast<CXXConversionDecl>(D);
+ SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From, ToType,
+ CandidateSet,
+ /*AllowObjCConversionOnExplicit=*/false,
+ /*AllowExplicit=*/true);
}
}
|
cor3ntin
reviewed
Sep 2, 2024
cor3ntin
approved these changes
Sep 13, 2024
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.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
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.
Conv
is not used whenConvTemplate
is not null, so we do not need to compute it on that path