[llvm-symbolizer] Minor typedef cleanup. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219682 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexander Potapenko 2014-10-14 13:40:44 +00:00
parent 45ed68789b
commit 49e7edc0fa
2 changed files with 20 additions and 23 deletions

View File

@ -85,7 +85,7 @@ void ModuleInfo::addSymbol(const SymbolRef &Symbol) {
SymbolName = SymbolName.drop_front(); SymbolName = SymbolName.drop_front();
// FIXME: If a function has alias, there are two entries in symbol table // FIXME: If a function has alias, there are two entries in symbol table
// with same address size. Make sure we choose the correct one. // with same address size. Make sure we choose the correct one.
SymbolMapTy &M = SymbolType == SymbolRef::ST_Function ? Functions : Objects; auto &M = SymbolType == SymbolRef::ST_Function ? Functions : Objects;
SymbolDesc SD = { SymbolAddress, SymbolSize }; SymbolDesc SD = { SymbolAddress, SymbolSize };
M.insert(std::make_pair(SD, SymbolName)); M.insert(std::make_pair(SD, SymbolName));
} }
@ -93,19 +93,20 @@ void ModuleInfo::addSymbol(const SymbolRef &Symbol) {
bool ModuleInfo::getNameFromSymbolTable(SymbolRef::Type Type, uint64_t Address, bool ModuleInfo::getNameFromSymbolTable(SymbolRef::Type Type, uint64_t Address,
std::string &Name, uint64_t &Addr, std::string &Name, uint64_t &Addr,
uint64_t &Size) const { uint64_t &Size) const {
const SymbolMapTy &M = Type == SymbolRef::ST_Function ? Functions : Objects; const auto &SymbolMap = Type == SymbolRef::ST_Function ? Functions : Objects;
if (M.empty()) if (SymbolMap.empty())
return false; return false;
SymbolDesc SD = { Address, Address }; SymbolDesc SD = { Address, Address };
SymbolMapTy::const_iterator it = M.upper_bound(SD); auto SymbolIterator = SymbolMap.upper_bound(SD);
if (it == M.begin()) if (SymbolIterator == SymbolMap.begin())
return false; return false;
--it; --SymbolIterator;
if (it->first.Size != 0 && it->first.Addr + it->first.Size <= Address) if (SymbolIterator->first.Size != 0 &&
SymbolIterator->first.Addr + SymbolIterator->first.Size <= Address)
return false; return false;
Name = it->second.str(); Name = SymbolIterator->second.str();
Addr = it->first.Addr; Addr = SymbolIterator->first.Addr;
Size = it->first.Size; Size = SymbolIterator->first.Size;
return true; return true;
} }
@ -295,7 +296,7 @@ static bool getGNUDebuglinkContents(const Binary *Bin, std::string &DebugName,
LLVMSymbolizer::BinaryPair LLVMSymbolizer::BinaryPair
LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
BinaryMapTy::iterator I = BinaryForPath.find(Path); const auto &I = BinaryForPath.find(Path);
if (I != BinaryForPath.end()) if (I != BinaryForPath.end())
return I->second; return I->second;
Binary *Bin = nullptr; Binary *Bin = nullptr;
@ -348,7 +349,7 @@ LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName
return nullptr; return nullptr;
ObjectFile *Res = nullptr; ObjectFile *Res = nullptr;
if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(Bin)) { if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(Bin)) {
ObjectFileForArchMapTy::iterator I = ObjectFileForArch.find( const auto &I = ObjectFileForArch.find(
std::make_pair(UB, ArchName)); std::make_pair(UB, ArchName));
if (I != ObjectFileForArch.end()) if (I != ObjectFileForArch.end())
return I->second; return I->second;
@ -367,7 +368,7 @@ LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName
ModuleInfo * ModuleInfo *
LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) {
ModuleMapTy::iterator I = Modules.find(ModuleName); const auto &I = Modules.find(ModuleName);
if (I != Modules.end()) if (I != Modules.end())
return I->second; return I->second;
std::string BinaryName = ModuleName; std::string BinaryName = ModuleName;

View File

@ -82,13 +82,10 @@ private:
} }
// Owns module info objects. // Owns module info objects.
typedef std::map<std::string, ModuleInfo *> ModuleMapTy; std::map<std::string, ModuleInfo *> Modules;
ModuleMapTy Modules; std::map<std::string, BinaryPair> BinaryForPath;
typedef std::map<std::string, BinaryPair> BinaryMapTy; std::map<std::pair<MachOUniversalBinary *, std::string>, ObjectFile *>
BinaryMapTy BinaryForPath; ObjectFileForArch;
typedef std::map<std::pair<MachOUniversalBinary *, std::string>, ObjectFile *>
ObjectFileForArchMapTy;
ObjectFileForArchMapTy ObjectFileForArch;
Options Opts; Options Opts;
static const char kBadString[]; static const char kBadString[];
@ -122,9 +119,8 @@ private:
return s1.Addr < s2.Addr; return s1.Addr < s2.Addr;
} }
}; };
typedef std::map<SymbolDesc, StringRef> SymbolMapTy; std::map<SymbolDesc, StringRef> Functions;
SymbolMapTy Functions; std::map<SymbolDesc, StringRef> Objects;
SymbolMapTy Objects;
}; };
} // namespace symbolize } // namespace symbolize