]> granicus.if.org Git - clang/commitdiff
[lldb][clang][modern-type-lookup] Use ASTImporterSharedState in ExternalASTMerger
authorRaphael Isemann <teemperor@gmail.com>
Mon, 30 Sep 2019 08:52:16 +0000 (08:52 +0000)
committerRaphael Isemann <teemperor@gmail.com>
Mon, 30 Sep 2019 08:52:16 +0000 (08:52 +0000)
Summary:
The ExternalASTMerger should use the ASTImporterSharedState. This allows it to
handle std::pair in LLDB (but the rest of libc++ is still work in progress).

Reviewers: martong, shafik, a.sidorin

Subscribers: rnkovacs, christof, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68140

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373193 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ExternalASTMerger.h
lib/AST/ExternalASTMerger.cpp

index d89189da04f02f0da323266beddf1bde10399f67..8e00776cf63a3f7745f8a2a7f7d7217a2ee9ce40 100644 (file)
@@ -14,6 +14,7 @@
 #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"
 
@@ -88,6 +89,11 @@ public:
 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,
index 4dc89f0f31a0a1ea3da94587ebeef16cec78d226..ea99e9bb934aef2d160783873a44c514c2483a84 100644 (file)
@@ -107,11 +107,13 @@ public:
   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.
@@ -314,6 +316,8 @@ void ExternalASTMerger::RecordOriginImpl(const DeclContext *ToDC, DCOrigin Origi
 
 ExternalASTMerger::ExternalASTMerger(const ImporterTarget &Target,
                                      llvm::ArrayRef<ImporterSource> Sources) : LogStream(&llvm::nulls()), Target(Target) {
+  SharedState = std::make_shared<ASTImporterSharedState>(
+      *Target.AST.getTranslationUnitDecl());
   AddSources(Sources);
 }
 
@@ -321,7 +325,7 @@ void ExternalASTMerger::AddSources(llvm::ArrayRef<ImporterSource> 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));
   }
 }