[Lldb-commits] [lldb] 98bde7f - [lldb] Avoid FileSpec indirection where we can use SupportFiles directly

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 3 14:38:46 PDT 2024


Author: Jonas Devlieghere
Date: 2024-09-03T14:38:39-07:00
New Revision: 98bde7fd872c10e49035d5dc5d2f2b44489f6a07

URL: https://github.com/llvm/llvm-project/commit/98bde7fd872c10e49035d5dc5d2f2b44489f6a07
DIFF: https://github.com/llvm/llvm-project/commit/98bde7fd872c10e49035d5dc5d2f2b44489f6a07.diff

LOG: [lldb] Avoid FileSpec indirection where we can use SupportFiles directly

Now that more parts of LLDB know about SupportFiles, avoid going through
FileSpec (and losing the Checksum in the process). Instead, use the
SupportFile directly.

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectSource.cpp
    lldb/source/Core/SourceManager.cpp
    lldb/source/Symbol/LineTable.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 1fc122420388d8..86c090f9f36c16 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1053,7 +1053,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
                   ? sc.line_entry.column
                   : 0;
           target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-              std::make_shared<SupportFile>(sc.comp_unit->GetPrimaryFile()),
+              sc.comp_unit->GetPrimarySupportFile(),
               sc.line_entry.line, column, lines_to_back_up,
               m_options.num_lines - lines_to_back_up, "->",
               &result.GetOutputStream(), GetBreakpointLocations());
@@ -1174,7 +1174,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
             m_options.num_lines = 10;
           const uint32_t column = 0;
           target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-              std::make_shared<SupportFile>(sc.comp_unit->GetPrimaryFile()),
+              sc.comp_unit->GetPrimarySupportFile(),
               m_options.start_line, column, 0, m_options.num_lines, "",
               &result.GetOutputStream(), GetBreakpointLocations());
 

diff  --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index f6e59ce731a573..f97d86ad79f6ab 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -504,8 +504,7 @@ void SourceManager::File::CommonInitializer(SupportFileSP support_file_sp,
               SymbolContext sc;
               sc_list.GetContextAtIndex(0, sc);
               if (sc.comp_unit)
-                SetSupportFile(std::make_shared<SupportFile>(
-                    sc.comp_unit->GetPrimaryFile()));
+                SetSupportFile(sc.comp_unit->GetPrimarySupportFile());
             }
           }
         }

diff  --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp
index 8fb002cc931719..3d2afcdd119975 100644
--- a/lldb/source/Symbol/LineTable.cpp
+++ b/lldb/source/Symbol/LineTable.cpp
@@ -288,8 +288,8 @@ bool LineTable::ConvertEntryAtIndexToLineEntry(uint32_t idx,
   else
     line_entry.range.SetByteSize(0);
 
-  line_entry.file_sp = std::make_shared<SupportFile>(
-      m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx));
+  line_entry.file_sp =
+      m_comp_unit->GetSupportFiles().GetSupportFileAtIndex(entry.file_idx);
   line_entry.original_file_sp =
       m_comp_unit->GetSupportFiles().GetSupportFileAtIndex(entry.file_idx);
   line_entry.line = entry.line;


        


More information about the lldb-commits mailing list