llvm.org GIT mirror llvm / 8591fa3
Add a unit test to verifies that attribute uniquing works so it doesn't break again. The folding set details can be subtle and broke twice in the last couple of weeks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172313 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 6 years ago
2 changed file(s) with 35 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //===- llvm/unittest/IR/AttributesTest.cpp - Attributes unit tests --------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/IR/Attributes.h"
10 #include "llvm/IR/LLVMContext.h"
11 #include "gtest/gtest.h"
12 using namespace llvm;
13
14 namespace {
15
16 TEST(Attributes, Uniquing) {
17 LLVMContext C;
18
19 Attribute AttrA = Attribute::get(C, Attribute::AlwaysInline);
20 Attribute AttrB = Attribute::get(C, Attribute::AlwaysInline);
21 EXPECT_EQ(AttrA, AttrB);
22
23 AttributeWithIndex AWIs[] = {
24 AttributeWithIndex::get(C, 1, Attribute::ZExt),
25 AttributeWithIndex::get(C, 2, Attribute::SExt)
26 };
27
28 AttributeSet SetA = AttributeSet::get(C, AWIs);
29 AttributeSet SetB = AttributeSet::get(C, AWIs);
30 EXPECT_EQ(SetA, SetB);
31 }
32
33 } // end anonymous namespace
44 )
55
66 set(IRSources
7 AttributesTest.cpp
78 ConstantsTest.cpp
89 DominatorTreeTest.cpp
910 IRBuilderTest.cpp