From 28d735230f0b3ac964f07e91594fb6c38772f0e6 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 28 Jul 2011 02:27:12 +0000 Subject: [PATCH] Make sure that the landingpad instruction takes a Constant* as the clause's value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136326 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Instructions.h | 6 +++--- lib/AsmParser/LLParser.cpp | 7 ++++--- lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- lib/VMCore/Core.cpp | 2 +- lib/VMCore/Instructions.cpp | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 82d58162f68..f520310529b 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1852,7 +1852,7 @@ public: void setCleanup(bool Val) { IsCleanup = Val; } /// addClause - Add a clause to the landing pad. - void addClause(ClauseType CT, Value *ClauseVal); + void addClause(ClauseType CT, Constant *ClauseVal); /// getClauseType - Return the type of the clause at this index. The two /// supported clauses are Catch and Filter. @@ -1862,9 +1862,9 @@ public: } /// getClauseValue - Return the value of the clause at this index. - Value *getClauseValue(unsigned I) const { + Constant *getClauseValue(unsigned I) const { assert(I + 1 < getNumOperands() && "Index too large!"); - return OperandList[I + 1]; + return cast(OperandList[I + 1]); } /// getNumClauses - Get the number of clauses for this landing pad. diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 547abfe24e7..b3f4d476a24 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -3528,7 +3528,7 @@ bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) { bool IsCleanup = EatIfPresent(lltok::kw_cleanup); - SmallVector, 16> Clauses; + SmallVector, 16> Clauses; while (Lex.getKind() == lltok::kw_catch || Lex.getKind() == lltok::kw_filter){ LandingPadInst::ClauseType CT; if (Lex.getKind() == lltok::kw_catch) { @@ -3543,14 +3543,15 @@ bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) { Value *V; LocTy VLoc; if (ParseTypeAndValue(V, VLoc, PFS)) return true; - Clauses.push_back(std::make_pair(CT, V)); + Clauses.push_back(std::make_pair(CT, cast(V))); } while (EatIfPresent(lltok::comma)); } LandingPadInst *LP = LandingPadInst::Create(Ty, PersFn, Clauses.size()); LP->setCleanup(IsCleanup); - for (SmallVectorImpl >::iterator + for (SmallVectorImpl >::iterator I = Clauses.begin(), E = Clauses.end(); I != E; ++I) LP->addClause(I->first, I->second); diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 37cc7949afe..4b83958e784 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2550,7 +2550,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { return Error("Invalid LANDINGPAD record"); } - LP->addClause(CT, Val); + LP->addClause(CT, cast(Val)); } I = LP; diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index 6664afc1882..5e93c73a344 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -1715,7 +1715,7 @@ void LLVMAddClause(LLVMValueRef LandingPad, LLVMLandingPadClauseTy ClauseTy, LLVMValueRef ClauseVal) { unwrap(LandingPad)-> addClause(static_cast(ClauseTy), - unwrap(ClauseVal)); + cast(unwrap(ClauseVal))); } void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) { diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 9398c7f872c..968a565197c 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -228,14 +228,14 @@ void LandingPadInst::reserveClauses(unsigned Size) { Use::zap(OldOps, OldOps + e, true); } -void LandingPadInst::addClause(ClauseType CT, Value *ClauseVal) { +void LandingPadInst::addClause(ClauseType CT, Constant *ClauseVal) { unsigned OpNo = getNumOperands(); if (OpNo + 1 > ReservedSpace) growOperands(); assert(OpNo < ReservedSpace && "Growing didn't work!"); ClauseIdxs.push_back(CT); ++NumOperands; - OperandList[OpNo] = ClauseVal; + OperandList[OpNo] = (Value*)ClauseVal; } //===----------------------------------------------------------------------===//