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

Include Cleaner fails for symbols forward-declared and aliased #2043

Open
graveljp opened this issue May 17, 2024 · 0 comments
Open

Include Cleaner fails for symbols forward-declared and aliased #2043

graveljp opened this issue May 17, 2024 · 0 comments

Comments

@graveljp
Copy link

Clangd's include cleaner fails for symbols from one file forward-declared and aliased in a different file. In the following example, both "forward.h" and "impl.h" are required for the code to compile. Yet, clangd claims "impl.h" is unused. It's not unused since it's providing Foo::kValue.

impl.h

#pragma once

namespace impl {
enum class Foo : int {
  kValue = 0
};
}

forward.h

#pragma once

namespace impl {
  enum class Foo : int;
}

using impl::Foo;

main.cc

#include "forward.h"
#include "impl.h"  // Clangd warns: "Included header impl.h is not used directly "

int main() {
  Foo foo = Foo::kValue;
  return 1;
}

System information

Output of clangd --version:
clangd version 19.0.0git (https://github.com/llvm/llvm-project.git 55e59083cb610f30ad21fe8c8cdb9900534937ec)
Features: linux
Platform: x86_64-unknown-linux-gnu

Editor/LSP plugin:
VSCode

Operating system:
Linux

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

1 participant