aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Linker
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-25 06:48:06 +0000
committerChris Lattner <sabre@nondot.org>2012-01-25 06:48:06 +0000
commita1f00f4d488eb5daff52faaf99c62ee652fd3b85 (patch)
tree0eae19e36e8626cb494b38c88596988b44299120 /lib/Linker
parent969ba287cd2be9b2d6843db6fa5337585f84283b (diff)
downloadexternal_llvm-a1f00f4d488eb5daff52faaf99c62ee652fd3b85.zip
external_llvm-a1f00f4d488eb5daff52faaf99c62ee652fd3b85.tar.gz
external_llvm-a1f00f4d488eb5daff52faaf99c62ee652fd3b85.tar.bz2
use Constant::getAggregateElement to simplify a bunch of code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 563aed5..60fa9a7 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -844,21 +844,10 @@ bool ModuleLinker::linkAliasProto(GlobalAlias *SGA) {
}
static void getArrayElements(Constant *C, SmallVectorImpl<Constant*> &Dest) {
- if (ConstantArray *I = dyn_cast<ConstantArray>(C)) {
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- Dest.push_back(I->getOperand(i));
- return;
- }
-
- if (ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(C)) {
- for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
- Dest.push_back(CDS->getElementAsConstant(i));
- return;
- }
-
- ConstantAggregateZero *CAZ = cast<ConstantAggregateZero>(C);
- Dest.append(cast<ArrayType>(C->getType())->getNumElements(),
- CAZ->getSequentialElement());
+ unsigned NumElements = cast<ArrayType>(C->getType())->getNumElements();
+
+ for (unsigned i = 0; i != NumElements; ++i)
+ Dest.push_back(C->getAggregateElement(i));
}
void ModuleLinker::linkAppendingVarInit(const AppendingVarInfo &AVI) {