llvm / llvm/llvm-project

[clangd] [Signature help] [C++23] Parameter hints do not appear for static operator (and some obscure interaction with templates)

Open
#196,153 10 comments 0 reactions 0 assignees Claimed by @Ippo47 View on GitHub
clangd
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

In the following example code I do not get any parameter hints for the operator, but if I manually type in `true` clangd recognizes that I am calling the operator.

```
struct Abc {
static void operator()(bool a) {}
};

void test() {
Abc abc;
abc(^);
}
```

Image

If I remove the `static` from the operator definition I do get the paramtere hints.

```
struct Abc {
void operator()(bool a) {}
};

void test() {
Abc abc;
abc(^);
}
```

Image

As straight forward as this bug seems to be, I stumbled upon some more odd behaviour. Consider now me using 2 parameters, this still does not work with static as you can see here.

```
struct Abc {
static void operator()(bool a, bool b) {}
};

void test() {
Abc abc;
abc(^);
}
```

Image

But if I now template my operator it does work.

```
struct Abc {
template
static void operator()(T a, bool b) {}
};

void test() {
Abc abc;
abc(^);
}
```

Image

The odd part here is that I **need** 2 parameters for my operator, because the templated version with only 1 parameter does **not** work.

```
struct Abc {
template
static void operator()(T a) {}
};

void test() {
Abc abc;
abc(^);
}
```

Image

Also it is important that the template type is used in the parameters, otherwise it does **not** work.

```
struct Abc {
template
static void operator()(bool a, bool b) { T c; }
};

void test() {
Abc abc;
abc(^);
}
```

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.