From a805e0fb18ca3b85712a587b72e5048e78d8f1da Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 20 Dec 2019 19:38:02 +0100 Subject: [PATCH] [lldb][NFC] Remove utility methods in TestClangASTImporter We have a central header for all these methods so we can just use those for creating ClangASTContexts. --- lldb/unittests/Symbol/TestClangASTImporter.cpp | 43 +++++--------------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp b/lldb/unittests/Symbol/TestClangASTImporter.cpp index ce4bdab..9a03f85 100644 --- a/lldb/unittests/Symbol/TestClangASTImporter.cpp +++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp @@ -33,33 +33,6 @@ public: HostInfo::Terminate(); FileSystem::Terminate(); } - -protected: - std::unique_ptr createAST() { - return std::make_unique(HostInfo::GetTargetTriple()); - } - - CompilerType createRecord(ClangASTContext &ast, llvm::StringRef name) { - return ast.CreateRecordType(ast.getASTContext()->getTranslationUnitDecl(), - lldb::AccessType::eAccessPublic, name, 0, - lldb::LanguageType::eLanguageTypeC); - } - - /// Create a record with the given name and a field with the given type - /// and name. - CompilerType createRecordWithField(ClangASTContext &ast, - llvm::StringRef record_name, - CompilerType field_type, - llvm::StringRef field_name) { - CompilerType t = createRecord(ast, record_name); - - ClangASTContext::StartTagDeclarationDefinition(t); - ast.AddFieldToRecordType(t, field_name, field_type, - lldb::AccessType::eAccessPublic, 7); - ClangASTContext::CompleteTagDeclarationDefinition(t); - - return t; - } }; TEST_F(TestClangASTImporter, CanImportInvalidType) { @@ -76,7 +49,7 @@ TEST_F(TestClangASTImporter, CopyDeclTagDecl) { // Tests that the ClangASTImporter::CopyDecl can copy TagDecls. clang_utils::SourceASTWithRecord source; - std::unique_ptr target_ast = createAST(); + std::unique_ptr target_ast = clang_utils::createAST(); ClangASTImporter importer; clang::Decl *imported = @@ -101,7 +74,7 @@ TEST_F(TestClangASTImporter, CopyTypeTagDecl) { // Tests that the ClangASTImporter::CopyType can copy TagDecls types. clang_utils::SourceASTWithRecord source; - std::unique_ptr target_ast = createAST(); + std::unique_ptr target_ast = clang_utils::createAST(); ClangASTImporter importer; CompilerType imported = importer.CopyType(*target_ast, source.record_type); @@ -126,7 +99,7 @@ TEST_F(TestClangASTImporter, DeportDeclTagDecl) { // Tests that the ClangASTImporter::DeportDecl completely copies TagDecls. clang_utils::SourceASTWithRecord source; - std::unique_ptr target_ast = createAST(); + std::unique_ptr target_ast = clang_utils::createAST(); ClangASTImporter importer; clang::Decl *imported = @@ -148,7 +121,7 @@ TEST_F(TestClangASTImporter, DeportTypeTagDecl) { // Tests that the ClangASTImporter::CopyType can deport TagDecl types. clang_utils::SourceASTWithRecord source; - std::unique_ptr target_ast = createAST(); + std::unique_ptr target_ast = clang_utils::createAST(); ClangASTImporter importer; CompilerType imported = importer.DeportType(*target_ast, source.record_type); @@ -173,7 +146,7 @@ TEST_F(TestClangASTImporter, MetadataPropagation) { const lldb::user_id_t metadata = 123456; source.ast->SetMetadataAsUserID(source.record_decl, metadata); - std::unique_ptr target_ast = createAST(); + std::unique_ptr target_ast = clang_utils::createAST(); ClangASTImporter importer; clang::Decl *imported = @@ -195,14 +168,14 @@ TEST_F(TestClangASTImporter, MetadataPropagationIndirectImport) { const lldb::user_id_t metadata = 123456; source.ast->SetMetadataAsUserID(source.record_decl, metadata); - std::unique_ptr temporary_ast = createAST(); + std::unique_ptr temporary_ast = clang_utils::createAST(); ClangASTImporter importer; clang::Decl *temporary_imported = importer.CopyDecl(temporary_ast->getASTContext(), source.record_decl); ASSERT_NE(nullptr, temporary_imported); - std::unique_ptr target_ast = createAST(); + std::unique_ptr target_ast = clang_utils::createAST(); clang::Decl *imported = importer.CopyDecl(target_ast->getASTContext(), temporary_imported); ASSERT_NE(nullptr, imported); @@ -219,7 +192,7 @@ TEST_F(TestClangASTImporter, MetadataPropagationAfterCopying) { clang_utils::SourceASTWithRecord source; const lldb::user_id_t metadata = 123456; - std::unique_ptr target_ast = createAST(); + std::unique_ptr target_ast = clang_utils::createAST(); ClangASTImporter importer; clang::Decl *imported = -- 2.7.4