We've been going back and forth between GEPs and complex DWARF
expressions based on the context pointer; this goes back to the latter,
as that fixes simple nested variables for CodeView with LLVM >= 6.
I guess it also helps for debuginfos of nested vars with enabled
optimizations.
And make sure the template instance names include the template
parameters, a regression after #2826.
Also prevent `TemplatedSymbol(...).TemplatedSymbol` names, just use
`TemplatedSymbol!(...)` instead.
Once again closer to GDC and Clang's output, and attaching static variables to the module scope prevents an assert from triggering in IR/DIBuilder.cpp:
checkGlobalVariableScope(): Assertion `CT->getIdentifier().empty() && "Context of a global variable should not be a type with identifier"'
Previously entries were made children of the compile unit, and both global and imported symbols were only accessible by using their mangled name, or since the latest commit by their qualified name.
This brings the DWARF output closer to GDC's.
Static arrays of classes, pointers to class (and perhaps global class variables) ended up with a wrong DIType because of wrong CreateTypeDescription() calls for class types.
Ex.: Array!FuncDeclaration caused an infinite recursion crash in GDB, because for its « FuncDeclaration[SMALLARRAYCAP] smallarray » field DIBuilder::CreateSArrayType() had DIBuilder return a value type instead of a reference type for FuncDeclaration.
- Fix the value of closure variables in the parent function. Previously the passed value was the GEP instruction into .frame, and that instruction corresponds to a register so resulted in "DWARF-2 expression error: DW_OP_reg operations must be used either alone(...)" (also the address was incorrect anyway because the offset would get doubled by 'addr')
- When emitting debug info for a parent function parameter that is accessed from a nested function, call DIBuilder.createAutoVariable instead of createParameterVariable. Two different variables for the same parameter index was triggering an assert in llvm::DbgVariable::addMMIEntry. This fixes the compilation of druntime and phobos when building against LLVM 3.8.