-
Couldn't load subscription status.
- Fork 15k
[Clang] Fix a wrong diagnostic about a local variable inside a lambda in unevaluated context need capture #165098
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7061,8 +7061,15 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, | |
| // anonymous unions in class templates). | ||
| } | ||
|
|
||
| if (!ParentDependsOnArgs) | ||
| if (!ParentDependsOnArgs) { | ||
| if (auto Found = | ||
| CurrentInstantiationScope | ||
| ? CurrentInstantiationScope->getInstantiationOfIfExists(D) | ||
| : nullptr) { | ||
| return cast<NamedDecl>(Found->dyn_cast<Decl *>()); | ||
|
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. Using of 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.
|
||
| } | ||
| return D; | ||
| } | ||
|
|
||
| ParentDC = FindInstantiatedContext(Loc, ParentDC, TemplateArgs); | ||
| if (!ParentDC) | ||
|
|
||
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.
I find ternary operator inside of an if uncommon, can we simply do
and spell out the type?
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.
We really need an equivalent to
.?in C++ :DMore seriously though, embedding conditional logic inside conditions is difficult to read, so we stick to reasonably linear boolean operations.
I pondered this for a bit an I think agree with @Fznamznon's proposal with an early return
if (!Found).As for the use of
auto- as a general rule if the type is not mentioned explicitly on the RHS, you should make it explicit in the variable declaration.i.e