[yaml2obj/obj2yaml] - Add support for .stack_sizes sections.
[llvm-complete.git] / unittests / Support / TypeNameTest.cpp
blobc8962933e9cee66a69de5536d0a40934a0a3537b
1 //===- TypeNameTest.cpp ---------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/TypeName.h"
10 #include "llvm/Support/raw_ostream.h"
11 #include "gtest/gtest.h"
13 using namespace llvm;
15 namespace {
16 namespace N1 {
17 struct S1 {};
18 class C1 {};
19 union U1 {};
22 TEST(TypeNameTest, Names) {
23 struct S2 {};
25 StringRef S1Name = getTypeName<N1::S1>();
26 StringRef C1Name = getTypeName<N1::C1>();
27 StringRef U1Name = getTypeName<N1::U1>();
28 StringRef S2Name = getTypeName<S2>();
30 #if defined(__clang__) || defined(__GNUC__) || defined(__INTEL_COMPILER) || \
31 defined(_MSC_VER)
32 EXPECT_TRUE(S1Name.endswith("::N1::S1")) << S1Name.str();
33 EXPECT_TRUE(C1Name.endswith("::N1::C1")) << C1Name.str();
34 EXPECT_TRUE(U1Name.endswith("::N1::U1")) << U1Name.str();
35 #ifdef __clang__
36 EXPECT_TRUE(S2Name.endswith("S2")) << S2Name.str();
37 #else
38 EXPECT_TRUE(S2Name.endswith("::S2")) << S2Name.str();
39 #endif
40 #else
41 EXPECT_EQ("UNKNOWN_TYPE", S1Name);
42 EXPECT_EQ("UNKNOWN_TYPE", C1Name);
43 EXPECT_EQ("UNKNOWN_TYPE", U1Name);
44 EXPECT_EQ("UNKNOWN_TYPE", S2Name);
45 #endif
48 } // end anonymous namespace