mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Run code through clang-modernize -loop-convert to create range-based for loops, and manually fix some stuff up.
This commit is contained in:
@ -12,16 +12,16 @@
|
||||
|
||||
bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
|
||||
{
|
||||
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
|
||||
if (i->iAddress == _iAddress)
|
||||
for (auto& bp : m_BreakPoints)
|
||||
if (bp.iAddress == _iAddress)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
|
||||
{
|
||||
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
|
||||
if (i->iAddress == _iAddress && i->bTemporary)
|
||||
for (auto& bp : m_BreakPoints)
|
||||
if (bp.iAddress == _iAddress && bp.bTemporary)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -29,29 +29,28 @@ bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
|
||||
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
|
||||
{
|
||||
TBreakPointsStr bps;
|
||||
for (TBreakPoints::const_iterator i = m_BreakPoints.begin();
|
||||
i != m_BreakPoints.end(); ++i)
|
||||
for (const auto& bp : m_BreakPoints)
|
||||
{
|
||||
if (!i->bTemporary)
|
||||
if (!bp.bTemporary)
|
||||
{
|
||||
std::stringstream bp;
|
||||
bp << std::hex << i->iAddress << " " << (i->bOn ? "n" : "");
|
||||
bps.push_back(bp.str());
|
||||
std::stringstream ss;
|
||||
ss << std::hex << bp.iAddress << " " << (bp.bOn ? "n" : "");
|
||||
bps.push_back(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
return bps;
|
||||
}
|
||||
|
||||
void BreakPoints::AddFromStrings(const TBreakPointsStr& bps)
|
||||
void BreakPoints::AddFromStrings(const TBreakPointsStr& bpstrs)
|
||||
{
|
||||
for (TBreakPointsStr::const_iterator i = bps.begin(); i != bps.end(); ++i)
|
||||
for (const auto& bpstr : bpstrs)
|
||||
{
|
||||
TBreakPoint bp;
|
||||
std::stringstream bpstr;
|
||||
bpstr << std::hex << *i;
|
||||
bpstr >> bp.iAddress;
|
||||
bp.bOn = i->find("n") != i->npos;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << bpstr;
|
||||
ss >> bp.iAddress;
|
||||
bp.bOn = bpstr.find("n") != bpstr.npos;
|
||||
bp.bTemporary = false;
|
||||
Add(bp);
|
||||
}
|
||||
@ -115,35 +114,34 @@ void BreakPoints::Clear()
|
||||
MemChecks::TMemChecksStr MemChecks::GetStrings() const
|
||||
{
|
||||
TMemChecksStr mcs;
|
||||
for (TMemChecks::const_iterator i = m_MemChecks.begin();
|
||||
i != m_MemChecks.end(); ++i)
|
||||
for (const auto& bp : m_MemChecks)
|
||||
{
|
||||
std::stringstream mc;
|
||||
mc << std::hex << i->StartAddress;
|
||||
mc << " " << (i->bRange ? i->EndAddress : i->StartAddress) << " " <<
|
||||
(i->bRange ? "n" : "") << (i->OnRead ? "r" : "") <<
|
||||
(i->OnWrite ? "w" : "") << (i->Log ? "l" : "") << (i->Break ? "p" : "");
|
||||
mc << std::hex << bp.StartAddress;
|
||||
mc << " " << (bp.bRange ? bp.EndAddress : bp.StartAddress) << " " <<
|
||||
(bp.bRange ? "n" : "") << (bp.OnRead ? "r" : "") <<
|
||||
(bp.OnWrite ? "w" : "") << (bp.Log ? "l" : "") << (bp.Break ? "p" : "");
|
||||
mcs.push_back(mc.str());
|
||||
}
|
||||
|
||||
return mcs;
|
||||
}
|
||||
|
||||
void MemChecks::AddFromStrings(const TMemChecksStr& mcs)
|
||||
void MemChecks::AddFromStrings(const TMemChecksStr& mcstrs)
|
||||
{
|
||||
for (TMemChecksStr::const_iterator i = mcs.begin(); i != mcs.end(); ++i)
|
||||
for (const auto& mcstr : mcstrs)
|
||||
{
|
||||
TMemCheck mc;
|
||||
std::stringstream mcstr;
|
||||
mcstr << std::hex << *i;
|
||||
mcstr >> mc.StartAddress;
|
||||
mc.bRange = i->find("n") != i->npos;
|
||||
mc.OnRead = i->find("r") != i->npos;
|
||||
mc.OnWrite = i->find("w") != i->npos;
|
||||
mc.Log = i->find("l") != i->npos;
|
||||
mc.Break = i->find("p") != i->npos;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << mcstr;
|
||||
ss >> mc.StartAddress;
|
||||
mc.bRange = mcstr.find("n") != mcstr.npos;
|
||||
mc.OnRead = mcstr.find("r") != mcstr.npos;
|
||||
mc.OnWrite = mcstr.find("w") != mcstr.npos;
|
||||
mc.Log = mcstr.find("l") != mcstr.npos;
|
||||
mc.Break = mcstr.find("p") != mcstr.npos;
|
||||
if (mc.bRange)
|
||||
mcstr >> mc.EndAddress;
|
||||
ss >> mc.EndAddress;
|
||||
else
|
||||
mc.EndAddress = mc.StartAddress;
|
||||
Add(mc);
|
||||
@ -170,15 +168,15 @@ void MemChecks::Remove(u32 _Address)
|
||||
|
||||
TMemCheck *MemChecks::GetMemCheck(u32 address)
|
||||
{
|
||||
for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
|
||||
for (auto& bp : m_MemChecks)
|
||||
{
|
||||
if (i->bRange)
|
||||
if (bp.bRange)
|
||||
{
|
||||
if (address >= i->StartAddress && address <= i->EndAddress)
|
||||
return &(*i);
|
||||
if (address >= bp.StartAddress && address <= bp.EndAddress)
|
||||
return &(bp);
|
||||
}
|
||||
else if (i->StartAddress == address)
|
||||
return &(*i);
|
||||
else if (bp.StartAddress == address)
|
||||
return &(bp);
|
||||
}
|
||||
|
||||
// none found
|
||||
|
@ -211,24 +211,21 @@ std::vector<std::string> cdio_get_devices ()
|
||||
// Returns true if device is a cdrom/dvd drive
|
||||
bool cdio_is_cdrom(std::string device)
|
||||
{
|
||||
#ifdef __linux__
|
||||
#ifndef _WIN32
|
||||
// Resolve symbolic links. This allows symbolic links to valid
|
||||
// drives to be passed from the command line with the -e flag.
|
||||
char resolved_path[MAX_PATH];
|
||||
char *devname = realpath(device.c_str(), resolved_path);
|
||||
if (!devname)
|
||||
return false;
|
||||
device = devname;
|
||||
#endif
|
||||
|
||||
std::vector<std::string> devices = cdio_get_devices();
|
||||
bool res = false;
|
||||
for (unsigned int i = 0; i < devices.size(); i++)
|
||||
for (auto& odevice : devices)
|
||||
{
|
||||
#ifdef __linux__
|
||||
if (strncmp(devices[i].c_str(), devname, MAX_PATH) == 0)
|
||||
#else
|
||||
if (strncmp(devices[i].c_str(), device.c_str(), MAX_PATH) == 0)
|
||||
#endif
|
||||
if (strncmp(odevice.c_str(), device.c_str(), MAX_PATH) == 0)
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
|
@ -90,10 +90,10 @@ public:
|
||||
case MODE_WRITE:
|
||||
case MODE_MEASURE:
|
||||
case MODE_VERIFY:
|
||||
for (auto itr = x.begin(); itr != x.end(); ++itr)
|
||||
for (auto& elem : x)
|
||||
{
|
||||
Do(itr->first);
|
||||
Do(itr->second);
|
||||
Do(elem.first);
|
||||
Do(elem.second);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -134,8 +134,8 @@ public:
|
||||
Do(size);
|
||||
x.resize(size);
|
||||
|
||||
for (auto itr = x.begin(); itr != x.end(); ++itr)
|
||||
Do(*itr);
|
||||
for (auto& elem : x)
|
||||
Do(elem);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -21,11 +21,11 @@
|
||||
CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, const CFileSearch::XStringVector& _rDirectories)
|
||||
{
|
||||
// Reverse the loop order for speed?
|
||||
for (size_t j = 0; j < _rSearchStrings.size(); j++)
|
||||
for (auto& _rSearchString : _rSearchStrings)
|
||||
{
|
||||
for (size_t i = 0; i < _rDirectories.size(); i++)
|
||||
for (auto& _rDirectory : _rDirectories)
|
||||
{
|
||||
FindFiles(_rSearchStrings[j], _rDirectories[i]);
|
||||
FindFiles(_rSearchString, _rDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,18 +125,16 @@ bool IniFile::Section::Get(const char* key, std::vector<std::string>& out)
|
||||
size_t subEnd;
|
||||
|
||||
// split by ,
|
||||
while (subStart != std::string::npos) {
|
||||
|
||||
while (subStart != std::string::npos)
|
||||
{
|
||||
// Find next ,
|
||||
subEnd = temp.find_first_of(",", subStart);
|
||||
if (subStart != subEnd)
|
||||
// take from first char until next ,
|
||||
out.push_back(StripSpaces(temp.substr(subStart, subEnd - subStart)));
|
||||
|
||||
// Find the next non , char
|
||||
subStart = temp.find_first_not_of(",", subEnd);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -210,17 +208,17 @@ bool IniFile::Section::Delete(const char *key)
|
||||
|
||||
const IniFile::Section* IniFile::GetSection(const char* sectionName) const
|
||||
{
|
||||
for (std::vector<Section>::const_iterator iter = sections.begin(); iter != sections.end(); ++iter)
|
||||
if (!strcasecmp(iter->name.c_str(), sectionName))
|
||||
return (&(*iter));
|
||||
for (const auto& sect : sections)
|
||||
if (!strcasecmp(sect.name.c_str(), sectionName))
|
||||
return (&(sect));
|
||||
return 0;
|
||||
}
|
||||
|
||||
IniFile::Section* IniFile::GetSection(const char* sectionName)
|
||||
{
|
||||
for (std::vector<Section>::iterator iter = sections.begin(); iter != sections.end(); ++iter)
|
||||
if (!strcasecmp(iter->name.c_str(), sectionName))
|
||||
return (&(*iter));
|
||||
for (auto& sect : sections)
|
||||
if (!strcasecmp(sect.name.c_str(), sectionName))
|
||||
return (&(sect));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -291,9 +289,9 @@ bool IniFile::GetLines(const char* sectionName, std::vector<std::string>& lines,
|
||||
return false;
|
||||
|
||||
lines.clear();
|
||||
for (std::vector<std::string>::const_iterator iter = section->lines.begin(); iter != section->lines.end(); ++iter)
|
||||
for (std::string line : section->lines)
|
||||
{
|
||||
std::string line = StripSpaces(*iter);
|
||||
line = StripSpaces(line);
|
||||
|
||||
if (remove_comments)
|
||||
{
|
||||
@ -399,20 +397,15 @@ bool IniFile::Save(const char* filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto iter = sections.begin(); iter != sections.end(); ++iter)
|
||||
for (auto& section : sections)
|
||||
{
|
||||
const Section& section = *iter;
|
||||
|
||||
if (section.keys_order.size() != 0 || section.lines.size() != 0)
|
||||
out << "[" << section.name << "]" << std::endl;
|
||||
|
||||
if (section.keys_order.size() == 0)
|
||||
{
|
||||
for (auto liter = section.lines.begin(); liter != section.lines.end(); ++liter)
|
||||
{
|
||||
std::string s = *liter;
|
||||
for (auto s : section.lines)
|
||||
out << s << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -81,14 +81,14 @@ LogManager::LogManager()
|
||||
m_consoleLog = new ConsoleListener();
|
||||
m_debuggerLog = new DebuggerLogListener();
|
||||
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
for (auto& container : m_Log)
|
||||
{
|
||||
m_Log[i]->SetEnable(true);
|
||||
m_Log[i]->AddListener(m_fileLog);
|
||||
m_Log[i]->AddListener(m_consoleLog);
|
||||
container->SetEnable(true);
|
||||
container->AddListener(m_fileLog);
|
||||
container->AddListener(m_consoleLog);
|
||||
#ifdef _MSC_VER
|
||||
if (IsDebuggerPresent())
|
||||
m_Log[i]->AddListener(m_debuggerLog);
|
||||
container->AddListener(m_debuggerLog);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -102,8 +102,8 @@ LogManager::~LogManager()
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
|
||||
}
|
||||
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
delete m_Log[i];
|
||||
for (auto& container : m_Log)
|
||||
delete container;
|
||||
|
||||
delete m_fileLog;
|
||||
delete m_consoleLog;
|
||||
|
@ -36,7 +36,7 @@ int AshmemCreateFileMapping(const char *name, size_t size)
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
// We don't really care if we can't set the name, it is optional
|
||||
// We don't really care if we can't set the name, it is optional
|
||||
ret = ioctl(fd, ASHMEM_SET_NAME, name);
|
||||
|
||||
ret = ioctl(fd, ASHMEM_SET_SIZE, size);
|
||||
@ -263,7 +263,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
|
||||
base_attempts = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
// Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors.
|
||||
@ -289,9 +288,8 @@ void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemAr
|
||||
{
|
||||
const MemoryView* view = &views[i];
|
||||
u8** outptrs[2] = {view->out_ptr_low, view->out_ptr};
|
||||
for (int j = 0; j < 2; j++)
|
||||
for (auto outptr : outptrs)
|
||||
{
|
||||
u8** outptr = outptrs[j];
|
||||
if (outptr && *outptr && !freeset.count(*outptr))
|
||||
{
|
||||
arena->ReleaseView(*outptr, view->size);
|
||||
|
@ -28,18 +28,18 @@ void SymbolDB::Clear(const char *prefix)
|
||||
void SymbolDB::Index()
|
||||
{
|
||||
int i = 0;
|
||||
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
|
||||
for (auto& func : functions)
|
||||
{
|
||||
iter->second.index = i++;
|
||||
func.second.index = i++;
|
||||
}
|
||||
}
|
||||
|
||||
Symbol *SymbolDB::GetSymbolFromName(const char *name)
|
||||
{
|
||||
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
|
||||
for (auto& func : functions)
|
||||
{
|
||||
if (!strcmp(iter->second.name.c_str(), name))
|
||||
return &iter->second;
|
||||
if (!strcmp(func.second.name.c_str(), name))
|
||||
return &func.second;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -298,8 +298,8 @@ void SysConf::GenerateSysConf()
|
||||
items[26].data[0] = 0x01;
|
||||
|
||||
|
||||
for (int i = 0; i < 27; i++)
|
||||
m_Entries.push_back(items[i]);
|
||||
for (auto& item : items)
|
||||
m_Entries.push_back(item);
|
||||
|
||||
File::CreateFullPath(m_FilenameDefault);
|
||||
File::IOFile g(m_FilenameDefault, "wb");
|
||||
|
Reference in New Issue
Block a user