summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExternalASTSource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ExternalASTSource.cpp')
-rw-r--r--clang/lib/AST/ExternalASTSource.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp
index 05a17db6bf0..ae8297cecd1 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -14,7 +14,9 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace clang;
@@ -60,3 +62,21 @@ ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
}
void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { }
+
+uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
+ uint32_t OldGeneration = CurrentGeneration;
+
+ // Make sure the generation of the topmost external source for the context is
+ // incremented. That might not be us.
+ auto *P = C.getExternalSource();
+ if (P && P != this)
+ CurrentGeneration = P->incrementGeneration(C);
+ else {
+ // FIXME: Only bump the generation counter if the current generation number
+ // has been observed?
+ if (!++CurrentGeneration)
+ llvm::report_fatal_error("generation counter overflowed", false);
+ }
+
+ return OldGeneration;
+}
OpenPOWER on IntegriCloud