teemperor created this revision.
teemperor added reviewers: martong, shafik.
Herald added subscribers: lldb-commits, JDevlieghere, christof, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a project: LLDB.
teemperor added a comment.
Just putting this up as I don't want to merge that before the weekend. Patch
itself is obvious.
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).
Repository:
rLLDB LLDB
https://reviews.llvm.org/D68140
Files:
clang/include/clang/AST/ExternalASTMerger.h
clang/lib/AST/ExternalASTMerger.cpp
lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile
lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
Index: lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
@@ -0,0 +1,6 @@
+#include <utility>
+
+int main(int argc, char **argv) {
+ std::pair<int, long> pair = std::make_pair<int, float>(1, 2L);
+ return pair.first; // Set break point at this line.
+}
Index: lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
@@ -0,0 +1,19 @@
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class LibcxxModernTypeLookup(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test(self):
+ self.build()
+
+ # Activate modern-type-lookup.
+ self.runCmd("settings set target.experimental.use-modern-type-lookup true")
+
+ lldbutil.run_to_source_breakpoint(self,
+ "// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
+
+ # Test a few simple expressions that should still work with modern-type-lookup.
+ self.expect("expr pair", substrs=["(std::", "pair<int, long", "= (first = 1, second = 2)"])
Index: lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
Index: clang/lib/AST/ExternalASTMerger.cpp
===================================================================
--- clang/lib/AST/ExternalASTMerger.cpp
+++ clang/lib/AST/ExternalASTMerger.cpp
@@ -107,11 +107,13 @@
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 @@
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 @@
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));
}
}
Index: clang/include/clang/AST/ExternalASTMerger.h
===================================================================
--- clang/include/clang/AST/ExternalASTMerger.h
+++ clang/include/clang/AST/ExternalASTMerger.h
@@ -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,7 @@
private:
/// The target for this ExtenralASTMerger.
ImporterTarget Target;
+ std::shared_ptr<ASTImporterSharedState> SharedState;
public:
ExternalASTMerger(const ImporterTarget &Target,
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits