summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lldb][NFC] Create type-safe function for creating a CompilerType from a ↵Raphael Isemann2020-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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).
* [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] Return a reference from ClangASTContext::getASTContext and ↵Raphael Isemann2019-12-211-8/+6
| | | | | | | | | | | remove dead nullptr checks ClangASTContext::getASTContext() currently returns a ptr but we have an assert there since a while that the ASTContext is not a nullptr. This causes that we still have a lot of code that is doing nullptr checks on the result of getASTContext() which is all unreachable code. This patch changes the return value to a reference to make it clear this can't be a nullptr and deletes all the nullptr checks.
* [lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClassRaphael Isemann2019-12-171-3/+2
|
* [lldb][NFC] Remove all unnecessary includes for ClangASTSourceCommon.hRaphael Isemann2019-12-171-1/+1
| | | | | These files only need the definition of ClangASTMetadata (which was previously in the ClangASTSourceCommon.h) or don't need the include at all.
* Fix ClangASTContext::CreateParameterDeclaration to not call addDeclShafik Yaghmour2019-08-021-1/+1
| | | | | | | | | Summary: The change https://reviews.llvm.org/D55575 modified ClangASTContext::CreateParameterDeclaration to call decl_ctx->addDecl(decl); this caused a regression since the existing code in DWARFASTParserClang::ParseChildParameters is called with the containing DeclContext. So when end up with cases where we are parsing a parameter for a member function and the parameter is added to the CXXRecordDecl as opposed to the CXXMethodDecl. This example is given in the regression test TestBreakpointInMemberFuncWNonPrimitiveParams.py which without this fix in a modules build leads to assert on setting a breakpoint in a member function with non primitive parameters. This scenario would be common when debugging LLDB or clang. Differential Revision: https://reviews.llvm.org/D65414 llvm-svn: 367726
* [Symbol] Use llvm::Expected when getting TypeSystemsAlex Langford2019-07-301-9/+2
| | | | | | | | | | | | | | | | | | Summary: This commit achieves the following: - Functions used to return a `TypeSystem *` return an `llvm::Expected<TypeSystem *>` now. This means that the result of a call is always checked, forcing clients to move more carefully. - `TypeSystemMap::GetTypeSystemForLanguage` will either return an Error or a non-null pointer to a TypeSystem. Reviewers: JDevlieghere, davide, compnerd Subscribers: jdoerfert, lldb-commits Differential Revision: https://reviews.llvm.org/D65122 llvm-svn: 367360
* [NativePDB] Make GetOrCreateDeclForUid return an lldb CompilerDeclNathan Lanza2019-07-211-7/+9
| | | | | | | | | We intend to make PdbAstBuilder abstract and implement PdbAstBuilderClang along with any other languages that wish to use PDBs. Thus, change GetOrCreateDeclForUid from returning a clang decl to a lldb_private::CompilerDecl. llvm-svn: 366650
* [NativePDB] Add a FromCompilerDecl for going from lldb -> clangNathan Lanza2019-07-171-0/+4
| | | | | | | | | | Summary: A common transformation in NativePDB is to go from lldb types to clang types and vice versa. This function automates one of those steps. Differential Revision: https://reviews.llvm.org/D64851 llvm-svn: 366345
* [NativePDB] Make GetTranslationUnitDecl return an lldb CompilerDeclCtxNathan Lanza2019-07-171-9/+10
| | | | | | | | | | | Summary: We intend to make PdbAstBuilder abstract and implement PdbAstBuilderClang along with any other languages that wish to use PDBs. This is the first step. Differential Revision: https://reviews.llvm.org/D64852 llvm-svn: 366293
* [NativePDB] Add anonymous namespaces supportAleksandr Urakov2019-04-221-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds anonymous namespaces support to the native PDB plugin. I had to reference from the main function variables of the types that are inside of the anonymous namespace to include them in debug info. Without the references they are not included. I think it's because they are static, then are visible only in the current translation unit, so they are not needed without any references to them. There is also the problem case with variables of types that are nested in template structs. For now I've left FIXME in the test because this case is not related to the change. Reviewers: zturner, asmith, labath, stella.stamenova, amccarth Reviewed By: amccarth Subscribers: zloyrobot, aprantl, teemperor, lldb-commits, leonid.mashinskiy Tags: #lldb Differential Revision: https://reviews.llvm.org/D60817 llvm-svn: 358873
* [NativePDB] Add basic support of methods recostruction in ASTAleksandr Urakov2019-01-291-6/+14
| | | | | | | | | | | | | | | | | | Summary: This patch adds the basic support of methods reconstruction by native PDB plugin. It contains only most obvious changes (it processes LF_ONEMETHOD and LF_METHOD records), some things still remain unsolved: - mangled names retrieving; - support of template methods. Reviewers: zturner, labath, lemo, stella.stamenova Reviewed by: zturner Differential Revision: https://reviews.llvm.org/D56126 llvm-svn: 352464
* [NativePDB] Add support for parsing typedef records.Zachary Turner2019-01-101-41/+145
| | | | | | | | | | | | | | | | | | | | Typedefs are represented as S_UDT records in the globals stream. This creates a strange situation where "types" are actually represented as "symbols", so they need special handling. In order to test this, we don't just use lldb and print out some variables causing the AST to get created, because variables whose type is a typedef will have debug info referencing the original type, not the typedef. So we use lldb-test instead which will parse all debug info in the entire file. This exposed some problems with lldb-test and the native reader, mainly that certain types of obscure symbols which we can find when iterating every single record would trigger crashes. These have been fixed as well so that lldb-test can be used to test this functionality. Differential Revision: https://reviews.llvm.org/D56461 llvm-svn: 350888
* [PdbAstBuilder] Remove unused functionsJonas Devlieghere2019-01-081-17/+0
| | | | | | | PdbAstBuilder.cpp:273:20: warning: unused function 'GetParentUniqueName' [-Wunused-function] PdbAstBuilder.cpp:267:13: warning: unused function 'IsUniqueNameEnumTag' [-Wunused-function] llvm-svn: 350652
* Try to fix Green Dragon bot.Zachary Turner2019-01-021-2/+2
| | | | | | | It doesn't like this std::tie() for some reason, hopefuly this fixes it. llvm-svn: 350262
* [NativePDB] Implement ParseDeclsForContext.Zachary Turner2019-01-021-35/+414
| | | | | | | | | | | This is a first step towards getting lldb-test symbols working with the native plugin. There is a remaining issue, which is that the plugin expects that ParseDeclsForContext will also create lldb symbols rather than just the decls, but the native pdb plugin doesn't currently do this. This will be addressed in a followup patch. llvm-svn: 350243
* [NativePDB] Create VarDecls for global variables.Zachary Turner2018-12-201-7/+21
| | | | | | | | | | Previously we would create these for local variables but not for global variables. Also updated existing tests which created global variables to check for them in the resulting AST. llvm-svn: 349854
* [NativePDB] Correctly reconstruct DeclContext for nested enums.Zachary Turner2018-12-181-1/+4
| | | | | | | | | | | | We reconstruct the AST hierarchy by trying to hack up a mangled name for the parent type using the child type's mangled name. This was failing for enums because their tag type is represented with two letters ("W4") instead of one letter ("T", "U", etc) as it is with classes, structs, and unions. After accounting for this we can now correctly determine when an enum is nested inside of a namespace or a class. llvm-svn: 349565
* [NativePDB] Decouple AST reconstruction from lldb Symbol creation.Zachary Turner2018-12-171-0/+865
Previously the code that parsed debug info to create lldb's Symbol objects such as Variable, Type, Function, etc was tightly coupled to the AST reconstruction code. This made it difficult / impossible to implement functions such as ParseDeclsForContext() that were only supposed to be operating on clang AST's. By splitting these apart, the logic becomes much cleaner and we have a clear separation of responsibilities. llvm-svn: 349383
OpenPOWER on IntegriCloud