Adding -flto will drop variable in namespace from .debug_names:
echo 'namespace N { int varname; int func() { return varname; } } int main(){ N::func(); }'|clang++ -Wall -Werror -gdwarf-5 -gpubnames -fuse-ld=lld -flto -x c++ -;llvm-dwarfdump -debug-names
In .debug_names N::func is always present but N::varname is present only when -flto is not used.
Unfortunately I do not know much more what to do with it so posting it FYI.
The testcase should use *.ll format but then I could not make it use LLD LTO.