<div dir="ltr"><div>Hi,</div><div><br></div><div>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.</div><div><br></div><div>Abstract:</div><div>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.</div><div>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.</div><div><br></div><div>Question:</div><div>Is there a way to implement a removing no longer used types? E.g.</div><div><br></div><div>template <typename FooParam></div><div>struct Foo</div><div>{</div><div>    using FooResult = typename Bar<FooParam>::BarResult;</div><div>};</div><div><br></div><div>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).</div><div>So basically is there any way to detect if type is still referenced somewhere, so I can remove it if it isn't?</div><div><br></div><div>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 (:</div><div><br></div><div>Thanks in advance for help!</div><div><br></div><div>Stryku</div></div>