From: Chris Lattner Date: Mon, 30 Jan 2012 06:20:36 +0000 (+0000) Subject: Simplify code by using the new getAggregateElement method that got added X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89f42834092621ab6ebac24e09b17b61ac000b6b;p=clang Simplify code by using the new getAggregateElement method that got added recently. This also conveniently gets clang ready for a change about to land in mainline. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149225 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 0e19a4015a..3dd5cb9ba9 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -511,10 +511,8 @@ CodeGenFunction::EmitReferenceBindingToExpr(const Expr *E, /// input field number being accessed. unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts) { - if (isa(Elts)) - return 0; - - return cast(Elts->getOperand(Idx))->getZExtValue(); + return cast(Elts->getAggregateElement(Idx)) + ->getZExtValue(); } void CodeGenFunction::EmitCheck(llvm::Value *Address, unsigned Size) { @@ -1779,12 +1777,8 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) { llvm::Constant *BaseElts = Base.getExtVectorElts(); SmallVector CElts; - for (unsigned i = 0, e = Indices.size(); i != e; ++i) { - if (isa(BaseElts)) - CElts.push_back(llvm::ConstantInt::get(Int32Ty, 0)); - else - CElts.push_back(cast(BaseElts->getOperand(Indices[i]))); - } + for (unsigned i = 0, e = Indices.size(); i != e; ++i) + CElts.push_back(BaseElts->getAggregateElement(Indices[i])); llvm::Constant *CV = llvm::ConstantVector::get(CElts); return LValue::MakeExtVectorElt(Base.getExtVectorAddr(), CV, type); }