1 //===- MCDisassemblerTest.cpp - Tests for MCDisassembler.cpp --------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/MC/MCDisassembler/MCDisassembler.h"
10 #include "gtest/gtest.h"
14 TEST(MCDisassembler
, XCOFFSymbolPriorityTest
) {
16 SymbolInfoTy
SIT1(0x100000, "sym1", None
, 1, false);
17 SymbolInfoTy
SIT2(0x110000, "sym2", None
, 2, false);
18 SymbolInfoTy
SIT3(0x120000, ".func", XCOFF::XMC_PR
, 3, true);
19 SymbolInfoTy
SIT4(0x120000, ".text", XCOFF::XMC_PR
, 4, false);
20 SymbolInfoTy
SIT5(0x130000, "TOC", XCOFF::XMC_TC0
, 5, false);
21 SymbolInfoTy
SIT6(0x130000, "func", XCOFF::XMC_TC
, 6, false);
23 // Test that higher addresses would appear later than lower ones when symbols
24 // are sorted in ascending order.
25 EXPECT_TRUE(SIT1
< SIT2
);
26 EXPECT_FALSE(SIT2
< SIT1
);
28 // Test that symbols with a StorageMappingClass have higher priority than those
30 EXPECT_TRUE(SIT2
< SIT5
);
31 EXPECT_FALSE(SIT5
< SIT2
);
33 // Test that symbols with a TC0 StorageMappingClass have lower priority than those
34 // with some other StorageMappingClass.
35 EXPECT_TRUE(SIT5
< SIT6
);
36 EXPECT_FALSE(SIT6
< SIT5
);
38 // Test label symbols have higher priorty than non-label symbols.
39 EXPECT_TRUE(SIT4
< SIT3
);
40 EXPECT_FALSE(SIT3
< SIT4
);
42 // Test symbols comparing with themselves.
43 EXPECT_FALSE(SIT1
< SIT1
);
44 EXPECT_FALSE(SIT2
< SIT2
);
45 EXPECT_FALSE(SIT3
< SIT3
);
46 EXPECT_FALSE(SIT4
< SIT4
);
47 EXPECT_FALSE(SIT5
< SIT5
);
48 EXPECT_FALSE(SIT6
< SIT6
);