summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp2
-rw-r--r--lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exebin7168 -> 7168 bytes
-rw-r--r--lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdbbin143360 -> 102400 bytes
-rw-r--r--lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp58
4 files changed, 54 insertions, 6 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index b4a106ad064..3406dfd3326 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -919,7 +919,7 @@ clang::DeclContext *PDBASTParser::GetDeclContextContainingSymbol(
// Split context and retrieve nested namespaces
auto curr_context = m_ast.GetTranslationUnitDecl();
- auto from = 0;
+ std::string::size_type from = 0;
while (from < context_size) {
auto to = context.find("::", from);
if (to == std::string::npos)
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe
index 21a4bd2b4ef..d5a67f62816 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe
Binary files differ
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb
index acf241bcb5d..81daa86f2ac 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb
Binary files differ
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());
}
OpenPOWER on IntegriCloud