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
) {
15 SymbolInfoTy
SIT1(std::nullopt
, 0x100000, "sym1", 1, false);
16 SymbolInfoTy
SIT2(std::nullopt
, 0x110000, "sym2", 2, false);
17 SymbolInfoTy
SIT3(XCOFF::XMC_PR
, 0x120000, ".func", 3, true);
18 SymbolInfoTy
SIT4(XCOFF::XMC_PR
, 0x120000, ".text", 4, false);
19 SymbolInfoTy
SIT5(XCOFF::XMC_TC0
, 0x130000, "TOC", 5, false);
20 SymbolInfoTy
SIT6(XCOFF::XMC_TC
, 0x130000, "func", 6, false);
22 // Test that higher addresses would appear later than lower ones when symbols
23 // are sorted in ascending order.
24 EXPECT_TRUE(SIT1
< SIT2
);
25 EXPECT_FALSE(SIT2
< SIT1
);
27 // Test that symbols with a StorageMappingClass have higher priority than those
29 EXPECT_TRUE(SIT2
< SIT5
);
30 EXPECT_FALSE(SIT5
< SIT2
);
32 // Test that symbols with a TC0 StorageMappingClass have lower priority than those
33 // with some other StorageMappingClass.
34 EXPECT_TRUE(SIT5
< SIT6
);
35 EXPECT_FALSE(SIT6
< SIT5
);
37 // Test label symbols have higher priorty than non-label symbols.
38 EXPECT_TRUE(SIT4
< SIT3
);
39 EXPECT_FALSE(SIT3
< SIT4
);
41 // Test symbols comparing with themselves.
42 EXPECT_FALSE(SIT1
< SIT1
);
43 EXPECT_FALSE(SIT2
< SIT2
);
44 EXPECT_FALSE(SIT3
< SIT3
);
45 EXPECT_FALSE(SIT4
< SIT4
);
46 EXPECT_FALSE(SIT5
< SIT5
);
47 EXPECT_FALSE(SIT6
< SIT6
);