[lldb][NFC] Make CompilerDeclContext construction type safe
authorRaphael Isemann <teemperor@gmail.com>
Mon, 23 Dec 2019 08:05:07 +0000 (09:05 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Mon, 23 Dec 2019 08:56:54 +0000 (09:56 +0100)
commit42ec584a8b4e604360b7a4d45a65c570d58b1bf9
tree4aad4736fe921fd2e1fdbd916671d736709a4fdc
parent6d5e35e89d73711b494c83d3f8b68582d06a0b53
[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).
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/ClangASTContext.cpp
lldb/unittests/Symbol/TestClangASTContext.cpp
lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp