1 //===-- SourceManager.cpp ---------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Core/SourceManager.h" 11 12 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 // Project includes 16 #include "lldb/Core/DataBuffer.h" 17 #include "lldb/Core/Debugger.h" 18 #include "lldb/Core/Module.h" 19 #include "lldb/Host/FileSystem.h" 20 #include "lldb/Symbol/CompileUnit.h" 21 #include "lldb/Symbol/Function.h" 22 #include "lldb/Symbol/SymbolContext.h" 23 #include "lldb/Target/Target.h" 24 #include "lldb/Utility/AnsiTerminal.h" 25 #include "lldb/Utility/RegularExpression.h" 26 #include "lldb/Utility/Stream.h" 27 28 using namespace lldb; 29 using namespace lldb_private; 30 31 static inline bool is_newline_char(char ch) { return ch == '\n' || ch == '\r'; } 32 33 //---------------------------------------------------------------------- 34 // SourceManager constructor 35 //---------------------------------------------------------------------- 36 SourceManager::SourceManager(const TargetSP &target_sp) 37 : m_last_file_sp(), m_last_line(0), m_last_count(0), m_default_set(false), 38 m_target_wp(target_sp), 39 m_debugger_wp(target_sp->GetDebugger().shared_from_this()) {} 40 41 SourceManager::SourceManager(const DebuggerSP &debugger_sp) 42 : m_last_file_sp(), m_last_line(0), m_last_count(0), m_default_set(false), 43 m_target_wp(), m_debugger_wp(debugger_sp) {} 44 45 //---------------------------------------------------------------------- 46 // Destructor 47 //---------------------------------------------------------------------- 48 SourceManager::~SourceManager() {} 49 50 SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) { 51 bool same_as_previous = 52 m_last_file_sp && m_last_file_sp->FileSpecMatches(file_spec); 53 54 DebuggerSP debugger_sp(m_debugger_wp.lock()); 55 FileSP file_sp; 56 if (same_as_previous) 57 file_sp = m_last_file_sp; 58 else if (debugger_sp) 59 file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec); 60 61 TargetSP target_sp(m_target_wp.lock()); 62 63 // It the target source path map has been updated, get this file again so we 64 // can successfully remap the source file 65 if (target_sp && file_sp && 66 file_sp->GetSourceMapModificationID() != 67 target_sp->GetSourcePathMap().GetModificationID()) 68 file_sp.reset(); 69 70 // Update the file contents if needed if we found a file 71 if (file_sp) 72 file_sp->UpdateIfNeeded(); 73 74 // If file_sp is no good or it points to a non-existent file, reset it. 75 if (!file_sp || !file_sp->GetFileSpec().Exists()) { 76 if (target_sp) 77 file_sp.reset(new File(file_spec, target_sp.get())); 78 else 79 file_sp.reset(new File(file_spec, debugger_sp)); 80 81 if (debugger_sp) 82 debugger_sp->GetSourceFileCache().AddSourceFile(file_sp); 83 } 84 return file_sp; 85 } 86 87 static bool should_show_stop_column_with_ansi(DebuggerSP debugger_sp) { 88 // We don't use ANSI stop column formatting if we can't lookup values from 89 // the debugger. 90 if (!debugger_sp) 91 return false; 92 93 // We don't use ANSI stop column formatting if the debugger doesn't think 94 // it should be using color. 95 if (!debugger_sp->GetUseColor()) 96 return false; 97 98 // We only use ANSI stop column formatting if we're either supposed to show 99 // ANSI where available (which we know we have when we get to this point), or 100 // if we're only supposed to use ANSI. 101 const auto value = debugger_sp->GetStopShowColumn(); 102 return ((value == eStopShowColumnAnsiOrCaret) || 103 (value == eStopShowColumnAnsi)); 104 } 105 106 static bool should_show_stop_column_with_caret(DebuggerSP debugger_sp) { 107 // We don't use text-based stop column formatting if we can't lookup values 108 // from the debugger. 109 if (!debugger_sp) 110 return false; 111 112 // If we're asked to show the first available of ANSI or caret, then 113 // we do show the caret when ANSI is not available. 114 const auto value = debugger_sp->GetStopShowColumn(); 115 if ((value == eStopShowColumnAnsiOrCaret) && !debugger_sp->GetUseColor()) 116 return true; 117 118 // The only other time we use caret is if we're explicitly asked to show 119 // caret. 120 return value == eStopShowColumnCaret; 121 } 122 123 size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile( 124 uint32_t start_line, uint32_t count, uint32_t curr_line, uint32_t column, 125 const char *current_line_cstr, Stream *s, 126 const SymbolContextList *bp_locs) { 127 if (count == 0) 128 return 0; 129 size_t return_value = 0; 130 if (start_line == 0) { 131 if (m_last_line != 0 && m_last_line != UINT32_MAX) 132 start_line = m_last_line + m_last_count; 133 else 134 start_line = 1; 135 } 136 137 if (!m_default_set) { 138 FileSpec tmp_spec; 139 uint32_t tmp_line; 140 GetDefaultFileAndLine(tmp_spec, tmp_line); 141 } 142 143 m_last_line = start_line; 144 m_last_count = count; 145 146 if (m_last_file_sp.get()) { 147 const uint32_t end_line = start_line + count - 1; 148 for (uint32_t line = start_line; line <= end_line; ++line) { 149 if (!m_last_file_sp->LineIsValid(line)) { 150 m_last_line = UINT32_MAX; 151 break; 152 } 153 154 char prefix[32] = ""; 155 if (bp_locs) { 156 uint32_t bp_count = bp_locs->NumLineEntriesWithLine(line); 157 158 if (bp_count > 0) 159 ::snprintf(prefix, sizeof(prefix), "[%u] ", bp_count); 160 else 161 ::snprintf(prefix, sizeof(prefix), " "); 162 } 163 164 return_value += 165 s->Printf("%s%2.2s %-4u\t", prefix, 166 line == curr_line ? current_line_cstr : "", line); 167 size_t this_line_size = m_last_file_sp->DisplaySourceLines( 168 line, line == curr_line ? column : 0, 0, 0, s); 169 if (column != 0 && line == curr_line && 170 should_show_stop_column_with_caret(m_debugger_wp.lock())) { 171 // Display caret cursor. 172 std::string src_line; 173 m_last_file_sp->GetLine(line, src_line); 174 return_value += s->Printf(" \t"); 175 // Insert a space for every non-tab character in the source line. 176 for (size_t i = 0; i + 1 < column && i < src_line.length(); ++i) 177 return_value += s->PutChar(src_line[i] == '\t' ? '\t' : ' '); 178 // Now add the caret. 179 return_value += s->Printf("^\n"); 180 } 181 if (this_line_size == 0) { 182 m_last_line = UINT32_MAX; 183 break; 184 } else 185 return_value += this_line_size; 186 } 187 } 188 return return_value; 189 } 190 191 size_t SourceManager::DisplaySourceLinesWithLineNumbers( 192 const FileSpec &file_spec, uint32_t line, uint32_t column, 193 uint32_t context_before, uint32_t context_after, 194 const char *current_line_cstr, Stream *s, 195 const SymbolContextList *bp_locs) { 196 FileSP file_sp(GetFile(file_spec)); 197 198 uint32_t start_line; 199 uint32_t count = context_before + context_after + 1; 200 if (line > context_before) 201 start_line = line - context_before; 202 else 203 start_line = 1; 204 205 if (m_last_file_sp.get() != file_sp.get()) { 206 if (line == 0) 207 m_last_line = 0; 208 m_last_file_sp = file_sp; 209 } 210 return DisplaySourceLinesWithLineNumbersUsingLastFile( 211 start_line, count, line, column, current_line_cstr, s, bp_locs); 212 } 213 214 size_t SourceManager::DisplayMoreWithLineNumbers( 215 Stream *s, uint32_t count, bool reverse, const SymbolContextList *bp_locs) { 216 // If we get called before anybody has set a default file and line, then try 217 // to figure it out here. 218 const bool have_default_file_line = m_last_file_sp && m_last_line > 0; 219 if (!m_default_set) { 220 FileSpec tmp_spec; 221 uint32_t tmp_line; 222 GetDefaultFileAndLine(tmp_spec, tmp_line); 223 } 224 225 if (m_last_file_sp) { 226 if (m_last_line == UINT32_MAX) 227 return 0; 228 229 if (reverse && m_last_line == 1) 230 return 0; 231 232 if (count > 0) 233 m_last_count = count; 234 else if (m_last_count == 0) 235 m_last_count = 10; 236 237 if (m_last_line > 0) { 238 if (reverse) { 239 // If this is the first time we've done a reverse, then back up one more 240 // time so we end 241 // up showing the chunk before the last one we've shown: 242 if (m_last_line > m_last_count) 243 m_last_line -= m_last_count; 244 else 245 m_last_line = 1; 246 } else if (have_default_file_line) 247 m_last_line += m_last_count; 248 } else 249 m_last_line = 1; 250 251 const uint32_t column = 0; 252 return DisplaySourceLinesWithLineNumbersUsingLastFile( 253 m_last_line, m_last_count, UINT32_MAX, column, "", s, bp_locs); 254 } 255 return 0; 256 } 257 258 bool SourceManager::SetDefaultFileAndLine(const FileSpec &file_spec, 259 uint32_t line) { 260 FileSP old_file_sp = m_last_file_sp; 261 m_last_file_sp = GetFile(file_spec); 262 263 m_default_set = true; 264 if (m_last_file_sp) { 265 m_last_line = line; 266 return true; 267 } else { 268 m_last_file_sp = old_file_sp; 269 return false; 270 } 271 } 272 273 bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) { 274 if (m_last_file_sp) { 275 file_spec = m_last_file_sp->GetFileSpec(); 276 line = m_last_line; 277 return true; 278 } else if (!m_default_set) { 279 TargetSP target_sp(m_target_wp.lock()); 280 281 if (target_sp) { 282 // If nobody has set the default file and line then try here. If there's 283 // no executable, then we 284 // will try again later when there is one. Otherwise, if we can't find it 285 // we won't look again, 286 // somebody will have to set it (for instance when we stop somewhere...) 287 Module *executable_ptr = target_sp->GetExecutableModulePointer(); 288 if (executable_ptr) { 289 SymbolContextList sc_list; 290 ConstString main_name("main"); 291 bool symbols_okay = false; // Force it to be a debug symbol. 292 bool inlines_okay = true; 293 bool append = false; 294 size_t num_matches = executable_ptr->FindFunctions( 295 main_name, NULL, lldb::eFunctionNameTypeBase, inlines_okay, 296 symbols_okay, append, sc_list); 297 for (size_t idx = 0; idx < num_matches; idx++) { 298 SymbolContext sc; 299 sc_list.GetContextAtIndex(idx, sc); 300 if (sc.function) { 301 lldb_private::LineEntry line_entry; 302 if (sc.function->GetAddressRange() 303 .GetBaseAddress() 304 .CalculateSymbolContextLineEntry(line_entry)) { 305 SetDefaultFileAndLine(line_entry.file, line_entry.line); 306 file_spec = m_last_file_sp->GetFileSpec(); 307 line = m_last_line; 308 return true; 309 } 310 } 311 } 312 } 313 } 314 } 315 return false; 316 } 317 318 void SourceManager::FindLinesMatchingRegex(FileSpec &file_spec, 319 RegularExpression ®ex, 320 uint32_t start_line, 321 uint32_t end_line, 322 std::vector<uint32_t> &match_lines) { 323 match_lines.clear(); 324 FileSP file_sp = GetFile(file_spec); 325 if (!file_sp) 326 return; 327 return file_sp->FindLinesMatchingRegex(regex, start_line, end_line, 328 match_lines); 329 } 330 331 SourceManager::File::File(const FileSpec &file_spec, 332 lldb::DebuggerSP debugger_sp) 333 : m_file_spec_orig(file_spec), m_file_spec(file_spec), 334 m_mod_time(FileSystem::GetModificationTime(file_spec)), 335 m_debugger_wp(debugger_sp) { 336 CommonInitializer(file_spec, nullptr); 337 } 338 339 SourceManager::File::File(const FileSpec &file_spec, Target *target) 340 : m_file_spec_orig(file_spec), m_file_spec(file_spec), 341 m_mod_time(FileSystem::GetModificationTime(file_spec)), 342 m_debugger_wp(target ? target->GetDebugger().shared_from_this() 343 : DebuggerSP()) { 344 CommonInitializer(file_spec, target); 345 } 346 347 void SourceManager::File::CommonInitializer(const FileSpec &file_spec, 348 Target *target) { 349 if (m_mod_time == llvm::sys::TimePoint<>()) { 350 if (target) { 351 m_source_map_mod_id = target->GetSourcePathMap().GetModificationID(); 352 353 if (!file_spec.GetDirectory() && file_spec.GetFilename()) { 354 // If this is just a file name, lets see if we can find it in the 355 // target: 356 bool check_inlines = false; 357 SymbolContextList sc_list; 358 size_t num_matches = 359 target->GetImages().ResolveSymbolContextForFilePath( 360 file_spec.GetFilename().AsCString(), 0, check_inlines, 361 lldb::eSymbolContextModule | lldb::eSymbolContextCompUnit, 362 sc_list); 363 bool got_multiple = false; 364 if (num_matches != 0) { 365 if (num_matches > 1) { 366 SymbolContext sc; 367 FileSpec *test_cu_spec = NULL; 368 369 for (unsigned i = 0; i < num_matches; i++) { 370 sc_list.GetContextAtIndex(i, sc); 371 if (sc.comp_unit) { 372 if (test_cu_spec) { 373 if (test_cu_spec != static_cast<FileSpec *>(sc.comp_unit)) 374 got_multiple = true; 375 break; 376 } else 377 test_cu_spec = sc.comp_unit; 378 } 379 } 380 } 381 if (!got_multiple) { 382 SymbolContext sc; 383 sc_list.GetContextAtIndex(0, sc); 384 m_file_spec = sc.comp_unit; 385 m_mod_time = FileSystem::GetModificationTime(m_file_spec); 386 } 387 } 388 } 389 // Try remapping if m_file_spec does not correspond to an existing file. 390 if (!m_file_spec.Exists()) { 391 FileSpec new_file_spec; 392 // Check target specific source remappings first, then fall back to 393 // modules objects can have individual path remappings that were 394 // detected 395 // when the debug info for a module was found. 396 // then 397 if (target->GetSourcePathMap().FindFile(m_file_spec, new_file_spec) || 398 target->GetImages().FindSourceFile(m_file_spec, new_file_spec)) { 399 m_file_spec = new_file_spec; 400 m_mod_time = FileSystem::GetModificationTime(m_file_spec); 401 } 402 } 403 } 404 } 405 406 if (m_mod_time != llvm::sys::TimePoint<>()) 407 m_data_sp = m_file_spec.ReadFileContents(); 408 } 409 410 uint32_t SourceManager::File::GetLineOffset(uint32_t line) { 411 if (line == 0) 412 return UINT32_MAX; 413 414 if (line == 1) 415 return 0; 416 417 if (CalculateLineOffsets(line)) { 418 if (line < m_offsets.size()) 419 return m_offsets[line - 1]; // yes we want "line - 1" in the index 420 } 421 return UINT32_MAX; 422 } 423 424 uint32_t SourceManager::File::GetNumLines() { 425 CalculateLineOffsets(); 426 return m_offsets.size(); 427 } 428 429 const char *SourceManager::File::PeekLineData(uint32_t line) { 430 if (!LineIsValid(line)) 431 return NULL; 432 433 size_t line_offset = GetLineOffset(line); 434 if (line_offset < m_data_sp->GetByteSize()) 435 return (const char *)m_data_sp->GetBytes() + line_offset; 436 return NULL; 437 } 438 439 uint32_t SourceManager::File::GetLineLength(uint32_t line, 440 bool include_newline_chars) { 441 if (!LineIsValid(line)) 442 return false; 443 444 size_t start_offset = GetLineOffset(line); 445 size_t end_offset = GetLineOffset(line + 1); 446 if (end_offset == UINT32_MAX) 447 end_offset = m_data_sp->GetByteSize(); 448 449 if (end_offset > start_offset) { 450 uint32_t length = end_offset - start_offset; 451 if (include_newline_chars == false) { 452 const char *line_start = 453 (const char *)m_data_sp->GetBytes() + start_offset; 454 while (length > 0) { 455 const char last_char = line_start[length - 1]; 456 if ((last_char == '\r') || (last_char == '\n')) 457 --length; 458 else 459 break; 460 } 461 } 462 return length; 463 } 464 return 0; 465 } 466 467 bool SourceManager::File::LineIsValid(uint32_t line) { 468 if (line == 0) 469 return false; 470 471 if (CalculateLineOffsets(line)) 472 return line < m_offsets.size(); 473 return false; 474 } 475 476 void SourceManager::File::UpdateIfNeeded() { 477 // TODO: use host API to sign up for file modifications to anything in our 478 // source cache and only update when we determine a file has been updated. 479 // For now we check each time we want to display info for the file. 480 auto curr_mod_time = FileSystem::GetModificationTime(m_file_spec); 481 482 if (curr_mod_time != llvm::sys::TimePoint<>() && 483 m_mod_time != curr_mod_time) { 484 m_mod_time = curr_mod_time; 485 m_data_sp = m_file_spec.ReadFileContents(); 486 m_offsets.clear(); 487 } 488 } 489 490 size_t SourceManager::File::DisplaySourceLines(uint32_t line, uint32_t column, 491 uint32_t context_before, 492 uint32_t context_after, 493 Stream *s) { 494 // Nothing to write if there's no stream. 495 if (!s) 496 return 0; 497 498 // Sanity check m_data_sp before proceeding. 499 if (!m_data_sp) 500 return 0; 501 502 const uint32_t start_line = 503 line <= context_before ? 1 : line - context_before; 504 const uint32_t start_line_offset = GetLineOffset(start_line); 505 if (start_line_offset != UINT32_MAX) { 506 const uint32_t end_line = line + context_after; 507 uint32_t end_line_offset = GetLineOffset(end_line + 1); 508 if (end_line_offset == UINT32_MAX) 509 end_line_offset = m_data_sp->GetByteSize(); 510 511 assert(start_line_offset <= end_line_offset); 512 size_t bytes_written = 0; 513 if (start_line_offset < end_line_offset) { 514 size_t count = end_line_offset - start_line_offset; 515 const uint8_t *cstr = m_data_sp->GetBytes() + start_line_offset; 516 517 bool displayed_line = false; 518 519 if (column && (column < count)) { 520 auto debugger_sp = m_debugger_wp.lock(); 521 if (should_show_stop_column_with_ansi(debugger_sp) && debugger_sp) { 522 // Check if we have any ANSI codes with which to mark this column. 523 // If not, no need to do this work. 524 auto ansi_prefix_entry = debugger_sp->GetStopShowColumnAnsiPrefix(); 525 auto ansi_suffix_entry = debugger_sp->GetStopShowColumnAnsiSuffix(); 526 527 // We only bother breaking up the line to format the marked column if 528 // there is any marking specified on both sides of the marked column. 529 // In ANSI-terminal-sequence land, there must be a post if there is a 530 // pre format, and vice versa. 531 if (ansi_prefix_entry && ansi_suffix_entry) { 532 // Mark the current column with the desired escape sequence for 533 // formatting the column (e.g. underline, inverse, etc.) 534 535 // First print the part before the column to mark. 536 bytes_written = s->Write(cstr, column - 1); 537 538 // Write the pre escape sequence. 539 const SymbolContext *sc = nullptr; 540 const ExecutionContext *exe_ctx = nullptr; 541 const Address addr = LLDB_INVALID_ADDRESS; 542 ValueObject *valobj = nullptr; 543 const bool function_changed = false; 544 const bool initial_function = false; 545 546 FormatEntity::Format(*ansi_prefix_entry, *s, sc, exe_ctx, &addr, 547 valobj, function_changed, initial_function); 548 549 // Write the marked column. 550 bytes_written += s->Write(cstr + column - 1, 1); 551 552 // Write the post escape sequence. 553 FormatEntity::Format(*ansi_suffix_entry, *s, sc, exe_ctx, &addr, 554 valobj, function_changed, initial_function); 555 556 // And finish up with the rest of the line. 557 bytes_written += s->Write(cstr + column, count - column); 558 559 // Keep track of the fact that we just wrote the line. 560 displayed_line = true; 561 } 562 } 563 } 564 565 // If we didn't end up displaying the line with ANSI codes for whatever 566 // reason, display it now sans codes. 567 if (!displayed_line) 568 bytes_written = s->Write(cstr, count); 569 570 // Ensure we get an end of line character one way or another. 571 if (!is_newline_char(cstr[count - 1])) 572 bytes_written += s->EOL(); 573 } 574 return bytes_written; 575 } 576 return 0; 577 } 578 579 void SourceManager::File::FindLinesMatchingRegex( 580 RegularExpression ®ex, uint32_t start_line, uint32_t end_line, 581 std::vector<uint32_t> &match_lines) { 582 match_lines.clear(); 583 584 if (!LineIsValid(start_line) || 585 (end_line != UINT32_MAX && !LineIsValid(end_line))) 586 return; 587 if (start_line > end_line) 588 return; 589 590 for (uint32_t line_no = start_line; line_no < end_line; line_no++) { 591 std::string buffer; 592 if (!GetLine(line_no, buffer)) 593 break; 594 if (regex.Execute(buffer)) { 595 match_lines.push_back(line_no); 596 } 597 } 598 } 599 600 bool SourceManager::File::FileSpecMatches(const FileSpec &file_spec) { 601 return FileSpec::Equal(m_file_spec, file_spec, false); 602 } 603 604 bool lldb_private::operator==(const SourceManager::File &lhs, 605 const SourceManager::File &rhs) { 606 if (lhs.m_file_spec != rhs.m_file_spec) 607 return false; 608 return lhs.m_mod_time == rhs.m_mod_time; 609 } 610 611 bool SourceManager::File::CalculateLineOffsets(uint32_t line) { 612 line = 613 UINT32_MAX; // TODO: take this line out when we support partial indexing 614 if (line == UINT32_MAX) { 615 // Already done? 616 if (!m_offsets.empty() && m_offsets[0] == UINT32_MAX) 617 return true; 618 619 if (m_offsets.empty()) { 620 if (m_data_sp.get() == NULL) 621 return false; 622 623 const char *start = (char *)m_data_sp->GetBytes(); 624 if (start) { 625 const char *end = start + m_data_sp->GetByteSize(); 626 627 // Calculate all line offsets from scratch 628 629 // Push a 1 at index zero to indicate the file has been completely 630 // indexed. 631 m_offsets.push_back(UINT32_MAX); 632 const char *s; 633 for (s = start; s < end; ++s) { 634 char curr_ch = *s; 635 if (is_newline_char(curr_ch)) { 636 if (s + 1 < end) { 637 char next_ch = s[1]; 638 if (is_newline_char(next_ch)) { 639 if (curr_ch != next_ch) 640 ++s; 641 } 642 } 643 m_offsets.push_back(s + 1 - start); 644 } 645 } 646 if (!m_offsets.empty()) { 647 if (m_offsets.back() < size_t(end - start)) 648 m_offsets.push_back(end - start); 649 } 650 return true; 651 } 652 } else { 653 // Some lines have been populated, start where we last left off 654 assert("Not implemented yet" && false); 655 } 656 657 } else { 658 // Calculate all line offsets up to "line" 659 assert("Not implemented yet" && false); 660 } 661 return false; 662 } 663 664 bool SourceManager::File::GetLine(uint32_t line_no, std::string &buffer) { 665 if (!LineIsValid(line_no)) 666 return false; 667 668 size_t start_offset = GetLineOffset(line_no); 669 size_t end_offset = GetLineOffset(line_no + 1); 670 if (end_offset == UINT32_MAX) { 671 end_offset = m_data_sp->GetByteSize(); 672 } 673 buffer.assign((char *)m_data_sp->GetBytes() + start_offset, 674 end_offset - start_offset); 675 676 return true; 677 } 678 679 void SourceManager::SourceFileCache::AddSourceFile(const FileSP &file_sp) { 680 FileSpec file_spec; 681 FileCache::iterator pos = m_file_cache.find(file_spec); 682 if (pos == m_file_cache.end()) 683 m_file_cache[file_spec] = file_sp; 684 else { 685 if (file_sp != pos->second) 686 m_file_cache[file_spec] = file_sp; 687 } 688 } 689 690 SourceManager::FileSP SourceManager::SourceFileCache::FindSourceFile( 691 const FileSpec &file_spec) const { 692 FileSP file_sp; 693 FileCache::const_iterator pos = m_file_cache.find(file_spec); 694 if (pos != m_file_cache.end()) 695 file_sp = pos->second; 696 return file_sp; 697 } 698