mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
Readdress r236990, use of static members on a non-static variable.
The TargetRegistry is just a namespace-like class, instantiated in one place to use a range-based for loop. Instead, expose access to the registry via a range-based 'targets()' function instead. This makes most uses a bit awkward/more verbose - but eventually we should just add a range-based find_if function which will streamline these functions. I'm happy to mkae them a bit awkward in the interim as encouragement to improve the algorithms in time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237059 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -49,21 +49,19 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
|
||||
// Adjust the triple to match what the user requested.
|
||||
const Target *TheTarget = nullptr;
|
||||
if (!MArch.empty()) {
|
||||
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||
ie = TargetRegistry::end(); it != ie; ++it) {
|
||||
if (MArch == it->getName()) {
|
||||
TheTarget = &*it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto I = std::find_if(
|
||||
TargetRegistry::targets().begin(), TargetRegistry::targets().end(),
|
||||
[&](const Target &T) { return MArch == T.getName(); });
|
||||
|
||||
if (!TheTarget) {
|
||||
if (I == TargetRegistry::targets().end()) {
|
||||
if (ErrorStr)
|
||||
*ErrorStr = "No available targets are compatible with this -march, "
|
||||
"see -version for the available targets.\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TheTarget = &*I;
|
||||
|
||||
// Adjust the triple to match (if known), otherwise stick with the
|
||||
// requested/host triple.
|
||||
Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch);
|
||||
|
Reference in New Issue
Block a user