[Lldb-commits] [lldb] r326858 - [SymbolFilePDB] Get line number for PDBSymbolTypeEnum

Aaron Smith via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 6 16:35:27 PST 2018


Author: asmith
Date: Tue Mar  6 16:35:27 2018
New Revision: 326858

URL: http://llvm.org/viewvc/llvm-project?rev=326858&view=rev
Log:
[SymbolFilePDB] Get line number for PDBSymbolTypeEnum

Reviewers: zturner, lldb-commits, rnk

Reviewed By: zturner

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D44164

Modified:
    lldb/trunk/lit/SymbolFile/PDB/enums-layout.test
    lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp

Modified: lldb/trunk/lit/SymbolFile/PDB/enums-layout.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/PDB/enums-layout.test?rev=326858&r1=326857&r2=326858&view=diff
==============================================================================
--- lldb/trunk/lit/SymbolFile/PDB/enums-layout.test (original)
+++ lldb/trunk/lit/SymbolFile/PDB/enums-layout.test Tue Mar  6 16:35:27 2018
@@ -8,35 +8,35 @@ RUN: lldb-test symbols %T/SimpleTypesTes
 
 CHECK: Module [[CU:.*]]
 CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[CU]])
-CHECK:      Type{{.*}} , name = "Enum", size = 4, compiler_type = {{.*}} enum Enum {
+CHECK:      Type{{.*}} , name = "Enum", size = 4, decl = SimpleTypesTest.cpp:19, compiler_type = {{.*}} enum Enum {
 CHECK-NEXT:    RED,
 CHECK-NEXT:    GREEN,
 CHECK-NEXT:    BLUE
 CHECK-NEXT:}
 
-CHECK:      Type{{.*}} , name = "EnumConst", size = 4, compiler_type = {{.*}} enum EnumConst {
+CHECK:      Type{{.*}} , name = "EnumConst", size = 4,  decl = SimpleTypesTest.cpp:22, compiler_type = {{.*}} enum EnumConst {
 CHECK-NEXT:    LOW,
 CHECK-NEXT:    NORMAL,
 CHECK-NEXT:    HIGH
 CHECK-NEXT:}
 
-CHECK:      Type{{.*}} , name = "EnumEmpty", size = 4, compiler_type = {{.*}} enum EnumEmpty {
+CHECK:      Type{{.*}} , name = "EnumEmpty", size = 4,  decl = SimpleTypesTest.cpp:25, compiler_type = {{.*}} enum EnumEmpty {
 CHECK-NEXT:}
 
-CHECK:      Type{{.*}} , name = "EnumUChar", size = 1, compiler_type = {{.*}} enum EnumUChar {
+CHECK:      Type{{.*}} , name = "EnumUChar", size = 1,  decl = SimpleTypesTest.cpp:28, compiler_type = {{.*}} enum EnumUChar {
 CHECK-NEXT:    ON,
 CHECK-NEXT:    OFF,
 CHECK-NEXT:    AUTO
 CHECK-NEXT:}
 
 ; Note that `enum EnumClass` is tested instead of `enum class EnumClass`
-CHECK:      Type{{.*}} , name = "EnumClass", size = 4, compiler_type = {{.*}} enum EnumClass {
+CHECK:      Type{{.*}} , name = "EnumClass", size = 4,  decl = SimpleTypesTest.cpp:32, compiler_type = {{.*}} enum EnumClass {
 CHECK-NEXT:    YES,
 CHECK-NEXT:    NO,
 CHECK-NEXT:    DEFAULT
 CHECK-NEXT:}
 
-CHECK:      Type{{.*}} , name = "EnumStruct", size = 4, compiler_type = {{.*}} enum EnumStruct {
+CHECK:      Type{{.*}} , name = "EnumStruct", size = 4,  decl = SimpleTypesTest.cpp:35, compiler_type = {{.*}} enum EnumStruct {
 CHECK-NEXT:    red,
 CHECK-NEXT:    blue,
 CHECK-NEXT:    black

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=326858&r1=326857&r2=326858&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp Tue Mar  6 16:35:27 2018
@@ -170,14 +170,17 @@ ConstString GetPDBBuiltinTypeName(const
 
 bool GetDeclarationForSymbol(const PDBSymbol &symbol, Declaration &decl) {
   auto &raw_sym = symbol.getRawSymbol();
-  auto lines_up = symbol.getSession().findLineNumbersByAddress(
-      raw_sym.getVirtualAddress(), raw_sym.getLength());
-  if (!lines_up)
-    return false;
-  auto first_line_up = lines_up->getNext();
-  if (!first_line_up)
-    return false;
+  auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
 
+  if (!first_line_up) {
+    auto lines_up = symbol.getSession().findLineNumbersByAddress(
+        raw_sym.getVirtualAddress(), raw_sym.getLength());
+    if (!lines_up)
+      return false;
+    first_line_up = lines_up->getNext();
+    if (!first_line_up)
+      return false;
+  }
   uint32_t src_file_id = first_line_up->getSourceFileId();
   auto src_file_up = symbol.getSession().getSourceFileById(src_file_id);
   if (!src_file_up)
@@ -269,6 +272,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTyp
     if (ClangASTContext::StartTagDeclarationDefinition(ast_enum))
       ClangASTContext::CompleteTagDeclarationDefinition(ast_enum);
 
+    GetDeclarationForSymbol(type, decl);
     return std::make_shared<lldb_private::Type>(
         type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), bytes,
         nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,




More information about the lldb-commits mailing list