[Lldb-commits] [lldb] r341942 - [PDB] Fix problems after rL341782
Aleksandr Urakov via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 11 07:03:12 PDT 2018
Author: aleksandr.urakov
Date: Tue Sep 11 07:03:12 2018
New Revision: 341942
URL: http://llvm.org/viewvc/llvm-project?rev=341942&view=rev
Log:
[PDB] Fix problems after rL341782
Summary:
This commit fixes following problems after rL341782:
- Broken SymbolFilePDBTests
- Warning on comparison of integers of different signs
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D51162
Modified:
lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe
lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb
lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp?rev=341942&r1=341941&r2=341942&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp Tue Sep 11 07:03:12 2018
@@ -919,7 +919,7 @@ clang::DeclContext *PDBASTParser::GetDec
// 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)
Modified: lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe?rev=341942&r1=341941&r2=341942&view=diff
==============================================================================
Binary files lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe (original) and lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe Tue Sep 11 07:03:12 2018 differ
Modified: lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb?rev=341942&r1=341941&r2=341942&view=diff
==============================================================================
Binary files lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb (original) and lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb Tue Sep 11 07:03:12 2018 differ
Modified: lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp?rev=341942&r1=341941&r2=341942&view=diff
==============================================================================
--- lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp (original)
+++ lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Tue Sep 11 07:03:12 2018
@@ -389,13 +389,41 @@ TEST_F(SymbolFilePDBTests, TestNestedCla
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, TestClassInNa
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());
}
More information about the lldb-commits
mailing list