blob: ebcb772bc373963f67ba3ce334fd5327dec2df64 [file] [log] [blame]
Benjamin Kramer8591fa32013-01-12 14:13:45 +00001//===- llvm/unittest/IR/AttributesTest.cpp - Attributes unit tests --------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/IR/Attributes.h"
11#include "llvm/IR/LLVMContext.h"
12#include "gtest/gtest.h"
13using namespace llvm;
14
15namespace {
16
17TEST(Attributes, Uniquing) {
18 LLVMContext C;
19
20 Attribute AttrA = Attribute::get(C, Attribute::AlwaysInline);
21 Attribute AttrB = Attribute::get(C, Attribute::AlwaysInline);
22 EXPECT_EQ(AttrA, AttrB);
23
Bill Wendlingc83f6212013-01-27 03:39:10 +000024 AttributeSet ASs[] = {
25 AttributeSet::get(C, 1, Attribute::ZExt),
26 AttributeSet::get(C, 2, Attribute::SExt)
Benjamin Kramer8591fa32013-01-12 14:13:45 +000027 };
28
Bill Wendlingc83f6212013-01-27 03:39:10 +000029 AttributeSet SetA = AttributeSet::get(C, ASs);
30 AttributeSet SetB = AttributeSet::get(C, ASs);
Benjamin Kramer8591fa32013-01-12 14:13:45 +000031 EXPECT_EQ(SetA, SetB);
32}
33
Peter Collingbourne7bba9c52013-08-02 22:29:40 +000034TEST(Attributes, Ordering) {
35 LLVMContext C;
36
37 AttributeSet ASs[] = {
38 AttributeSet::get(C, 2, Attribute::ZExt),
39 AttributeSet::get(C, 1, Attribute::SExt)
40 };
41
42 AttributeSet SetA = AttributeSet::get(C, ASs);
43 AttributeSet SetB = SetA.removeAttributes(C, 1, ASs[1]);
44 EXPECT_NE(SetA, SetB);
45}
46
Benjamin Kramer8591fa32013-01-12 14:13:45 +000047} // end anonymous namespace