Skip to content

Commit c994b8e

Browse files
committed
[clang][AST] Fix generation with multiple external sources
ExternalASTSource::incrementGeneration returns the OldGeneration, which must be taken into account in case it is delegated to the topmost external source. This obsoletes a long-standing downstream patch in Cling that was previously submitted in https://reviews.llvm.org/D39714.
1 parent f7de3d3 commit c994b8e

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎interpreter/llvm-project/clang/lib/AST/ExternalASTSource.cpp‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,20 @@ void ExternalASTSource::FindExternalLexicalDecls(
118118
void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {}
119119

120120
uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
121-
uint32_t OldGeneration = CurrentGeneration;
122-
123121
// Make sure the generation of the topmost external source for the context is
124122
// incremented. That might not be us.
125123
auto *P = C.getExternalSource();
126-
if (P && P != this)
124+
if (P && P != this) {
125+
// The call itself returns the OldGeneration of the topmost external source.
127126
CurrentGeneration = P->incrementGeneration(C);
128-
else {
129-
// FIXME: Only bump the generation counter if the current generation number
130-
// has been observed?
131-
if (!++CurrentGeneration)
132-
llvm::reportFatalUsageError("generation counter overflowed");
133127
}
134128

129+
uint32_t OldGeneration = CurrentGeneration;
130+
131+
// FIXME: Only bump the generation counter if the current generation number
132+
// has been observed?
133+
if (!++CurrentGeneration)
134+
llvm::reportFatalUsageError("generation counter overflowed");
135+
135136
return OldGeneration;
136137
}

0 commit comments

Comments
 (0)