Previously we would create an lldb::Function object for each function parsed, but we would not add these to the clang AST. This is a first step towards getting local variable support working, as we first need an AST decl so that when we create local variable entries, they have the proper DeclContext.
Clang-cl emits S_LOCAL symbols while MSVC emits S_REGREL32 and S_REGISTER symbols. So, to get more test coverage, I added an MSVC test as well. Also a little NFC cleanup in the main source file (basically just making sure these decls get added to the decl map).
I don't want to block this patch, but my thoughts after reading this is that this is repeating the same mistakes that we did with dwarf. The reason we need so much to run our tests in so many configurations is that we haven't found a way way to handle the fact that some things can be expressed in multiple ways in the debug info other than compiling the source code with the compiler which happens to use that dialect. Then, if a later e.g. clang chooses to do the same thing that msvc does, we lose coverage here without anyone noticing. For low-level details like these, I believe a test where the type of the symbol is explicit would be more appropriate (for dwarf that might be a .s file, I don't know if that would work for pdbs).
I considered this, and we actually have a test that does (see s_constant.s). The reason I didn't do it here because my experience writing s_constant.s taught me just how difficult it is to write these assembly files.
However, now I have a new idea. We can teach llvm-pdbutil to dump its output exactly in llvm assembly format, so the output can just be copy-pasted into a .s file. Then, we can build something with MSVC, dump it to .s format, and paste individual records into a test and mix and match them as necessary to create all the interesting cases.
For the purposes of this test, we don't even need to run the program, so it actually doesn't even matter if the addresses in the debug info records are correct. All we care about is that the AST is reconstructed correctly. I'll add this to my todo list because I think it would be a really useful feature.
|577 ↗||(On Diff #177039)|
Let me know how the new diff looks.