1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/unittests/Analysis/CallGraphTest.cpp
Chandler Carruth ae65e281f3 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00

61 lines
1.9 KiB
C++

//=======- CallGraphTest.cpp - Unit tests for the CG analysis -------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/CallGraph.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "gtest/gtest.h"
using namespace llvm;
namespace {
template <typename Ty> void canSpecializeGraphTraitsIterators(Ty *G) {
typedef typename GraphTraits<Ty *>::NodeRef NodeRef;
auto I = GraphTraits<Ty *>::nodes_begin(G);
auto E = GraphTraits<Ty *>::nodes_end(G);
auto X = ++I;
// Should be able to iterate over all nodes of the graph.
static_assert(std::is_same<decltype(*I), NodeRef>::value,
"Node type does not match");
static_assert(std::is_same<decltype(*X), NodeRef>::value,
"Node type does not match");
static_assert(std::is_same<decltype(*E), NodeRef>::value,
"Node type does not match");
NodeRef N = GraphTraits<Ty *>::getEntryNode(G);
auto S = GraphTraits<NodeRef>::child_begin(N);
auto F = GraphTraits<NodeRef>::child_end(N);
// Should be able to iterate over immediate successors of a node.
static_assert(std::is_same<decltype(*S), NodeRef>::value,
"Node type does not match");
static_assert(std::is_same<decltype(*F), NodeRef>::value,
"Node type does not match");
}
TEST(CallGraphTest, GraphTraitsSpecialization) {
LLVMContext Context;
Module M("", Context);
CallGraph CG(M);
canSpecializeGraphTraitsIterators(&CG);
}
TEST(CallGraphTest, GraphTraitsConstSpecialization) {
LLVMContext Context;
Module M("", Context);
CallGraph CG(M);
canSpecializeGraphTraitsIterators(const_cast<const CallGraph *>(&CG));
}
}