This patch moves DWARFTypePrinter class to its own file, so that it
might be reused. It will help D96035, which uses DWARFTypePrinter.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I don't especially object to moving this to a separate file - but maybe it'd be more suitable to have this exposed as a function on DWARFDie, rather than exposing the whole DWARFTypePrinter API?
i.e. something similar to this:
void DWARFDie::dumpTypeQualifiedName(raw_ostream& OS); void DWARFDie::dumpTypeUnqualifiedName(raw_ostream& OS, std::string *OriginalFullName = nullptr);
If that is a preferred variant - I will change the patch accordingly.
Though, The variant with a separate class has an advantage in that it separates dumping functionality from the DWARFDie class.
That is similar to the "Model-View" pattern. If we would add more dumps(for different programming languages, or for different DWARFDie kinds) then we would be necessary to add more dumping functions into the DWARFDie interface, which is probably not a good thing:
void DWARFDie::dumpSubprogram(raw_ostream& OS); void DWARFDie::dumpRanges(raw_ostream& OS);
From that point of view, using a separate class for dumping probably looks preferable. It allows keeping the DWARFDie interface simpler.
But if adding specific dumping methods to the DWARFDie looks better for us - I am OK to do this.
Oh, fair point - how about free functions, then? void dumpTypeQualifiedName(DWARFDie D, raw_ostream &OS) - that sort of thing?
addressed comments(left DWARFTypePrinter inside DWARFDie.cpp, created two functions for type printing)