summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lldb] Remove default llvm::Triple argument from ClangASTContext constructorRaphael Isemann2020-01-081-2/+3
| | | | | | | | | | | Creating an ASTContext with an unknown triple is rarely a good idea (as usually all our ASTs have a valid triple that is either from the host or the target) and the default argument makes it far to easy to implicitly create such an AST. Let's remove it and force people to pass a triple. The only place where we don't pass a triple is a DWARFASTParserClangTests where we now just pass the host triple instead (the test doesn't depend on any triple so this shouldn't change anything).
* [lldb] Add sanity check to CreateDeclContext and fixed illformed ↵Raphael Isemann2019-12-231-1/+1
| | | | | | | | | | | | | | | | | | | | | CompilerContext in ClangExpressionDeclMap. This adds a check that the ClangASTContext actually fits to the DeclContext that we want to create a CompilerDeclContext for. If the ClangASTContext (and its associated ASTContext) does not fit to the DeclContext (that is, the DeclContext wasn't created by the ASTContext), all computations using this malformed CompilerDeclContext will yield unpredictable results. Also fixes the only place that actually hits this assert which is the construction of a CompilerDeclContext in ClangExpressionDeclMap where we pass an unrelated ASTContext instead of the ASTContext of the current expression. I had to revert my previous change to DWARFASTParserClangTests.cpp back to using the unsafe direct construction of CompilerDeclContext as this assert won't work if the DeclContext we pass isn't a valid DeclContext in the first place.
* [lldb] Add a SubsystemRAII that takes care of calling Initialize and ↵Raphael Isemann2019-12-231-13/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Terminate in the unit tests Summary: Many of our tests need to initialize certain subsystems/plugins of LLDB such as `FileSystem` or `HostInfo` by calling their static `Initialize` functions before the test starts and then calling `::Terminate` after the test is done (in reverse order). This adds a lot of error-prone boilerplate code to our testing code. This patch adds a RAII called SubsystemRAII that ensures that we always call ::Initialize and then call ::Terminate after the test is done (and that the Terminate calls are always in the reverse order of the ::Initialize calls). It also gets rid of all of the boilerplate that we had for these calls. Per-fixture initialization is still not very nice with this approach as it would require some kind of static unique_ptr that gets manually assigned/reseted from the gtest SetUpTestCase/TearDownTestCase functions. Because of that I changed all per-fixture setup to now do per-test setup which can be done by just having the SubsystemRAII as a member of the test fixture. This change doesn't influence our normal test runtime as LIT anyway runs each test case separately (and the Initialize/Terminate calls are anyway not very expensive). It will however make running all tests in a single executable slightly slower. Reviewers: labath, JDevlieghere, martong, espindola, shafik Reviewed By: labath Subscribers: mgorny, rnkovacs, emaste, MaskRay, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71630
* [lldb][NFC] Make CompilerDeclContext construction type safeRaphael Isemann2019-12-231-1/+1
| | | | | | | | | | | | | | | 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][NFC] Create the ASTContext in ClangASTContext exactly once.Raphael Isemann2019-10-021-2/+15
| | | | | | | | | | | | | | | Reason for this patch is the Ssame reason as for the previous patches: Having a ClangASTContext and being able to switch the associated ASTContext isn't a use case we have (or should have), so let's simplify all this code. This way it becomes clearer in what order we initialize data structures. The DWARFASTParserClangTests changes are necessary as the test is using a ClangASTContext but relied on the fact that no called function ever calls getASTContext() on our ClangASTContext (as that would create the ASTContext). As we now always create the ASTContext the fact that we had an uninitialized FileSystem made the test crash. llvm-svn: 373457
* Enhance SymbolFileDWARF::ParseDeclsForContext performancePavel Labath2019-09-241-15/+23
| | | | | | | | | | | | | | | | | | | This implements DWARFASTParserClang::EnsureAllDIEsInDeclContextHaveBeenParsed so as to provide a faster way to ensure all DIEs linked to a certain declaration context have been parsed. Currently, we rely on SymbolFileDWARF::ParseDeclsForContext calling DWARFASTParserClang::GetDIEForDeclContext, and only then DWARFASTParserClang::GetDeclForUIDFromDWARF. This change shortcuts that logic and removes redundant calls to DWARFASTParserClang:: GetClangDeclForDIE by deleting DIEs from the m_decl_ctx_to_die map once they have been parsed. Differential Revision: https://reviews.llvm.org/D67760 Patch by Guilherme Andrade <guiandrade@google.com>. llvm-svn: 372744
* Fix GetDIEForDeclContext so it only returns entries matching the provided ↵Pavel Labath2019-08-291-0/+47
context Currently, we return all the entries such that their decl_ctx pointer >= decl_ctx provided. Instead, we should return only the ones that decl_ctx pointer == decl_ctx provided. Differential Revision: https://reviews.llvm.org/D66357 Patch by Guilherme Andrade <guiandrade@google.com>. llvm-svn: 370374
OpenPOWER on IntegriCloud