aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-02 17:04:01 +0000
committerOwen Anderson <resistor@mac.com>2009-07-02 17:04:01 +0000
commit04cbeecefa39842809cf704d380b71386120039e (patch)
tree6e650bb3bc6028c01b09812624d18652bea10ca2 /lib
parente785adea6a677d6d98fa87763e1db138b7537f12 (diff)
downloadexternal_llvm-04cbeecefa39842809cf704d380b71386120039e.zip
external_llvm-04cbeecefa39842809cf704d380b71386120039e.tar.gz
external_llvm-04cbeecefa39842809cf704d380b71386120039e.tar.bz2
Use LLVMContext for generating UndefValue constants too!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AsmParser/LLParser.cpp14
-rw-r--r--lib/AsmParser/LLParser.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index a266fa7..6d61f54 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -1374,8 +1374,8 @@ LLParser::PerFunctionState::~PerFunctionState() {
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()));
+ I->second.first->replaceAllUsesWith(
+ P.getContext().getUndef(I->second.first->getType()));
delete I->second.first;
I->second.first = 0;
}
@@ -1383,8 +1383,8 @@ LLParser::PerFunctionState::~PerFunctionState() {
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()));
+ I->second.first->replaceAllUsesWith(
+ P.getContext().getUndef(I->second.first->getType()));
delete I->second.first;
I->second.first = 0;
}
@@ -2074,12 +2074,12 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID,
if ((!Ty->isFirstClassType() || Ty == Type::LabelTy) &&
!isa<OpaqueType>(Ty))
return Error(ID.Loc, "invalid type for undef constant");
- V = UndefValue::get(Ty);
+ V = Context.getUndef(Ty);
return false;
case ValID::t_EmptyArray:
if (!isa<ArrayType>(Ty) || cast<ArrayType>(Ty)->getNumElements() != 0)
return Error(ID.Loc, "invalid empty array initializer");
- V = UndefValue::get(Ty);
+ V = Context.getUndef(Ty);
return false;
case ValID::t_Zero:
// FIXME: LabelTy should not be a first-class type.
@@ -2604,7 +2604,7 @@ bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
RVs.push_back(RV);
}
- RV = UndefValue::get(PFS.getFunction().getReturnType());
+ RV = Context.getUndef(PFS.getFunction().getReturnType());
for (unsigned i = 0, e = RVs.size(); i != e; ++i) {
Instruction *I = InsertValueInst::Create(RV, RVs[i], i, "mrv");
BB->getInstList().push_back(I);
diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h
index ae1d9c7..6691f60 100644
--- a/lib/AsmParser/LLParser.h
+++ b/lib/AsmParser/LLParser.h
@@ -77,6 +77,8 @@ namespace llvm {
Context(m->getContext()), Lex(F, Err), M(m) {}
bool Run();
+ LLVMContext& getContext() { return Context; }
+
private:
bool Error(LocTy L, const std::string &Msg) const {