mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-07 02:01:43 +00:00

Summary: This class is a list of AttributeSetNodes corresponding the function prototype of a call or function declaration. This class used to be called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is typically accessed by parameter and return value index, so "AttributeList" seems like a more intuitive name. Rename AttributeSetImpl to AttributeListImpl to follow suit. It's useful to rename this class so that we can rename AttributeSetNode to AttributeSet later. AttributeSet is the set of attributes that apply to a single function, argument, or return value. Reviewers: sanjoy, javed.absar, chandlerc, pete Reviewed By: pete Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits Differential Revision: https://reviews.llvm.org/D31102 llvm-svn: 298393
53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
//===- llvm/unittest/IR/AttributesTest.cpp - Attributes unit tests --------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/IR/Attributes.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "gtest/gtest.h"
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
TEST(Attributes, Uniquing) {
|
|
LLVMContext C;
|
|
|
|
Attribute AttrA = Attribute::get(C, Attribute::AlwaysInline);
|
|
Attribute AttrB = Attribute::get(C, Attribute::AlwaysInline);
|
|
EXPECT_EQ(AttrA, AttrB);
|
|
|
|
AttributeList ASs[] = {AttributeList::get(C, 1, Attribute::ZExt),
|
|
AttributeList::get(C, 2, Attribute::SExt)};
|
|
|
|
AttributeList SetA = AttributeList::get(C, ASs);
|
|
AttributeList SetB = AttributeList::get(C, ASs);
|
|
EXPECT_EQ(SetA, SetB);
|
|
}
|
|
|
|
TEST(Attributes, Ordering) {
|
|
LLVMContext C;
|
|
|
|
Attribute Align4 = Attribute::get(C, Attribute::Alignment, 4);
|
|
Attribute Align5 = Attribute::get(C, Attribute::Alignment, 5);
|
|
Attribute Deref4 = Attribute::get(C, Attribute::Dereferenceable, 4);
|
|
Attribute Deref5 = Attribute::get(C, Attribute::Dereferenceable, 5);
|
|
EXPECT_TRUE(Align4 < Align5);
|
|
EXPECT_TRUE(Align4 < Deref4);
|
|
EXPECT_TRUE(Align4 < Deref5);
|
|
EXPECT_TRUE(Align5 < Deref4);
|
|
|
|
AttributeList ASs[] = {AttributeList::get(C, 2, Attribute::ZExt),
|
|
AttributeList::get(C, 1, Attribute::SExt)};
|
|
|
|
AttributeList SetA = AttributeList::get(C, ASs);
|
|
AttributeList SetB = SetA.removeAttributes(C, 1, ASs[1]);
|
|
EXPECT_NE(SetA, SetB);
|
|
}
|
|
|
|
} // end anonymous namespace
|