#define LLVM_CLANG_AST_EXTERNALASTMERGER_H
#include "clang/AST/ASTImporter.h"
+#include "clang/AST/ASTImporterSharedState.h"
#include "clang/AST/ExternalASTSource.h"
#include "llvm/Support/raw_ostream.h"
private:
/// The target for this ExtenralASTMerger.
ImporterTarget Target;
+ /// ExternalASTMerger has multiple ASTImporters that import into the same
+ /// TU. This is the shared state for all ASTImporters of this
+ /// ExternalASTMerger.
+ /// See also the CrossTranslationUnitContext that has a similar setup.
+ std::shared_ptr<ASTImporterSharedState> SharedState;
public:
ExternalASTMerger(const ImporterTarget &Target,
LazyASTImporter(ExternalASTMerger &_Parent, ASTContext &ToContext,
FileManager &ToFileManager, ASTContext &FromContext,
FileManager &FromFileManager,
- const ExternalASTMerger::OriginMap &_FromOrigins)
+ const ExternalASTMerger::OriginMap &_FromOrigins,
+ std::shared_ptr<ASTImporterSharedState> SharedState)
: ASTImporter(ToContext, ToFileManager, FromContext, FromFileManager,
- /*MinimalImport=*/true),
+ /*MinimalImport=*/true, SharedState),
Parent(_Parent), Reverse(FromContext, FromFileManager, ToContext,
- ToFileManager, /*MinimalImport=*/true), FromOrigins(_FromOrigins) {}
+ ToFileManager, /*MinimalImport=*/true),
+ FromOrigins(_FromOrigins) {}
/// Whenever a DeclContext is imported, ensure that ExternalASTSource's origin
/// map is kept up to date. Also set the appropriate flags.
ExternalASTMerger::ExternalASTMerger(const ImporterTarget &Target,
llvm::ArrayRef<ImporterSource> Sources) : LogStream(&llvm::nulls()), Target(Target) {
+ SharedState = std::make_shared<ASTImporterSharedState>(
+ *Target.AST.getTranslationUnitDecl());
AddSources(Sources);
}
for (const ImporterSource &S : Sources) {
assert(&S.AST != &Target.AST);
Importers.push_back(std::make_unique<LazyASTImporter>(
- *this, Target.AST, Target.FM, S.AST, S.FM, S.OM));
+ *this, Target.AST, Target.FM, S.AST, S.FM, S.OM, SharedState));
}
}