Fixes the issue highlighted in http://lists.llvm.org/pipermail/cfe-dev/2014-June/037500.html.
The DW_AT_decl_file and DW_AT_decl_line attributes on namespaces prevent LLVM from uniquing types that are in the same namespace. They also don't carry any meaningful information.
Here's the canonical example of why this is broken:
$ cat test1.cpp #include "test.h" // namespace test is in test.h test::Test<int> foo1() { return test::Test<int>(); } $ cat test2.cpp namespace test { // namespace test is in test2.cpp } #include "test.h" test::Test<int> foo2() { return test::Test<int>(); } $ cat test.h namespace test { template <class T> class Test { }; } $ clang++ -g -emit-llvm test1.cpp -S -o test1.ll $ clang++ -g -emit-llvm test2.cpp -S -o test2.ll $ llvm-link test1.ll test2.ll -S -o linked.ll $ llc linked.ll
This patch removes the line and file attribute from DINamespace, and generates anonymous namespaces as distinct to prevent uniquing where it would be incorrect. The discussion in the linked thread predates distinct MDNodes which was the missing ingredient to make this happen.
rdar://problem/17484998
This is no longer accurate (& the code below's no longer correct)?