Skip to content
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

Support expanding decltype(expr) #1456

Closed
v1nh1shungry opened this issue Jan 8, 2023 · 1 comment
Closed

Support expanding decltype(expr) #1456

v1nh1shungry opened this issue Jan 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@v1nh1shungry
Copy link

Like the existing code action Expand auto type, a new tweak that can expand

decltype(0) i;
// ^ cursor here

to

int i;
@v1nh1shungry v1nh1shungry added the enhancement New feature or request label Jan 8, 2023
@v1nh1shungry
Copy link
Author

Expanding decltype(expr) is kind of similar to expanding auto. It may be a good idea to directly enable the existing ExpandAutoType action to expand decltype(expr). There is also a FIXME comment saying "support decltype" in ExpandAutoType.cpp.

So I wrote a rough implementation: https://reviews.llvm.org/D141226.

I have a feeling that this won't bring much enhancement, but I think the cost is still acceptable. Could anyone please have a look and give some suggestions?

Thanks!

CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Jan 13, 2023
Enable the existing tweak `ExpandAutoType` to expand
`decltype(expr)`, e.g.

```
decltype(0) i;
```

will expand to

```
int i;
```

Therefore, rename the tweak `ExpandAutoType` to `ExpandDeducedType`.

This patch also fixes some nits,

* avoid replacing reference to a function
* avoid replacing array types and reference to an array

Fixes clangd/clangd#1456

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D141226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant