[cfe-dev] Remove unused types from ASTContext

mateusz janek via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 26 14:19:35 PDT 2017


Hi,

Before I'll begin, I want to say that I don't want to implement below
'feature' in a clang production code. I want to create my own custom build
for my own needs.

Abstract:
I'm developing a hobby project which creates a lot of types in a compile
time, in one .cpp file. Really a lot. I tried to compile next version, but
it was compiling whole night and took ~30G of memory (16G RAM + swap) and
wasn't able to finish. I know that almost all of these types are 'used'
only once, they're kind of helpers.
Basically what I want to achieve is to decrease memory usage to not need to
use the swap, because it increases compilation time a lot.

Question:
Is there a way to implement a removing no longer used types? E.g.

template <typename FooParam>
struct Foo
{
    using FooResult = typename Bar<FooParam>::BarResult;
};

And I'd want to remove the 'Bar<FooParam>' type from a 'ASTContext' because
I know that I won't need it anymore. (then, if there will again occur an
initialization of very same 'Bar<FooParam>', I'm ok with that I'll need to
create it from the scratch).
So basically is there any way to detect if type is still referenced
somewhere, so I can remove it if it isn't?

I hope I've described my problem well. I know that in fact I'm asking for a
explanation how types in clang are related to each other - that's a lot,
but I'd really like to learn and understand that (:

Thanks in advance for help!

Stryku
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170426/5f374eeb/attachment.html>


More information about the cfe-dev mailing list