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

Wrong parameter types in extracted function #640

Closed
OleksandrKvl opened this issue Jan 5, 2021 · 1 comment
Closed

Wrong parameter types in extracted function #640

OleksandrKvl opened this issue Jan 5, 2021 · 1 comment
Assignees

Comments

@OleksandrKvl
Copy link

Extracting from this function:

void f(const std::vector<int> &v1, std::vector<int>& v2)
{
    const auto x = v1.size() + v2.size();
}

results in broken parameter types for std::vector:

void extracted(std::const std::vector<int>& v1, std::std::vector<int>& v2)
{
    const auto x = v1.size() + v2.size();
}

The problem is probably somewhere in printType()/getQualification() functions which yield a wrong string representation of a type.

System information
Output of clangd --version: Ubuntu clangd version 11.0.1-++20201218093155+43ff75f2c3fe-1exp120201218203809.158
Editor/LSP plugin: vscode 1.52.1, clangd 0.1.8
Operating system: Ubuntu 20.04

@HighCommander4
Copy link

Similar to #524

@gislan gislan self-assigned this Jan 7, 2021
arichardson pushed a commit to arichardson/llvm-project that referenced this issue Mar 29, 2021
When printing QualType with qualifiers like "const", or pointing to an
elaborated type, we would print garbage like:
  std::const std::vector<int>&
with the initial std:: being calculated correctly, but inserted in the
wrong place and the second std:: not removed (due to elaborated type).

This affected, among others, ExtractFunction and ExpandAuto tweaks.

This change introduces a new callback to PrintingPolicy, which allows us
to influence the printing of namespace qualifiers. In the future, the
same callback can be used to improve handling of "using namespace"
directives as well.

Fixes:
  clangd/clangd#640 (ExtractFunction)
  clangd/clangd#264 (ExpandAuto)
  First point of clangd/clangd#524

Differential Revision: https://reviews.llvm.org/D94259
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
When printing QualType with qualifiers like "const", or pointing to an
elaborated type, we would print garbage like:
  std::const std::vector<int>&
with the initial std:: being calculated correctly, but inserted in the
wrong place and the second std:: not removed (due to elaborated type).

This affected, among others, ExtractFunction and ExpandAuto tweaks.

This change introduces a new callback to PrintingPolicy, which allows us
to influence the printing of namespace qualifiers. In the future, the
same callback can be used to improve handling of "using namespace"
directives as well.

Fixes:
  clangd/clangd#640 (ExtractFunction)
  clangd/clangd#264 (ExpandAuto)
  First point of clangd/clangd#524

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

No branches or pull requests

3 participants