[cfe-dev] Remove unused types from ASTContext

mateusz janek via cfe-dev cfe-dev at lists.llvm.org
Tue May 2 14:35:10 PDT 2017


Thanks everyone for an interest. I really appreciate your help and I see
your points.

To be able to release next version of ctai, I implemented a simplified
example.

One more clarification Reid,
>My understanding is that constexpr functions were designed as a more
convenient, readable, and efficient way to implement these kinds of
metaprograms, so I suggest using them instead.
One of the assumptions during ctai implementation was to use template
classes/structs everywhere, without constexpr functions and objects. There
is a kind of stereotype that templates are difficult and I wanted to
challenge myself with program like that. In fact, with constexpr
functions/objects it would be too easy (:

Thanks again,
Stryku


2017-05-02 18:16 GMT+02:00 Reid Kleckner <rnk at google.com>:

> On Tue, May 2, 2017 at 5:37 AM, mats petersson via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> The problem is that the compiler doesn't work anywhere like that
>> currently, and I'm pretty sure you can't (with less than lots of months of
>> effort, if it's at all possible) make it work like that.
>>
>> Part of the reason for the compiler "not working like that" is that it
>> does things in phases: It forms AST of the entire  program, then runs
>> semantic analysis on the entire AST, and then runs the CodeGen on the
>> entire AST. Oh, and debug info is generated alongside CodeGen, and knowing
>> the types in debug symbols is probably useful [although I don't know how
>> useful debuggers are in debugging Template Meta Programming code - not
>> something I spend much time working on in general].
>>
>
> This is mostly correct, but clang semantic analysis and IR generation
> actually happen incrementally after every top-level decl. Some things get
> deferred to end of TU, so that triggers further analysis and IR gen.
>
> I'm pretty sure we can't do the "delete" steps Mateusz describes because
> we can't instantiate a template once and then throw away the instantiated
> specialization later. We have to keep it around in case something would
> reinstantiate it. The point of instantiation is pretty important in C++, so
> I don't think we would want to implement a mode that throws away implicit
> instantiations.
>
> Finally, it's not practical to implement such a mode because we use a
> BumpPtrAllocator memory management strategy in ASTContext. That means AST
> nodes live until end of TU, and there is no infrastructure to free and
> re-allocate their memory.
>
> My understanding is that constexpr functions were designed as a more
> convenient, readable, and efficient way to implement these kinds of
> metaprograms, so I suggest using them instead.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170502/ccfe3417/attachment.html>


More information about the cfe-dev mailing list