AttributesTest.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===- 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. #include "llvm/IR/Attributes.h"
  10. #include "llvm/IR/LLVMContext.h"
  11. #include "gtest/gtest.h"
  12. using namespace llvm;
  13. namespace {
  14. TEST(Attributes, Uniquing) {
  15. LLVMContext C;
  16. Attribute AttrA = Attribute::get(C, Attribute::AlwaysInline);
  17. Attribute AttrB = Attribute::get(C, Attribute::AlwaysInline);
  18. EXPECT_EQ(AttrA, AttrB);
  19. AttributeSet ASs[] = {
  20. AttributeSet::get(C, 1, Attribute::ZExt),
  21. AttributeSet::get(C, 2, Attribute::SExt)
  22. };
  23. AttributeSet SetA = AttributeSet::get(C, ASs);
  24. AttributeSet SetB = AttributeSet::get(C, ASs);
  25. EXPECT_EQ(SetA, SetB);
  26. }
  27. TEST(Attributes, Ordering) {
  28. LLVMContext C;
  29. AttributeSet ASs[] = {
  30. AttributeSet::get(C, 2, Attribute::ZExt),
  31. AttributeSet::get(C, 1, Attribute::SExt)
  32. };
  33. AttributeSet SetA = AttributeSet::get(C, ASs);
  34. AttributeSet SetB = SetA.removeAttributes(C, 1, ASs[1]);
  35. EXPECT_NE(SetA, SetB);
  36. }
  37. } // end anonymous namespace