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
Missing FoundDecl in ConceptReference. #82628
Comments
@llvm/issue-subscribers-clang-frontend Author: Haojian Wu (hokein)
Given the following code, the `FoundDecl` is null in the `Foo`'s AST node (`ConceptReference`).
This breaks some clang tools: include-cleaner will report the file of the underlying decl, rather than the one for using decl; clangd's go-to-def on |
I think the reason is that llvm-project/clang/include/clang/Sema/Lookup.h Lines 563 to 567 in 1f6a347
llvm-project/clang/lib/Sema/SemaTemplate.cpp Lines 5076 to 5080 in 1f6a347
Perhaps it should have been |
And applying that modification gives us the AST: `-ConceptDecl 0x7fd5249c13c8 <line:6:1, col:40> col:29 Bar
|-TemplateTypeParmDecl 0x7fd5249c1230 <col:10, col:19> col:19 referenced typename depth 0 index 0 T
`-ConceptSpecializationExpr 0x7fd5249c1398 <col:35, col:40> 'bool' UsingShadow 0x7fd5249c11b0 'Foo' compared to that before:
|
@llvm/issue-subscribers-c-20 Author: Haojian Wu (hokein)
Given the following code, the `FoundDecl` is null in the `Foo`'s AST node (`ConceptReference`).
This breaks some clang tools: include-cleaner will report the file of the underlying decl, rather than the one for using decl; clangd's go-to-def on |
@zyn0217 thanks for the investigation, it makes sense, do you mind sending out a fix? |
Hmm, this is more complicated than I expected: for the type constraint cases, e.g. namespace ns {
template<typename T> concept Foo = true;
}
using ns::Foo;
template <Foo T> // <-- Note here
void foo(); The llvm-project/clang/lib/AST/TemplateName.cpp Lines 145 to 152 in 597f976
llvm-project/clang/lib/Sema/SemaTemplate.cpp Lines 1145 to 1177 in 597f976
|
The type constraint cases are not that hard to tackle, but constraints on (I hope I can figure them all out, but it takes some time.) |
The `ConceptReference`'s `FoundDecl` claims it "can differ from `NamedConcept` when, for example, the concept was found through a `UsingShadowDecl`", but such the contract was not previously respected. Fixes #82628
Given the following code, the
FoundDecl
is null in theFoo
's AST node (ConceptReference
).This breaks some clang tools: include-cleaner will report the file of the underlying decl, rather than the one for using decl; clangd's go-to-def on
Foo
jumps to the underlying decl.The text was updated successfully, but these errors were encountered: