This diff is a preview of the implementation of the LLVM portion of the CodeView RFC being discussed on the llvm-dev and cfe-dev lists. The code isn't ready for detailed code review yet. There will likely be some changes to the design based on feedback, plus there's still a bit of code clean-up to do. Once the design is settled and I've got the code finalized, I'll break it up into more easily-digestible patches for official code review. For now, though, this diff should be useful to anyone who has read the RFC and wants to see some concrete details.
The new LLVMCodeView library under lib\CodeView and the corresponding include directory implements support for emitting debug info in the CodeView format. This phase of the design only includes support for CodeView type records. Clients that need to emit type records will use a class derived from TypeTableBuilder. TypeTableBuilder provides member functions for writing each kind of type record; each of these functions eventually calls the writeRecord virtual function to emit the actual bits of the record. Derived classes override writeRecord to implement the folding of duplicate records and the actual emission to the appropriate destination. LLVMCodeView provides MemoryTypeTableBuilder, which creates the table in memory. When Clang emits type records, it uses MDTypeTableBuilder, which emits to LLVM metadata.
The rest of the types in LLVMCodeView define the actual CodeView type records and all of the supporting enums and other types used in the type records. The TypeIndex class is of particular interest, because it is used by clients as a handle to a type in the type table.
The remaining changes are mostly in lib\IR, where the debug info metadata, DIBuilder, and the readers and writers thereof needed to be updated to support CodeView. I added the new DICodeViewTypes and DICodeViewUDT nodes, added a DICodeViewTypes field to DICompileUnit, and added TypeIndex fields to DISubprogram and DIVariable.