mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
auto and range-for-ify some things to make changing container types a bit easier in the (possibly near) future
llvm-svn: 248212
This commit is contained in:
parent
c8b097b7ef
commit
57458fd3a3
@ -730,8 +730,7 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc, unsigned L,
|
||||
if (GlobalValue *Val = M->getNamedValue(Name)) {
|
||||
// See if this was a redefinition. If so, there is no entry in
|
||||
// ForwardRefVals.
|
||||
std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator
|
||||
I = ForwardRefVals.find(Name);
|
||||
auto I = ForwardRefVals.find(Name);
|
||||
if (I == ForwardRefVals.end())
|
||||
return Error(NameLoc, "redefinition of global named '@" + Name + "'");
|
||||
|
||||
@ -814,8 +813,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
return Error(NameLoc, "redefinition of global '@" + Name + "'");
|
||||
}
|
||||
} else {
|
||||
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
|
||||
I = ForwardRefValIDs.find(NumberedVals.size());
|
||||
auto I = ForwardRefValIDs.find(NumberedVals.size());
|
||||
if (I != ForwardRefValIDs.end()) {
|
||||
GVal = I->second.first;
|
||||
ForwardRefValIDs.erase(I);
|
||||
@ -1081,8 +1079,7 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
|
||||
// If this is a forward reference for the value, see if we already created a
|
||||
// forward ref record.
|
||||
if (!Val) {
|
||||
std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator
|
||||
I = ForwardRefVals.find(Name);
|
||||
auto I = ForwardRefVals.find(Name);
|
||||
if (I != ForwardRefVals.end())
|
||||
Val = I->second.first;
|
||||
}
|
||||
@ -1113,8 +1110,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
|
||||
// If this is a forward reference for the value, see if we already created a
|
||||
// forward ref record.
|
||||
if (!Val) {
|
||||
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
|
||||
I = ForwardRefValIDs.find(ID);
|
||||
auto I = ForwardRefValIDs.find(ID);
|
||||
if (I != ForwardRefValIDs.end())
|
||||
Val = I->second.first;
|
||||
}
|
||||
@ -2217,23 +2213,22 @@ LLParser::PerFunctionState::PerFunctionState(LLParser &p, Function &f,
|
||||
|
||||
LLParser::PerFunctionState::~PerFunctionState() {
|
||||
// If there were any forward referenced non-basicblock values, delete them.
|
||||
for (std::map<std::string, std::pair<Value*, LocTy> >::iterator
|
||||
I = ForwardRefVals.begin(), E = ForwardRefVals.end(); I != E; ++I)
|
||||
if (!isa<BasicBlock>(I->second.first)) {
|
||||
I->second.first->replaceAllUsesWith(
|
||||
UndefValue::get(I->second.first->getType()));
|
||||
delete I->second.first;
|
||||
I->second.first = nullptr;
|
||||
}
|
||||
|
||||
for (std::map<unsigned, std::pair<Value*, LocTy> >::iterator
|
||||
I = ForwardRefValIDs.begin(), E = ForwardRefValIDs.end(); I != E; ++I)
|
||||
if (!isa<BasicBlock>(I->second.first)) {
|
||||
I->second.first->replaceAllUsesWith(
|
||||
UndefValue::get(I->second.first->getType()));
|
||||
delete I->second.first;
|
||||
I->second.first = nullptr;
|
||||
}
|
||||
for (const auto &P : ForwardRefVals) {
|
||||
if (isa<BasicBlock>(P.second.first))
|
||||
continue;
|
||||
P.second.first->replaceAllUsesWith(
|
||||
UndefValue::get(P.second.first->getType()));
|
||||
delete P.second.first;
|
||||
}
|
||||
|
||||
for (const auto &P : ForwardRefValIDs) {
|
||||
if (isa<BasicBlock>(P.second.first))
|
||||
continue;
|
||||
P.second.first->replaceAllUsesWith(
|
||||
UndefValue::get(P.second.first->getType()));
|
||||
delete P.second.first;
|
||||
}
|
||||
}
|
||||
|
||||
bool LLParser::PerFunctionState::FinishFunction() {
|
||||
@ -2260,8 +2255,7 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name, Type *Ty,
|
||||
// If this is a forward reference for the value, see if we already created a
|
||||
// forward ref record.
|
||||
if (!Val) {
|
||||
std::map<std::string, std::pair<Value*, LocTy> >::iterator
|
||||
I = ForwardRefVals.find(Name);
|
||||
auto I = ForwardRefVals.find(Name);
|
||||
if (I != ForwardRefVals.end())
|
||||
Val = I->second.first;
|
||||
}
|
||||
@ -2334,8 +2328,7 @@ Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty, LocTy Loc,
|
||||
// If this is a forward reference for the value, see if we already created a
|
||||
// forward ref record.
|
||||
if (!Val) {
|
||||
std::map<unsigned, std::pair<Value*, LocTy> >::iterator
|
||||
I = ForwardRefValIDs.find(ID);
|
||||
auto I = ForwardRefValIDs.find(ID);
|
||||
if (I != ForwardRefValIDs.end())
|
||||
Val = I->second.first;
|
||||
}
|
||||
@ -2421,8 +2414,7 @@ bool LLParser::PerFunctionState::SetInstName(int NameID,
|
||||
return P.Error(NameLoc, "instruction expected to be numbered '%" +
|
||||
Twine(NumberedVals.size()) + "'");
|
||||
|
||||
std::map<unsigned, std::pair<Value*, LocTy> >::iterator FI =
|
||||
ForwardRefValIDs.find(NameID);
|
||||
auto FI = ForwardRefValIDs.find(NameID);
|
||||
if (FI != ForwardRefValIDs.end()) {
|
||||
Value *Sentinel = FI->second.first;
|
||||
if (Sentinel->getType() != Inst->getType())
|
||||
@ -2450,8 +2442,7 @@ bool LLParser::PerFunctionState::SetInstName(int NameID,
|
||||
}
|
||||
|
||||
// Otherwise, the instruction had a name. Resolve forward refs and set it.
|
||||
std::map<std::string, std::pair<Value*, LocTy> >::iterator
|
||||
FI = ForwardRefVals.find(NameStr);
|
||||
auto FI = ForwardRefVals.find(NameStr);
|
||||
if (FI != ForwardRefVals.end()) {
|
||||
Value *Sentinel = FI->second.first;
|
||||
if (Sentinel->getType() != Inst->getType())
|
||||
@ -4439,8 +4430,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
if (!FunctionName.empty()) {
|
||||
// If this was a definition of a forward reference, remove the definition
|
||||
// from the forward reference table and fill in the forward ref.
|
||||
std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator FRVI =
|
||||
ForwardRefVals.find(FunctionName);
|
||||
auto FRVI = ForwardRefVals.find(FunctionName);
|
||||
if (FRVI != ForwardRefVals.end()) {
|
||||
Fn = M->getFunction(FunctionName);
|
||||
if (!Fn)
|
||||
@ -4462,8 +4452,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
} else {
|
||||
// If this is a definition of a forward referenced function, make sure the
|
||||
// types agree.
|
||||
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator I
|
||||
= ForwardRefValIDs.find(NumberedVals.size());
|
||||
auto I = ForwardRefValIDs.find(NumberedVals.size());
|
||||
if (I != ForwardRefValIDs.end()) {
|
||||
Fn = cast<Function>(I->second.first);
|
||||
if (Fn->getType() != PFT)
|
||||
|
Loading…
Reference in New Issue
Block a user