diff options
Diffstat (limited to 'llvm/unittests/IR')
-rw-r--r-- | llvm/unittests/IR/AttributesTest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/IR/AttributesTest.cpp b/llvm/unittests/IR/AttributesTest.cpp index e0be2343a14..06da35aca57 100644 --- a/llvm/unittests/IR/AttributesTest.cpp +++ b/llvm/unittests/IR/AttributesTest.cpp @@ -8,6 +8,7 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/DerivedTypes.h" #include "gtest/gtest.h" using namespace llvm; @@ -40,6 +41,10 @@ TEST(Attributes, Ordering) { EXPECT_TRUE(Align4 < Deref5); EXPECT_TRUE(Align5 < Deref4); + Attribute ByVal = Attribute::get(C, Attribute::ByVal, Type::getInt32Ty(C)); + EXPECT_FALSE(ByVal < Attribute::get(C, Attribute::ZExt)); + EXPECT_TRUE(ByVal < Align4); + AttributeList ASs[] = {AttributeList::get(C, 2, Attribute::ZExt), AttributeList::get(C, 1, Attribute::SExt)}; @@ -166,4 +171,19 @@ TEST(Attributes, OverflowGet) { EXPECT_EQ(2U, AL.getNumAttrSets()); } +TEST(Attributes, StringRepresentation) { + LLVMContext C; + StructType *Ty = StructType::create(Type::getInt32Ty(C), "mystruct"); + + // Insufficiently careful printing can result in byval(%mystruct = { i32 }) + Attribute A = Attribute::getWithByValType(C, Ty); + EXPECT_EQ(A.getAsString(), "byval(%mystruct)"); + + A = Attribute::getWithByValType(C, nullptr); + EXPECT_EQ(A.getAsString(), "byval"); + + A = Attribute::getWithByValType(C, Type::getInt32Ty(C)); + EXPECT_EQ(A.getAsString(), "byval(i32)"); +} + } // end anonymous namespace |