[Lldb-commits] [PATCH] D44456: [SymbolFilePDB] Simplify getting the source file path

2018-03-19 Thread Aaron Smith via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327925: [SymbolFilePDB] Simplify getting the source file 
path (authored by asmith, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44456?vs=138299=139032#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44456

Files:
  lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h

Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -198,9 +198,6 @@
   void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland _compiland,
uint32_t );
 
-  std::string GetSourceFileNameForPDBCompiland(
-  const llvm::pdb::PDBSymbolCompiland *pdb_compiland);
-
   std::unique_ptr
   GetPDBCompilandByUID(uint32_t uid);
 
Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -614,59 +614,6 @@
   return resolved_flags;
 }
 
-std::string SymbolFilePDB::GetSourceFileNameForPDBCompiland(
-const PDBSymbolCompiland *pdb_compiland) {
-  if (!pdb_compiland)
-return std::string();
-
-  std::string source_file_name;
-  // `getSourceFileName` returns the basename of the original source file
-  // used to generate this compiland.  It does not return the full path.
-  // Currently the only way to get that is to do a basename lookup to get the
-  // IPDBSourceFile, but this is ambiguous in the case of two source files
-  // with the same name contributing to the same compiland. This is an edge
-  // case that we ignore for now, although we need to a long-term solution.
-  std::string file_name = pdb_compiland->getSourceFileName();
-  if (!file_name.empty()) {
-auto one_src_file_up =
-m_session_up->findOneSourceFile(pdb_compiland, file_name,
-PDB_NameSearchFlags::NS_CaseInsensitive);
-if (one_src_file_up)
-  source_file_name = one_src_file_up->getFileName();
-  }
-  // For some reason, source file name could be empty, so we will walk through
-  // all source files of this compiland, and determine the right source file
-  // if any that is used to generate this compiland based on language
-  // indicated in compilanddetails language field.
-  if (!source_file_name.empty())
-return source_file_name;
-
-  auto details_up = pdb_compiland->findOneChild();
-  PDB_Lang pdb_lang = details_up ? details_up->getLanguage() : PDB_Lang::Cpp;
-  auto src_files_up =
-  m_session_up->getSourceFilesForCompiland(*pdb_compiland);
-  if (src_files_up) {
-while (auto file_up = src_files_up->getNext()) {
-  FileSpec file_spec(file_up->getFileName(), false,
- FileSpec::ePathSyntaxWindows);
-  auto file_extension = file_spec.GetFileNameExtension();
-  if (pdb_lang == PDB_Lang::Cpp || pdb_lang == PDB_Lang::C) {
-static const char* exts[] = { "cpp", "c", "cc", "cxx" };
-if (llvm::is_contained(exts, file_extension.GetStringRef().lower())) {
-  source_file_name = file_up->getFileName();
-  break;
-}
-  } else if (pdb_lang == PDB_Lang::Masm &&
- ConstString::Compare(file_extension, ConstString("ASM"),
-  false) == 0) {
-source_file_name = file_up->getFileName();
-break;
-  }
-}
-  }
-  return source_file_name;
-}
-
 uint32_t SymbolFilePDB::ResolveSymbolContext(
 const lldb_private::FileSpec _spec, uint32_t line, bool check_inlines,
 uint32_t resolve_scope, lldb_private::SymbolContextList _list) {
@@ -690,15 +637,7 @@
   // For inline functions, we don't have to match the FileSpec since they
   // could be defined in headers other than file specified in FileSpec.
   if (!check_inlines) {
-// `getSourceFileName` returns the basename of the original source file
-// used to generate this compiland.  It does not return the full path.
-// Currently the only way to get that is to do a basename lookup to get
-// the IPDBSourceFile, but this is ambiguous in the case of two source
-// files with the same name contributing to the same compiland.  This is
-// a moderately extreme edge case, so we consider this OK for now,
-// although we need to find a long-term solution.
-std::string source_file =
-GetSourceFileNameForPDBCompiland(compiland.get());
+std::string source_file = compiland->getSourceFileFullPath();
 if (source_file.empty())
   

[Lldb-commits] [PATCH] D44456: [SymbolFilePDB] Simplify getting the source file path

2018-03-13 Thread Aaron Smith via Phabricator via lldb-commits
asmith added a comment.

Has a dependence on https://reviews.llvm.org/D44458


Repository:
  rL LLVM

https://reviews.llvm.org/D44456



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44456: [SymbolFilePDB] Simplify getting the source file path

2018-03-13 Thread Aaron Smith via Phabricator via lldb-commits
asmith created this revision.
asmith added reviewers: zturner, rnk, lldb-commits.
Herald added a subscriber: llvm-commits.

Replace SymbolFilePDB::GetSourceFileNameForPDBCompiland() with 
PDBSymbolCompiland::getSourceFileFullPath().


Repository:
  rL LLVM

https://reviews.llvm.org/D44456

Files:
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.h

Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -198,9 +198,6 @@
   void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland *pdb_compiland,
uint32_t );
 
-  std::string GetSourceFileNameForPDBCompiland(
-  const llvm::pdb::PDBSymbolCompiland *pdb_compiland);
-
   std::unique_ptr
   GetPDBCompilandByUID(uint32_t uid);
 
Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -589,59 +589,6 @@
   return resolved_flags;
 }
 
