diff options
| author | Justin Bogner <mail@justinbogner.com> | 2015-12-09 21:21:07 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2015-12-09 21:21:07 +0000 |
| commit | b7389d6714f8f4e46a28b90aa4a103f0586a08ab (patch) | |
| tree | 27f218758cfc34dd1ba5c5969cb58f048b416d3d /llvm/unittests | |
| parent | db51357c113ac1e65d22ac5e4199f0a7857b88bf (diff) | |
| download | bcm5719-llvm-b7389d6714f8f4e46a28b90aa4a103f0586a08ab.tar.gz bcm5719-llvm-b7389d6714f8f4e46a28b90aa4a103f0586a08ab.zip | |
IR: Make ConstantDataArray::getFP actually return a ConstantDataArray
The ConstantDataArray::getFP(LLVMContext &, ArrayRef<uint16_t>)
overload has had a typo in it since it was written, where it will
create a Vector instead of an Array. This obviously doesn't work at
all, but it turns out that until r254991 there weren't actually any
callers of this overload. Fix the typo and add some test coverage.
llvm-svn: 255157
Diffstat (limited to 'llvm/unittests')
| -rw-r--r-- | llvm/unittests/IR/ConstantsTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp index 8c33453d293..0bf98f35b3c 100644 --- a/llvm/unittests/IR/ConstantsTest.cpp +++ b/llvm/unittests/IR/ConstantsTest.cpp @@ -389,6 +389,29 @@ static std::string getNameOfType(Type *T) { return S; } +TEST(ConstantsTest, BuildConstantDataArrays) { + LLVMContext Context; + std::unique_ptr<Module> M(new Module("MyModule", Context)); + + for (Type *T : {Type::getInt8Ty(Context), Type::getInt16Ty(Context), + Type::getInt32Ty(Context), Type::getInt64Ty(Context)}) { + ArrayType *ArrayTy = ArrayType::get(T, 2); + Constant *Vals[] = {ConstantInt::get(T, 0), ConstantInt::get(T, 1)}; + Constant *CDV = ConstantArray::get(ArrayTy, Vals); + ASSERT_TRUE(dyn_cast<ConstantDataArray>(CDV) != nullptr) + << " T = " << getNameOfType(T); + } + + for (Type *T : {Type::getHalfTy(Context), Type::getFloatTy(Context), + Type::getDoubleTy(Context)}) { + ArrayType *ArrayTy = ArrayType::get(T, 2); + Constant *Vals[] = {ConstantFP::get(T, 0), ConstantFP::get(T, 1)}; + Constant *CDV = ConstantArray::get(ArrayTy, Vals); + ASSERT_TRUE(dyn_cast<ConstantDataArray>(CDV) != nullptr) + << " T = " << getNameOfType(T); + } +} + TEST(ConstantsTest, BuildConstantDataVectors) { LLVMContext Context; std::unique_ptr<Module> M(new Module("MyModule", Context)); |

