#include "llvm/Testing/Support/Error.h"
#include <functional>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <llvm/ADT/Any.h>
#include <llvm/Analysis/CGSCCPassManager.h>
#include <llvm/Analysis/LoopAnalysisManager.h>
#include <llvm/AsmParser/Parser.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/PassInstrumentation.h>
#include <llvm/IR/PassManager.h>
#include <llvm/Passes/PassBuilder.h>
#include <llvm/Support/Regex.h>
#include <llvm/Support/SourceMgr.h>
#include <llvm/Transforms/Scalar/LoopPassManager.h>
usingnamespacellvm;
namespace {
AnyNumber;
DoAll;
Not;
Return;
WithArgs;
_;
template <typename DerivedT, typename IRUnitT,
typename AnalysisManagerT = AnalysisManager<IRUnitT>,
typename... ExtraArgTs>
class MockAnalysisHandleBase { … };
template <typename DerivedT, typename IRUnitT, typename AnalysisManagerT,
typename... ExtraArgTs>
AnalysisKey MockAnalysisHandleBase<DerivedT, IRUnitT, AnalysisManagerT,
ExtraArgTs...>::Analysis::Key;
template <typename DerivedT, typename IRUnitT,
typename AnalysisManagerT = AnalysisManager<IRUnitT>,
typename... ExtraArgTs>
class MockPassHandleBase { … };
template <typename IRUnitT> struct MockPassHandle;
template <>
struct MockPassHandle<Loop>
: MockPassHandleBase<MockPassHandle<Loop>, Loop, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &> { … };
template <>
struct MockPassHandle<LoopNest>
: MockPassHandleBase<MockPassHandle<LoopNest>, LoopNest,
LoopAnalysisManager, LoopStandardAnalysisResults &,
LPMUpdater &> { … };
template <>
struct MockPassHandle<Function>
: MockPassHandleBase<MockPassHandle<Function>, Function> { … };
template <>
struct MockPassHandle<LazyCallGraph::SCC>
: MockPassHandleBase<MockPassHandle<LazyCallGraph::SCC>, LazyCallGraph::SCC,
CGSCCAnalysisManager, LazyCallGraph &,
CGSCCUpdateResult &> { … };
template <>
struct MockPassHandle<Module>
: MockPassHandleBase<MockPassHandle<Module>, Module> { … };
template <typename IRUnitT> struct MockAnalysisHandle;
template <>
struct MockAnalysisHandle<Loop>
: MockAnalysisHandleBase<MockAnalysisHandle<Loop>, Loop,
LoopAnalysisManager,
LoopStandardAnalysisResults &> { … };
template <>
struct MockAnalysisHandle<Function>
: MockAnalysisHandleBase<MockAnalysisHandle<Function>, Function> { … };
template <>
struct MockAnalysisHandle<LazyCallGraph::SCC>
: MockAnalysisHandleBase<MockAnalysisHandle<LazyCallGraph::SCC>,
LazyCallGraph::SCC, CGSCCAnalysisManager,
LazyCallGraph &> { … };
template <>
struct MockAnalysisHandle<Module>
: MockAnalysisHandleBase<MockAnalysisHandle<Module>, Module> { … };
static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) { … }
template <typename IRUnitT> std::string getName(const IRUnitT &IR) { … }
template <> std::string getName(const StringRef &name) { … }
template <> std::string getName(const Any &WrappedIR) { … }
MATCHER_P(HasName, Name, "") { … }
MATCHER_P(HasNameRegex, Name, "") { … }
struct MockPassInstrumentationCallbacks { … };
ExtraMockPassHandle;
template <typename PassManagerT> class PassBuilderCallbacksTest;
PassBuilderCallbacksTest<PassManager<TestIRUnitT, AnalysisManager<TestIRUnitT, ExtraAnalysisArgTs...>, ExtraPassArgTs...>>;
ModuleCallbacksTest;
CGSCCCallbacksTest;
FunctionCallbacksTest;
LoopCallbacksTest;
TEST_F(ModuleCallbacksTest, Passes) { … }
TEST_F(ModuleCallbacksTest, InstrumentedPasses) { … }
TEST_F(ModuleCallbacksTest, InstrumentedSkippedPasses) { … }
TEST_F(FunctionCallbacksTest, Passes) { … }
TEST_F(FunctionCallbacksTest, InstrumentedPasses) { … }
TEST_F(FunctionCallbacksTest, InstrumentedSkippedPasses) { … }
TEST_F(LoopCallbacksTest, Passes) { … }
TEST_F(LoopCallbacksTest, InstrumentedPasses) { … }
TEST_F(LoopCallbacksTest, InstrumentedInvalidatingPasses) { … }
TEST_F(LoopCallbacksTest, InstrumentedInvalidatingLoopNestPasses) { … }
TEST_F(LoopCallbacksTest, InstrumentedSkippedPasses) { … }
TEST_F(CGSCCCallbacksTest, Passes) { … }
TEST_F(CGSCCCallbacksTest, InstrumentedPasses) { … }
TEST_F(CGSCCCallbacksTest, InstrumentedInvalidatingPasses) { … }
TEST_F(CGSCCCallbacksTest, InstrumentedSkippedPasses) { … }
TEST_F(ModuleCallbacksTest, AnalysisUtilities) { … }
TEST_F(CGSCCCallbacksTest, PassUtilities) { … }
TEST_F(FunctionCallbacksTest, AnalysisUtilities) { … }
TEST_F(LoopCallbacksTest, PassUtilities) { … }
TEST_F(ModuleCallbacksTest, ParseTopLevelPipeline) { … }
}