summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-12-30 21:20:01 +0100
committerRaphael Isemann <teemperor@gmail.com>2020-01-02 11:54:45 +0100
commitfe8e25a48a2a0f8f508499ba950181dba3d600b0 (patch)
tree00b7970625121b4b408d3b7de6f1b97f55a78a48 /lldb/source/Plugins/SymbolFile
parenta2976c490da3b6d7253d4034ae507a760457ea18 (diff)
downloadbcm5719-llvm-fe8e25a48a2a0f8f508499ba950181dba3d600b0.tar.gz
bcm5719-llvm-fe8e25a48a2a0f8f508499ba950181dba3d600b0.zip
[lldb][NFC] Create type-safe function for creating a CompilerType from a QualType
LLDB frequently converts QualType to CompilerType. This is currently done like this: result = CompilerType(this, qual_type_var.getAsOpaquePtr()) There are a few shortcomings in this current approach: 1. CompilerType's constructor takes a void* pointer so it isn't type safe. 2. We can't add any sanity checks to the CompilerType constructor (e.g. that the type actually belongs to the passed ClangASTContext) without expanding the TypeSystem API. 3. The logic for converting QualType->CompilerType is spread out over all of LLDB so changing it is difficult (e.g., what if we want to just pass the type ptr and not the 1type_ptr | qual_flags1 to CompilerType). This patch adds a `ClangASTContext::GetType` function similar to the other GetTypeForDecl functions that does this conversion in a type safe way. It also adds a sanity check for Tag-based types that the type actually belongs to the current ClangASTContext (Types don't seem to know their ASTContext, so we have to workaround by looking at the decl for the underlying TagDecl. This doesn't cover all types we construct but it's better than no sanity check).
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 96dd72bb100..3cae9a19001 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2086,8 +2086,8 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
clang::TypeSourceInfo *type_source_info =
base_class->getTypeSourceInfo();
if (type_source_info) {
- CompilerType base_class_type(
- &m_ast, type_source_info->getType().getAsOpaquePtr());
+ CompilerType base_class_type =
+ m_ast.GetType(type_source_info->getType());
if (!base_class_type.GetCompleteType()) {
auto module = dwarf->GetObjectFile()->GetModule();
module->ReportError(":: Class '%s' has a base class '%s' which "
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 7a1a64816f4..4588c80aa1b 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -1078,7 +1078,7 @@ void PdbAstBuilder::CreateFunctionParameters(PdbCompilandSymId func_id,
PdbCompilandSymId param_uid(func_id.modi, record_offset);
clang::QualType qt = GetOrCreateType(param_type);
- CompilerType param_type_ct(&m_clang, qt.getAsOpaquePtr());
+ CompilerType param_type_ct = m_clang.GetType(qt);
clang::ParmVarDecl *param = m_clang.CreateParameterDeclaration(
&function_decl, param_name.str().c_str(), param_type_ct,
clang::SC_None, true);
OpenPOWER on IntegriCloud