[lldb][NFC] Move utility functions from ClangASTImporter and ClangExpressionDeclMap to own header
diff --git a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
index 6fac1684..36d45fe 100644
--- a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
+++ b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h"
-#include "TestingSupport/TestUtilities.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -78,7 +78,7 @@
void SetUp() override {
importer = std::make_shared<ClangASTImporter>();
decl_map = std::make_unique<FakeClangExpressionDeclMap>(importer);
- target_ast = createAST();
+ target_ast = clang_utils::createAST();
decl_map->InstallASTContext(*target_ast, *target_ast->getFileManager());
}
@@ -87,21 +87,6 @@
decl_map.reset();
target_ast.reset();
}
-
- clang::DeclarationName getDeclarationName(ClangASTContext &ast,
- llvm::StringRef name) {
- clang::IdentifierInfo &II = ast.getIdentifierTable()->get(name);
- return ast.getASTContext()->DeclarationNames.getIdentifier(&II);
- }
-
- CompilerType createRecord(ClangASTContext &ast, llvm::StringRef name) {
- CompilerType t = ast.CreateRecordType(ast.getASTContext()->getTranslationUnitDecl(),
- lldb::AccessType::eAccessPublic, name, 0,
- lldb::LanguageType::eLanguageTypeC);
- ClangASTContext::StartTagDeclarationDefinition(t);
- ClangASTContext::CompleteTagDeclarationDefinition(t);
- return t;
- }
};
} // namespace
@@ -110,7 +95,8 @@
// Setup a NameSearchContext for 'foo'.
llvm::SmallVector<clang::NamedDecl *, 16> decls;
- clang::DeclarationName name = getDeclarationName(*target_ast, "foo");
+ clang::DeclarationName name =
+ clang_utils::getDeclarationName(*target_ast, "foo");
const clang::DeclContext *dc = target_ast->GetTranslationUnitDecl();
NameSearchContext search(*decl_map, decls, name, dc);
@@ -127,12 +113,13 @@
// to the scratch AST context.
llvm::StringRef decl_name = "$persistent_class";
CompilerType persistent_type =
- createRecord(*decl_map->m_scratch_context, decl_name);
+ clang_utils::createRecord(*decl_map->m_scratch_context, decl_name);
decl_map->AddPersistentDeclForTest(ClangUtil::GetAsTagDecl(persistent_type));
// Setup a NameSearchContext for $persistent_class;
llvm::SmallVector<clang::NamedDecl *, 16> decls;
- clang::DeclarationName name = getDeclarationName(*target_ast, decl_name);
+ clang::DeclarationName name =
+ clang_utils::getDeclarationName(*target_ast, decl_name);
const clang::DeclContext *dc = target_ast->GetTranslationUnitDecl();
NameSearchContext search(*decl_map, decls, name, dc);