brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 9220b60 Raw
48 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8/// \file9/// This file defines an AttributorTestBase class, which provides helpers to10/// parse a LLVM IR string and create Attributor11//===----------------------------------------------------------------------===//12#ifndef LLVM_UNITTESTS_TRANSFORMS_ATTRIBUTOR_TESTBASE_H13#define LLVM_UNITTESTS_TRANSFORMS_ATTRIBUTOR_TESTBASE_H14 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 28namespace llvm {29 30/// Helper class to create a module from assembly string and an Attributor31class AttributorTestBase : public testing::Test {32protected:33  std::unique_ptr<LLVMContext> Ctx;34  std::unique_ptr<Module> M;35 36  AttributorTestBase() : Ctx(new LLVMContext) {}37 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 llvm47 48#endif