Relax language comparison when matching up C++ forward decls with definitions

when dealing with -gmodules debug info.

This fixes the bot failures on Darwin.

A recent clang change (presumably https://reviews.llvm.org/D104291)
introduced a bug where .pcm files would identify themselves as
DW_LANG_C_plus_plus, but the .o that references them would identify as
DW_LANG_C_plus_plus_14. While that bug needs to be fixed, too, it
shows that the current strict comparison also isn't meaningful.

rdar://79423225
This commit is contained in:
Adrian Prantl
2021-06-16 18:17:58 -07:00
parent 562bfe1274
commit 42e2a90684
3 changed files with 11 additions and 2 deletions

View File

@@ -157,7 +157,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
// The type in the Clang module must have the same language as the current CU.
LanguageSet languages;
languages.Insert(SymbolFileDWARF::GetLanguage(*die.GetCU()));
languages.Insert(SymbolFileDWARF::GetLanguageFamily(*die.GetCU()));
llvm::DenseSet<SymbolFile *> searched_symbol_files;
clang_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
searched_symbol_files, pcm_types);

View File

@@ -2412,7 +2412,7 @@ void SymbolFileDWARF::FindTypes(
return;
m_index->GetTypes(name, [&](DWARFDIE die) {
if (!languages[GetLanguage(*die.GetCU())])
if (!languages[GetLanguageFamily(*die.GetCU())])
return true;
llvm::SmallVector<CompilerContext, 4> die_context;
@@ -3886,3 +3886,10 @@ LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {
LanguageType SymbolFileDWARF::GetLanguage(DWARFUnit &unit) {
return LanguageTypeFromDWARF(unit.GetDWARFLanguageType());
}
LanguageType SymbolFileDWARF::GetLanguageFamily(DWARFUnit &unit) {
auto lang = (llvm::dwarf::SourceLanguage)unit.GetDWARFLanguageType();
if (llvm::dwarf::isCPlusPlus(lang))
lang = DW_LANG_C_plus_plus;
return LanguageTypeFromDWARF(lang);
}

View File

@@ -317,6 +317,8 @@ public:
static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
static lldb::LanguageType GetLanguage(DWARFUnit &unit);
/// Same as GetLanguage() but reports all C++ versions as C++ (no version).
static lldb::LanguageType GetLanguageFamily(DWARFUnit &unit);
protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>