[lldb] Unify the two CreateTypedef implementations in TypeSystemClang

Authored by teemperor on Dec 17 2020, 1:46 AM.


[lldb] Unify the two CreateTypedef implementations in TypeSystemClang

To get LLDB one step closer to fulfil the software redundancy requirements of
modern aircrafts, we apparently decided to have two separately maintained
implementations of CreateTypedef in TypeSystemClang. Let's pass on the idea of
an LLDB-powered jetliner and deleted one implementation.

On a more serious note: This function got duplicated a long time ago when the
idea of CompilerType with a backing TypeSystemClang subclass happened
(56939cb31061d24ae3d1fc62da38b57e78bb2556). One implementation was supposed to
be called from CompilerType::CreateTypedef and the other has just always been
around to create typedefs. By accident one of the implementations is only used
by the PDB parser while the CompilerType::CreateTypedef backend is used by the
rest of LLDB.

We also had some patches over the year that only fixed one of the two functions
(D18099 for example only fixed up the CompilerType::CreateTypedef
implementation). D51162 and D86140 both fixed the same missing addDecl call
for one of the two implementations.

This patch:

  • deletes the CreateTypedefType function as its only used by the PDB parser and the CreateTypedef implementation is anyway needed as it's the backend implementation of CompilerType.
  • replaces the calls in the PDB parser by just calling the CompilerType wrapper.
  • moves the documentation to the remaining function.
  • moves the check for empty typedef names that was only in the deleted implementation to the other (I don't think this fixes anything as I believe all callers are already doing the same check).

I'll fix up the usual stuff (not using StringRef, not doing early exit) in a NFC

This patch is not NFC as the PDB parser now calls the function that has the fix
from D18099.

Reviewed By: labath, JDevlieghere

Differential Revision: https://reviews.llvm.org/D93382