forked from OSchip/llvm-project
[lldb][NFC] Remove redundant ASTContext args to CopyDecl/DeportDecl
We already pass a Decl here and the additional ASTContext needs to match the Decl. We might as well just pass the Decl and then extract the ASTContext from that.
This commit is contained in:
parent
2f209ccfbe
commit
6be76f491f
|
@ -50,13 +50,11 @@ public:
|
|||
|
||||
CompilerType CopyType(ClangASTContext &dst, const CompilerType &src_type);
|
||||
|
||||
clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx,
|
||||
clang::Decl *decl);
|
||||
clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
|
||||
|
||||
CompilerType DeportType(ClangASTContext &dst, const CompilerType &src_type);
|
||||
|
||||
clang::Decl *DeportDecl(clang::ASTContext *dst_ctx,
|
||||
clang::ASTContext *src_ctx, clang::Decl *decl);
|
||||
clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
|
||||
|
||||
/// Sets the layout for the given RecordDecl. The layout will later be
|
||||
/// used by Clang's during code generation. Not calling this function for
|
||||
|
|
|
@ -453,8 +453,7 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
|
|||
ConstString name_cs(name.str().c_str());
|
||||
|
||||
Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(
|
||||
ClangASTContext::GetScratch(m_target)->getASTContext(), m_ast_context,
|
||||
decl);
|
||||
ClangASTContext::GetScratch(m_target)->getASTContext(), decl);
|
||||
|
||||
if (!D_scratch) {
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
|
|
@ -1823,9 +1823,8 @@ NamespaceDecl *ClangASTSource::AddNamespace(
|
|||
}
|
||||
|
||||
clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
|
||||
clang::ASTContext &from_context = src_decl->getASTContext();
|
||||
if (m_ast_importer_sp) {
|
||||
return m_ast_importer_sp->CopyDecl(m_ast_context, &from_context, src_decl);
|
||||
return m_ast_importer_sp->CopyDecl(m_ast_context, src_decl);
|
||||
} else {
|
||||
lldbassert(0 && "No mechanism for copying a decl!");
|
||||
return nullptr;
|
||||
|
|
|
@ -65,10 +65,10 @@ CompilerType ClangASTImporter::CopyType(ClangASTContext &dst_ast,
|
|||
}
|
||||
|
||||
clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
|
||||
clang::ASTContext *src_ast,
|
||||
clang::Decl *decl) {
|
||||
ImporterDelegateSP delegate_sp;
|
||||
|
||||
clang::ASTContext *src_ast = &decl->getASTContext();
|
||||
delegate_sp = GetDelegate(dst_ast, src_ast);
|
||||
|
||||
ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
|
||||
|
@ -320,10 +320,10 @@ CompilerType ClangASTImporter::DeportType(ClangASTContext &dst,
|
|||
}
|
||||
|
||||
clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
|
||||
clang::ASTContext *src_ctx,
|
||||
clang::Decl *decl) {
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
clang::ASTContext *src_ctx = &decl->getASTContext();
|
||||
LLDB_LOGF(log,
|
||||
" [ClangASTImporter] DeportDecl called on (%sDecl*)%p from "
|
||||
"(ASTContext*)%p to (ASTContext*)%p",
|
||||
|
@ -337,7 +337,7 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
|
|||
clang::Decl *result;
|
||||
{
|
||||
CompleteTagDeclsScope complete_scope(*this, dst_ctx, src_ctx);
|
||||
result = CopyDecl(dst_ctx, src_ctx, decl);
|
||||
result = CopyDecl(dst_ctx, decl);
|
||||
}
|
||||
|
||||
if (!result)
|
||||
|
|
|
@ -18,16 +18,12 @@
|
|||
using namespace lldb_private;
|
||||
using namespace lldb;
|
||||
|
||||
static std::unique_ptr<ClangASTContext> createAST() {
|
||||
return std::make_unique<ClangASTContext>(HostInfo::GetTargetTriple());
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct FakeClangExpressionDeclMap : public ClangExpressionDeclMap {
|
||||
FakeClangExpressionDeclMap(const ClangASTImporterSP &importer)
|
||||
: ClangExpressionDeclMap(false, nullptr, lldb::TargetSP(), importer,
|
||||
nullptr) {
|
||||
m_scratch_context = createAST();
|
||||
m_scratch_context = clang_utils::createAST();
|
||||
}
|
||||
std::unique_ptr<ClangASTContext> m_scratch_context;
|
||||
/// Adds a persistent decl that can be found by the ClangExpressionDeclMap
|
||||
|
|
|
@ -80,8 +80,7 @@ TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
|
|||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(),
|
||||
source.ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the correct decl by just comparing their qualified name.
|
||||
|
@ -131,8 +130,7 @@ TEST_F(TestClangASTImporter, DeportDeclTagDecl) {
|
|||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.DeportDecl(target_ast->getASTContext(),
|
||||
source.ast->getASTContext(), source.record_decl);
|
||||
importer.DeportDecl(target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the correct decl by just comparing their qualified name.
|
||||
|
@ -179,8 +177,7 @@ TEST_F(TestClangASTImporter, MetadataPropagation) {
|
|||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(),
|
||||
source.ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the same Metadata.
|
||||
|
@ -202,14 +199,12 @@ TEST_F(TestClangASTImporter, MetadataPropagationIndirectImport) {
|
|||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *temporary_imported =
|
||||
importer.CopyDecl(temporary_ast->getASTContext(),
|
||||
source.ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(temporary_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, temporary_imported);
|
||||
|
||||
std::unique_ptr<ClangASTContext> target_ast = createAST();
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(),
|
||||
temporary_ast->getASTContext(), temporary_imported);
|
||||
importer.CopyDecl(target_ast->getASTContext(), temporary_imported);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the same Metadata.
|
||||
|
@ -228,8 +223,7 @@ TEST_F(TestClangASTImporter, MetadataPropagationAfterCopying) {
|
|||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(),
|
||||
source.ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// The TagDecl has been imported. Now set the metadata of the source and
|
||||
|
|
Loading…
Reference in New Issue