Skip to content

Commit

Permalink
[clangd][c++20] Add concept Hover tests.
Browse files Browse the repository at this point in the history
Concepts aren't fully supporteb by hover yet. For the currently
supported case we add a test here to prevent regressions in the future.

Differential Revision: https://reviews.llvm.org/D155558
  • Loading branch information
jensmassberg committed Jul 18, 2023
1 parent b71ac7e commit e9ab43d
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions clang-tools-extra/clangd/unittests/HoverTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,32 @@ class Foo final {})cpp";
HI.Kind = index::SymbolKind::TypeAlias;
HI.Definition = "Foo<int>";
}},
// constrained template parameter
{R"cpp(
template<class T> concept Fooable = true;
template<[[Foo^able]] T>
void bar(T t) {}
)cpp",
[](HoverInfo &HI) {
HI.NamespaceScope = "";
HI.Name = "Fooable";
HI.Kind = index::SymbolKind::Concept;
HI.Definition = "template <class T>\nconcept Fooable = true";
}},
{R"cpp(
template<class T> concept Fooable = true;
template<Fooable [[T^T]]>
void bar(TT t) {}
)cpp",
[](HoverInfo &HI) {
HI.Name = "TT";
HI.Type = "class";
HI.AccessSpecifier = "public";
HI.NamespaceScope = "";
HI.LocalScope = "bar::";
HI.Kind = index::SymbolKind::TemplateTypeParm;
HI.Definition = "Fooable TT";
}},

// empty macro
{R"cpp(
Expand Down Expand Up @@ -3025,17 +3051,17 @@ TEST(Hover, Providers) {
const char *Code;
const std::function<void(HoverInfo &)> ExpectedBuilder;
} Cases[] = {{R"cpp(
struct Foo {};
struct Foo {};
Foo F = Fo^o{};
)cpp",
[](HoverInfo &HI) { HI.Provider = ""; }},
{R"cpp(
#include "foo.h"
#include "foo.h"
Foo F = Fo^o{};
)cpp",
[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
{R"cpp(
#include "all.h"
#include "all.h"
Foo F = Fo^o{};
)cpp",
[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
Expand All @@ -3055,7 +3081,7 @@ TEST(Hover, Providers) {
)cpp",
[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
{R"cpp(
#include "foo.h"
#include "foo.h"
Foo A;
Foo B;
Foo C = A ^+ B;
Expand Down

0 comments on commit e9ab43d

Please sign in to comment.