diff options
| author | Raphael Isemann <teemperor@gmail.com> | 2019-12-23 09:05:07 +0100 |
|---|---|---|
| committer | Raphael Isemann <teemperor@gmail.com> | 2019-12-23 09:56:54 +0100 |
| commit | 42ec584a8b4e604360b7a4d45a65c570d58b1bf9 (patch) | |
| tree | 4aad4736fe921fd2e1fdbd916671d736709a4fdc /lldb/source/Plugins/SymbolFile/PDB | |
| parent | 6d5e35e89d73711b494c83d3f8b68582d06a0b53 (diff) | |
| download | bcm5719-llvm-42ec584a8b4e604360b7a4d45a65c570d58b1bf9.tar.gz bcm5719-llvm-42ec584a8b4e604360b7a4d45a65c570d58b1bf9.zip | |
[lldb][NFC] Make CompilerDeclContext construction type safe
The CompilerDeclContext constructor takes a void* pointer which
means that all callers of this constructor need to first explicitly
convert all pointers to clang::DeclContext*. This causes that we
for example can't just pass a TranslationUnitDecl* to the constructor without
first casting it to its parent class (as it inherits from both
Decl and DeclContext so the void* pointer is actually a Decl*).
This patch introduces a utility function in the ClangASTContext
which gets rid of the requirement to cast all pointers to
clang::DeclContext. Also moves all constructor calls to use this
function instead which is NFC (beside the change in
DWARFASTParserClangTests.cpp).
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/PDB')
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 7 |
2 files changed, 4 insertions, 5 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index bbbd3415158..f647abf7b5f 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -556,7 +556,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { CompilerType target_ast_type = target_type->GetFullCompilerType(); ast_typedef = m_ast.CreateTypedefType( - target_ast_type, name.c_str(), CompilerDeclContext(&m_ast, decl_ctx)); + target_ast_type, name.c_str(), m_ast.CreateDeclContext(decl_ctx)); if (!ast_typedef) return nullptr; diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index b3e06fdd1a5..917ab68af41 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -666,7 +666,7 @@ SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) { if (!decl_context) return GetDeclContextContainingUID(uid); - return CompilerDeclContext(clang_ast_ctx, decl_context); + return clang_ast_ctx->CreateDeclContext(decl_context); } lldb_private::CompilerDeclContext @@ -695,7 +695,7 @@ SymbolFilePDB::GetDeclContextContainingUID(lldb::user_id_t uid) { auto decl_context = pdb->GetDeclContextContainingSymbol(*symbol); assert(decl_context); - return CompilerDeclContext(clang_ast_ctx, decl_context); + return clang_ast_ctx->CreateDeclContext(decl_context); } void SymbolFilePDB::ParseDeclsForContext( @@ -1703,8 +1703,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace( if (!namespace_decl) return CompilerDeclContext(); - return CompilerDeclContext(clang_type_system, - static_cast<clang::DeclContext *>(namespace_decl)); + return clang_type_system->CreateDeclContext(namespace_decl); } lldb_private::ConstString SymbolFilePDB::GetPluginName() { |

