This is an archive of the discontinued LLVM Phabricator instance.

[clang][clangd][c++20] Improve support of type constraints in TemplateTypeParms.
Needs ReviewPublic

Authored by massberg on Jul 17 2023, 6:50 AM.

Details

Reviewers
sammccall
Summary

Consider type constraints of TemplateTypeParmDecls in FindTarget.
To this end TemplateTypeParmTypeLoc:getLocalSourceRange() now also includes
the whole constraint if there is any.

In clangd this enables that Hover now works for type constraints of auto function parameters and
template parameters.

Diff Detail

Event Timeline

massberg created this revision.Jul 17 2023, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 6:50 AM
massberg requested review of this revision.Jul 17 2023, 6:50 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 17 2023, 6:50 AM
massberg added inline comments.Jul 17 2023, 6:54 AM
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
562

This is now a TemplateTypeParmTypeLoc as we have extended TemplateTypeParmTypeLoc:getLocalSourceRange() to include the constraint. Might this be problematic?

clang/unittests/AST/SourceLocationTest.cpp
274

This range looks a bit to long. What I'm doing wrong?

massberg added inline comments.Jul 17 2023, 7:35 AM
clang/unittests/AST/SourceLocationTest.cpp
274

Arg, ok T is also a constrained template type parameter, but with this patch we consider the whole template type parameter as concept which is in this case wrong (but works for the constrained auto as function parameter).

nridge added a subscriber: nridge.Jul 22 2023, 5:53 PM