summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-12-09 05:50:11 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-12-09 05:50:11 +0000
commit8d3e580cc758a5b9ac0dc7d88a481a8fd98624fe (patch)
tree48a58ff715b85a4a78d15689182ef454b55889fe /llvm/lib/AsmParser/LLParser.cpp
parente9efecaa5232becbb7e55484443b78637d58d54a (diff)
downloadbcm5719-llvm-8d3e580cc758a5b9ac0dc7d88a481a8fd98624fe.tar.gz
bcm5719-llvm-8d3e580cc758a5b9ac0dc7d88a481a8fd98624fe.zip
Revert "AsmParser: Reject invalid mismatch between forward ref and def"
This reverts commit r223754. I've upset the buildbots. llvm-svn: 223755
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index df4a16abe1c..e1c00cc4af0 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -787,36 +787,33 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
if (Ty->isFunctionTy() || Ty->isLabelTy())
return Error(TyLoc, "invalid type for global variable");
- GlobalValue *GVal = nullptr;
+ GlobalVariable *GV = nullptr;
// See if the global was forward referenced, if so, use the global.
if (!Name.empty()) {
- GVal = M->getNamedValue(Name);
- if (GVal) {
+ if (GlobalValue *GVal = M->getNamedValue(Name)) {
if (!ForwardRefVals.erase(Name) || !isa<GlobalValue>(GVal))
return Error(NameLoc, "redefinition of global '@" + Name + "'");
+ GV = cast<GlobalVariable>(GVal);
}
} else {
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
I = ForwardRefValIDs.find(NumberedVals.size());
if (I != ForwardRefValIDs.end()) {
- GVal = I->second.first;
+ GV = cast<GlobalVariable>(I->second.first);
ForwardRefValIDs.erase(I);
}
}
- GlobalVariable *GV;
if (!GV) {
GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, nullptr,
Name, nullptr, GlobalVariable::NotThreadLocal,
AddrSpace);
} else {
- if (GVal->getType()->getElementType() != Ty)
+ if (GV->getType()->getElementType() != Ty)
return Error(TyLoc,
"forward reference and definition of global have different types");
- GV = cast<GlobalVariable>(GVal);
-
// Move the forward-reference to the correct spot in the module.
M->getGlobalList().splice(M->global_end(), M->getGlobalList(), GV);
}
OpenPOWER on IntegriCloud