diff options
Diffstat (limited to 'lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp')
| -rw-r--r-- | lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp index 1e867b172ee..c99255c356d 100644 --- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -389,13 +389,41 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) { SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; TypeMap results; - EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class::NestedClass"), - nullptr, false, 0, searched_files, results)); + + auto clang_ast_ctx = llvm::dyn_cast_or_null<ClangASTContext>( + symfile->GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + EXPECT_NE(nullptr, clang_ast_ctx); + + EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class"), nullptr, false, 0, + searched_files, results)); EXPECT_EQ(1u, results.GetSize()); + + auto Class = results.GetTypeAtIndex(0); + EXPECT_TRUE(Class); + EXPECT_TRUE(Class->IsValidType()); + + auto ClassCompilerType = Class->GetFullCompilerType(); + EXPECT_TRUE(ClassCompilerType.IsValid()); + + auto ClassDeclCtx = clang_ast_ctx->GetDeclContextForType(ClassCompilerType); + EXPECT_NE(nullptr, ClassDeclCtx); + + // There are two symbols for nested classes: one belonging to enclosing class + // and one is global. We process correctly this case and create the same + // compiler type for both, but `FindTypes` may return more than one type + // (with the same compiler type) because the symbols have different IDs. + auto ClassCompilerDeclCtx = CompilerDeclContext(clang_ast_ctx, ClassDeclCtx); + EXPECT_LE(1u, symfile->FindTypes(sc, ConstString("NestedClass"), + &ClassCompilerDeclCtx, false, 0, + searched_files, results)); + EXPECT_LE(1u, results.GetSize()); + lldb::TypeSP udt_type = results.GetTypeAtIndex(0); - EXPECT_EQ(ConstString("Class::NestedClass"), udt_type->GetName()); + EXPECT_EQ(ConstString("NestedClass"), udt_type->GetName()); + CompilerType compiler_type = udt_type->GetForwardCompilerType(); EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType())); + EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NestedClass"), udt_type->GetByteSize()); } @@ -412,13 +440,33 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) { SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; TypeMap results; - EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("NS::NSClass"), nullptr, + + auto clang_ast_ctx = llvm::dyn_cast_or_null<ClangASTContext>( + symfile->GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + EXPECT_NE(nullptr, clang_ast_ctx); + + auto ast_ctx = clang_ast_ctx->getASTContext(); + EXPECT_NE(nullptr, ast_ctx); + + auto tu = ast_ctx->getTranslationUnitDecl(); + EXPECT_NE(nullptr, tu); + + symfile->ParseDeclsForContext(CompilerDeclContext( + clang_ast_ctx, static_cast<clang::DeclContext *>(tu))); + + auto ns_namespace = symfile->FindNamespace(sc, ConstString("NS"), nullptr); + EXPECT_TRUE(ns_namespace.IsValid()); + + EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("NSClass"), &ns_namespace, false, 0, searched_files, results)); EXPECT_EQ(1u, results.GetSize()); + lldb::TypeSP udt_type = results.GetTypeAtIndex(0); - EXPECT_EQ(ConstString("NS::NSClass"), udt_type->GetName()); + EXPECT_EQ(ConstString("NSClass"), udt_type->GetName()); + CompilerType compiler_type = udt_type->GetForwardCompilerType(); EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType())); + EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NSClass"), udt_type->GetByteSize()); } |

