The generation counter mechanism of the AST is currently implemented inside the ExternalASTSource. These counters
work as intended with clang's module setup, but causes problems with cling and ROOT's setup:
In cling we attach multiple ExternalASTSources which will cause the ASTReader to fail. The ASTReader assumes it's the
only attached external source. So it will increase it's own generation counter and then reads the top-level generation
counter of the ASTContext to get back it's own generation counter.
In ROOT we also attach after cling's startup another ExternalASTSource which will further disrupt existing generation
counters. The new multiplexer that is added as the new top level source will essentially reset all existing generation
counters back to zero.
This patch fixes those problems by merging all generation counters into a single one in the ASTContext. This
prevents that sometimes we are incrementing and then reading the different counters. It also prevents
that attaching a new counter or having multiple counters suddenly forces us to keep all those counters
in a consistent state.
Is there a reason to ask the ExternalASTSource for the generation here rather than directly asking the ASTContext? (Is there any circumstance in which we would expect or even allow them to return different numbers?)