[Symbol] Decouple clang from CompilerType
Summary:
Ideally CompilerType would have no knowledge of clang or any individual
TypeSystem. Decoupling clang is relatively straightforward.
Differential Revision: https://reviews.llvm.org/D66102
llvm-svn: 368741
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 3841b59..b199a5a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -2066,7 +2066,8 @@
// seems to be generating bad types on occasion.
return CompilerType();
- return CompilerType(m_ast_context, copied_qual_type);
+ return CompilerType(ClangASTContext::GetASTContext(m_ast_context),
+ copied_qual_type.getAsOpaquePtr());
}
clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
@@ -2194,7 +2195,9 @@
proto_info));
return AddFunDecl(
- CompilerType(m_ast_source.m_ast_context, generic_function_type), true);
+ CompilerType(ClangASTContext::GetASTContext(m_ast_source.m_ast_context),
+ generic_function_type.getAsOpaquePtr()),
+ true);
}
clang::NamedDecl *
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index b266b55..55772e0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1288,8 +1288,10 @@
if (value_decl == nullptr)
return false;
- lldb_private::CompilerType compiler_type(&value_decl->getASTContext(),
- value_decl->getType());
+ lldb_private::CompilerType compiler_type(
+ lldb_private::ClangASTContext::GetASTContext(
+ &value_decl->getASTContext()),
+ value_decl->getType().getAsOpaquePtr());
const Type *value_type = nullptr;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index 5f484bd..64ab39b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -10,6 +10,7 @@
#ifndef liblldb_IRForTarget_h_
#define liblldb_IRForTarget_h_
+#include "lldb/Core/ClangForward.h"
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Status.h"
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 404dabf..7219c01 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -461,12 +461,13 @@
: SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
m_id_type() {
if (valobj_sp) {
- clang::ASTContext *ast = valobj_sp->GetExecutionContextRef()
- .GetTargetSP()
- ->GetScratchClangASTContext()
- ->getASTContext();
- if (ast)
- m_id_type = CompilerType(ast, ast->ObjCBuiltinIdTy);
+ auto *clang_ast_context = valobj_sp->GetExecutionContextRef()
+ .GetTargetSP()
+ ->GetScratchClangASTContext();
+ if (clang_ast_context)
+ m_id_type = CompilerType(
+ clang_ast_context,
+ clang_ast_context->getASTContext()->ObjCBuiltinIdTy.getAsOpaquePtr());
if (valobj_sp->GetProcessSP())
m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize();
}
@@ -609,12 +610,13 @@
if (valobj_sp) {
CompilerType type = valobj_sp->GetCompilerType();
if (type) {
- ClangASTContext *ast = valobj_sp->GetExecutionContextRef()
- .GetTargetSP()
- ->GetScratchClangASTContext();
- if (ast)
- m_id_type = CompilerType(ast->getASTContext(),
- ast->getASTContext()->ObjCBuiltinIdTy);
+ auto *clang_ast_context = valobj_sp->GetExecutionContextRef()
+ .GetTargetSP()
+ ->GetScratchClangASTContext();
+ if (clang_ast_context)
+ m_id_type = CompilerType(clang_ast_context,
+ clang_ast_context->getASTContext()
+ ->ObjCBuiltinIdTy.getAsOpaquePtr());
}
}
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index 26654e9..2bfe7ad 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -149,8 +149,9 @@
}
ClangASTContext::AddFieldToRecordType(
union_type, element.name.c_str(),
- CompilerType(&ast_ctx, element.type), lldb::eAccessPublic,
- element.bitfield);
+ CompilerType(ClangASTContext::GetASTContext(&ast_ctx),
+ element.type.getAsOpaquePtr()),
+ lldb::eAccessPublic, element.bitfield);
++count;
}
ClangASTContext::CompleteTagDeclarationDefinition(union_type);
@@ -172,7 +173,9 @@
if (!lldb_ctx)
return clang::QualType();
CompilerType array_type(lldb_ctx->CreateArrayType(
- CompilerType(&ast_ctx, element_type), size, false));
+ CompilerType(ClangASTContext::GetASTContext(&ast_ctx),
+ element_type.getAsOpaquePtr()),
+ size, false));
return ClangUtil::GetQualType(array_type);
}
@@ -375,7 +378,8 @@
if (name && name[0]) {
StringLexer lexer(name);
clang::QualType qual_type = BuildType(ast_ctx, lexer, for_expression);
- return CompilerType(&ast_ctx, qual_type);
+ return CompilerType(ClangASTContext::GetASTContext(&ast_ctx),
+ qual_type.getAsOpaquePtr());
}
return CompilerType();
}
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 4ab384e..47c4ad0 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -120,24 +120,31 @@
return clang_ast.GetBasicType(eBasicTypeBool);
case PDB_BuiltinType::Long:
if (width == ast->getTypeSize(ast->LongTy))
- return CompilerType(ast, ast->LongTy);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->LongTy.getAsOpaquePtr());
if (width == ast->getTypeSize(ast->LongLongTy))
- return CompilerType(ast, ast->LongLongTy);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->LongLongTy.getAsOpaquePtr());
break;
case PDB_BuiltinType::ULong:
if (width == ast->getTypeSize(ast->UnsignedLongTy))
- return CompilerType(ast, ast->UnsignedLongTy);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->UnsignedLongTy.getAsOpaquePtr());
if (width == ast->getTypeSize(ast->UnsignedLongLongTy))
- return CompilerType(ast, ast->UnsignedLongLongTy);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->UnsignedLongLongTy.getAsOpaquePtr());
break;
case PDB_BuiltinType::WCharT:
if (width == ast->getTypeSize(ast->WCharTy))
- return CompilerType(ast, ast->WCharTy);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->WCharTy.getAsOpaquePtr());
break;
case PDB_BuiltinType::Char16:
- return CompilerType(ast, ast->Char16Ty);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->Char16Ty.getAsOpaquePtr());
case PDB_BuiltinType::Char32:
- return CompilerType(ast, ast->Char32Ty);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->Char32Ty.getAsOpaquePtr());
case PDB_BuiltinType::Float:
// Note: types `long double` and `double` have same bit size in MSVC and
// there is no information in the PDB to distinguish them. So when falling