diff options
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/PDBContext.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/PDBContext.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/llvm/lib/DebugInfo/PDB/PDBContext.cpp b/llvm/lib/DebugInfo/PDB/PDBContext.cpp index 561a91ea08b..73c56162430 100644 --- a/llvm/lib/DebugInfo/PDB/PDBContext.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBContext.cpp @@ -96,26 +96,24 @@ std::string PDBContext::getFunctionName(uint64_t Address, if (NameKind == DINameKind::None) return std::string(); + std::unique_ptr<PDBSymbol> FuncSymbol = + Session->findSymbolByAddress(Address, PDB_SymType::Function); + auto *Func = dyn_cast_or_null<PDBSymbolFunc>(FuncSymbol.get()); + if (NameKind == DINameKind::LinkageName) { // It is not possible to get the mangled linkage name through a // PDBSymbolFunc. For that we have to specifically request a // PDBSymbolPublicSymbol. auto PublicSym = Session->findSymbolByAddress(Address, PDB_SymType::PublicSymbol); - if (auto PS = dyn_cast_or_null<PDBSymbolPublicSymbol>(PublicSym.get())) - return PS->getName(); + if (auto *PS = dyn_cast_or_null<PDBSymbolPublicSymbol>(PublicSym.get())) { + // If we also have a function symbol, prefer the use of public symbol name + // only if it refers to the same address. The public symbol uses the + // linkage name while the function does not. + if (!Func || Func->getVirtualAddress() == PS->getVirtualAddress()) + return PS->getName(); + } } - auto FuncSymbol = - Session->findSymbolByAddress(Address, PDB_SymType::Function); - - // This could happen either if there was no public symbol (e.g. not - // external) or the user requested the short name. In the former case, - // although they technically requested the linkage name, if the linkage - // name is not available we fallback to at least returning a non-empty - // string. - if (auto Func = dyn_cast_or_null<PDBSymbolFunc>(FuncSymbol.get())) - return Func->getName(); - - return std::string(); + return Func ? Func->getName() : std::string(); } |