Clang supports having SourceLocations added to most declarations which are used for error diagnostics
to let the user know from which file/line a certain declaration came from.
Currently we assign all Clang declarations that are generated by the DWARF parser an invalid
SourceLocation, which leads to confusing error messages that tell the user things such as "previously declared here:"
but not any file path or line number that tells the user where "here" is.
This patch partly fixes the issue by assigning all declarations generated by the DWARF parser a valid SourceLocation.
The SourceLocations that are generated all point to dummy files that are just located in memory and just contain
the string <content of /path/to/file.cpp>. This is just done to keep this patch simple, but the idea is that in the
future we open the actual source files and let the SourceLocations point there to the right line/column. For now
we just display the file path which is the only thing we get correct for now.
The new diagnostics look like this:
(lldb) expr --top-level -- struct Foo {}; error: <user expression 0>:1:8: redefinition of 'Foo' struct Foo {}; ^ /path/to/test/loc.cpp: previous definition is here
The old diagnostics are the same but are missing the part before and after the "previous definition is here" error.
This feature can be turned off by setting plugin.symbol-file.dwarf.use-source-locations to false.
Partly fixes rdar://8670536
nit: I usually spell the default return value as return {} but there's no LLVM coding style rule for this.