Attributor: Do not treat pointer vectors as valid for unsupported attributes (#121149)
[llvm-project.git] / llvm / unittests / ExecutionEngine / Orc / MemoryFlagsTest.cpp
blob270ea2f442b9eed65384dc82943eb404e563a82f
1 //===------- MemoryFlagsTest.cpp - Test MemoryFlags and related APIs ------===//
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/ExecutionEngine/Orc/Shared/MemoryFlags.h"
10 #include "gtest/gtest.h"
12 #include <future>
14 using namespace llvm;
15 using namespace llvm::orc;
17 TEST(MemProtTest, Basics) {
18 MemProt MPNone = MemProt::None;
20 EXPECT_EQ(MPNone & MemProt::Read, MemProt::None);
21 EXPECT_EQ(MPNone & MemProt::Write, MemProt::None);
22 EXPECT_EQ(MPNone & MemProt::Exec, MemProt::None);
24 EXPECT_EQ(MPNone | MemProt::Read, MemProt::Read);
25 EXPECT_EQ(MPNone | MemProt::Write, MemProt::Write);
26 EXPECT_EQ(MPNone | MemProt::Exec, MemProt::Exec);
28 MemProt MPAll = MemProt::Read | MemProt::Write | MemProt::Exec;
29 EXPECT_EQ(MPAll & MemProt::Read, MemProt::Read);
30 EXPECT_EQ(MPAll & MemProt::Write, MemProt::Write);
31 EXPECT_EQ(MPAll & MemProt::Exec, MemProt::Exec);
34 TEST(AllocGroupSmallMap, EmptyMap) {
35 AllocGroupSmallMap<bool> EM;
36 EXPECT_TRUE(EM.empty());
37 EXPECT_EQ(EM.size(), 0u);
40 TEST(AllocGroupSmallMap, NonEmptyMap) {
41 AllocGroupSmallMap<unsigned> NEM;
42 NEM[MemProt::Read] = 42;
44 EXPECT_FALSE(NEM.empty());
45 EXPECT_EQ(NEM.size(), 1U);
46 EXPECT_EQ(NEM[MemProt::Read], 42U);
47 EXPECT_EQ(NEM.find(MemProt::Read), NEM.begin());
48 EXPECT_EQ(NEM.find(MemProt::Read | MemProt::Write), NEM.end());
50 NEM[MemProt::Read | MemProt::Write] = 7;
51 EXPECT_EQ(NEM.size(), 2U);
52 EXPECT_EQ(NEM.begin()->second, 42U);
53 EXPECT_EQ((NEM.begin() + 1)->second, 7U);