[Lldb-commits] [lldb] a805e0f - [lldb][NFC] Remove utility methods in TestClangASTImporter

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 20 10:40:14 PST 2019


Author: Raphael Isemann
Date: 2019-12-20T19:39:49+01:00
New Revision: a805e0fb18ca3b85712a587b72e5048e78d8f1da

URL: https://github.com/llvm/llvm-project/commit/a805e0fb18ca3b85712a587b72e5048e78d8f1da
DIFF: https://github.com/llvm/llvm-project/commit/a805e0fb18ca3b85712a587b72e5048e78d8f1da.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/unittests/Symbol/TestClangASTImporter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp b/lldb/unittests/Symbol/TestClangASTImporter.cpp
index ce4bdab6cfb8..9a03f854db1a 100644
--- a/lldb/unittests/Symbol/TestClangASTImporter.cpp
+++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
@@ -33,33 +33,6 @@ class TestClangASTImporter : public testing::Test {
     HostInfo::Terminate();
     FileSystem::Terminate();
   }
-
-protected:
-  std::unique_ptr<ClangASTContext> createAST() {
-    return std::make_unique<ClangASTContext>(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<ClangASTContext> target_ast = createAST();
+  std::unique_ptr<ClangASTContext> 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<ClangASTContext> target_ast = createAST();
+  std::unique_ptr<ClangASTContext> 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<ClangASTContext> target_ast = createAST();
+  std::unique_ptr<ClangASTContext> 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<ClangASTContext> target_ast = createAST();
+  std::unique_ptr<ClangASTContext> 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<ClangASTContext> target_ast = createAST();
+  std::unique_ptr<ClangASTContext> 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<ClangASTContext> temporary_ast = createAST();
+  std::unique_ptr<ClangASTContext> 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<ClangASTContext> target_ast = createAST();
+  std::unique_ptr<ClangASTContext> 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<ClangASTContext> target_ast = createAST();
+  std::unique_ptr<ClangASTContext> target_ast = clang_utils::createAST();
 
   ClangASTImporter importer;
   clang::Decl *imported =


        


More information about the lldb-commits mailing list