summaryrefslogtreecommitdiff
path: root/unittests/VMCore/DerivedTypesTest.cpp
blob: 2e0450d6e5cec4fc29d52765f58facae9a9f3c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//===- llvm/unittest/VMCore/DerivedTypesTest.cpp - Types unit tests -------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "../lib/VMCore/LLVMContextImpl.h"
#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
#include "llvm/LLVMContext.h"
using namespace llvm;

namespace {

TEST(OpaqueTypeTest, RegisterWithContext) {
  LLVMContext C;
  LLVMContextImpl *pImpl = C.pImpl;

  // 1 refers to the AlwaysOpaqueTy allocated in the Context's constructor and
  // destroyed in the destructor.
  EXPECT_EQ(1u, pImpl->OpaqueTypes.size());
  {
    PATypeHolder Type = OpaqueType::get(C);
    EXPECT_EQ(2u, pImpl->OpaqueTypes.size());
  }
  EXPECT_EQ(1u, pImpl->OpaqueTypes.size());
}

}  // namespace