-std::string SymbolFilePDB::GetSourceFileNameForPDBCompiland(
-const PDBSymbolCompiland *pdb_compiland) {
-  if (!pdb_compiland)
-return std::string();
-
-  std::string source_file_name;
-  // `getSourceFileName` returns the basename of the original source file
-  // used to generate this compiland.  It does not return the full path.
-  // Currently the only way to get that is to do a basename lookup to get the
-  // IPDBSourceFile, but this is ambiguous in the case of two source files
-  // with the same name contributing to the same compiland. This is an edge
-  // case that we ignore for now, although we need to a long-term solution.
-  std::string file_name = pdb_compiland->getSourceFileName();
-  if (!file_name.empty()) {
-auto one_src_file_up =
-m_session_up->findOneSourceFile(pdb_compiland, file_name,
-PDB_NameSearchFlags::NS_CaseInsensitive);
-if (one_src_file_up)
-  source_file_name = one_src_file_up->getFileName();
-  }
-  // For some reason, source file name could be empty, so we will walk through
-  // all source files of this compiland, and determine the right source file
-  // if any that is used to generate this compiland based on language
-  // indicated in compilanddetails language field.
-  if (!source_file_name.empty())
-return source_file_name;
-
-  auto details_up = pdb_compiland->findOneChild();
-  PDB_Lang pdb_lang = details_up ? details_up->getLanguage() : PDB_Lang::Cpp;
-  auto src_files_up =
-  m_session_up->getSourceFilesForCompiland(*pdb_compiland);
-  if (src_files_up) {
-while (auto file_up = src_files_up->getNext()) {
-  FileSpec file_spec(file_up->getFileName(), false,
- FileSpec::ePathSyntaxWindows);
-  auto file_extension = file_spec.GetFileNameExtension();
-  if (pdb_lang == PDB_Lang::Cpp || pdb_lang == PDB_Lang::C) {
-static const char* exts[] = { "cpp", "c", "cc", "cxx" };
-if (llvm::is_contained(exts, file_extension.GetStringRef().lower())) {
-  source_file_name = file_up->getFileName();
-  break;
-}
-  } else if (pdb_lang == PDB_Lang::Masm &&
- ConstString::Compare(file_extension, ConstString("ASM"),
-  false) == 0) {
-source_file_name = file_up->getFileName();
-break;
-  }
-}
-  }
-  return source_file_name;
-}
-
 uint32_t SymbolFilePDB::ResolveSymbolContext(
 const lldb_private::FileSpec _spec, uint32_t line, bool check_inlines,
 uint32_t resolve_scope, lldb_private::SymbolContextList _list) {
@@ -665,15 +612,7 @@
   // For inline functions, we don't have to match the FileSpec since they
   // could be defined in headers other than file specified in FileSpec.
   if (!check_inlines) {
-// `getSourceFileName` returns the basename of the original source file
-// used to generate this compiland.  It does not return the full path.
-// Currently the only way to get that is to do a basename lookup to get
-// the IPDBSourceFile, but this is ambiguous in the case of two source
-// files with the same name contributing to the same compiland.  This is
-// a moderately extreme edge case, so we consider this OK for now,
-// although we need to find a long-term solution.
-std::string source_file =
-GetSourceFileNameForPDBCompiland(compiland.get());
+std::string source_file = compiland->getSourceFileFullPath();
 if (source_file.empty())
   continue;
 FileSpec this_spec(source_file, false, FileSpec::ePathSyntaxWindows);
@@ -1262,7 +1201,7 @@
   if (lang == lldb::LanguageType::eLanguageTypeUnknown)
 return CompUnitSP();
 
-