mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 14:36:46 +00:00
[Clang] Retain the angle loci for invented template parameters of constraints (#92104)
Clangd uses it to determine whether the argument is within the selection range. Fixes https://github.com/clangd/clangd/issues/2033
This commit is contained in:
parent
d9db266499
commit
8070b2defa
@ -589,6 +589,12 @@ TEST(SelectionTest, CommonAncestor) {
|
||||
auto x = [[ns::^C<int>]];
|
||||
)cpp",
|
||||
"ConceptReference"},
|
||||
{R"cpp(
|
||||
template <typename T, typename K>
|
||||
concept D = true;
|
||||
template <typename T> void g(D<[[^T]]> auto abc) {}
|
||||
)cpp",
|
||||
"TemplateTypeParmTypeLoc"},
|
||||
};
|
||||
|
||||
for (const Case &C : Cases) {
|
||||
|
@ -3099,7 +3099,8 @@ InventTemplateParameter(TypeProcessingState &state, QualType T,
|
||||
// The 'auto' appears in the decl-specifiers; we've not finished forming
|
||||
// TypeSourceInfo for it yet.
|
||||
TemplateIdAnnotation *TemplateId = D.getDeclSpec().getRepAsTemplateId();
|
||||
TemplateArgumentListInfo TemplateArgsInfo;
|
||||
TemplateArgumentListInfo TemplateArgsInfo(TemplateId->LAngleLoc,
|
||||
TemplateId->RAngleLoc);
|
||||
bool Invalid = false;
|
||||
if (TemplateId->LAngleLoc.isValid()) {
|
||||
ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
|
||||
|
@ -107,3 +107,16 @@ auto FooFunc(C auto V) -> C decltype(auto) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace constraint_auto_params {
|
||||
|
||||
template <class T, class K>
|
||||
concept C = true;
|
||||
|
||||
template<class T>
|
||||
void g(C<T> auto Foo) {}
|
||||
|
||||
// CHECK: TemplateTypeParmDecl {{.*}} depth 0 index 1 Foo:auto
|
||||
// CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} <col:8, col:11>
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user