1 //===- llvm/unittest/Transforms/IPO/AttributorTestBase.h -----------------===//
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 //===----------------------------------------------------------------------===//
8 /// \file
9 /// This file defines an AttributorTestBase class, which provides helpers to
10 /// parse a LLVM IR string and create Attributor
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_UNITTESTS_TRANSFORMS_ATTRIBUTOR_TESTBASE_H
13 #define LLVM_UNITTESTS_TRANSFORMS_ATTRIBUTOR_TESTBASE_H
14 
15 #include "llvm/Analysis/CGSCCPassManager.h"
16 #include "llvm/Analysis/CallGraphSCCPass.h"
17 #include "llvm/AsmParser/Parser.h"
18 #include "llvm/IR/Module.h"
19 #include "llvm/IR/PassManager.h"
20 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/SourceMgr.h"
22 #include "llvm/Testing/Support/Error.h"
23 #include "llvm/Transforms/IPO/Attributor.h"
24 #include "llvm/Transforms/Utils/CallGraphUpdater.h"
25 #include "gtest/gtest.h"
26 #include <memory>
27 
28 namespace llvm {
29 
30 /// Helper class to create a module from assembly string and an Attributor
31 class AttributorTestBase : public testing::Test {
32 protected:
33   std::unique_ptr<LLVMContext> Ctx;
34   std::unique_ptr<Module> M;
35 
AttributorTestBase()36   AttributorTestBase() : Ctx(new LLVMContext) {}
37 
parseModule(const char * ModuleString)38   Module &parseModule(const char *ModuleString) {
39     SMDiagnostic Err;
40     M = parseAssemblyString(ModuleString, Err, *Ctx);
41     EXPECT_TRUE(M);
42     return *M;
43   }
44 };
45 
46 } // namespace llvm
47 
48 #endif