Open syyyr opened 2 days ago
@llvm/issue-subscribers-clangd
Author: Václav Kubernát (syyyr)
Reduced testcase:
test.hpp:
template <typename F>
void call(F f) { f(0); }
test.cpp:
#include "test.hpp"
namespace {
void bar() {}
}
void foo() {
call([](auto) { bar(); });
}
int main() {
foo();
}
The issue is that clangd skips parsing the bodies of function templates in included headers for performance reasons, so it doesn't see the call to bar()
that's inside the instantiation of call()
.
I think this performance optimization means clangd is unable to reliably issue -Wunneeded-internal-declaration
. Maybe clangd should just disable this warning even if it's present in the compile flags?
A workaround for now is to disable the warning for clangd by adding the following to a .clangd
config file:
CompileFlags:
Add: [-Wno-unneeded-internal-declaration]
Hi, I have this code (sorry it has Qt, I'm not able to reproduce it without it):
This code results in
bar()
being called and "Hello from bar" being printed. However, when I open this file in my editor, where I use clangd, I get a warning that says:This is wrong, it is needed, because it is called.
The command I use to compile this program is:
My clang version: