summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/unittests')
-rw-r--r--contrib/llvm/unittests/ADT/APFloatTest.cpp579
-rw-r--r--contrib/llvm/unittests/ADT/APIntTest.cpp346
-rw-r--r--contrib/llvm/unittests/ADT/BitVectorTest.cpp194
-rw-r--r--contrib/llvm/unittests/ADT/DeltaAlgorithmTest.cpp100
-rw-r--r--contrib/llvm/unittests/ADT/DenseMapTest.cpp179
-rw-r--r--contrib/llvm/unittests/ADT/DenseSetTest.cpp30
-rw-r--r--contrib/llvm/unittests/ADT/ImmutableSetTest.cpp201
-rw-r--r--contrib/llvm/unittests/ADT/Makefile23
-rw-r--r--contrib/llvm/unittests/ADT/SmallBitVectorTest.cpp189
-rw-r--r--contrib/llvm/unittests/ADT/SmallStringTest.cpp48
-rw-r--r--contrib/llvm/unittests/ADT/SmallVectorTest.cpp408
-rw-r--r--contrib/llvm/unittests/ADT/SparseBitVectorTest.cpp36
-rw-r--r--contrib/llvm/unittests/ADT/StringMapTest.cpp207
-rw-r--r--contrib/llvm/unittests/ADT/StringRefTest.cpp273
-rw-r--r--contrib/llvm/unittests/ADT/TripleTest.cpp149
-rw-r--r--contrib/llvm/unittests/ADT/TwineTest.cpp75
-rw-r--r--contrib/llvm/unittests/ADT/ValueMapTest.cpp294
-rw-r--r--contrib/llvm/unittests/ADT/ilistTest.cpp44
-rw-r--r--contrib/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp129
-rw-r--r--contrib/llvm/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp238
-rw-r--r--contrib/llvm/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp279
-rw-r--r--contrib/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp806
-rw-r--r--contrib/llvm/unittests/ExecutionEngine/JIT/Makefile18
-rw-r--r--contrib/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp164
-rw-r--r--contrib/llvm/unittests/ExecutionEngine/Makefile18
-rw-r--r--contrib/llvm/unittests/Makefile17
-rw-r--r--contrib/llvm/unittests/Makefile.unittest54
-rw-r--r--contrib/llvm/unittests/Support/AllocatorTest.cpp143
-rw-r--r--contrib/llvm/unittests/Support/CommandLineTest.cpp60
-rw-r--r--contrib/llvm/unittests/Support/ConstantRangeTest.cpp351
-rw-r--r--contrib/llvm/unittests/Support/LeakDetectorTest.cpp31
-rw-r--r--contrib/llvm/unittests/Support/Makefile15
-rw-r--r--contrib/llvm/unittests/Support/MathExtrasTest.cpp104
-rw-r--r--contrib/llvm/unittests/Support/RegexTest.cpp94
-rw-r--r--contrib/llvm/unittests/Support/System.cpp16
-rw-r--r--contrib/llvm/unittests/Support/TypeBuilderTest.cpp253
-rw-r--r--contrib/llvm/unittests/Support/ValueHandleTest.cpp412
-rw-r--r--contrib/llvm/unittests/Support/raw_ostream_test.cpp146
-rw-r--r--contrib/llvm/unittests/Transforms/Makefile17
-rw-r--r--contrib/llvm/unittests/Transforms/Utils/Cloning.cpp141
-rw-r--r--contrib/llvm/unittests/Transforms/Utils/Makefile15
-rw-r--r--contrib/llvm/unittests/VMCore/ConstantsTest.cpp113
-rw-r--r--contrib/llvm/unittests/VMCore/DerivedTypesTest.cpp33
-rw-r--r--contrib/llvm/unittests/VMCore/InstructionsTest.cpp128
-rw-r--r--contrib/llvm/unittests/VMCore/Makefile15
-rw-r--r--contrib/llvm/unittests/VMCore/MetadataTest.cpp144
-rw-r--r--contrib/llvm/unittests/VMCore/PassManagerTest.cpp527
-rw-r--r--contrib/llvm/unittests/VMCore/VerifierTest.cpp45
48 files changed, 0 insertions, 7901 deletions
diff --git a/contrib/llvm/unittests/ADT/APFloatTest.cpp b/contrib/llvm/unittests/ADT/APFloatTest.cpp
deleted file mode 100644
index 964b04d..0000000
--- a/contrib/llvm/unittests/ADT/APFloatTest.cpp
+++ /dev/null
@@ -1,579 +0,0 @@
-//===- llvm/unittest/ADT/APFloat.cpp - APFloat unit tests ---------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <ostream>
-#include <string>
-#include "llvm/Support/raw_ostream.h"
-#include "gtest/gtest.h"
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/SmallVector.h"
-
-using namespace llvm;
-
-static double convertToDoubleFromString(const char *Str) {
- llvm::APFloat F(0.0);
- F.convertFromString(Str, llvm::APFloat::rmNearestTiesToEven);
- return F.convertToDouble();
-}
-
-static std::string convertToString(double d, unsigned Prec, unsigned Pad) {
- llvm::SmallVector<char, 100> Buffer;
- llvm::APFloat F(d);
- F.toString(Buffer, Prec, Pad);
- return std::string(Buffer.data(), Buffer.size());
-}
-
-namespace {
-
-TEST(APFloatTest, Zero) {
- EXPECT_EQ(0.0f, APFloat(APFloat::IEEEsingle, 0.0f).convertToFloat());
- EXPECT_EQ(-0.0f, APFloat(APFloat::IEEEsingle, -0.0f).convertToFloat());
-
- EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, 0.0).convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, -0.0).convertToDouble());
-}
-
-TEST(APFloatTest, fromZeroDecimalString) {
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "00000.").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+00000.").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-00000.").convertToDouble());
-
- EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, ".00000").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.00000").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.00000").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0000.00000").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0000.00000").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0000.00000").convertToDouble());
-}
-
-TEST(APFloatTest, fromZeroDecimalSingleExponentString) {
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e-1").convertToDouble());
-
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.e1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.e1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.e1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.e+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.e+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.e+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.e-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.e-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.e-1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0e1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0e1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0e1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0e+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0e+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0e+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0e-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0e-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0e-1").convertToDouble());
-
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0e1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0e1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0e1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0e+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0e+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0e+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0e-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0e-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0e-1").convertToDouble());
-
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "000.0000e1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+000.0000e+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-000.0000e+1").convertToDouble());
-}
-
-TEST(APFloatTest, fromZeroDecimalLargeExponentString) {
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e1234").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e1234").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e1234").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e+1234").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e+1234").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e+1234").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e-1234").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e-1234").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e-1234").convertToDouble());
-
- EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e1234").convertToDouble());
- EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e-1234").convertToDouble());
-
- EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, StringRef("0e1234\02", 6)).convertToDouble());
-}
-
-TEST(APFloatTest, fromZeroHexadecimalString) {
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0p1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0p+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0p-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p-1").convertToDouble());
-
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.p1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.p1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.p+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.p+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.p-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.p-1").convertToDouble());
-
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.0p1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x.0p1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x.0p1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.0p+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x.0p+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x.0p+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.0p-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x.0p-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x.0p-1").convertToDouble());
-
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.0p1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.0p1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.0p1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.0p+1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.0p+1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.0p+1").convertToDouble());
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.0p-1").convertToDouble());
- EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.0p-1").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.0p-1").convertToDouble());
-
-
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p1").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p1234").convertToDouble());
- EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1234").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1234").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1234").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1234").convertToDouble());
- EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p1234").convertToDouble());
-}
-
-TEST(APFloatTest, fromDecimalString) {
- EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble, "1").convertToDouble());
- EXPECT_EQ(2.0, APFloat(APFloat::IEEEdouble, "2.").convertToDouble());
- EXPECT_EQ(0.5, APFloat(APFloat::IEEEdouble, ".5").convertToDouble());
- EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble, "1.0").convertToDouble());
- EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble, "-2").convertToDouble());
- EXPECT_EQ(-4.0, APFloat(APFloat::IEEEdouble, "-4.").convertToDouble());
- EXPECT_EQ(-0.5, APFloat(APFloat::IEEEdouble, "-.5").convertToDouble());
- EXPECT_EQ(-1.5, APFloat(APFloat::IEEEdouble, "-1.5").convertToDouble());
- EXPECT_EQ(1.25e12, APFloat(APFloat::IEEEdouble, "1.25e12").convertToDouble());
- EXPECT_EQ(1.25e+12, APFloat(APFloat::IEEEdouble, "1.25e+12").convertToDouble());
- EXPECT_EQ(1.25e-12, APFloat(APFloat::IEEEdouble, "1.25e-12").convertToDouble());
- EXPECT_EQ(1024.0, APFloat(APFloat::IEEEdouble, "1024.").convertToDouble());
- EXPECT_EQ(1024.05, APFloat(APFloat::IEEEdouble, "1024.05000").convertToDouble());
- EXPECT_EQ(0.05, APFloat(APFloat::IEEEdouble, ".05000").convertToDouble());
- EXPECT_EQ(2.0, APFloat(APFloat::IEEEdouble, "2.").convertToDouble());
- EXPECT_EQ(2.0e2, APFloat(APFloat::IEEEdouble, "2.e2").convertToDouble());
- EXPECT_EQ(2.0e+2, APFloat(APFloat::IEEEdouble, "2.e+2").convertToDouble());
- EXPECT_EQ(2.0e-2, APFloat(APFloat::IEEEdouble, "2.e-2").convertToDouble());
- EXPECT_EQ(2.05e2, APFloat(APFloat::IEEEdouble, "002.05000e2").convertToDouble());
- EXPECT_EQ(2.05e+2, APFloat(APFloat::IEEEdouble, "002.05000e+2").convertToDouble());
- EXPECT_EQ(2.05e-2, APFloat(APFloat::IEEEdouble, "002.05000e-2").convertToDouble());
- EXPECT_EQ(2.05e12, APFloat(APFloat::IEEEdouble, "002.05000e12").convertToDouble());
- EXPECT_EQ(2.05e+12, APFloat(APFloat::IEEEdouble, "002.05000e+12").convertToDouble());
- EXPECT_EQ(2.05e-12, APFloat(APFloat::IEEEdouble, "002.05000e-12").convertToDouble());
-
- // These are "carefully selected" to overflow the fast log-base
- // calculations in APFloat.cpp
- EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "99e99999").isInfinity());
- EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-99e99999").isInfinity());
- EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "1e-99999").isPosZero());
- EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-1e-99999").isNegZero());
-}
-
-TEST(APFloatTest, fromHexadecimalString) {
- EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble, "0x1p0").convertToDouble());
- EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble, "+0x1p0").convertToDouble());
- EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble, "-0x1p0").convertToDouble());
-
- EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble, "0x1p+0").convertToDouble());
- EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble, "+0x1p+0").convertToDouble());
- EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble, "-0x1p+0").convertToDouble());
-
- EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble, "0x1p-0").convertToDouble());
- EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble, "+0x1p-0").convertToDouble());
- EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble, "-0x1p-0").convertToDouble());
-
-
- EXPECT_EQ( 2.0, APFloat(APFloat::IEEEdouble, "0x1p1").convertToDouble());
- EXPECT_EQ(+2.0, APFloat(APFloat::IEEEdouble, "+0x1p1").convertToDouble());
- EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble, "-0x1p1").convertToDouble());
-
- EXPECT_EQ( 2.0, APFloat(APFloat::IEEEdouble, "0x1p+1").convertToDouble());
- EXPECT_EQ(+2.0, APFloat(APFloat::IEEEdouble, "+0x1p+1").convertToDouble());
- EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble, "-0x1p+1").convertToDouble());
-
- EXPECT_EQ( 0.5, APFloat(APFloat::IEEEdouble, "0x1p-1").convertToDouble());
- EXPECT_EQ(+0.5, APFloat(APFloat::IEEEdouble, "+0x1p-1").convertToDouble());
- EXPECT_EQ(-0.5, APFloat(APFloat::IEEEdouble, "-0x1p-1").convertToDouble());
-
-
- EXPECT_EQ( 3.0, APFloat(APFloat::IEEEdouble, "0x1.8p1").convertToDouble());
- EXPECT_EQ(+3.0, APFloat(APFloat::IEEEdouble, "+0x1.8p1").convertToDouble());
- EXPECT_EQ(-3.0, APFloat(APFloat::IEEEdouble, "-0x1.8p1").convertToDouble());
-
- EXPECT_EQ( 3.0, APFloat(APFloat::IEEEdouble, "0x1.8p+1").convertToDouble());
- EXPECT_EQ(+3.0, APFloat(APFloat::IEEEdouble, "+0x1.8p+1").convertToDouble());
- EXPECT_EQ(-3.0, APFloat(APFloat::IEEEdouble, "-0x1.8p+1").convertToDouble());
-
- EXPECT_EQ( 0.75, APFloat(APFloat::IEEEdouble, "0x1.8p-1").convertToDouble());
- EXPECT_EQ(+0.75, APFloat(APFloat::IEEEdouble, "+0x1.8p-1").convertToDouble());
- EXPECT_EQ(-0.75, APFloat(APFloat::IEEEdouble, "-0x1.8p-1").convertToDouble());
-
-
- EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000.000p1").convertToDouble());
- EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000.000p1").convertToDouble());
- EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000.000p1").convertToDouble());
-
- EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000.000p+1").convertToDouble());
- EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000.000p+1").convertToDouble());
- EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000.000p+1").convertToDouble());
-
- EXPECT_EQ( 2048.0, APFloat(APFloat::IEEEdouble, "0x1000.000p-1").convertToDouble());
- EXPECT_EQ(+2048.0, APFloat(APFloat::IEEEdouble, "+0x1000.000p-1").convertToDouble());
- EXPECT_EQ(-2048.0, APFloat(APFloat::IEEEdouble, "-0x1000.000p-1").convertToDouble());
-
-
- EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000p1").convertToDouble());
- EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000p1").convertToDouble());
- EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000p1").convertToDouble());
-
- EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000p+1").convertToDouble());
- EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000p+1").convertToDouble());
- EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000p+1").convertToDouble());
-
- EXPECT_EQ( 2048.0, APFloat(APFloat::IEEEdouble, "0x1000p-1").convertToDouble());
- EXPECT_EQ(+2048.0, APFloat(APFloat::IEEEdouble, "+0x1000p-1").convertToDouble());
- EXPECT_EQ(-2048.0, APFloat(APFloat::IEEEdouble, "-0x1000p-1").convertToDouble());
-
-
- EXPECT_EQ( 16384.0, APFloat(APFloat::IEEEdouble, "0x10p10").convertToDouble());
- EXPECT_EQ(+16384.0, APFloat(APFloat::IEEEdouble, "+0x10p10").convertToDouble());
- EXPECT_EQ(-16384.0, APFloat(APFloat::IEEEdouble, "-0x10p10").convertToDouble());
-
- EXPECT_EQ( 16384.0, APFloat(APFloat::IEEEdouble, "0x10p+10").convertToDouble());
- EXPECT_EQ(+16384.0, APFloat(APFloat::IEEEdouble, "+0x10p+10").convertToDouble());
- EXPECT_EQ(-16384.0, APFloat(APFloat::IEEEdouble, "-0x10p+10").convertToDouble());
-
- EXPECT_EQ( 0.015625, APFloat(APFloat::IEEEdouble, "0x10p-10").convertToDouble());
- EXPECT_EQ(+0.015625, APFloat(APFloat::IEEEdouble, "+0x10p-10").convertToDouble());
- EXPECT_EQ(-0.015625, APFloat(APFloat::IEEEdouble, "-0x10p-10").convertToDouble());
-
- EXPECT_EQ(1.0625, APFloat(APFloat::IEEEdouble, "0x1.1p0").convertToDouble());
- EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble, "0x1p0").convertToDouble());
-
- EXPECT_EQ(2.71828, convertToDoubleFromString("2.71828"));
-}
-
-TEST(APFloatTest, toString) {
- ASSERT_EQ("10", convertToString(10.0, 6, 3));
- ASSERT_EQ("1.0E+1", convertToString(10.0, 6, 0));
- ASSERT_EQ("10100", convertToString(1.01E+4, 5, 2));
- ASSERT_EQ("1.01E+4", convertToString(1.01E+4, 4, 2));
- ASSERT_EQ("1.01E+4", convertToString(1.01E+4, 5, 1));
- ASSERT_EQ("0.0101", convertToString(1.01E-2, 5, 2));
- ASSERT_EQ("0.0101", convertToString(1.01E-2, 4, 2));
- ASSERT_EQ("1.01E-2", convertToString(1.01E-2, 5, 1));
- ASSERT_EQ("0.7853981633974483", convertToString(0.78539816339744830961, 0, 3));
- ASSERT_EQ("4.940656458412465E-324", convertToString(4.9406564584124654e-324, 0, 3));
- ASSERT_EQ("873.1834", convertToString(873.1834, 0, 1));
- ASSERT_EQ("8.731834E+2", convertToString(873.1834, 0, 0));
-}
-
-static APInt nanbits(const fltSemantics &Sem,
- bool SNaN, bool Negative, uint64_t fill) {
- APInt apfill(64, fill);
- if (SNaN)
- return APFloat::getSNaN(Sem, Negative, &apfill).bitcastToAPInt();
- else
- return APFloat::getQNaN(Sem, Negative, &apfill).bitcastToAPInt();
-}
-
-TEST(APFloatTest, makeNaN) {
- ASSERT_EQ(0x7fc00000, nanbits(APFloat::IEEEsingle, false, false, 0));
- ASSERT_EQ(0xffc00000, nanbits(APFloat::IEEEsingle, false, true, 0));
- ASSERT_EQ(0x7fc0ae72, nanbits(APFloat::IEEEsingle, false, false, 0xae72));
- ASSERT_EQ(0x7fffae72, nanbits(APFloat::IEEEsingle, false, false, 0xffffae72));
- ASSERT_EQ(0x7fa00000, nanbits(APFloat::IEEEsingle, true, false, 0));
- ASSERT_EQ(0xffa00000, nanbits(APFloat::IEEEsingle, true, true, 0));
- ASSERT_EQ(0x7f80ae72, nanbits(APFloat::IEEEsingle, true, false, 0xae72));
- ASSERT_EQ(0x7fbfae72, nanbits(APFloat::IEEEsingle, true, false, 0xffffae72));
-
- ASSERT_EQ(0x7ff8000000000000ULL, nanbits(APFloat::IEEEdouble, false, false, 0));
- ASSERT_EQ(0xfff8000000000000ULL, nanbits(APFloat::IEEEdouble, false, true, 0));
- ASSERT_EQ(0x7ff800000000ae72ULL, nanbits(APFloat::IEEEdouble, false, false, 0xae72));
- ASSERT_EQ(0x7fffffffffffae72ULL, nanbits(APFloat::IEEEdouble, false, false, 0xffffffffffffae72ULL));
- ASSERT_EQ(0x7ff4000000000000ULL, nanbits(APFloat::IEEEdouble, true, false, 0));
- ASSERT_EQ(0xfff4000000000000ULL, nanbits(APFloat::IEEEdouble, true, true, 0));
- ASSERT_EQ(0x7ff000000000ae72ULL, nanbits(APFloat::IEEEdouble, true, false, 0xae72));
- ASSERT_EQ(0x7ff7ffffffffae72ULL, nanbits(APFloat::IEEEdouble, true, false, 0xffffffffffffae72ULL));
-}
-
-#ifdef GTEST_HAS_DEATH_TEST
-#ifndef NDEBUG
-TEST(APFloatTest, SemanticsDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEsingle, 0.0f).convertToDouble(), "Float semantics are not IEEEdouble");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, 0.0 ).convertToFloat(), "Float semantics are not IEEEsingle");
-}
-
-TEST(APFloatTest, StringDecimalDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ""), "Invalid string length");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+"), "String has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-"), "String has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("\0", 1)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\0", 2)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02", 3)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02e1", 5)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e\0", 3)), "Invalid character in exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\0", 4)), "Invalid character in exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\02", 5)), "Invalid character in exponent");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0f"), "Invalid character in significand");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".."), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "..0"), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0.0"), "String contains multiple dots");
-}
-
-TEST(APFloatTest, StringDecimalSignificandDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-."), "Significand has no digits");
-
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-e"), "Significand has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-e1"), "Significand has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+.e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-.e1"), "Significand has no digits");
-
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+.e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-.e"), "Significand has no digits");
-}
-
-TEST(APFloatTest, StringDecimalExponentDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+1e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-1e"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+1.e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-1.e"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+.1e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-.1e"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.1e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+1.1e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-1.1e"), "Exponent has no digits");
-
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1e+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1e-"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e-"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0e"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0e+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0e-"), "Exponent has no digits");
-}
-
-TEST(APFloatTest, StringHexadecimalDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x"), "Invalid string");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x"), "Invalid string");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x"), "Invalid string");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x0"), "Hex strings require an exponent");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x0."), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x0."), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x0."), "Hex strings require an exponent");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.0"), "Hex strings require an exponent");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x0.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x0.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x0.0"), "Hex strings require an exponent");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x\0", 3)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\0", 4)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02", 5)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02p1", 7)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p\0", 5)), "Invalid character in exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\0", 6)), "Invalid character in exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\02", 7)), "Invalid character in exponent");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p0f"), "Invalid character in exponent");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x..p1"), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x..0p1"), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.0.0p1"), "String contains multiple dots");
-}
-
-TEST(APFloatTest, StringHexadecimalSignificandDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x."), "Significand has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0xp"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0xp"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0xp"), "Significand has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0xp+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0xp+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0xp+"), "Significand has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0xp-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0xp-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0xp-"), "Significand has no digits");
-
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.p"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.p"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.p"), "Significand has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.p+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.p+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.p+"), "Significand has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.p-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.p-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.p-"), "Significand has no digits");
-}
-
-TEST(APFloatTest, StringHexadecimalExponentDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1p"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1p+"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1p-"), "Exponent has no digits");
-
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.p"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.p+"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.p-"), "Exponent has no digits");
-
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.1p"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.1p+"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.1p-"), "Exponent has no digits");
-
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.1p"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.1p+"), "Exponent has no digits");
-
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.1p-"), "Exponent has no digits");
-}
-#endif
-#endif
-
-}
diff --git a/contrib/llvm/unittests/ADT/APIntTest.cpp b/contrib/llvm/unittests/ADT/APIntTest.cpp
deleted file mode 100644
index d08e86a..0000000
--- a/contrib/llvm/unittests/ADT/APIntTest.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-//===- llvm/unittest/ADT/APInt.cpp - APInt unit tests ---------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <ostream>
-#include "gtest/gtest.h"
-#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/SmallString.h"
-
-using namespace llvm;
-
-namespace {
-
-// Test that APInt shift left works when bitwidth > 64 and shiftamt == 0
-TEST(APIntTest, ShiftLeftByZero) {
- APInt One = APInt::getNullValue(65) + 1;
- APInt Shl = One.shl(0);
- EXPECT_EQ(true, Shl[0]);
- EXPECT_EQ(false, Shl[1]);
-}
-
-TEST(APIntTest, i128_NegativeCount) {
- APInt Minus3(128, static_cast<uint64_t>(-3), true);
- EXPECT_EQ(126u, Minus3.countLeadingOnes());
- EXPECT_EQ(-3, Minus3.getSExtValue());
-
- APInt Minus1(128, static_cast<uint64_t>(-1), true);
- EXPECT_EQ(0u, Minus1.countLeadingZeros());
- EXPECT_EQ(128u, Minus1.countLeadingOnes());
- EXPECT_EQ(128u, Minus1.getActiveBits());
- EXPECT_EQ(0u, Minus1.countTrailingZeros());
- EXPECT_EQ(128u, Minus1.countTrailingOnes());
- EXPECT_EQ(128u, Minus1.countPopulation());
- EXPECT_EQ(-1, Minus1.getSExtValue());
-}
-
-TEST(APIntTest, i33_Count) {
- APInt i33minus2(33, static_cast<uint64_t>(-2), true);
- EXPECT_EQ(0u, i33minus2.countLeadingZeros());
- EXPECT_EQ(32u, i33minus2.countLeadingOnes());
- EXPECT_EQ(33u, i33minus2.getActiveBits());
- EXPECT_EQ(1u, i33minus2.countTrailingZeros());
- EXPECT_EQ(32u, i33minus2.countPopulation());
- EXPECT_EQ(-2, i33minus2.getSExtValue());
- EXPECT_EQ(((uint64_t)-2)&((1ull<<33) -1), i33minus2.getZExtValue());
-}
-
-TEST(APIntTest, i65_Count) {
- APInt i65minus(65, 0, true);
- i65minus.set(64);
- EXPECT_EQ(0u, i65minus.countLeadingZeros());
- EXPECT_EQ(1u, i65minus.countLeadingOnes());
- EXPECT_EQ(65u, i65minus.getActiveBits());
- EXPECT_EQ(64u, i65minus.countTrailingZeros());
- EXPECT_EQ(1u, i65minus.countPopulation());
-}
-
-TEST(APIntTest, i128_PositiveCount) {
- APInt u128max = APInt::getAllOnesValue(128);
- EXPECT_EQ(128u, u128max.countLeadingOnes());
- EXPECT_EQ(0u, u128max.countLeadingZeros());
- EXPECT_EQ(128u, u128max.getActiveBits());
- EXPECT_EQ(0u, u128max.countTrailingZeros());
- EXPECT_EQ(128u, u128max.countTrailingOnes());
- EXPECT_EQ(128u, u128max.countPopulation());
-
- APInt u64max(128, static_cast<uint64_t>(-1), false);
- EXPECT_EQ(64u, u64max.countLeadingZeros());
- EXPECT_EQ(0u, u64max.countLeadingOnes());
- EXPECT_EQ(64u, u64max.getActiveBits());
- EXPECT_EQ(0u, u64max.countTrailingZeros());
- EXPECT_EQ(64u, u64max.countTrailingOnes());
- EXPECT_EQ(64u, u64max.countPopulation());
- EXPECT_EQ((uint64_t)~0ull, u64max.getZExtValue());
-
- APInt zero(128, 0, true);
- EXPECT_EQ(128u, zero.countLeadingZeros());
- EXPECT_EQ(0u, zero.countLeadingOnes());
- EXPECT_EQ(0u, zero.getActiveBits());
- EXPECT_EQ(128u, zero.countTrailingZeros());
- EXPECT_EQ(0u, zero.countTrailingOnes());
- EXPECT_EQ(0u, zero.countPopulation());
- EXPECT_EQ(0u, zero.getSExtValue());
- EXPECT_EQ(0u, zero.getZExtValue());
-
- APInt one(128, 1, true);
- EXPECT_EQ(127u, one.countLeadingZeros());
- EXPECT_EQ(0u, one.countLeadingOnes());
- EXPECT_EQ(1u, one.getActiveBits());
- EXPECT_EQ(0u, one.countTrailingZeros());
- EXPECT_EQ(1u, one.countTrailingOnes());
- EXPECT_EQ(1u, one.countPopulation());
- EXPECT_EQ(1, one.getSExtValue());
- EXPECT_EQ(1u, one.getZExtValue());
-}
-
-TEST(APIntTest, i1) {
- const APInt neg_two(1, static_cast<uint64_t>(-2), true);
- const APInt neg_one(1, static_cast<uint64_t>(-1), true);
- const APInt zero(1, 0);
- const APInt one(1, 1);
- const APInt two(1, 2);
-
- EXPECT_EQ(0, neg_two.getSExtValue());
- EXPECT_EQ(-1, neg_one.getSExtValue());
- EXPECT_EQ(1u, neg_one.getZExtValue());
- EXPECT_EQ(0u, zero.getZExtValue());
- EXPECT_EQ(-1, one.getSExtValue());
- EXPECT_EQ(1u, one.getZExtValue());
- EXPECT_EQ(0u, two.getZExtValue());
- EXPECT_EQ(0, two.getSExtValue());
-
- // Basic equalities for 1-bit values.
- EXPECT_EQ(zero, two);
- EXPECT_EQ(zero, neg_two);
- EXPECT_EQ(one, neg_one);
- EXPECT_EQ(two, neg_two);
-
- // Additions.
- EXPECT_EQ(two, one + one);
- EXPECT_EQ(zero, neg_one + one);
- EXPECT_EQ(neg_two, neg_one + neg_one);
-
- // Subtractions.
- EXPECT_EQ(neg_two, neg_one - one);
- EXPECT_EQ(two, one - neg_one);
- EXPECT_EQ(zero, one - one);
-
- // Shifts.
- EXPECT_EQ(zero, one << one);
- EXPECT_EQ(one, one << zero);
- EXPECT_EQ(zero, one.shl(1));
- EXPECT_EQ(one, one.shl(0));
- EXPECT_EQ(zero, one.lshr(1));
- EXPECT_EQ(zero, one.ashr(1));
-
- // Multiplies.
- EXPECT_EQ(neg_one, neg_one * one);
- EXPECT_EQ(neg_one, one * neg_one);
- EXPECT_EQ(one, neg_one * neg_one);
- EXPECT_EQ(one, one * one);
-
- // Divides.
- EXPECT_EQ(neg_one, one.sdiv(neg_one));
- EXPECT_EQ(neg_one, neg_one.sdiv(one));
- EXPECT_EQ(one, neg_one.sdiv(neg_one));
- EXPECT_EQ(one, one.sdiv(one));
-
- EXPECT_EQ(neg_one, one.udiv(neg_one));
- EXPECT_EQ(neg_one, neg_one.udiv(one));
- EXPECT_EQ(one, neg_one.udiv(neg_one));
- EXPECT_EQ(one, one.udiv(one));
-
- // Remainders.
- EXPECT_EQ(zero, neg_one.srem(one));
- EXPECT_EQ(zero, neg_one.urem(one));
- EXPECT_EQ(zero, one.srem(neg_one));
-}
-
-TEST(APIntTest, fromString) {
- EXPECT_EQ(APInt(32, 0), APInt(32, "0", 2));
- EXPECT_EQ(APInt(32, 1), APInt(32, "1", 2));
- EXPECT_EQ(APInt(32, 2), APInt(32, "10", 2));
- EXPECT_EQ(APInt(32, 3), APInt(32, "11", 2));
- EXPECT_EQ(APInt(32, 4), APInt(32, "100", 2));
-
- EXPECT_EQ(APInt(32, 0), APInt(32, "+0", 2));
- EXPECT_EQ(APInt(32, 1), APInt(32, "+1", 2));
- EXPECT_EQ(APInt(32, 2), APInt(32, "+10", 2));
- EXPECT_EQ(APInt(32, 3), APInt(32, "+11", 2));
- EXPECT_EQ(APInt(32, 4), APInt(32, "+100", 2));
-
- EXPECT_EQ(APInt(32, uint64_t(-0LL)), APInt(32, "-0", 2));
- EXPECT_EQ(APInt(32, uint64_t(-1LL)), APInt(32, "-1", 2));
- EXPECT_EQ(APInt(32, uint64_t(-2LL)), APInt(32, "-10", 2));
- EXPECT_EQ(APInt(32, uint64_t(-3LL)), APInt(32, "-11", 2));
- EXPECT_EQ(APInt(32, uint64_t(-4LL)), APInt(32, "-100", 2));
-
-
- EXPECT_EQ(APInt(32, 0), APInt(32, "0", 8));
- EXPECT_EQ(APInt(32, 1), APInt(32, "1", 8));
- EXPECT_EQ(APInt(32, 7), APInt(32, "7", 8));
- EXPECT_EQ(APInt(32, 8), APInt(32, "10", 8));
- EXPECT_EQ(APInt(32, 15), APInt(32, "17", 8));
- EXPECT_EQ(APInt(32, 16), APInt(32, "20", 8));
-
- EXPECT_EQ(APInt(32, +0), APInt(32, "+0", 8));
- EXPECT_EQ(APInt(32, +1), APInt(32, "+1", 8));
- EXPECT_EQ(APInt(32, +7), APInt(32, "+7", 8));
- EXPECT_EQ(APInt(32, +8), APInt(32, "+10", 8));
- EXPECT_EQ(APInt(32, +15), APInt(32, "+17", 8));
- EXPECT_EQ(APInt(32, +16), APInt(32, "+20", 8));
-
- EXPECT_EQ(APInt(32, uint64_t(-0LL)), APInt(32, "-0", 8));
- EXPECT_EQ(APInt(32, uint64_t(-1LL)), APInt(32, "-1", 8));
- EXPECT_EQ(APInt(32, uint64_t(-7LL)), APInt(32, "-7", 8));
- EXPECT_EQ(APInt(32, uint64_t(-8LL)), APInt(32, "-10", 8));
- EXPECT_EQ(APInt(32, uint64_t(-15LL)), APInt(32, "-17", 8));
- EXPECT_EQ(APInt(32, uint64_t(-16LL)), APInt(32, "-20", 8));
-
-
- EXPECT_EQ(APInt(32, 0), APInt(32, "0", 10));
- EXPECT_EQ(APInt(32, 1), APInt(32, "1", 10));
- EXPECT_EQ(APInt(32, 9), APInt(32, "9", 10));
- EXPECT_EQ(APInt(32, 10), APInt(32, "10", 10));
- EXPECT_EQ(APInt(32, 19), APInt(32, "19", 10));
- EXPECT_EQ(APInt(32, 20), APInt(32, "20", 10));
-
- EXPECT_EQ(APInt(32, uint64_t(-0LL)), APInt(32, "-0", 10));
- EXPECT_EQ(APInt(32, uint64_t(-1LL)), APInt(32, "-1", 10));
- EXPECT_EQ(APInt(32, uint64_t(-9LL)), APInt(32, "-9", 10));
- EXPECT_EQ(APInt(32, uint64_t(-10LL)), APInt(32, "-10", 10));
- EXPECT_EQ(APInt(32, uint64_t(-19LL)), APInt(32, "-19", 10));
- EXPECT_EQ(APInt(32, uint64_t(-20LL)), APInt(32, "-20", 10));
-
-
- EXPECT_EQ(APInt(32, 0), APInt(32, "0", 16));
- EXPECT_EQ(APInt(32, 1), APInt(32, "1", 16));
- EXPECT_EQ(APInt(32, 15), APInt(32, "F", 16));
- EXPECT_EQ(APInt(32, 16), APInt(32, "10", 16));
- EXPECT_EQ(APInt(32, 31), APInt(32, "1F", 16));
- EXPECT_EQ(APInt(32, 32), APInt(32, "20", 16));
-
- EXPECT_EQ(APInt(32, uint64_t(-0LL)), APInt(32, "-0", 16));
- EXPECT_EQ(APInt(32, uint64_t(-1LL)), APInt(32, "-1", 16));
- EXPECT_EQ(APInt(32, uint64_t(-15LL)), APInt(32, "-F", 16));
- EXPECT_EQ(APInt(32, uint64_t(-16LL)), APInt(32, "-10", 16));
- EXPECT_EQ(APInt(32, uint64_t(-31LL)), APInt(32, "-1F", 16));
- EXPECT_EQ(APInt(32, uint64_t(-32LL)), APInt(32, "-20", 16));
-}
-
-TEST(APIntTest, StringBitsNeeded2) {
- EXPECT_EQ(1U, APInt::getBitsNeeded( "0", 2));
- EXPECT_EQ(1U, APInt::getBitsNeeded( "1", 2));
- EXPECT_EQ(2U, APInt::getBitsNeeded( "10", 2));
- EXPECT_EQ(2U, APInt::getBitsNeeded( "11", 2));
- EXPECT_EQ(3U, APInt::getBitsNeeded("100", 2));
-
- EXPECT_EQ(1U, APInt::getBitsNeeded( "+0", 2));
- EXPECT_EQ(1U, APInt::getBitsNeeded( "+1", 2));
- EXPECT_EQ(2U, APInt::getBitsNeeded( "+10", 2));
- EXPECT_EQ(2U, APInt::getBitsNeeded( "+11", 2));
- EXPECT_EQ(3U, APInt::getBitsNeeded("+100", 2));
-
- EXPECT_EQ(2U, APInt::getBitsNeeded( "-0", 2));
- EXPECT_EQ(2U, APInt::getBitsNeeded( "-1", 2));
- EXPECT_EQ(3U, APInt::getBitsNeeded( "-10", 2));
- EXPECT_EQ(3U, APInt::getBitsNeeded( "-11", 2));
- EXPECT_EQ(4U, APInt::getBitsNeeded("-100", 2));
-}
-
-TEST(APIntTest, StringBitsNeeded8) {
- EXPECT_EQ(3U, APInt::getBitsNeeded( "0", 8));
- EXPECT_EQ(3U, APInt::getBitsNeeded( "7", 8));
- EXPECT_EQ(6U, APInt::getBitsNeeded("10", 8));
- EXPECT_EQ(6U, APInt::getBitsNeeded("17", 8));
- EXPECT_EQ(6U, APInt::getBitsNeeded("20", 8));
-
- EXPECT_EQ(3U, APInt::getBitsNeeded( "+0", 8));
- EXPECT_EQ(3U, APInt::getBitsNeeded( "+7", 8));
- EXPECT_EQ(6U, APInt::getBitsNeeded("+10", 8));
- EXPECT_EQ(6U, APInt::getBitsNeeded("+17", 8));
- EXPECT_EQ(6U, APInt::getBitsNeeded("+20", 8));
-
- EXPECT_EQ(4U, APInt::getBitsNeeded( "-0", 8));
- EXPECT_EQ(4U, APInt::getBitsNeeded( "-7", 8));
- EXPECT_EQ(7U, APInt::getBitsNeeded("-10", 8));
- EXPECT_EQ(7U, APInt::getBitsNeeded("-17", 8));
- EXPECT_EQ(7U, APInt::getBitsNeeded("-20", 8));
-}
-
-TEST(APIntTest, StringBitsNeeded10) {
- EXPECT_EQ(1U, APInt::getBitsNeeded( "0", 10));
- EXPECT_EQ(2U, APInt::getBitsNeeded( "3", 10));
- EXPECT_EQ(4U, APInt::getBitsNeeded( "9", 10));
- EXPECT_EQ(4U, APInt::getBitsNeeded("10", 10));
- EXPECT_EQ(5U, APInt::getBitsNeeded("19", 10));
- EXPECT_EQ(5U, APInt::getBitsNeeded("20", 10));
-
- EXPECT_EQ(1U, APInt::getBitsNeeded( "+0", 10));
- EXPECT_EQ(4U, APInt::getBitsNeeded( "+9", 10));
- EXPECT_EQ(4U, APInt::getBitsNeeded("+10", 10));
- EXPECT_EQ(5U, APInt::getBitsNeeded("+19", 10));
- EXPECT_EQ(5U, APInt::getBitsNeeded("+20", 10));
-
- EXPECT_EQ(2U, APInt::getBitsNeeded( "-0", 10));
- EXPECT_EQ(5U, APInt::getBitsNeeded( "-9", 10));
- EXPECT_EQ(5U, APInt::getBitsNeeded("-10", 10));
- EXPECT_EQ(6U, APInt::getBitsNeeded("-19", 10));
- EXPECT_EQ(6U, APInt::getBitsNeeded("-20", 10));
-}
-
-TEST(APIntTest, StringBitsNeeded16) {
- EXPECT_EQ(4U, APInt::getBitsNeeded( "0", 16));
- EXPECT_EQ(4U, APInt::getBitsNeeded( "F", 16));
- EXPECT_EQ(8U, APInt::getBitsNeeded("10", 16));
- EXPECT_EQ(8U, APInt::getBitsNeeded("1F", 16));
- EXPECT_EQ(8U, APInt::getBitsNeeded("20", 16));
-
- EXPECT_EQ(4U, APInt::getBitsNeeded( "+0", 16));
- EXPECT_EQ(4U, APInt::getBitsNeeded( "+F", 16));
- EXPECT_EQ(8U, APInt::getBitsNeeded("+10", 16));
- EXPECT_EQ(8U, APInt::getBitsNeeded("+1F", 16));
- EXPECT_EQ(8U, APInt::getBitsNeeded("+20", 16));
-
- EXPECT_EQ(5U, APInt::getBitsNeeded( "-0", 16));
- EXPECT_EQ(5U, APInt::getBitsNeeded( "-F", 16));
- EXPECT_EQ(9U, APInt::getBitsNeeded("-10", 16));
- EXPECT_EQ(9U, APInt::getBitsNeeded("-1F", 16));
- EXPECT_EQ(9U, APInt::getBitsNeeded("-20", 16));
-}
-
-TEST(APIntTest, Log2) {
- EXPECT_EQ(APInt(15, 7).logBase2(), 2U);
- EXPECT_EQ(APInt(15, 7).ceilLogBase2(), 3U);
- EXPECT_EQ(APInt(15, 7).exactLogBase2(), -1);
- EXPECT_EQ(APInt(15, 8).logBase2(), 3U);
- EXPECT_EQ(APInt(15, 8).ceilLogBase2(), 3U);
- EXPECT_EQ(APInt(15, 8).exactLogBase2(), 3);
- EXPECT_EQ(APInt(15, 9).logBase2(), 3U);
- EXPECT_EQ(APInt(15, 9).ceilLogBase2(), 4U);
- EXPECT_EQ(APInt(15, 9).exactLogBase2(), -1);
-}
-
-#ifdef GTEST_HAS_DEATH_TEST
-#ifndef NDEBUG
-TEST(APIntTest, StringDeath) {
- EXPECT_DEATH(APInt(0, "", 0), "Bitwidth too small");
- EXPECT_DEATH(APInt(32, "", 0), "Invalid string length");
- EXPECT_DEATH(APInt(32, "0", 0), "Radix should be 2, 8, 10, or 16!");
- EXPECT_DEATH(APInt(32, "", 10), "Invalid string length");
- EXPECT_DEATH(APInt(32, "-", 10), "String is only a sign, needs a value.");
- EXPECT_DEATH(APInt(1, "1234", 10), "Insufficient bit width");
- EXPECT_DEATH(APInt(32, "\0", 10), "Invalid string length");
- EXPECT_DEATH(APInt(32, StringRef("1\02", 3), 10), "Invalid character in digit string");
- EXPECT_DEATH(APInt(32, "1L", 10), "Invalid character in digit string");
-}
-#endif
-#endif
-
-}
diff --git a/contrib/llvm/unittests/ADT/BitVectorTest.cpp b/contrib/llvm/unittests/ADT/BitVectorTest.cpp
deleted file mode 100644
index a9fc133..0000000
--- a/contrib/llvm/unittests/ADT/BitVectorTest.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-//===- llvm/unittest/ADT/BitVectorTest.cpp - BitVector tests --------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Some of these tests fail on PowerPC for unknown reasons.
-#ifndef __ppc__
-
-#include "llvm/ADT/BitVector.h"
-#include "gtest/gtest.h"
-
-using namespace llvm;
-
-namespace {
-
-TEST(BitVectorTest, TrivialOperation) {
- BitVector Vec;
- EXPECT_EQ(0U, Vec.count());
- EXPECT_EQ(0U, Vec.size());
- EXPECT_FALSE(Vec.any());
- EXPECT_TRUE(Vec.none());
- EXPECT_TRUE(Vec.empty());
-
- Vec.resize(5, true);
- EXPECT_EQ(5U, Vec.count());
- EXPECT_EQ(5U, Vec.size());
- EXPECT_TRUE(Vec.any());
- EXPECT_FALSE(Vec.none());
- EXPECT_FALSE(Vec.empty());
-
- Vec.resize(11);
- EXPECT_EQ(5U, Vec.count());
- EXPECT_EQ(11U, Vec.size());
- EXPECT_TRUE(Vec.any());
- EXPECT_FALSE(Vec.none());
- EXPECT_FALSE(Vec.empty());
-
- BitVector Inv = ~Vec;
- EXPECT_EQ(6U, Inv.count());
- EXPECT_EQ(11U, Inv.size());
- EXPECT_TRUE(Inv.any());
- EXPECT_FALSE(Inv.none());
- EXPECT_FALSE(Inv.empty());
-
- EXPECT_FALSE(Inv == Vec);
- EXPECT_TRUE(Inv != Vec);
- Vec = ~Vec;
- EXPECT_TRUE(Inv == Vec);
- EXPECT_FALSE(Inv != Vec);
-
- // Add some "interesting" data to Vec.
- Vec.resize(23, true);
- Vec.resize(25, false);
- Vec.resize(26, true);
- Vec.resize(29, false);
- Vec.resize(33, true);
- Vec.resize(57, false);
- unsigned Count = 0;
- for (unsigned i = Vec.find_first(); i != -1u; i = Vec.find_next(i)) {
- ++Count;
- EXPECT_TRUE(Vec[i]);
- EXPECT_TRUE(Vec.test(i));
- }
- EXPECT_EQ(Count, Vec.count());
- EXPECT_EQ(Count, 23u);
- EXPECT_FALSE(Vec[0]);
- EXPECT_TRUE(Vec[32]);
- EXPECT_FALSE(Vec[56]);
- Vec.resize(61, false);
-
- BitVector Copy = Vec;
- BitVector Alt(3, false);
- Alt.resize(6, true);
- std::swap(Alt, Vec);
- EXPECT_TRUE(Copy == Alt);
- EXPECT_TRUE(Vec.size() == 6);
- EXPECT_TRUE(Vec.count() == 3);
- EXPECT_TRUE(Vec.find_first() == 3);
- std::swap(Copy, Vec);
-
- // Add some more "interesting" data.
- Vec.resize(68, true);
- Vec.resize(78, false);
- Vec.resize(89, true);
- Vec.resize(90, false);
- Vec.resize(91, true);
- Vec.resize(130, false);
- Count = 0;
- for (unsigned i = Vec.find_first(); i != -1u; i = Vec.find_next(i)) {
- ++Count;
- EXPECT_TRUE(Vec[i]);
- EXPECT_TRUE(Vec.test(i));
- }
- EXPECT_EQ(Count, Vec.count());
- EXPECT_EQ(Count, 42u);
- EXPECT_FALSE(Vec[0]);
- EXPECT_TRUE(Vec[32]);
- EXPECT_FALSE(Vec[60]);
- EXPECT_FALSE(Vec[129]);
-
- Vec.flip(60);
- EXPECT_TRUE(Vec[60]);
- EXPECT_EQ(Count + 1, Vec.count());
- Vec.flip(60);
- EXPECT_FALSE(Vec[60]);
- EXPECT_EQ(Count, Vec.count());
-
- Vec.reset(32);
- EXPECT_FALSE(Vec[32]);
- EXPECT_EQ(Count - 1, Vec.count());
- Vec.set(32);
- EXPECT_TRUE(Vec[32]);
- EXPECT_EQ(Count, Vec.count());
-
- Vec.flip();
- EXPECT_EQ(Vec.size() - Count, Vec.count());
-
- Vec.reset();
- EXPECT_EQ(0U, Vec.count());
- EXPECT_EQ(130U, Vec.size());
- EXPECT_FALSE(Vec.any());
- EXPECT_TRUE(Vec.none());
- EXPECT_FALSE(Vec.empty());
-
- Inv = ~BitVector();
- EXPECT_EQ(0U, Inv.count());
- EXPECT_EQ(0U, Inv.size());
- EXPECT_FALSE(Inv.any());
- EXPECT_TRUE(Inv.none());
- EXPECT_TRUE(Inv.empty());
-
- Vec.clear();
- EXPECT_EQ(0U, Vec.count());
- EXPECT_EQ(0U, Vec.size());
- EXPECT_FALSE(Vec.any());
- EXPECT_TRUE(Vec.none());
- EXPECT_TRUE(Vec.empty());
-}
-
-TEST(BitVectorTest, CompoundAssignment) {
- BitVector A;
- A.resize(10);
- A.set(4);
- A.set(7);
-
- BitVector B;
- B.resize(50);
- B.set(5);
- B.set(18);
-
- A |= B;
- EXPECT_TRUE(A.test(4));
- EXPECT_TRUE(A.test(5));
- EXPECT_TRUE(A.test(7));
- EXPECT_TRUE(A.test(18));
- EXPECT_EQ(4U, A.count());
- EXPECT_EQ(50U, A.size());
-
- B.resize(10);
- B.set();
- B.reset(2);
- B.reset(7);
- A &= B;
- EXPECT_FALSE(A.test(2));
- EXPECT_FALSE(A.test(7));
- EXPECT_EQ(2U, A.count());
- EXPECT_EQ(50U, A.size());
-
- B.resize(100);
- B.set();
-
- A ^= B;
- EXPECT_TRUE(A.test(2));
- EXPECT_TRUE(A.test(7));
- EXPECT_EQ(98U, A.count());
- EXPECT_EQ(100U, A.size());
-}
-
-TEST(BitVectorTest, ProxyIndex) {
- BitVector Vec(3);
- EXPECT_TRUE(Vec.none());
- Vec[0] = Vec[1] = Vec[2] = true;
- EXPECT_EQ(Vec.size(), Vec.count());
- Vec[2] = Vec[1] = Vec[0] = false;
- EXPECT_TRUE(Vec.none());
-}
-
-}
-
-#endif
diff --git a/contrib/llvm/unittests/ADT/DeltaAlgorithmTest.cpp b/contrib/llvm/unittests/ADT/DeltaAlgorithmTest.cpp
deleted file mode 100644
index a1884cd..0000000
--- a/contrib/llvm/unittests/ADT/DeltaAlgorithmTest.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-//===- llvm/unittest/ADT/DeltaAlgorithmTest.cpp ---------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/DeltaAlgorithm.h"
-#include <algorithm>
-#include <cstdarg>
-using namespace llvm;
-
-namespace std {
-
-std::ostream &operator<<(std::ostream &OS,
- const std::set<unsigned> &S) {
- OS << "{";
- for (std::set<unsigned>::const_iterator it = S.begin(),
- ie = S.end(); it != ie; ++it) {
- if (it != S.begin())
- OS << ",";
- OS << *it;
- }
- OS << "}";
- return OS;
-}
-
-}
-
-namespace {
-
-class FixedDeltaAlgorithm : public DeltaAlgorithm {
- changeset_ty FailingSet;
- unsigned NumTests;
-
-protected:
- virtual bool ExecuteOneTest(const changeset_ty &Changes) {
- ++NumTests;
- return std::includes(Changes.begin(), Changes.end(),
- FailingSet.begin(), FailingSet.end());
- }
-
-public:
- FixedDeltaAlgorithm(const changeset_ty &_FailingSet)
- : FailingSet(_FailingSet),
- NumTests(0) {}
-
- unsigned getNumTests() const { return NumTests; }
-};
-
-std::set<unsigned> fixed_set(unsigned N, ...) {
- std::set<unsigned> S;
- va_list ap;
- va_start(ap, N);
- for (unsigned i = 0; i != N; ++i)
- S.insert(va_arg(ap, unsigned));
- va_end(ap);
- return S;
-}
-
-std::set<unsigned> range(unsigned Start, unsigned End) {
- std::set<unsigned> S;
- while (Start != End)
- S.insert(Start++);
- return S;
-}
-
-std::set<unsigned> range(unsigned N) {
- return range(0, N);
-}
-
-TEST(DeltaAlgorithmTest, Basic) {
- // P = {3,5,7} \in S
- // [0, 20) should minimize to {3,5,7} in a reasonable number of tests.
- std::set<unsigned> Fails = fixed_set(3, 3, 5, 7);
- FixedDeltaAlgorithm FDA(Fails);
- EXPECT_EQ(fixed_set(3, 3, 5, 7), FDA.Run(range(20)));
- EXPECT_GE(33U, FDA.getNumTests());
-
- // P = {3,5,7} \in S
- // [10, 20) should minimize to [10,20)
- EXPECT_EQ(range(10,20), FDA.Run(range(10,20)));
-
- // P = [0,4) \in S
- // [0, 4) should minimize to [0,4) in 11 tests.
- //
- // 11 = |{ {},
- // {0}, {1}, {2}, {3},
- // {1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2},
- // {0, 1}, {2, 3} }|
- FDA = FixedDeltaAlgorithm(range(10));
- EXPECT_EQ(range(4), FDA.Run(range(4)));
- EXPECT_EQ(11U, FDA.getNumTests());
-}
-
-}
-
diff --git a/contrib/llvm/unittests/ADT/DenseMapTest.cpp b/contrib/llvm/unittests/ADT/DenseMapTest.cpp
deleted file mode 100644
index afac651..0000000
--- a/contrib/llvm/unittests/ADT/DenseMapTest.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-//===- llvm/unittest/ADT/DenseMapMap.cpp - DenseMap unit tests --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/DenseMap.h"
-
-using namespace llvm;
-
-namespace {
-
-// Test fixture
-class DenseMapTest : public testing::Test {
-protected:
- DenseMap<uint32_t, uint32_t> uintMap;
- DenseMap<uint32_t *, uint32_t *> uintPtrMap;
- uint32_t dummyInt;
-};
-
-// Empty map tests
-TEST_F(DenseMapTest, EmptyIntMapTest) {
- // Size tests
- EXPECT_EQ(0u, uintMap.size());
- EXPECT_TRUE(uintMap.empty());
-
- // Iterator tests
- EXPECT_TRUE(uintMap.begin() == uintMap.end());
-
- // Lookup tests
- EXPECT_FALSE(uintMap.count(0u));
- EXPECT_TRUE(uintMap.find(0u) == uintMap.end());
- EXPECT_EQ(0u, uintMap.lookup(0u));
-}
-
-// Empty map tests for pointer map
-TEST_F(DenseMapTest, EmptyPtrMapTest) {
- // Size tests
- EXPECT_EQ(0u, uintPtrMap.size());
- EXPECT_TRUE(uintPtrMap.empty());
-
- // Iterator tests
- EXPECT_TRUE(uintPtrMap.begin() == uintPtrMap.end());
-
- // Lookup tests
- EXPECT_FALSE(uintPtrMap.count(&dummyInt));
- EXPECT_TRUE(uintPtrMap.find(&dummyInt) == uintPtrMap.begin());
- EXPECT_EQ(0, uintPtrMap.lookup(&dummyInt));
-}
-
-// Constant map tests
-TEST_F(DenseMapTest, ConstEmptyMapTest) {
- const DenseMap<uint32_t, uint32_t> & constUintMap = uintMap;
- const DenseMap<uint32_t *, uint32_t *> & constUintPtrMap = uintPtrMap;
- EXPECT_EQ(0u, constUintMap.size());
- EXPECT_EQ(0u, constUintPtrMap.size());
- EXPECT_TRUE(constUintMap.empty());
- EXPECT_TRUE(constUintPtrMap.empty());
- EXPECT_TRUE(constUintMap.begin() == constUintMap.end());
- EXPECT_TRUE(constUintPtrMap.begin() == constUintPtrMap.end());
-}
-
-// A map with a single entry
-TEST_F(DenseMapTest, SingleEntryMapTest) {
- uintMap[0] = 1;
-
- // Size tests
- EXPECT_EQ(1u, uintMap.size());
- EXPECT_FALSE(uintMap.begin() == uintMap.end());
- EXPECT_FALSE(uintMap.empty());
-
- // Iterator tests
- DenseMap<uint32_t, uint32_t>::iterator it = uintMap.begin();
- EXPECT_EQ(0u, it->first);
- EXPECT_EQ(1u, it->second);
- ++it;
- EXPECT_TRUE(it == uintMap.end());
-
- // Lookup tests
- EXPECT_TRUE(uintMap.count(0u));
- EXPECT_TRUE(uintMap.find(0u) == uintMap.begin());
- EXPECT_EQ(1u, uintMap.lookup(0u));
- EXPECT_EQ(1u, uintMap[0]);
-}
-
-// Test clear() method
-TEST_F(DenseMapTest, ClearTest) {
- uintMap[0] = 1;
- uintMap.clear();
-
- EXPECT_EQ(0u, uintMap.size());
- EXPECT_TRUE(uintMap.empty());
- EXPECT_TRUE(uintMap.begin() == uintMap.end());
-}
-
-// Test erase(iterator) method
-TEST_F(DenseMapTest, EraseTest) {
- uintMap[0] = 1;
- uintMap.erase(uintMap.begin());
-
- EXPECT_EQ(0u, uintMap.size());
- EXPECT_TRUE(uintMap.empty());
- EXPECT_TRUE(uintMap.begin() == uintMap.end());
-}
-
-// Test erase(value) method
-TEST_F(DenseMapTest, EraseTest2) {
- uintMap[0] = 1;
- uintMap.erase(0);
-
- EXPECT_EQ(0u, uintMap.size());
- EXPECT_TRUE(uintMap.empty());
- EXPECT_TRUE(uintMap.begin() == uintMap.end());
-}
-
-// Test insert() method
-TEST_F(DenseMapTest, InsertTest) {
- uintMap.insert(std::make_pair(0u, 1u));
- EXPECT_EQ(1u, uintMap.size());
- EXPECT_EQ(1u, uintMap[0]);
-}
-
-// Test copy constructor method
-TEST_F(DenseMapTest, CopyConstructorTest) {
- uintMap[0] = 1;
- DenseMap<uint32_t, uint32_t> copyMap(uintMap);
-
- EXPECT_EQ(1u, copyMap.size());
- EXPECT_EQ(1u, copyMap[0]);
-}
-
-// Test assignment operator method
-TEST_F(DenseMapTest, AssignmentTest) {
- uintMap[0] = 1;
- DenseMap<uint32_t, uint32_t> copyMap = uintMap;
-
- EXPECT_EQ(1u, copyMap.size());
- EXPECT_EQ(1u, copyMap[0]);
-}
-
-// A more complex iteration test
-TEST_F(DenseMapTest, IterationTest) {
- bool visited[100];
-
- // Insert 100 numbers into the map
- for (int i = 0; i < 100; ++i) {
- visited[i] = false;
- uintMap[i] = 3;
- }
-
- // Iterate over all numbers and mark each one found.
- for (DenseMap<uint32_t, uint32_t>::iterator it = uintMap.begin();
- it != uintMap.end(); ++it) {
- visited[it->first] = true;
- }
-
- // Ensure every number was visited.
- for (int i = 0; i < 100; ++i) {
- ASSERT_TRUE(visited[i]) << "Entry #" << i << " was never visited";
- }
-}
-
-// const_iterator test
-TEST_F(DenseMapTest, ConstIteratorTest) {
- // Check conversion from iterator to const_iterator.
- DenseMap<uint32_t, uint32_t>::iterator it = uintMap.begin();
- DenseMap<uint32_t, uint32_t>::const_iterator cit(it);
- EXPECT_TRUE(it == cit);
-
- // Check copying of const_iterators.
- DenseMap<uint32_t, uint32_t>::const_iterator cit2(cit);
- EXPECT_TRUE(cit == cit2);
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/DenseSetTest.cpp b/contrib/llvm/unittests/ADT/DenseSetTest.cpp
deleted file mode 100644
index 7a35f52..0000000
--- a/contrib/llvm/unittests/ADT/DenseSetTest.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//===- llvm/unittest/ADT/DenseSetTest.cpp - DenseSet unit tests --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include <llvm/ADT/DenseSet.h>
-
-using namespace llvm;
-
-namespace {
-
-// Test fixture
-class DenseSetTest : public testing::Test {
-};
-
-// Test hashing with a set of only two entries.
-TEST_F(DenseSetTest, DoubleEntrySetTest) {
- llvm::DenseSet<unsigned> set(2);
- set.insert(0);
- set.insert(1);
- // Original failure was an infinite loop in this call:
- EXPECT_EQ(0, set.count(2));
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/ImmutableSetTest.cpp b/contrib/llvm/unittests/ADT/ImmutableSetTest.cpp
deleted file mode 100644
index 1be510d..0000000
--- a/contrib/llvm/unittests/ADT/ImmutableSetTest.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-//===----------- ImmutableSetTest.cpp - ImmutableSet unit tests ------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/ImmutableSet.h"
-
-using namespace llvm;
-
-namespace {
-class ImmutableSetTest : public testing::Test {
-protected:
- // for callback tests
- static char buffer[10];
-
- struct MyIter {
- int counter;
- char *ptr;
-
- MyIter() : counter(0), ptr(buffer) {
- for (unsigned i=0; i<sizeof(buffer);++i) buffer[i]='\0';
- }
- void operator()(char c) {
- *ptr++ = c;
- ++counter;
- }
- };
-};
-char ImmutableSetTest::buffer[10];
-
-
-TEST_F(ImmutableSetTest, EmptyIntSetTest) {
- ImmutableSet<int>::Factory f;
-
- EXPECT_TRUE(f.GetEmptySet() == f.GetEmptySet());
- EXPECT_FALSE(f.GetEmptySet() != f.GetEmptySet());
- EXPECT_TRUE(f.GetEmptySet().isEmpty());
-
- ImmutableSet<int> S = f.GetEmptySet();
- EXPECT_EQ(0u, S.getHeight());
- EXPECT_TRUE(S.begin() == S.end());
- EXPECT_FALSE(S.begin() != S.end());
-}
-
-
-TEST_F(ImmutableSetTest, OneElemIntSetTest) {
- ImmutableSet<int>::Factory f;
- ImmutableSet<int> S = f.GetEmptySet();
-
- ImmutableSet<int> S2 = f.Add(S, 3);
- EXPECT_TRUE(S.isEmpty());
- EXPECT_FALSE(S2.isEmpty());
- EXPECT_FALSE(S == S2);
- EXPECT_TRUE(S != S2);
- EXPECT_FALSE(S.contains(3));
- EXPECT_TRUE(S2.contains(3));
- EXPECT_FALSE(S2.begin() == S2.end());
- EXPECT_TRUE(S2.begin() != S2.end());
-
- ImmutableSet<int> S3 = f.Add(S, 2);
- EXPECT_TRUE(S.isEmpty());
- EXPECT_FALSE(S3.isEmpty());
- EXPECT_FALSE(S == S3);
- EXPECT_TRUE(S != S3);
- EXPECT_FALSE(S.contains(2));
- EXPECT_TRUE(S3.contains(2));
-
- EXPECT_FALSE(S2 == S3);
- EXPECT_TRUE(S2 != S3);
- EXPECT_FALSE(S2.contains(2));
- EXPECT_FALSE(S3.contains(3));
-}
-
-TEST_F(ImmutableSetTest, MultiElemIntSetTest) {
- ImmutableSet<int>::Factory f;
- ImmutableSet<int> S = f.GetEmptySet();
-
- ImmutableSet<int> S2 = f.Add(f.Add(f.Add(S, 3), 4), 5);
- ImmutableSet<int> S3 = f.Add(f.Add(f.Add(S2, 9), 20), 43);
- ImmutableSet<int> S4 = f.Add(S2, 9);
-
- EXPECT_TRUE(S.isEmpty());
- EXPECT_FALSE(S2.isEmpty());
- EXPECT_FALSE(S3.isEmpty());
- EXPECT_FALSE(S4.isEmpty());
-
- EXPECT_FALSE(S.contains(3));
- EXPECT_FALSE(S.contains(9));
-
- EXPECT_TRUE(S2.contains(3));
- EXPECT_TRUE(S2.contains(4));
- EXPECT_TRUE(S2.contains(5));
- EXPECT_FALSE(S2.contains(9));
- EXPECT_FALSE(S2.contains(0));
-
- EXPECT_TRUE(S3.contains(43));
- EXPECT_TRUE(S3.contains(20));
- EXPECT_TRUE(S3.contains(9));
- EXPECT_TRUE(S3.contains(3));
- EXPECT_TRUE(S3.contains(4));
- EXPECT_TRUE(S3.contains(5));
- EXPECT_FALSE(S3.contains(0));
-
- EXPECT_TRUE(S4.contains(9));
- EXPECT_TRUE(S4.contains(3));
- EXPECT_TRUE(S4.contains(4));
- EXPECT_TRUE(S4.contains(5));
- EXPECT_FALSE(S4.contains(20));
- EXPECT_FALSE(S4.contains(43));
-}
-
-TEST_F(ImmutableSetTest, RemoveIntSetTest) {
- ImmutableSet<int>::Factory f;
- ImmutableSet<int> S = f.GetEmptySet();
-
- ImmutableSet<int> S2 = f.Add(f.Add(S, 4), 5);
- ImmutableSet<int> S3 = f.Add(S2, 3);
- ImmutableSet<int> S4 = f.Remove(S3, 3);
-
- EXPECT_TRUE(S3.contains(3));
- EXPECT_FALSE(S2.contains(3));
- EXPECT_FALSE(S4.contains(3));
-
- EXPECT_TRUE(S2 == S4);
- EXPECT_TRUE(S3 != S2);
- EXPECT_TRUE(S3 != S4);
-
- EXPECT_TRUE(S3.contains(4));
- EXPECT_TRUE(S3.contains(5));
-
- EXPECT_TRUE(S4.contains(4));
- EXPECT_TRUE(S4.contains(5));
-}
-
-TEST_F(ImmutableSetTest, CallbackCharSetTest) {
- ImmutableSet<char>::Factory f;
- ImmutableSet<char> S = f.GetEmptySet();
-
- ImmutableSet<char> S2 = f.Add(f.Add(f.Add(S, 'a'), 'e'), 'i');
- ImmutableSet<char> S3 = f.Add(f.Add(S2, 'o'), 'u');
-
- S3.foreach<MyIter>();
-
- ASSERT_STREQ("aeiou", buffer);
-}
-
-TEST_F(ImmutableSetTest, Callback2CharSetTest) {
- ImmutableSet<char>::Factory f;
- ImmutableSet<char> S = f.GetEmptySet();
-
- ImmutableSet<char> S2 = f.Add(f.Add(f.Add(S, 'b'), 'c'), 'd');
- ImmutableSet<char> S3 = f.Add(f.Add(f.Add(S2, 'f'), 'g'), 'h');
-
- MyIter obj;
- S3.foreach<MyIter>(obj);
- ASSERT_STREQ("bcdfgh", buffer);
- ASSERT_EQ(6, obj.counter);
-
- MyIter obj2;
- S2.foreach<MyIter>(obj2);
- ASSERT_STREQ("bcd", buffer);
- ASSERT_EQ(3, obj2.counter);
-
- MyIter obj3;
- S.foreach<MyIter>(obj);
- ASSERT_STREQ("", buffer);
- ASSERT_EQ(0, obj3.counter);
-}
-
-TEST_F(ImmutableSetTest, IterLongSetTest) {
- ImmutableSet<long>::Factory f;
- ImmutableSet<long> S = f.GetEmptySet();
-
- ImmutableSet<long> S2 = f.Add(f.Add(f.Add(S, 0), 1), 2);
- ImmutableSet<long> S3 = f.Add(f.Add(f.Add(S2, 3), 4), 5);
-
- int i = 0;
- for (ImmutableSet<long>::iterator I = S.begin(), E = S.end(); I != E; ++I) {
- ASSERT_EQ(i++, *I);
- }
- ASSERT_EQ(0, i);
-
- i = 0;
- for (ImmutableSet<long>::iterator I = S2.begin(), E = S2.end(); I != E; ++I) {
- ASSERT_EQ(i++, *I);
- }
- ASSERT_EQ(3, i);
-
- i = 0;
- for (ImmutableSet<long>::iterator I = S3.begin(), E = S3.end(); I != E; I++) {
- ASSERT_EQ(i++, *I);
- }
- ASSERT_EQ(6, i);
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/Makefile b/contrib/llvm/unittests/ADT/Makefile
deleted file mode 100644
index fe08328..0000000
--- a/contrib/llvm/unittests/ADT/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-##===- unittests/ADT/Makefile ------------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../..
-TESTNAME = ADT
-LINK_COMPONENTS := core support
-
-include $(LEVEL)/Makefile.config
-
-# Xfail BitVectorTest for now on PPC Darwin. 7598360.
-ifeq ($(ARCH),PowerPC)
-ifeq ($(TARGET_OS),Darwin)
-CPP.Flags += -DXFAIL
-endif
-endif
-
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/contrib/llvm/unittests/ADT/SmallBitVectorTest.cpp b/contrib/llvm/unittests/ADT/SmallBitVectorTest.cpp
deleted file mode 100644
index 9c69aad..0000000
--- a/contrib/llvm/unittests/ADT/SmallBitVectorTest.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-//===- llvm/unittest/ADT/SmallBitVectorTest.cpp - SmallBitVector tests ----===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ADT/SmallBitVector.h"
-#include "gtest/gtest.h"
-
-using namespace llvm;
-
-namespace {
-
-TEST(SmallBitVectorTest, TrivialOperation) {
- SmallBitVector Vec;
- EXPECT_EQ(0U, Vec.count());
- EXPECT_EQ(0U, Vec.size());
- EXPECT_FALSE(Vec.any());
- EXPECT_TRUE(Vec.none());
- EXPECT_TRUE(Vec.empty());
-
- Vec.resize(5, true);
- EXPECT_EQ(5U, Vec.count());
- EXPECT_EQ(5U, Vec.size());
- EXPECT_TRUE(Vec.any());
- EXPECT_FALSE(Vec.none());
- EXPECT_FALSE(Vec.empty());
-
- Vec.resize(11);
- EXPECT_EQ(5U, Vec.count());
- EXPECT_EQ(11U, Vec.size());
- EXPECT_TRUE(Vec.any());
- EXPECT_FALSE(Vec.none());
- EXPECT_FALSE(Vec.empty());
-
- SmallBitVector Inv = ~Vec;
- EXPECT_EQ(6U, Inv.count());
- EXPECT_EQ(11U, Inv.size());
- EXPECT_TRUE(Inv.any());
- EXPECT_FALSE(Inv.none());
- EXPECT_FALSE(Inv.empty());
-
- EXPECT_FALSE(Inv == Vec);
- EXPECT_TRUE(Inv != Vec);
- Vec = ~Vec;
- EXPECT_TRUE(Inv == Vec);
- EXPECT_FALSE(Inv != Vec);
-
- // Add some "interesting" data to Vec.
- Vec.resize(23, true);
- Vec.resize(25, false);
- Vec.resize(26, true);
- Vec.resize(29, false);
- Vec.resize(33, true);
- Vec.resize(57, false);
- unsigned Count = 0;
- for (unsigned i = Vec.find_first(); i != -1u; i = Vec.find_next(i)) {
- ++Count;
- EXPECT_TRUE(Vec[i]);
- EXPECT_TRUE(Vec.test(i));
- }
- EXPECT_EQ(Count, Vec.count());
- EXPECT_EQ(Count, 23u);
- EXPECT_FALSE(Vec[0]);
- EXPECT_TRUE(Vec[32]);
- EXPECT_FALSE(Vec[56]);
- Vec.resize(61, false);
-
- SmallBitVector Copy = Vec;
- SmallBitVector Alt(3, false);
- Alt.resize(6, true);
- std::swap(Alt, Vec);
- EXPECT_TRUE(Copy == Alt);
- EXPECT_TRUE(Vec.size() == 6);
- EXPECT_TRUE(Vec.count() == 3);
- EXPECT_TRUE(Vec.find_first() == 3);
- std::swap(Copy, Vec);
-
- // Add some more "interesting" data.
- Vec.resize(68, true);
- Vec.resize(78, false);
- Vec.resize(89, true);
- Vec.resize(90, false);
- Vec.resize(91, true);
- Vec.resize(130, false);
- Count = 0;
- for (unsigned i = Vec.find_first(); i != -1u; i = Vec.find_next(i)) {
- ++Count;
- EXPECT_TRUE(Vec[i]);
- EXPECT_TRUE(Vec.test(i));
- }
- EXPECT_EQ(Count, Vec.count());
- EXPECT_EQ(Count, 42u);
- EXPECT_FALSE(Vec[0]);
- EXPECT_TRUE(Vec[32]);
- EXPECT_FALSE(Vec[60]);
- EXPECT_FALSE(Vec[129]);
-
- Vec.flip(60);
- EXPECT_TRUE(Vec[60]);
- EXPECT_EQ(Count + 1, Vec.count());
- Vec.flip(60);
- EXPECT_FALSE(Vec[60]);
- EXPECT_EQ(Count, Vec.count());
-
- Vec.reset(32);
- EXPECT_FALSE(Vec[32]);
- EXPECT_EQ(Count - 1, Vec.count());
- Vec.set(32);
- EXPECT_TRUE(Vec[32]);
- EXPECT_EQ(Count, Vec.count());
-
- Vec.flip();
- EXPECT_EQ(Vec.size() - Count, Vec.count());
-
- Vec.reset();
- EXPECT_EQ(0U, Vec.count());
- EXPECT_EQ(130U, Vec.size());
- EXPECT_FALSE(Vec.any());
- EXPECT_TRUE(Vec.none());
- EXPECT_FALSE(Vec.empty());
-
- Inv = ~SmallBitVector();
- EXPECT_EQ(0U, Inv.count());
- EXPECT_EQ(0U, Inv.size());
- EXPECT_FALSE(Inv.any());
- EXPECT_TRUE(Inv.none());
- EXPECT_TRUE(Inv.empty());
-
- Vec.clear();
- EXPECT_EQ(0U, Vec.count());
- EXPECT_EQ(0U, Vec.size());
- EXPECT_FALSE(Vec.any());
- EXPECT_TRUE(Vec.none());
- EXPECT_TRUE(Vec.empty());
-}
-
-TEST(SmallBitVectorTest, CompoundAssignment) {
- SmallBitVector A;
- A.resize(10);
- A.set(4);
- A.set(7);
-
- SmallBitVector B;
- B.resize(50);
- B.set(5);
- B.set(18);
-
- A |= B;
- EXPECT_TRUE(A.test(4));
- EXPECT_TRUE(A.test(5));
- EXPECT_TRUE(A.test(7));
- EXPECT_TRUE(A.test(18));
- EXPECT_EQ(4U, A.count());
- EXPECT_EQ(50U, A.size());
-
- B.resize(10);
- B.set();
- B.reset(2);
- B.reset(7);
- A &= B;
- EXPECT_FALSE(A.test(2));
- EXPECT_FALSE(A.test(7));
- EXPECT_EQ(2U, A.count());
- EXPECT_EQ(50U, A.size());
-
- B.resize(100);
- B.set();
-
- A ^= B;
- EXPECT_TRUE(A.test(2));
- EXPECT_TRUE(A.test(7));
- EXPECT_EQ(98U, A.count());
- EXPECT_EQ(100U, A.size());
-}
-
-TEST(SmallBitVectorTest, ProxyIndex) {
- SmallBitVector Vec(3);
- EXPECT_TRUE(Vec.none());
- Vec[0] = Vec[1] = Vec[2] = true;
- EXPECT_EQ(Vec.size(), Vec.count());
- Vec[2] = Vec[1] = Vec[0] = false;
- EXPECT_TRUE(Vec.none());
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/SmallStringTest.cpp b/contrib/llvm/unittests/ADT/SmallStringTest.cpp
deleted file mode 100644
index 099d815..0000000
--- a/contrib/llvm/unittests/ADT/SmallStringTest.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-//===- llvm/unittest/ADT/SmallStringTest.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// SmallString unit tests.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/SmallString.h"
-#include <stdarg.h>
-#include <climits>
-#include <cstring>
-
-using namespace llvm;
-
-namespace {
-
-// Test fixture class
-class SmallStringTest : public testing::Test {
-protected:
- typedef SmallString<40> StringType;
-
- StringType theString;
-
- void assertEmpty(StringType & v) {
- // Size tests
- EXPECT_EQ(0u, v.size());
- EXPECT_TRUE(v.empty());
- // Iterator tests
- EXPECT_TRUE(v.begin() == v.end());
- }
-};
-
-// New string test.
-TEST_F(SmallStringTest, EmptyStringTest) {
- SCOPED_TRACE("EmptyStringTest");
- assertEmpty(theString);
- EXPECT_TRUE(theString.rbegin() == theString.rend());
-}
-
-}
-
diff --git a/contrib/llvm/unittests/ADT/SmallVectorTest.cpp b/contrib/llvm/unittests/ADT/SmallVectorTest.cpp
deleted file mode 100644
index 991c7d6..0000000
--- a/contrib/llvm/unittests/ADT/SmallVectorTest.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-//===- llvm/unittest/ADT/SmallVectorTest.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// SmallVector unit tests.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/SmallVector.h"
-#include <stdarg.h>
-#include <list>
-
-using namespace llvm;
-
-namespace {
-
-/// A helper class that counts the total number of constructor and
-/// destructor calls.
-class Constructable {
-private:
- static int numConstructorCalls;
- static int numDestructorCalls;
- static int numAssignmentCalls;
-
- int value;
-
-public:
- Constructable() : value(0) {
- ++numConstructorCalls;
- }
-
- Constructable(int val) : value(val) {
- ++numConstructorCalls;
- }
-
- Constructable(const Constructable & src) {
- value = src.value;
- ++numConstructorCalls;
- }
-
- ~Constructable() {
- ++numDestructorCalls;
- }
-
- Constructable & operator=(const Constructable & src) {
- value = src.value;
- ++numAssignmentCalls;
- return *this;
- }
-
- int getValue() const {
- return abs(value);
- }
-
- static void reset() {
- numConstructorCalls = 0;
- numDestructorCalls = 0;
- numAssignmentCalls = 0;
- }
-
- static int getNumConstructorCalls() {
- return numConstructorCalls;
- }
-
- static int getNumDestructorCalls() {
- return numDestructorCalls;
- }
-
- friend bool operator==(const Constructable & c0, const Constructable & c1) {
- return c0.getValue() == c1.getValue();
- }
-
- friend bool operator!=(const Constructable & c0, const Constructable & c1) {
- return c0.getValue() != c1.getValue();
- }
-};
-
-int Constructable::numConstructorCalls;
-int Constructable::numDestructorCalls;
-int Constructable::numAssignmentCalls;
-
-// Test fixture class
-class SmallVectorTest : public testing::Test {
-protected:
- typedef SmallVector<Constructable, 4> VectorType;
-
- VectorType theVector;
- VectorType otherVector;
-
- void SetUp() {
- Constructable::reset();
- }
-
- void assertEmpty(VectorType & v) {
- // Size tests
- EXPECT_EQ(0u, v.size());
- EXPECT_TRUE(v.empty());
-
- // Iterator tests
- EXPECT_TRUE(v.begin() == v.end());
- }
-
- // Assert that theVector contains the specified values, in order.
- void assertValuesInOrder(VectorType & v, size_t size, ...) {
- EXPECT_EQ(size, v.size());
-
- va_list ap;
- va_start(ap, size);
- for (size_t i = 0; i < size; ++i) {
- int value = va_arg(ap, int);
- EXPECT_EQ(value, v[i].getValue());
- }
-
- va_end(ap);
- }
-
- // Generate a sequence of values to initialize the vector.
- void makeSequence(VectorType & v, int start, int end) {
- for (int i = start; i <= end; ++i) {
- v.push_back(Constructable(i));
- }
- }
-};
-
-// New vector test.
-TEST_F(SmallVectorTest, EmptyVectorTest) {
- SCOPED_TRACE("EmptyVectorTest");
- assertEmpty(theVector);
- EXPECT_TRUE(theVector.rbegin() == theVector.rend());
- EXPECT_EQ(0, Constructable::getNumConstructorCalls());
- EXPECT_EQ(0, Constructable::getNumDestructorCalls());
-}
-
-// Simple insertions and deletions.
-TEST_F(SmallVectorTest, PushPopTest) {
- SCOPED_TRACE("PushPopTest");
-
- // Push an element
- theVector.push_back(Constructable(1));
-
- // Size tests
- assertValuesInOrder(theVector, 1u, 1);
- EXPECT_FALSE(theVector.begin() == theVector.end());
- EXPECT_FALSE(theVector.empty());
-
- // Push another element
- theVector.push_back(Constructable(2));
- assertValuesInOrder(theVector, 2u, 1, 2);
-
- // Pop one element
- theVector.pop_back();
- assertValuesInOrder(theVector, 1u, 1);
-
- // Pop another element
- theVector.pop_back();
- assertEmpty(theVector);
-
- // Check number of constructor calls. Should be 2 for each list element,
- // one for the argument to push_back, and one for the list element itself.
- EXPECT_EQ(4, Constructable::getNumConstructorCalls());
- EXPECT_EQ(4, Constructable::getNumDestructorCalls());
-}
-
-// Clear test.
-TEST_F(SmallVectorTest, ClearTest) {
- SCOPED_TRACE("ClearTest");
-
- makeSequence(theVector, 1, 2);
- theVector.clear();
-
- assertEmpty(theVector);
- EXPECT_EQ(4, Constructable::getNumConstructorCalls());
- EXPECT_EQ(4, Constructable::getNumDestructorCalls());
-}
-
-// Resize smaller test.
-TEST_F(SmallVectorTest, ResizeShrinkTest) {
- SCOPED_TRACE("ResizeShrinkTest");
-
- makeSequence(theVector, 1, 3);
- theVector.resize(1);
-
- assertValuesInOrder(theVector, 1u, 1);
- EXPECT_EQ(6, Constructable::getNumConstructorCalls());
- EXPECT_EQ(5, Constructable::getNumDestructorCalls());
-}
-
-// Resize bigger test.
-TEST_F(SmallVectorTest, ResizeGrowTest) {
- SCOPED_TRACE("ResizeGrowTest");
-
- theVector.resize(2);
-
- // The extra constructor/destructor calls come from the temporary object used
- // to initialize the contents of the resized array (via copy construction).
- EXPECT_EQ(3, Constructable::getNumConstructorCalls());
- EXPECT_EQ(1, Constructable::getNumDestructorCalls());
- EXPECT_EQ(2u, theVector.size());
-}
-
-// Resize with fill value.
-TEST_F(SmallVectorTest, ResizeFillTest) {
- SCOPED_TRACE("ResizeFillTest");
-
- theVector.resize(3, Constructable(77));
- assertValuesInOrder(theVector, 3u, 77, 77, 77);
-}
-
-// Overflow past fixed size.
-TEST_F(SmallVectorTest, OverflowTest) {
- SCOPED_TRACE("OverflowTest");
-
- // Push more elements than the fixed size.
- makeSequence(theVector, 1, 10);
-
- // Test size and values.
- EXPECT_EQ(10u, theVector.size());
- for (int i = 0; i < 10; ++i) {
- EXPECT_EQ(i+1, theVector[i].getValue());
- }
-
- // Now resize back to fixed size.
- theVector.resize(1);
-
- assertValuesInOrder(theVector, 1u, 1);
-}
-
-// Iteration tests.
-TEST_F(SmallVectorTest, IterationTest) {
- makeSequence(theVector, 1, 2);
-
- // Forward Iteration
- VectorType::iterator it = theVector.begin();
- EXPECT_TRUE(*it == theVector.front());
- EXPECT_TRUE(*it == theVector[0]);
- EXPECT_EQ(1, it->getValue());
- ++it;
- EXPECT_TRUE(*it == theVector[1]);
- EXPECT_TRUE(*it == theVector.back());
- EXPECT_EQ(2, it->getValue());
- ++it;
- EXPECT_TRUE(it == theVector.end());
- --it;
- EXPECT_TRUE(*it == theVector[1]);
- EXPECT_EQ(2, it->getValue());
- --it;
- EXPECT_TRUE(*it == theVector[0]);
- EXPECT_EQ(1, it->getValue());
-
- // Reverse Iteration
- VectorType::reverse_iterator rit = theVector.rbegin();
- EXPECT_TRUE(*rit == theVector[1]);
- EXPECT_EQ(2, rit->getValue());
- ++rit;
- EXPECT_TRUE(*rit == theVector[0]);
- EXPECT_EQ(1, rit->getValue());
- ++rit;
- EXPECT_TRUE(rit == theVector.rend());
- --rit;
- EXPECT_TRUE(*rit == theVector[0]);
- EXPECT_EQ(1, rit->getValue());
- --rit;
- EXPECT_TRUE(*rit == theVector[1]);
- EXPECT_EQ(2, rit->getValue());
-}
-
-// Swap test.
-TEST_F(SmallVectorTest, SwapTest) {
- SCOPED_TRACE("SwapTest");
-
- makeSequence(theVector, 1, 2);
- std::swap(theVector, otherVector);
-
- assertEmpty(theVector);
- assertValuesInOrder(otherVector, 2u, 1, 2);
-}
-
-// Append test
-TEST_F(SmallVectorTest, AppendTest) {
- SCOPED_TRACE("AppendTest");
-
- makeSequence(otherVector, 2, 3);
-
- theVector.push_back(Constructable(1));
- theVector.append(otherVector.begin(), otherVector.end());
-
- assertValuesInOrder(theVector, 3u, 1, 2, 3);
-}
-
-// Append repeated test
-TEST_F(SmallVectorTest, AppendRepeatedTest) {
- SCOPED_TRACE("AppendRepeatedTest");
-
- theVector.push_back(Constructable(1));
- theVector.append(2, Constructable(77));
- assertValuesInOrder(theVector, 3u, 1, 77, 77);
-}
-
-// Assign test
-TEST_F(SmallVectorTest, AssignTest) {
- SCOPED_TRACE("AssignTest");
-
- theVector.push_back(Constructable(1));
- theVector.assign(2, Constructable(77));
- assertValuesInOrder(theVector, 2u, 77, 77);
-}
-
-// Erase a single element
-TEST_F(SmallVectorTest, EraseTest) {
- SCOPED_TRACE("EraseTest");
-
- makeSequence(theVector, 1, 3);
- theVector.erase(theVector.begin());
- assertValuesInOrder(theVector, 2u, 2, 3);
-}
-
-// Erase a range of elements
-TEST_F(SmallVectorTest, EraseRangeTest) {
- SCOPED_TRACE("EraseRangeTest");
-
- makeSequence(theVector, 1, 3);
- theVector.erase(theVector.begin(), theVector.begin() + 2);
- assertValuesInOrder(theVector, 1u, 3);
-}
-
-// Insert a single element.
-TEST_F(SmallVectorTest, InsertTest) {
- SCOPED_TRACE("InsertTest");
-
- makeSequence(theVector, 1, 3);
- theVector.insert(theVector.begin() + 1, Constructable(77));
- assertValuesInOrder(theVector, 4u, 1, 77, 2, 3);
-}
-
-// Insert repeated elements.
-TEST_F(SmallVectorTest, InsertRepeatedTest) {
- SCOPED_TRACE("InsertRepeatedTest");
-
- makeSequence(theVector, 10, 15);
- theVector.insert(theVector.begin() + 1, 2, Constructable(16));
- assertValuesInOrder(theVector, 8u, 10, 16, 16, 11, 12, 13, 14, 15);
-}
-
-// Insert range.
-TEST_F(SmallVectorTest, InsertRangeTest) {
- SCOPED_TRACE("InsertRepeatedTest");
-
- makeSequence(theVector, 1, 3);
- theVector.insert(theVector.begin() + 1, 3, Constructable(77));
- assertValuesInOrder(theVector, 6u, 1, 77, 77, 77, 2, 3);
-}
-
-// Comparison tests.
-TEST_F(SmallVectorTest, ComparisonTest) {
- SCOPED_TRACE("ComparisonTest");
-
- makeSequence(theVector, 1, 3);
- makeSequence(otherVector, 1, 3);
-
- EXPECT_TRUE(theVector == otherVector);
- EXPECT_FALSE(theVector != otherVector);
-
- otherVector.clear();
- makeSequence(otherVector, 2, 4);
-
- EXPECT_FALSE(theVector == otherVector);
- EXPECT_TRUE(theVector != otherVector);
-}
-
-// Constant vector tests.
-TEST_F(SmallVectorTest, ConstVectorTest) {
- const VectorType constVector;
-
- EXPECT_EQ(0u, constVector.size());
- EXPECT_TRUE(constVector.empty());
- EXPECT_TRUE(constVector.begin() == constVector.end());
-}
-
-// Direct array access.
-TEST_F(SmallVectorTest, DirectVectorTest) {
- EXPECT_EQ(0u, theVector.size());
- EXPECT_LE(4u, theVector.capacity());
- EXPECT_EQ(0, Constructable::getNumConstructorCalls());
- theVector.end()[0] = 1;
- theVector.end()[1] = 2;
- theVector.end()[2] = 3;
- theVector.end()[3] = 4;
- theVector.set_size(4);
- EXPECT_EQ(4u, theVector.size());
- EXPECT_EQ(4, Constructable::getNumConstructorCalls());
- EXPECT_EQ(1, theVector[0].getValue());
- EXPECT_EQ(2, theVector[1].getValue());
- EXPECT_EQ(3, theVector[2].getValue());
- EXPECT_EQ(4, theVector[3].getValue());
-}
-
-TEST_F(SmallVectorTest, IteratorTest) {
- std::list<int> L;
- theVector.insert(theVector.end(), L.begin(), L.end());
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/SparseBitVectorTest.cpp b/contrib/llvm/unittests/ADT/SparseBitVectorTest.cpp
deleted file mode 100644
index d8fc5ce..0000000
--- a/contrib/llvm/unittests/ADT/SparseBitVectorTest.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//===- llvm/unittest/ADT/SparseBitVectorTest.cpp - SparseBitVector tests --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ADT/SparseBitVector.h"
-#include "gtest/gtest.h"
-
-using namespace llvm;
-
-namespace {
-
-TEST(SparseBitVectorTest, TrivialOperation) {
- SparseBitVector<> Vec;
- EXPECT_EQ(0U, Vec.count());
- EXPECT_FALSE(Vec.test(17));
- Vec.set(5);
- EXPECT_TRUE(Vec.test(5));
- EXPECT_FALSE(Vec.test(17));
- Vec.reset(6);
- EXPECT_TRUE(Vec.test(5));
- EXPECT_FALSE(Vec.test(6));
- Vec.reset(5);
- EXPECT_FALSE(Vec.test(5));
- EXPECT_TRUE(Vec.test_and_set(17));
- EXPECT_FALSE(Vec.test_and_set(17));
- EXPECT_TRUE(Vec.test(17));
- Vec.clear();
- EXPECT_FALSE(Vec.test(17));
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/StringMapTest.cpp b/contrib/llvm/unittests/ADT/StringMapTest.cpp
deleted file mode 100644
index 413f068..0000000
--- a/contrib/llvm/unittests/ADT/StringMapTest.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-//===- llvm/unittest/ADT/StringMapMap.cpp - StringMap unit tests ----------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/System/DataTypes.h"
-using namespace llvm;
-
-namespace {
-
-// Test fixture
-class StringMapTest : public testing::Test {
-protected:
- StringMap<uint32_t> testMap;
-
- static const char testKey[];
- static const uint32_t testValue;
- static const char* testKeyFirst;
- static size_t testKeyLength;
- static const std::string testKeyStr;
-
- void assertEmptyMap() {
- // Size tests
- EXPECT_EQ(0u, testMap.size());
- EXPECT_TRUE(testMap.empty());
-
- // Iterator tests
- EXPECT_TRUE(testMap.begin() == testMap.end());
-
- // Lookup tests
- EXPECT_EQ(0u, testMap.count(testKey));
- EXPECT_EQ(0u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
- EXPECT_EQ(0u, testMap.count(testKeyStr));
- EXPECT_TRUE(testMap.find(testKey) == testMap.end());
- EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
- testMap.end());
- EXPECT_TRUE(testMap.find(testKeyStr) == testMap.end());
- }
-
- void assertSingleItemMap() {
- // Size tests
- EXPECT_EQ(1u, testMap.size());
- EXPECT_FALSE(testMap.begin() == testMap.end());
- EXPECT_FALSE(testMap.empty());
-
- // Iterator tests
- StringMap<uint32_t>::iterator it = testMap.begin();
- EXPECT_STREQ(testKey, it->first());
- EXPECT_EQ(testValue, it->second);
- ++it;
- EXPECT_TRUE(it == testMap.end());
-
- // Lookup tests
- EXPECT_EQ(1u, testMap.count(testKey));
- EXPECT_EQ(1u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
- EXPECT_EQ(1u, testMap.count(testKeyStr));
- EXPECT_TRUE(testMap.find(testKey) == testMap.begin());
- EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
- testMap.begin());
- EXPECT_TRUE(testMap.find(testKeyStr) == testMap.begin());
- }
-};
-
-const char StringMapTest::testKey[] = "key";
-const uint32_t StringMapTest::testValue = 1u;
-const char* StringMapTest::testKeyFirst = testKey;
-size_t StringMapTest::testKeyLength = sizeof(testKey) - 1;
-const std::string StringMapTest::testKeyStr(testKey);
-
-// Empty map tests.
-TEST_F(StringMapTest, EmptyMapTest) {
- SCOPED_TRACE("EmptyMapTest");
- assertEmptyMap();
-}
-
-// Constant map tests.
-TEST_F(StringMapTest, ConstEmptyMapTest) {
- const StringMap<uint32_t>& constTestMap = testMap;
-
- // Size tests
- EXPECT_EQ(0u, constTestMap.size());
- EXPECT_TRUE(constTestMap.empty());
-
- // Iterator tests
- EXPECT_TRUE(constTestMap.begin() == constTestMap.end());
-
- // Lookup tests
- EXPECT_EQ(0u, constTestMap.count(testKey));
- EXPECT_EQ(0u, constTestMap.count(StringRef(testKeyFirst, testKeyLength)));
- EXPECT_EQ(0u, constTestMap.count(testKeyStr));
- EXPECT_TRUE(constTestMap.find(testKey) == constTestMap.end());
- EXPECT_TRUE(constTestMap.find(StringRef(testKeyFirst, testKeyLength)) ==
- constTestMap.end());
- EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end());
-}
-
-// A map with a single entry.
-TEST_F(StringMapTest, SingleEntryMapTest) {
- SCOPED_TRACE("SingleEntryMapTest");
- testMap[testKey] = testValue;
- assertSingleItemMap();
-}
-
-// Test clear() method.
-TEST_F(StringMapTest, ClearTest) {
- SCOPED_TRACE("ClearTest");
- testMap[testKey] = testValue;
- testMap.clear();
- assertEmptyMap();
-}
-
-// Test erase(iterator) method.
-TEST_F(StringMapTest, EraseIteratorTest) {
- SCOPED_TRACE("EraseIteratorTest");
- testMap[testKey] = testValue;
- testMap.erase(testMap.begin());
- assertEmptyMap();
-}
-
-// Test erase(value) method.
-TEST_F(StringMapTest, EraseValueTest) {
- SCOPED_TRACE("EraseValueTest");
- testMap[testKey] = testValue;
- testMap.erase(testKey);
- assertEmptyMap();
-}
-
-// Test inserting two values and erasing one.
-TEST_F(StringMapTest, InsertAndEraseTest) {
- SCOPED_TRACE("InsertAndEraseTest");
- testMap[testKey] = testValue;
- testMap["otherKey"] = 2;
- testMap.erase("otherKey");
- assertSingleItemMap();
-}
-
-// A more complex iteration test.
-TEST_F(StringMapTest, IterationTest) {
- bool visited[100];
-
- // Insert 100 numbers into the map
- for (int i = 0; i < 100; ++i) {
- std::stringstream ss;
- ss << "key_" << i;
- testMap[ss.str()] = i;
- visited[i] = false;
- }
-
- // Iterate over all numbers and mark each one found.
- for (StringMap<uint32_t>::iterator it = testMap.begin();
- it != testMap.end(); ++it) {
- std::stringstream ss;
- ss << "key_" << it->second;
- ASSERT_STREQ(ss.str().c_str(), it->first());
- visited[it->second] = true;
- }
-
- // Ensure every number was visited.
- for (int i = 0; i < 100; ++i) {
- ASSERT_TRUE(visited[i]) << "Entry #" << i << " was never visited";
- }
-}
-
-} // end anonymous namespace
-
-namespace llvm {
-
-template <>
-class StringMapEntryInitializer<uint32_t> {
-public:
- template <typename InitTy>
- static void Initialize(StringMapEntry<uint32_t> &T, InitTy InitVal) {
- T.second = InitVal;
- }
-};
-
-} // end llvm namespace
-
-namespace {
-
-// Test StringMapEntry::Create() method.
-TEST_F(StringMapTest, StringMapEntryTest) {
- StringMap<uint32_t>::value_type* entry =
- StringMap<uint32_t>::value_type::Create(
- testKeyFirst, testKeyFirst + testKeyLength, 1u);
- EXPECT_STREQ(testKey, entry->first());
- EXPECT_EQ(1u, entry->second);
- free(entry);
-}
-
-// Test insert() method.
-TEST_F(StringMapTest, InsertTest) {
- SCOPED_TRACE("InsertTest");
- testMap.insert(
- StringMap<uint32_t>::value_type::Create(
- testKeyFirst, testKeyFirst + testKeyLength,
- testMap.getAllocator(), 1u));
- assertSingleItemMap();
-}
-
-} // end anonymous namespace
diff --git a/contrib/llvm/unittests/ADT/StringRefTest.cpp b/contrib/llvm/unittests/ADT/StringRefTest.cpp
deleted file mode 100644
index 887ba5d..0000000
--- a/contrib/llvm/unittests/ADT/StringRefTest.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-//===- llvm/unittest/ADT/StringRefTest.cpp - StringRef unit tests ---------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
-
-namespace llvm {
-
-std::ostream &operator<<(std::ostream &OS, const StringRef &S) {
- OS << S;
- return OS;
-}
-
-std::ostream &operator<<(std::ostream &OS,
- const std::pair<StringRef, StringRef> &P) {
- OS << "(" << P.first << ", " << P.second << ")";
- return OS;
-}
-
-}
-
-namespace {
-TEST(StringRefTest, Construction) {
- EXPECT_EQ("", StringRef());
- EXPECT_EQ("hello", StringRef("hello"));
- EXPECT_EQ("hello", StringRef("hello world", 5));
- EXPECT_EQ("hello", StringRef(std::string("hello")));
-}
-
-TEST(StringRefTest, Iteration) {
- StringRef S("hello");
- const char *p = "hello";
- for (const char *it = S.begin(), *ie = S.end(); it != ie; ++it, ++p)
- EXPECT_EQ(*it, *p);
-}
-
-TEST(StringRefTest, StringOps) {
- const char *p = "hello";
- EXPECT_EQ(p, StringRef(p, 0).data());
- EXPECT_TRUE(StringRef().empty());
- EXPECT_EQ((size_t) 5, StringRef("hello").size());
- EXPECT_EQ(-1, StringRef("aab").compare("aad"));
- EXPECT_EQ( 0, StringRef("aab").compare("aab"));
- EXPECT_EQ( 1, StringRef("aab").compare("aaa"));
- EXPECT_EQ(-1, StringRef("aab").compare("aabb"));
- EXPECT_EQ( 1, StringRef("aab").compare("aa"));
-
- EXPECT_EQ(-1, StringRef("aab").compare_numeric("aad"));
- EXPECT_EQ( 0, StringRef("aab").compare_numeric("aab"));
- EXPECT_EQ( 1, StringRef("aab").compare_numeric("aaa"));
- EXPECT_EQ(-1, StringRef("aab").compare_numeric("aabb"));
- EXPECT_EQ( 1, StringRef("aab").compare_numeric("aa"));
- EXPECT_EQ(-1, StringRef("1").compare_numeric("10"));
- EXPECT_EQ( 0, StringRef("10").compare_numeric("10"));
- EXPECT_EQ( 0, StringRef("10a").compare_numeric("10a"));
- EXPECT_EQ( 1, StringRef("2").compare_numeric("1"));
- EXPECT_EQ( 0, StringRef("llvm_v1i64_ty").compare_numeric("llvm_v1i64_ty"));
-}
-
-TEST(StringRefTest, Operators) {
- EXPECT_EQ("", StringRef());
- EXPECT_TRUE(StringRef("aab") < StringRef("aad"));
- EXPECT_FALSE(StringRef("aab") < StringRef("aab"));
- EXPECT_TRUE(StringRef("aab") <= StringRef("aab"));
- EXPECT_FALSE(StringRef("aab") <= StringRef("aaa"));
- EXPECT_TRUE(StringRef("aad") > StringRef("aab"));
- EXPECT_FALSE(StringRef("aab") > StringRef("aab"));
- EXPECT_TRUE(StringRef("aab") >= StringRef("aab"));
- EXPECT_FALSE(StringRef("aaa") >= StringRef("aab"));
- EXPECT_EQ(StringRef("aab"), StringRef("aab"));
- EXPECT_FALSE(StringRef("aab") == StringRef("aac"));
- EXPECT_FALSE(StringRef("aab") != StringRef("aab"));
- EXPECT_TRUE(StringRef("aab") != StringRef("aac"));
- EXPECT_EQ('a', StringRef("aab")[1]);
-}
-
-TEST(StringRefTest, Substr) {
- StringRef Str("hello");
- EXPECT_EQ("lo", Str.substr(3));
- EXPECT_EQ("", Str.substr(100));
- EXPECT_EQ("hello", Str.substr(0, 100));
- EXPECT_EQ("o", Str.substr(4, 10));
-}
-
-TEST(StringRefTest, Slice) {
- StringRef Str("hello");
- EXPECT_EQ("l", Str.slice(2, 3));
- EXPECT_EQ("ell", Str.slice(1, 4));
- EXPECT_EQ("llo", Str.slice(2, 100));
- EXPECT_EQ("", Str.slice(2, 1));
- EXPECT_EQ("", Str.slice(10, 20));
-}
-
-TEST(StringRefTest, Split) {
- StringRef Str("hello");
- EXPECT_EQ(std::make_pair(StringRef("hello"), StringRef("")),
- Str.split('X'));
- EXPECT_EQ(std::make_pair(StringRef("h"), StringRef("llo")),
- Str.split('e'));
- EXPECT_EQ(std::make_pair(StringRef(""), StringRef("ello")),
- Str.split('h'));
- EXPECT_EQ(std::make_pair(StringRef("he"), StringRef("lo")),
- Str.split('l'));
- EXPECT_EQ(std::make_pair(StringRef("hell"), StringRef("")),
- Str.split('o'));
-
- EXPECT_EQ(std::make_pair(StringRef("hello"), StringRef("")),
- Str.rsplit('X'));
- EXPECT_EQ(std::make_pair(StringRef("h"), StringRef("llo")),
- Str.rsplit('e'));
- EXPECT_EQ(std::make_pair(StringRef(""), StringRef("ello")),
- Str.rsplit('h'));
- EXPECT_EQ(std::make_pair(StringRef("hel"), StringRef("o")),
- Str.rsplit('l'));
- EXPECT_EQ(std::make_pair(StringRef("hell"), StringRef("")),
- Str.rsplit('o'));
-}
-
-TEST(StringRefTest, Split2) {
- SmallVector<StringRef, 5> parts;
- SmallVector<StringRef, 5> expected;
-
- expected.push_back("ab"); expected.push_back("c");
- StringRef(",ab,,c,").split(parts, ",", -1, false);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back(""); expected.push_back("ab"); expected.push_back("");
- expected.push_back("c"); expected.push_back("");
- StringRef(",ab,,c,").split(parts, ",", -1, true);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("");
- StringRef("").split(parts, ",", -1, true);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- StringRef("").split(parts, ",", -1, false);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- StringRef(",").split(parts, ",", -1, false);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back(""); expected.push_back("");
- StringRef(",").split(parts, ",", -1, true);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a"); expected.push_back("b");
- StringRef("a,b").split(parts, ",", -1, true);
- EXPECT_TRUE(parts == expected);
-
- // Test MaxSplit
- expected.clear(); parts.clear();
- expected.push_back("a,,b,c");
- StringRef("a,,b,c").split(parts, ",", 0, true);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a,,b,c");
- StringRef("a,,b,c").split(parts, ",", 0, false);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a"); expected.push_back(",b,c");
- StringRef("a,,b,c").split(parts, ",", 1, true);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a"); expected.push_back(",b,c");
- StringRef("a,,b,c").split(parts, ",", 1, false);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a"); expected.push_back(""); expected.push_back("b,c");
- StringRef("a,,b,c").split(parts, ",", 2, true);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a"); expected.push_back("b,c");
- StringRef("a,,b,c").split(parts, ",", 2, false);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a"); expected.push_back(""); expected.push_back("b");
- expected.push_back("c");
- StringRef("a,,b,c").split(parts, ",", 3, true);
- EXPECT_TRUE(parts == expected);
-
- expected.clear(); parts.clear();
- expected.push_back("a"); expected.push_back("b"); expected.push_back("c");
- StringRef("a,,b,c").split(parts, ",", 3, false);
- EXPECT_TRUE(parts == expected);
-}
-
-TEST(StringRefTest, StartsWith) {
- StringRef Str("hello");
- EXPECT_TRUE(Str.startswith("he"));
- EXPECT_FALSE(Str.startswith("helloworld"));
- EXPECT_FALSE(Str.startswith("hi"));
-}
-
-TEST(StringRefTest, EndsWith) {
- StringRef Str("hello");
- EXPECT_TRUE(Str.endswith("lo"));
- EXPECT_FALSE(Str.endswith("helloworld"));
- EXPECT_FALSE(Str.endswith("worldhello"));
- EXPECT_FALSE(Str.endswith("so"));
-}
-
-TEST(StringRefTest, Find) {
- StringRef Str("hello");
- EXPECT_EQ(2U, Str.find('l'));
- EXPECT_EQ(StringRef::npos, Str.find('z'));
- EXPECT_EQ(StringRef::npos, Str.find("helloworld"));
- EXPECT_EQ(0U, Str.find("hello"));
- EXPECT_EQ(1U, Str.find("ello"));
- EXPECT_EQ(StringRef::npos, Str.find("zz"));
- EXPECT_EQ(2U, Str.find("ll", 2));
- EXPECT_EQ(StringRef::npos, Str.find("ll", 3));
-
- EXPECT_EQ(3U, Str.rfind('l'));
- EXPECT_EQ(StringRef::npos, Str.rfind('z'));
- EXPECT_EQ(StringRef::npos, Str.rfind("helloworld"));
- EXPECT_EQ(0U, Str.rfind("hello"));
- EXPECT_EQ(1U, Str.rfind("ello"));
- EXPECT_EQ(StringRef::npos, Str.rfind("zz"));
-
- EXPECT_EQ(2U, Str.find_first_of('l'));
- EXPECT_EQ(1U, Str.find_first_of("el"));
- EXPECT_EQ(StringRef::npos, Str.find_first_of("xyz"));
-
- EXPECT_EQ(1U, Str.find_first_not_of('h'));
- EXPECT_EQ(4U, Str.find_first_not_of("hel"));
- EXPECT_EQ(StringRef::npos, Str.find_first_not_of("hello"));
-}
-
-TEST(StringRefTest, Count) {
- StringRef Str("hello");
- EXPECT_EQ(2U, Str.count('l'));
- EXPECT_EQ(1U, Str.count('o'));
- EXPECT_EQ(0U, Str.count('z'));
- EXPECT_EQ(0U, Str.count("helloworld"));
- EXPECT_EQ(1U, Str.count("hello"));
- EXPECT_EQ(1U, Str.count("ello"));
- EXPECT_EQ(0U, Str.count("zz"));
-}
-
-TEST(StringRefTest, EditDistance) {
- StringRef Str("hello");
- EXPECT_EQ(2U, Str.edit_distance("hill"));
-}
-
-TEST(StringRefTest, Misc) {
- std::string Storage;
- raw_string_ostream OS(Storage);
- OS << StringRef("hello");
- EXPECT_EQ("hello", OS.str());
-}
-
-} // end anonymous namespace
diff --git a/contrib/llvm/unittests/ADT/TripleTest.cpp b/contrib/llvm/unittests/ADT/TripleTest.cpp
deleted file mode 100644
index 1a9e81a..0000000
--- a/contrib/llvm/unittests/ADT/TripleTest.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-//===----------- Triple.cpp - Triple unit tests ---------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/Triple.h"
-
-using namespace llvm;
-
-namespace {
-
-TEST(TripleTest, BasicParsing) {
- Triple T;
-
- T = Triple("");
- EXPECT_EQ("", T.getArchName().str());
- EXPECT_EQ("", T.getVendorName().str());
- EXPECT_EQ("", T.getOSName().str());
- EXPECT_EQ("", T.getEnvironmentName().str());
-
- T = Triple("-");
- EXPECT_EQ("", T.getArchName().str());
- EXPECT_EQ("", T.getVendorName().str());
- EXPECT_EQ("", T.getOSName().str());
- EXPECT_EQ("", T.getEnvironmentName().str());
-
- T = Triple("--");
- EXPECT_EQ("", T.getArchName().str());
- EXPECT_EQ("", T.getVendorName().str());
- EXPECT_EQ("", T.getOSName().str());
- EXPECT_EQ("", T.getEnvironmentName().str());
-
- T = Triple("---");
- EXPECT_EQ("", T.getArchName().str());
- EXPECT_EQ("", T.getVendorName().str());
- EXPECT_EQ("", T.getOSName().str());
- EXPECT_EQ("", T.getEnvironmentName().str());
-
- T = Triple("----");
- EXPECT_EQ("", T.getArchName().str());
- EXPECT_EQ("", T.getVendorName().str());
- EXPECT_EQ("", T.getOSName().str());
- EXPECT_EQ("-", T.getEnvironmentName().str());
-
- T = Triple("a");
- EXPECT_EQ("a", T.getArchName().str());
- EXPECT_EQ("", T.getVendorName().str());
- EXPECT_EQ("", T.getOSName().str());
- EXPECT_EQ("", T.getEnvironmentName().str());
-
- T = Triple("a-b");
- EXPECT_EQ("a", T.getArchName().str());
- EXPECT_EQ("b", T.getVendorName().str());
- EXPECT_EQ("", T.getOSName().str());
- EXPECT_EQ("", T.getEnvironmentName().str());
-
- T = Triple("a-b-c");
- EXPECT_EQ("a", T.getArchName().str());
- EXPECT_EQ("b", T.getVendorName().str());
- EXPECT_EQ("c", T.getOSName().str());
- EXPECT_EQ("", T.getEnvironmentName().str());
-
- T = Triple("a-b-c-d");
- EXPECT_EQ("a", T.getArchName().str());
- EXPECT_EQ("b", T.getVendorName().str());
- EXPECT_EQ("c", T.getOSName().str());
- EXPECT_EQ("d", T.getEnvironmentName().str());
-}
-
-TEST(TripleTest, ParsedIDs) {
- Triple T;
-
- T = Triple("i386-apple-darwin");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ(Triple::Apple, T.getVendor());
- EXPECT_EQ(Triple::Darwin, T.getOS());
-
- T = Triple("x86_64-pc-linux-gnu");
- EXPECT_EQ(Triple::x86_64, T.getArch());
- EXPECT_EQ(Triple::PC, T.getVendor());
- EXPECT_EQ(Triple::Linux, T.getOS());
-
- T = Triple("powerpc-dunno-notsure");
- EXPECT_EQ(Triple::ppc, T.getArch());
- EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
- EXPECT_EQ(Triple::UnknownOS, T.getOS());
-
- T = Triple("huh");
- EXPECT_EQ(Triple::UnknownArch, T.getArch());
-
- // Two exceptional cases.
-
- T = Triple("i386-mingw32");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ(Triple::PC, T.getVendor());
- EXPECT_EQ(Triple::MinGW32, T.getOS());
-
- T = Triple("arm-elf");
- EXPECT_EQ(Triple::arm, T.getArch());
- EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
- EXPECT_EQ(Triple::UnknownOS, T.getOS());
-}
-
-TEST(TripleTest, MutateName) {
- Triple T;
- EXPECT_EQ(Triple::UnknownArch, T.getArch());
- EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
- EXPECT_EQ(Triple::UnknownOS, T.getOS());
-
- T.setArchName("i386");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ("i386--", T.getTriple());
-
- T.setVendorName("pc");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ(Triple::PC, T.getVendor());
- EXPECT_EQ("i386-pc-", T.getTriple());
-
- T.setOSName("linux");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ(Triple::PC, T.getVendor());
- EXPECT_EQ(Triple::Linux, T.getOS());
- EXPECT_EQ("i386-pc-linux", T.getTriple());
-
- T.setEnvironmentName("gnu");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ(Triple::PC, T.getVendor());
- EXPECT_EQ(Triple::Linux, T.getOS());
- EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
-
- T.setOSName("freebsd");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ(Triple::PC, T.getVendor());
- EXPECT_EQ(Triple::FreeBSD, T.getOS());
- EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
-
- T.setOSAndEnvironmentName("darwin");
- EXPECT_EQ(Triple::x86, T.getArch());
- EXPECT_EQ(Triple::PC, T.getVendor());
- EXPECT_EQ(Triple::Darwin, T.getOS());
- EXPECT_EQ("i386-pc-darwin", T.getTriple());
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/TwineTest.cpp b/contrib/llvm/unittests/ADT/TwineTest.cpp
deleted file mode 100644
index 61e8a0a..0000000
--- a/contrib/llvm/unittests/ADT/TwineTest.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//===- TwineTest.cpp - Twine unit tests -----------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
-
-namespace {
-
-std::string repr(const Twine &Value) {
- std::string res;
- llvm::raw_string_ostream OS(res);
- Value.printRepr(OS);
- return OS.str();
-}
-
-TEST(TwineTest, Construction) {
- EXPECT_EQ("", Twine().str());
- EXPECT_EQ("hi", Twine("hi").str());
- EXPECT_EQ("hi", Twine(std::string("hi")).str());
- EXPECT_EQ("hi", Twine(StringRef("hi")).str());
- EXPECT_EQ("hi", Twine(StringRef(std::string("hi"))).str());
- EXPECT_EQ("hi", Twine(StringRef("hithere", 2)).str());
-}
-
-TEST(TwineTest, Numbers) {
- EXPECT_EQ("123", Twine(123U).str());
- EXPECT_EQ("123", Twine(123).str());
- EXPECT_EQ("-123", Twine(-123).str());
- EXPECT_EQ("123", Twine(123).str());
- EXPECT_EQ("-123", Twine(-123).str());
- EXPECT_EQ("123", Twine((char) 123).str());
- EXPECT_EQ("-123", Twine((signed char) -123).str());
-
- EXPECT_EQ("7b", Twine::utohexstr(123).str());
-}
-
-TEST(TwineTest, Concat) {
- // Check verse repr, since we care about the actual representation not just
- // the result.
-
- // Concat with null.
- EXPECT_EQ("(Twine null empty)",
- repr(Twine("hi").concat(Twine::createNull())));
- EXPECT_EQ("(Twine null empty)",
- repr(Twine::createNull().concat(Twine("hi"))));
-
- // Concat with empty.
- EXPECT_EQ("(Twine cstring:\"hi\" empty)",
- repr(Twine("hi").concat(Twine())));
- EXPECT_EQ("(Twine cstring:\"hi\" empty)",
- repr(Twine().concat(Twine("hi"))));
-
- // Concatenation of unary ropes.
- EXPECT_EQ("(Twine cstring:\"a\" cstring:\"b\")",
- repr(Twine("a").concat(Twine("b"))));
-
- // Concatenation of other ropes.
- EXPECT_EQ("(Twine rope:(Twine cstring:\"a\" cstring:\"b\") cstring:\"c\")",
- repr(Twine("a").concat(Twine("b")).concat(Twine("c"))));
- EXPECT_EQ("(Twine cstring:\"a\" rope:(Twine cstring:\"b\" cstring:\"c\"))",
- repr(Twine("a").concat(Twine("b").concat(Twine("c")))));
-}
-
- // I suppose linking in the entire code generator to add a unit test to check
- // the code size of the concat operation is overkill... :)
-
-} // end anonymous namespace
diff --git a/contrib/llvm/unittests/ADT/ValueMapTest.cpp b/contrib/llvm/unittests/ADT/ValueMapTest.cpp
deleted file mode 100644
index 2fc0938..0000000
--- a/contrib/llvm/unittests/ADT/ValueMapTest.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-//===- llvm/unittest/ADT/ValueMapTest.cpp - ValueMap unit tests -*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ADT/ValueMap.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/Config/config.h"
-
-#include "gtest/gtest.h"
-
-using namespace llvm;
-
-namespace {
-
-// Test fixture
-template<typename T>
-class ValueMapTest : public testing::Test {
-protected:
- Constant *ConstantV;
- OwningPtr<BitCastInst> BitcastV;
- OwningPtr<BinaryOperator> AddV;
-
- ValueMapTest() :
- ConstantV(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 0)),
- BitcastV(new BitCastInst(ConstantV, Type::getInt32Ty(getGlobalContext()))),
- AddV(BinaryOperator::CreateAdd(ConstantV, ConstantV)) {
- }
-};
-
-// Run everything on Value*, a subtype to make sure that casting works as
-// expected, and a const subtype to make sure we cast const correctly.
-typedef ::testing::Types<Value, Instruction, const Instruction> KeyTypes;
-TYPED_TEST_CASE(ValueMapTest, KeyTypes);
-
-TYPED_TEST(ValueMapTest, Null) {
- ValueMap<TypeParam*, int> VM1;
- VM1[NULL] = 7;
- EXPECT_EQ(7, VM1.lookup(NULL));
-}
-
-TYPED_TEST(ValueMapTest, FollowsValue) {
- ValueMap<TypeParam*, int> VM;
- VM[this->BitcastV.get()] = 7;
- EXPECT_EQ(7, VM.lookup(this->BitcastV.get()));
- EXPECT_EQ(0, VM.count(this->AddV.get()));
- this->BitcastV->replaceAllUsesWith(this->AddV.get());
- EXPECT_EQ(7, VM.lookup(this->AddV.get()));
- EXPECT_EQ(0, VM.count(this->BitcastV.get()));
- this->AddV.reset();
- EXPECT_EQ(0, VM.count(this->AddV.get()));
- EXPECT_EQ(0, VM.count(this->BitcastV.get()));
- EXPECT_EQ(0U, VM.size());
-}
-
-TYPED_TEST(ValueMapTest, OperationsWork) {
- ValueMap<TypeParam*, int> VM;
- ValueMap<TypeParam*, int> VM2(16); (void)VM2;
- typename ValueMapConfig<TypeParam*>::ExtraData Data;
- ValueMap<TypeParam*, int> VM3(Data, 16); (void)VM3;
- EXPECT_TRUE(VM.empty());
-
- VM[this->BitcastV.get()] = 7;
-
- // Find:
- typename ValueMap<TypeParam*, int>::iterator I =
- VM.find(this->BitcastV.get());
- ASSERT_TRUE(I != VM.end());
- EXPECT_EQ(this->BitcastV.get(), I->first);
- EXPECT_EQ(7, I->second);
- EXPECT_TRUE(VM.find(this->AddV.get()) == VM.end());
-
- // Const find:
- const ValueMap<TypeParam*, int> &CVM = VM;
- typename ValueMap<TypeParam*, int>::const_iterator CI =
- CVM.find(this->BitcastV.get());
- ASSERT_TRUE(CI != CVM.end());
- EXPECT_EQ(this->BitcastV.get(), CI->first);
- EXPECT_EQ(7, CI->second);
- EXPECT_TRUE(CVM.find(this->AddV.get()) == CVM.end());
-
- // Insert:
- std::pair<typename ValueMap<TypeParam*, int>::iterator, bool> InsertResult1 =
- VM.insert(std::make_pair(this->AddV.get(), 3));
- EXPECT_EQ(this->AddV.get(), InsertResult1.first->first);
- EXPECT_EQ(3, InsertResult1.first->second);
- EXPECT_TRUE(InsertResult1.second);
- EXPECT_EQ(true, VM.count(this->AddV.get()));
- std::pair<typename ValueMap<TypeParam*, int>::iterator, bool> InsertResult2 =
- VM.insert(std::make_pair(this->AddV.get(), 5));
- EXPECT_EQ(this->AddV.get(), InsertResult2.first->first);
- EXPECT_EQ(3, InsertResult2.first->second);
- EXPECT_FALSE(InsertResult2.second);
-
- // Erase:
- VM.erase(InsertResult2.first);
- EXPECT_EQ(false, VM.count(this->AddV.get()));
- EXPECT_EQ(true, VM.count(this->BitcastV.get()));
- VM.erase(this->BitcastV.get());
- EXPECT_EQ(false, VM.count(this->BitcastV.get()));
- EXPECT_EQ(0U, VM.size());
-
- // Range insert:
- SmallVector<std::pair<Instruction*, int>, 2> Elems;
- Elems.push_back(std::make_pair(this->AddV.get(), 1));
- Elems.push_back(std::make_pair(this->BitcastV.get(), 2));
- VM.insert(Elems.begin(), Elems.end());
- EXPECT_EQ(1, VM.lookup(this->AddV.get()));
- EXPECT_EQ(2, VM.lookup(this->BitcastV.get()));
-}
-
-template<typename ExpectedType, typename VarType>
-void CompileAssertHasType(VarType) {
- typedef char assert[is_same<ExpectedType, VarType>::value ? 1 : -1];
-}
-
-TYPED_TEST(ValueMapTest, Iteration) {
- ValueMap<TypeParam*, int> VM;
- VM[this->BitcastV.get()] = 2;
- VM[this->AddV.get()] = 3;
- size_t size = 0;
- for (typename ValueMap<TypeParam*, int>::iterator I = VM.begin(), E = VM.end();
- I != E; ++I) {
- ++size;
- std::pair<TypeParam*, int> value = *I; (void)value;
- CompileAssertHasType<TypeParam*>(I->first);
- if (I->second == 2) {
- EXPECT_EQ(this->BitcastV.get(), I->first);
- I->second = 5;
- } else if (I->second == 3) {
- EXPECT_EQ(this->AddV.get(), I->first);
- I->second = 6;
- } else {
- ADD_FAILURE() << "Iterated through an extra value.";
- }
- }
- EXPECT_EQ(2U, size);
- EXPECT_EQ(5, VM[this->BitcastV.get()]);
- EXPECT_EQ(6, VM[this->AddV.get()]);
-
- size = 0;
- // Cast to const ValueMap to avoid a bug in DenseMap's iterators.
- const ValueMap<TypeParam*, int>& CVM = VM;
- for (typename ValueMap<TypeParam*, int>::const_iterator I = CVM.begin(),
- E = CVM.end(); I != E; ++I) {
- ++size;
- std::pair<TypeParam*, int> value = *I; (void)value;
- CompileAssertHasType<TypeParam*>(I->first);
- if (I->second == 5) {
- EXPECT_EQ(this->BitcastV.get(), I->first);
- } else if (I->second == 6) {
- EXPECT_EQ(this->AddV.get(), I->first);
- } else {
- ADD_FAILURE() << "Iterated through an extra value.";
- }
- }
- EXPECT_EQ(2U, size);
-}
-
-TYPED_TEST(ValueMapTest, DefaultCollisionBehavior) {
- // By default, we overwrite the old value with the replaced value.
- ValueMap<TypeParam*, int> VM;
- VM[this->BitcastV.get()] = 7;
- VM[this->AddV.get()] = 9;
- this->BitcastV->replaceAllUsesWith(this->AddV.get());
- EXPECT_EQ(0, VM.count(this->BitcastV.get()));
- EXPECT_EQ(9, VM.lookup(this->AddV.get()));
-}
-
-TYPED_TEST(ValueMapTest, ConfiguredCollisionBehavior) {
- // TODO: Implement this when someone needs it.
-}
-
-template<typename KeyT>
-struct LockMutex : ValueMapConfig<KeyT> {
- struct ExtraData {
- sys::Mutex *M;
- bool *CalledRAUW;
- bool *CalledDeleted;
- };
- static void onRAUW(const ExtraData &Data, KeyT Old, KeyT New) {
- *Data.CalledRAUW = true;
- EXPECT_FALSE(Data.M->tryacquire()) << "Mutex should already be locked.";
- }
- static void onDelete(const ExtraData &Data, KeyT Old) {
- *Data.CalledDeleted = true;
- EXPECT_FALSE(Data.M->tryacquire()) << "Mutex should already be locked.";
- }
- static sys::Mutex *getMutex(const ExtraData &Data) { return Data.M; }
-};
-#if ENABLE_THREADS
-TYPED_TEST(ValueMapTest, LocksMutex) {
- sys::Mutex M(false); // Not recursive.
- bool CalledRAUW = false, CalledDeleted = false;
- typename LockMutex<TypeParam*>::ExtraData Data =
- {&M, &CalledRAUW, &CalledDeleted};
- ValueMap<TypeParam*, int, LockMutex<TypeParam*> > VM(Data);
- VM[this->BitcastV.get()] = 7;
- this->BitcastV->replaceAllUsesWith(this->AddV.get());
- this->AddV.reset();
- EXPECT_TRUE(CalledRAUW);
- EXPECT_TRUE(CalledDeleted);
-}
-#endif
-
-template<typename KeyT>
-struct NoFollow : ValueMapConfig<KeyT> {
- enum { FollowRAUW = false };
-};
-
-TYPED_TEST(ValueMapTest, NoFollowRAUW) {
- ValueMap<TypeParam*, int, NoFollow<TypeParam*> > VM;
- VM[this->BitcastV.get()] = 7;
- EXPECT_EQ(7, VM.lookup(this->BitcastV.get()));
- EXPECT_EQ(0, VM.count(this->AddV.get()));
- this->BitcastV->replaceAllUsesWith(this->AddV.get());
- EXPECT_EQ(7, VM.lookup(this->BitcastV.get()));
- EXPECT_EQ(0, VM.lookup(this->AddV.get()));
- this->AddV.reset();
- EXPECT_EQ(7, VM.lookup(this->BitcastV.get()));
- EXPECT_EQ(0, VM.lookup(this->AddV.get()));
- this->BitcastV.reset();
- EXPECT_EQ(0, VM.lookup(this->BitcastV.get()));
- EXPECT_EQ(0, VM.lookup(this->AddV.get()));
- EXPECT_EQ(0U, VM.size());
-}
-
-template<typename KeyT>
-struct CountOps : ValueMapConfig<KeyT> {
- struct ExtraData {
- int *Deletions;
- int *RAUWs;
- };
-
- static void onRAUW(const ExtraData &Data, KeyT Old, KeyT New) {
- ++*Data.RAUWs;
- }
- static void onDelete(const ExtraData &Data, KeyT Old) {
- ++*Data.Deletions;
- }
-};
-
-TYPED_TEST(ValueMapTest, CallsConfig) {
- int Deletions = 0, RAUWs = 0;
- typename CountOps<TypeParam*>::ExtraData Data = {&Deletions, &RAUWs};
- ValueMap<TypeParam*, int, CountOps<TypeParam*> > VM(Data);
- VM[this->BitcastV.get()] = 7;
- this->BitcastV->replaceAllUsesWith(this->AddV.get());
- EXPECT_EQ(0, Deletions);
- EXPECT_EQ(1, RAUWs);
- this->AddV.reset();
- EXPECT_EQ(1, Deletions);
- EXPECT_EQ(1, RAUWs);
- this->BitcastV.reset();
- EXPECT_EQ(1, Deletions);
- EXPECT_EQ(1, RAUWs);
-}
-
-template<typename KeyT>
-struct ModifyingConfig : ValueMapConfig<KeyT> {
- // We'll put a pointer here back to the ValueMap this key is in, so
- // that we can modify it (and clobber *this) before the ValueMap
- // tries to do the same modification. In previous versions of
- // ValueMap, that exploded.
- typedef ValueMap<KeyT, int, ModifyingConfig<KeyT> > **ExtraData;
-
- static void onRAUW(ExtraData Map, KeyT Old, KeyT New) {
- (*Map)->erase(Old);
- }
- static void onDelete(ExtraData Map, KeyT Old) {
- (*Map)->erase(Old);
- }
-};
-TYPED_TEST(ValueMapTest, SurvivesModificationByConfig) {
- ValueMap<TypeParam*, int, ModifyingConfig<TypeParam*> > *MapAddress;
- ValueMap<TypeParam*, int, ModifyingConfig<TypeParam*> > VM(&MapAddress);
- MapAddress = &VM;
- // Now the ModifyingConfig can modify the Map inside a callback.
- VM[this->BitcastV.get()] = 7;
- this->BitcastV->replaceAllUsesWith(this->AddV.get());
- EXPECT_FALSE(VM.count(this->BitcastV.get()));
- EXPECT_FALSE(VM.count(this->AddV.get()));
- VM[this->AddV.get()] = 7;
- this->AddV.reset();
- EXPECT_FALSE(VM.count(this->AddV.get()));
-}
-
-}
diff --git a/contrib/llvm/unittests/ADT/ilistTest.cpp b/contrib/llvm/unittests/ADT/ilistTest.cpp
deleted file mode 100644
index 09a699a..0000000
--- a/contrib/llvm/unittests/ADT/ilistTest.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//===- llvm/unittest/ADT/APInt.cpp - APInt unit tests ---------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <ostream>
-#include "gtest/gtest.h"
-#include "llvm/ADT/ilist.h"
-#include "llvm/ADT/ilist_node.h"
-
-using namespace llvm;
-
-namespace {
-
-struct Node : ilist_node<Node> {
- int Value;
-
- Node() {}
- Node(int _Value) : Value(_Value) {}
-};
-
-TEST(ilistTest, Basic) {
- ilist<Node> List;
- List.push_back(Node(1));
- EXPECT_EQ(1, List.back().Value);
- EXPECT_EQ(0, List.back().getPrevNode());
- EXPECT_EQ(0, List.back().getNextNode());
-
- List.push_back(Node(2));
- EXPECT_EQ(2, List.back().Value);
- EXPECT_EQ(2, List.front().getNextNode()->Value);
- EXPECT_EQ(1, List.back().getPrevNode()->Value);
-
- const ilist<Node> &ConstList = List;
- EXPECT_EQ(2, ConstList.back().Value);
- EXPECT_EQ(2, ConstList.front().getNextNode()->Value);
- EXPECT_EQ(1, ConstList.back().getPrevNode()->Value);
-}
-
-}
diff --git a/contrib/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/contrib/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
deleted file mode 100644
index 904ee2b..0000000
--- a/contrib/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-//===- ExecutionEngineTest.cpp - Unit tests for ExecutionEngine -----------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DerivedTypes.h"
-#include "llvm/GlobalVariable.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
-#include "gtest/gtest.h"
-
-using namespace llvm;
-
-namespace {
-
-class ExecutionEngineTest : public testing::Test {
-protected:
- ExecutionEngineTest()
- : M(new Module("<main>", getGlobalContext())),
- Engine(EngineBuilder(M).create()) {
- }
-
- virtual void SetUp() {
- ASSERT_TRUE(Engine.get() != NULL);
- }
-
- GlobalVariable *NewExtGlobal(const Type *T, const Twine &Name) {
- return new GlobalVariable(*M, T, false, // Not constant.
- GlobalValue::ExternalLinkage, NULL, Name);
- }
-
- Module *const M;
- const OwningPtr<ExecutionEngine> Engine;
-};
-
-TEST_F(ExecutionEngineTest, ForwardGlobalMapping) {
- GlobalVariable *G1 =
- NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
- int32_t Mem1 = 3;
- Engine->addGlobalMapping(G1, &Mem1);
- EXPECT_EQ(&Mem1, Engine->getPointerToGlobalIfAvailable(G1));
- int32_t Mem2 = 4;
- Engine->updateGlobalMapping(G1, &Mem2);
- EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1));
- Engine->updateGlobalMapping(G1, NULL);
- EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G1));
- Engine->updateGlobalMapping(G1, &Mem2);
- EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1));
-
- GlobalVariable *G2 =
- NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
- EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G2))
- << "The NULL return shouldn't depend on having called"
- << " updateGlobalMapping(..., NULL)";
- // Check that update...() can be called before add...().
- Engine->updateGlobalMapping(G2, &Mem1);
- EXPECT_EQ(&Mem1, Engine->getPointerToGlobalIfAvailable(G2));
- EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1))
- << "A second mapping shouldn't affect the first.";
-}
-
-TEST_F(ExecutionEngineTest, ReverseGlobalMapping) {
- GlobalVariable *G1 =
- NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
-
- int32_t Mem1 = 3;
- Engine->addGlobalMapping(G1, &Mem1);
- EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1));
- int32_t Mem2 = 4;
- Engine->updateGlobalMapping(G1, &Mem2);
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
- EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2));
-
- GlobalVariable *G2 =
- NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global2");
- Engine->updateGlobalMapping(G2, &Mem1);
- EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1));
- EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2));
- Engine->updateGlobalMapping(G1, NULL);
- EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1))
- << "Removing one mapping doesn't affect a different one.";
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem2));
- Engine->updateGlobalMapping(G2, &Mem2);
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
- EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem2))
- << "Once a mapping is removed, we can point another GV at the"
- << " now-free address.";
-}
-
-TEST_F(ExecutionEngineTest, ClearModuleMappings) {
- GlobalVariable *G1 =
- NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
-
- int32_t Mem1 = 3;
- Engine->addGlobalMapping(G1, &Mem1);
- EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1));
-
- Engine->clearGlobalMappingsFromModule(M);
-
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
-
- GlobalVariable *G2 =
- NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global2");
- // After clearing the module mappings, we can assign a new GV to the
- // same address.
- Engine->addGlobalMapping(G2, &Mem1);
- EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1));
-}
-
-TEST_F(ExecutionEngineTest, DestructionRemovesGlobalMapping) {
- GlobalVariable *G1 =
- NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
- int32_t Mem1 = 3;
- Engine->addGlobalMapping(G1, &Mem1);
- // Make sure the reverse mapping is enabled.
- EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1));
- // When the GV goes away, the ExecutionEngine should remove any
- // mappings that refer to it.
- G1->eraseFromParent();
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
-}
-
-}
diff --git a/contrib/llvm/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp b/contrib/llvm/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp
deleted file mode 100644
index a36ec3b..0000000
--- a/contrib/llvm/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-//===- JITEventListenerTest.cpp - Unit tests for JITEventListeners --------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ExecutionEngine/JITEventListener.h"
-
-#include "llvm/LLVMContext.h"
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/CodeGen/MachineCodeInfo.h"
-#include "llvm/ExecutionEngine/JIT.h"
-#include "llvm/Support/TypeBuilder.h"
-#include "llvm/Target/TargetSelect.h"
-#include "gtest/gtest.h"
-#include <vector>
-
-using namespace llvm;
-
-int dummy;
-
-namespace {
-
-struct FunctionEmittedEvent {
- // Indices are local to the RecordingJITEventListener, since the
- // JITEventListener interface makes no guarantees about the order of
- // calls between Listeners.
- unsigned Index;
- const Function *F;
- void *Code;
- size_t Size;
- JITEvent_EmittedFunctionDetails Details;
-};
-struct FunctionFreedEvent {
- unsigned Index;
- void *Code;
-};
-
-struct RecordingJITEventListener : public JITEventListener {
- std::vector<FunctionEmittedEvent> EmittedEvents;
- std::vector<FunctionFreedEvent> FreedEvents;
-
- int NextIndex;
-
- RecordingJITEventListener() : NextIndex(0) {}
-
- virtual void NotifyFunctionEmitted(const Function &F,
- void *Code, size_t Size,
- const EmittedFunctionDetails &Details) {
- FunctionEmittedEvent Event = {NextIndex++, &F, Code, Size, Details};
- EmittedEvents.push_back(Event);
- }
-
- virtual void NotifyFreeingMachineCode(void *OldPtr) {
- FunctionFreedEvent Event = {NextIndex++, OldPtr};
- FreedEvents.push_back(Event);
- }
-};
-
-class JITEventListenerTest : public testing::Test {
- protected:
- JITEventListenerTest()
- : M(new Module("module", getGlobalContext())),
- EE(EngineBuilder(M)
- .setEngineKind(EngineKind::JIT)
- .create()) {
- }
-
- Module *M;
- const OwningPtr<ExecutionEngine> EE;
-};
-
-Function *buildFunction(Module *M) {
- Function *Result = Function::Create(
- TypeBuilder<int32_t(int32_t), false>::get(getGlobalContext()),
- GlobalValue::ExternalLinkage, "id", M);
- Value *Arg = Result->arg_begin();
- BasicBlock *BB = BasicBlock::Create(M->getContext(), "entry", Result);
- ReturnInst::Create(M->getContext(), Arg, BB);
- return Result;
-}
-
-// Tests that a single JITEventListener follows JIT events accurately.
-TEST_F(JITEventListenerTest, Simple) {
- RecordingJITEventListener Listener;
- EE->RegisterJITEventListener(&Listener);
- Function *F1 = buildFunction(M);
- Function *F2 = buildFunction(M);
-
- void *F1_addr = EE->getPointerToFunction(F1);
- void *F2_addr = EE->getPointerToFunction(F2);
- EE->getPointerToFunction(F1); // Should do nothing.
- EE->freeMachineCodeForFunction(F1);
- EE->freeMachineCodeForFunction(F2);
-
- ASSERT_EQ(2U, Listener.EmittedEvents.size());
- ASSERT_EQ(2U, Listener.FreedEvents.size());
-
- EXPECT_EQ(0U, Listener.EmittedEvents[0].Index);
- EXPECT_EQ(F1, Listener.EmittedEvents[0].F);
- EXPECT_EQ(F1_addr, Listener.EmittedEvents[0].Code);
- EXPECT_LT(0U, Listener.EmittedEvents[0].Size)
- << "We don't know how big the function will be, but it had better"
- << " contain some bytes.";
-
- EXPECT_EQ(1U, Listener.EmittedEvents[1].Index);
- EXPECT_EQ(F2, Listener.EmittedEvents[1].F);
- EXPECT_EQ(F2_addr, Listener.EmittedEvents[1].Code);
- EXPECT_LT(0U, Listener.EmittedEvents[1].Size)
- << "We don't know how big the function will be, but it had better"
- << " contain some bytes.";
-
- EXPECT_EQ(2U, Listener.FreedEvents[0].Index);
- EXPECT_EQ(F1_addr, Listener.FreedEvents[0].Code);
-
- EXPECT_EQ(3U, Listener.FreedEvents[1].Index);
- EXPECT_EQ(F2_addr, Listener.FreedEvents[1].Code);
-
- F1->eraseFromParent();
- F2->eraseFromParent();
-}
-
-// Tests that a single JITEventListener follows JIT events accurately.
-TEST_F(JITEventListenerTest, MultipleListenersDontInterfere) {
- RecordingJITEventListener Listener1;
- RecordingJITEventListener Listener2;
- RecordingJITEventListener Listener3;
- Function *F1 = buildFunction(M);
- Function *F2 = buildFunction(M);
-
- EE->RegisterJITEventListener(&Listener1);
- EE->RegisterJITEventListener(&Listener2);
- void *F1_addr = EE->getPointerToFunction(F1);
- EE->RegisterJITEventListener(&Listener3);
- EE->UnregisterJITEventListener(&Listener1);
- void *F2_addr = EE->getPointerToFunction(F2);
- EE->UnregisterJITEventListener(&Listener2);
- EE->UnregisterJITEventListener(&Listener3);
- EE->freeMachineCodeForFunction(F1);
- EE->RegisterJITEventListener(&Listener2);
- EE->RegisterJITEventListener(&Listener3);
- EE->RegisterJITEventListener(&Listener1);
- EE->freeMachineCodeForFunction(F2);
- EE->UnregisterJITEventListener(&Listener1);
- EE->UnregisterJITEventListener(&Listener2);
- EE->UnregisterJITEventListener(&Listener3);
-
- // Listener 1.
- ASSERT_EQ(1U, Listener1.EmittedEvents.size());
- ASSERT_EQ(1U, Listener1.FreedEvents.size());
-
- EXPECT_EQ(0U, Listener1.EmittedEvents[0].Index);
- EXPECT_EQ(F1, Listener1.EmittedEvents[0].F);
- EXPECT_EQ(F1_addr, Listener1.EmittedEvents[0].Code);
- EXPECT_LT(0U, Listener1.EmittedEvents[0].Size)
- << "We don't know how big the function will be, but it had better"
- << " contain some bytes.";
-
- EXPECT_EQ(1U, Listener1.FreedEvents[0].Index);
- EXPECT_EQ(F2_addr, Listener1.FreedEvents[0].Code);
-
- // Listener 2.
- ASSERT_EQ(2U, Listener2.EmittedEvents.size());
- ASSERT_EQ(1U, Listener2.FreedEvents.size());
-
- EXPECT_EQ(0U, Listener2.EmittedEvents[0].Index);
- EXPECT_EQ(F1, Listener2.EmittedEvents[0].F);
- EXPECT_EQ(F1_addr, Listener2.EmittedEvents[0].Code);
- EXPECT_LT(0U, Listener2.EmittedEvents[0].Size)
- << "We don't know how big the function will be, but it had better"
- << " contain some bytes.";
-
- EXPECT_EQ(1U, Listener2.EmittedEvents[1].Index);
- EXPECT_EQ(F2, Listener2.EmittedEvents[1].F);
- EXPECT_EQ(F2_addr, Listener2.EmittedEvents[1].Code);
- EXPECT_LT(0U, Listener2.EmittedEvents[1].Size)
- << "We don't know how big the function will be, but it had better"
- << " contain some bytes.";
-
- EXPECT_EQ(2U, Listener2.FreedEvents[0].Index);
- EXPECT_EQ(F2_addr, Listener2.FreedEvents[0].Code);
-
- // Listener 3.
- ASSERT_EQ(1U, Listener3.EmittedEvents.size());
- ASSERT_EQ(1U, Listener3.FreedEvents.size());
-
- EXPECT_EQ(0U, Listener3.EmittedEvents[0].Index);
- EXPECT_EQ(F2, Listener3.EmittedEvents[0].F);
- EXPECT_EQ(F2_addr, Listener3.EmittedEvents[0].Code);
- EXPECT_LT(0U, Listener3.EmittedEvents[0].Size)
- << "We don't know how big the function will be, but it had better"
- << " contain some bytes.";
-
- EXPECT_EQ(1U, Listener3.FreedEvents[0].Index);
- EXPECT_EQ(F2_addr, Listener3.FreedEvents[0].Code);
-
- F1->eraseFromParent();
- F2->eraseFromParent();
-}
-
-TEST_F(JITEventListenerTest, MatchesMachineCodeInfo) {
- RecordingJITEventListener Listener;
- MachineCodeInfo MCI;
- Function *F = buildFunction(M);
-
- EE->RegisterJITEventListener(&Listener);
- EE->runJITOnFunction(F, &MCI);
- void *F_addr = EE->getPointerToFunction(F);
- EE->freeMachineCodeForFunction(F);
-
- ASSERT_EQ(1U, Listener.EmittedEvents.size());
- ASSERT_EQ(1U, Listener.FreedEvents.size());
-
- EXPECT_EQ(0U, Listener.EmittedEvents[0].Index);
- EXPECT_EQ(F, Listener.EmittedEvents[0].F);
- EXPECT_EQ(F_addr, Listener.EmittedEvents[0].Code);
- EXPECT_EQ(MCI.address(), Listener.EmittedEvents[0].Code);
- EXPECT_EQ(MCI.size(), Listener.EmittedEvents[0].Size);
-
- EXPECT_EQ(1U, Listener.FreedEvents[0].Index);
- EXPECT_EQ(F_addr, Listener.FreedEvents[0].Code);
-}
-
-class JITEnvironment : public testing::Environment {
- virtual void SetUp() {
- // Required to create a JIT.
- InitializeNativeTarget();
- }
-};
-testing::Environment* const jit_env =
- testing::AddGlobalTestEnvironment(new JITEnvironment);
-
-} // anonymous namespace
diff --git a/contrib/llvm/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp b/contrib/llvm/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
deleted file mode 100644
index ff5af3b..0000000
--- a/contrib/llvm/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-//===- JITMemoryManagerTest.cpp - Unit tests for the JIT memory manager ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/ExecutionEngine/JITMemoryManager.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
-#include "llvm/GlobalValue.h"
-#include "llvm/LLVMContext.h"
-
-using namespace llvm;
-
-namespace {
-
-Function *makeFakeFunction() {
- std::vector<const Type*> params;
- const FunctionType *FTy =
- FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false);
- return Function::Create(FTy, GlobalValue::ExternalLinkage);
-}
-
-// Allocate three simple functions that fit in the initial slab. This exercises
-// the code in the case that we don't have to allocate more memory to store the
-// function bodies.
-TEST(JITMemoryManagerTest, NoAllocations) {
- OwningPtr<JITMemoryManager> MemMgr(
- JITMemoryManager::CreateDefaultMemManager());
- uintptr_t size;
- std::string Error;
-
- // Allocate the functions.
- OwningPtr<Function> F1(makeFakeFunction());
- size = 1024;
- uint8_t *FunctionBody1 = MemMgr->startFunctionBody(F1.get(), size);
- memset(FunctionBody1, 0xFF, 1024);
- MemMgr->endFunctionBody(F1.get(), FunctionBody1, FunctionBody1 + 1024);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- OwningPtr<Function> F2(makeFakeFunction());
- size = 1024;
- uint8_t *FunctionBody2 = MemMgr->startFunctionBody(F2.get(), size);
- memset(FunctionBody2, 0xFF, 1024);
- MemMgr->endFunctionBody(F2.get(), FunctionBody2, FunctionBody2 + 1024);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- OwningPtr<Function> F3(makeFakeFunction());
- size = 1024;
- uint8_t *FunctionBody3 = MemMgr->startFunctionBody(F3.get(), size);
- memset(FunctionBody3, 0xFF, 1024);
- MemMgr->endFunctionBody(F3.get(), FunctionBody3, FunctionBody3 + 1024);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- // Deallocate them out of order, in case that matters.
- MemMgr->deallocateFunctionBody(FunctionBody2);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
- MemMgr->deallocateFunctionBody(FunctionBody1);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
- MemMgr->deallocateFunctionBody(FunctionBody3);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-}
-
-// Make three large functions that take up most of the space in the slab. Then
-// try allocating three smaller functions that don't require additional slabs.
-TEST(JITMemoryManagerTest, TestCodeAllocation) {
- OwningPtr<JITMemoryManager> MemMgr(
- JITMemoryManager::CreateDefaultMemManager());
- uintptr_t size;
- std::string Error;
-
- // Big functions are a little less than the largest block size.
- const uintptr_t smallFuncSize = 1024;
- const uintptr_t bigFuncSize = (MemMgr->GetDefaultCodeSlabSize() -
- smallFuncSize * 2);
-
- // Allocate big functions
- OwningPtr<Function> F1(makeFakeFunction());
- size = bigFuncSize;
- uint8_t *FunctionBody1 = MemMgr->startFunctionBody(F1.get(), size);
- ASSERT_LE(bigFuncSize, size);
- memset(FunctionBody1, 0xFF, bigFuncSize);
- MemMgr->endFunctionBody(F1.get(), FunctionBody1, FunctionBody1 + bigFuncSize);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- OwningPtr<Function> F2(makeFakeFunction());
- size = bigFuncSize;
- uint8_t *FunctionBody2 = MemMgr->startFunctionBody(F2.get(), size);
- ASSERT_LE(bigFuncSize, size);
- memset(FunctionBody2, 0xFF, bigFuncSize);
- MemMgr->endFunctionBody(F2.get(), FunctionBody2, FunctionBody2 + bigFuncSize);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- OwningPtr<Function> F3(makeFakeFunction());
- size = bigFuncSize;
- uint8_t *FunctionBody3 = MemMgr->startFunctionBody(F3.get(), size);
- ASSERT_LE(bigFuncSize, size);
- memset(FunctionBody3, 0xFF, bigFuncSize);
- MemMgr->endFunctionBody(F3.get(), FunctionBody3, FunctionBody3 + bigFuncSize);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- // Check that each large function took it's own slab.
- EXPECT_EQ(3U, MemMgr->GetNumCodeSlabs());
-
- // Allocate small functions
- OwningPtr<Function> F4(makeFakeFunction());
- size = smallFuncSize;
- uint8_t *FunctionBody4 = MemMgr->startFunctionBody(F4.get(), size);
- ASSERT_LE(smallFuncSize, size);
- memset(FunctionBody4, 0xFF, smallFuncSize);
- MemMgr->endFunctionBody(F4.get(), FunctionBody4,
- FunctionBody4 + smallFuncSize);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- OwningPtr<Function> F5(makeFakeFunction());
- size = smallFuncSize;
- uint8_t *FunctionBody5 = MemMgr->startFunctionBody(F5.get(), size);
- ASSERT_LE(smallFuncSize, size);
- memset(FunctionBody5, 0xFF, smallFuncSize);
- MemMgr->endFunctionBody(F5.get(), FunctionBody5,
- FunctionBody5 + smallFuncSize);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- OwningPtr<Function> F6(makeFakeFunction());
- size = smallFuncSize;
- uint8_t *FunctionBody6 = MemMgr->startFunctionBody(F6.get(), size);
- ASSERT_LE(smallFuncSize, size);
- memset(FunctionBody6, 0xFF, smallFuncSize);
- MemMgr->endFunctionBody(F6.get(), FunctionBody6,
- FunctionBody6 + smallFuncSize);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-
- // Check that the small functions didn't allocate any new slabs.
- EXPECT_EQ(3U, MemMgr->GetNumCodeSlabs());
-
- // Deallocate them out of order, in case that matters.
- MemMgr->deallocateFunctionBody(FunctionBody2);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
- MemMgr->deallocateFunctionBody(FunctionBody1);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
- MemMgr->deallocateFunctionBody(FunctionBody4);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
- MemMgr->deallocateFunctionBody(FunctionBody3);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
- MemMgr->deallocateFunctionBody(FunctionBody5);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
- MemMgr->deallocateFunctionBody(FunctionBody6);
- EXPECT_TRUE(MemMgr->CheckInvariants(Error)) << Error;
-}
-
-// Allocate five global ints of varying widths and alignment, and check their
-// alignment and overlap.
-TEST(JITMemoryManagerTest, TestSmallGlobalInts) {
- OwningPtr<JITMemoryManager> MemMgr(
- JITMemoryManager::CreateDefaultMemManager());
- uint8_t *a = (uint8_t *)MemMgr->allocateGlobal(8, 0);
- uint16_t *b = (uint16_t*)MemMgr->allocateGlobal(16, 2);
- uint32_t *c = (uint32_t*)MemMgr->allocateGlobal(32, 4);
- uint64_t *d = (uint64_t*)MemMgr->allocateGlobal(64, 8);
-
- // Check the alignment.
- EXPECT_EQ(0U, ((uintptr_t)b) & 0x1);
- EXPECT_EQ(0U, ((uintptr_t)c) & 0x3);
- EXPECT_EQ(0U, ((uintptr_t)d) & 0x7);
-
- // Initialize them each one at a time and make sure they don't overlap.
- *a = 0xff;
- *b = 0U;
- *c = 0U;
- *d = 0U;
- EXPECT_EQ(0xffU, *a);
- EXPECT_EQ(0U, *b);
- EXPECT_EQ(0U, *c);
- EXPECT_EQ(0U, *d);
- *a = 0U;
- *b = 0xffffU;
- EXPECT_EQ(0U, *a);
- EXPECT_EQ(0xffffU, *b);
- EXPECT_EQ(0U, *c);
- EXPECT_EQ(0U, *d);
- *b = 0U;
- *c = 0xffffffffU;
- EXPECT_EQ(0U, *a);
- EXPECT_EQ(0U, *b);
- EXPECT_EQ(0xffffffffU, *c);
- EXPECT_EQ(0U, *d);
- *c = 0U;
- *d = 0xffffffffffffffffULL;
- EXPECT_EQ(0U, *a);
- EXPECT_EQ(0U, *b);
- EXPECT_EQ(0U, *c);
- EXPECT_EQ(0xffffffffffffffffULL, *d);
-
- // Make sure we didn't allocate any extra slabs for this tiny amount of data.
- EXPECT_EQ(1U, MemMgr->GetNumDataSlabs());
-}
-
-// Allocate a small global, a big global, and a third global, and make sure we
-// only use two slabs for that.
-TEST(JITMemoryManagerTest, TestLargeGlobalArray) {
- OwningPtr<JITMemoryManager> MemMgr(
- JITMemoryManager::CreateDefaultMemManager());
- size_t Size = 4 * MemMgr->GetDefaultDataSlabSize();
- uint64_t *a = (uint64_t*)MemMgr->allocateGlobal(64, 8);
- uint8_t *g = MemMgr->allocateGlobal(Size, 8);
- uint64_t *b = (uint64_t*)MemMgr->allocateGlobal(64, 8);
-
- // Check the alignment.
- EXPECT_EQ(0U, ((uintptr_t)a) & 0x7);
- EXPECT_EQ(0U, ((uintptr_t)g) & 0x7);
- EXPECT_EQ(0U, ((uintptr_t)b) & 0x7);
-
- // Initialize them to make sure we don't segfault and make sure they don't
- // overlap.
- memset(a, 0x1, 8);
- memset(g, 0x2, Size);
- memset(b, 0x3, 8);
- EXPECT_EQ(0x0101010101010101ULL, *a);
- // Just check the edges.
- EXPECT_EQ(0x02U, g[0]);
- EXPECT_EQ(0x02U, g[Size - 1]);
- EXPECT_EQ(0x0303030303030303ULL, *b);
-
- // Check the number of slabs.
- EXPECT_EQ(2U, MemMgr->GetNumDataSlabs());
-}
-
-// Allocate lots of medium globals so that we can test moving the bump allocator
-// to a new slab.
-TEST(JITMemoryManagerTest, TestManyGlobals) {
- OwningPtr<JITMemoryManager> MemMgr(
- JITMemoryManager::CreateDefaultMemManager());
- size_t SlabSize = MemMgr->GetDefaultDataSlabSize();
- size_t Size = 128;
- int Iters = (SlabSize / Size) + 1;
-
- // We should start with no slabs.
- EXPECT_EQ(0U, MemMgr->GetNumDataSlabs());
-
- // After allocating a bunch of globals, we should have two.
- for (int I = 0; I < Iters; ++I)
- MemMgr->allocateGlobal(Size, 8);
- EXPECT_EQ(2U, MemMgr->GetNumDataSlabs());
-
- // And after much more, we should have three.
- for (int I = 0; I < Iters; ++I)
- MemMgr->allocateGlobal(Size, 8);
- EXPECT_EQ(3U, MemMgr->GetNumDataSlabs());
-}
-
-// Allocate lots of function stubs so that we can test moving the stub bump
-// allocator to a new slab.
-TEST(JITMemoryManagerTest, TestManyStubs) {
- OwningPtr<JITMemoryManager> MemMgr(
- JITMemoryManager::CreateDefaultMemManager());
- size_t SlabSize = MemMgr->GetDefaultStubSlabSize();
- size_t Size = 128;
- int Iters = (SlabSize / Size) + 1;
-
- // We should start with no slabs.
- EXPECT_EQ(0U, MemMgr->GetNumDataSlabs());
-
- // After allocating a bunch of stubs, we should have two.
- for (int I = 0; I < Iters; ++I)
- MemMgr->allocateStub(NULL, Size, 8);
- EXPECT_EQ(2U, MemMgr->GetNumStubSlabs());
-
- // And after much more, we should have three.
- for (int I = 0; I < Iters; ++I)
- MemMgr->allocateStub(NULL, Size, 8);
- EXPECT_EQ(3U, MemMgr->GetNumStubSlabs());
-}
-
-}
diff --git a/contrib/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp b/contrib/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp
deleted file mode 100644
index 8f0582d..0000000
--- a/contrib/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp
+++ /dev/null
@@ -1,806 +0,0 @@
-//===- JITTest.cpp - Unit tests for the JIT -------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/Assembly/Parser.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Constant.h"
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/ExecutionEngine/JIT.h"
-#include "llvm/ExecutionEngine/JITMemoryManager.h"
-#include "llvm/Function.h"
-#include "llvm/GlobalValue.h"
-#include "llvm/GlobalVariable.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#include "llvm/Support/IRBuilder.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/TypeBuilder.h"
-#include "llvm/Target/TargetSelect.h"
-#include "llvm/Type.h"
-
-#include <vector>
-
-using namespace llvm;
-
-namespace {
-
-Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) {
- std::vector<const Type*> params;
- const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(),
- params, false);
- Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M);
- BasicBlock *Entry = BasicBlock::Create(M->getContext(), "entry", F);
- IRBuilder<> builder(Entry);
- Value *Load = builder.CreateLoad(G);
- const Type *GTy = G->getType()->getElementType();
- Value *Add = builder.CreateAdd(Load, ConstantInt::get(GTy, 1LL));
- builder.CreateStore(Add, G);
- builder.CreateRet(Add);
- return F;
-}
-
-std::string DumpFunction(const Function *F) {
- std::string Result;
- raw_string_ostream(Result) << "" << *F;
- return Result;
-}
-
-class RecordingJITMemoryManager : public JITMemoryManager {
- const OwningPtr<JITMemoryManager> Base;
-public:
- RecordingJITMemoryManager()
- : Base(JITMemoryManager::CreateDefaultMemManager()) {
- stubsAllocated = 0;
- }
-
- void setSizeRequired(bool Required) { SizeRequired = Required; }
-
- virtual void setMemoryWritable() { Base->setMemoryWritable(); }
- virtual void setMemoryExecutable() { Base->setMemoryExecutable(); }
- virtual void setPoisonMemory(bool poison) { Base->setPoisonMemory(poison); }
- virtual void AllocateGOT() { Base->AllocateGOT(); }
- virtual uint8_t *getGOTBase() const { return Base->getGOTBase(); }
- struct StartFunctionBodyCall {
- StartFunctionBodyCall(uint8_t *Result, const Function *F,
- uintptr_t ActualSize, uintptr_t ActualSizeResult)
- : Result(Result), F(F), F_dump(DumpFunction(F)),
- ActualSize(ActualSize), ActualSizeResult(ActualSizeResult) {}
- uint8_t *Result;
- const Function *F;
- std::string F_dump;
- uintptr_t ActualSize;
- uintptr_t ActualSizeResult;
- };
- std::vector<StartFunctionBodyCall> startFunctionBodyCalls;
- virtual uint8_t *startFunctionBody(const Function *F,
- uintptr_t &ActualSize) {
- uintptr_t InitialActualSize = ActualSize;
- uint8_t *Result = Base->startFunctionBody(F, ActualSize);
- startFunctionBodyCalls.push_back(
- StartFunctionBodyCall(Result, F, InitialActualSize, ActualSize));
- return Result;
- }
- int stubsAllocated;
- virtual uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize,
- unsigned Alignment) {
- stubsAllocated++;
- return Base->allocateStub(F, StubSize, Alignment);
- }
- struct EndFunctionBodyCall {
- EndFunctionBodyCall(const Function *F, uint8_t *FunctionStart,
- uint8_t *FunctionEnd)
- : F(F), F_dump(DumpFunction(F)),
- FunctionStart(FunctionStart), FunctionEnd(FunctionEnd) {}
- const Function *F;
- std::string F_dump;
- uint8_t *FunctionStart;
- uint8_t *FunctionEnd;
- };
- std::vector<EndFunctionBodyCall> endFunctionBodyCalls;
- virtual void endFunctionBody(const Function *F, uint8_t *FunctionStart,
- uint8_t *FunctionEnd) {
- endFunctionBodyCalls.push_back(
- EndFunctionBodyCall(F, FunctionStart, FunctionEnd));
- Base->endFunctionBody(F, FunctionStart, FunctionEnd);
- }
- virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) {
- return Base->allocateSpace(Size, Alignment);
- }
- virtual uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment) {
- return Base->allocateGlobal(Size, Alignment);
- }
- struct DeallocateFunctionBodyCall {
- DeallocateFunctionBodyCall(const void *Body) : Body(Body) {}
- const void *Body;
- };
- std::vector<DeallocateFunctionBodyCall> deallocateFunctionBodyCalls;
- virtual void deallocateFunctionBody(void *Body) {
- deallocateFunctionBodyCalls.push_back(DeallocateFunctionBodyCall(Body));
- Base->deallocateFunctionBody(Body);
- }
- struct DeallocateExceptionTableCall {
- DeallocateExceptionTableCall(const void *ET) : ET(ET) {}
- const void *ET;
- };
- std::vector<DeallocateExceptionTableCall> deallocateExceptionTableCalls;
- virtual void deallocateExceptionTable(void *ET) {
- deallocateExceptionTableCalls.push_back(DeallocateExceptionTableCall(ET));
- Base->deallocateExceptionTable(ET);
- }
- struct StartExceptionTableCall {
- StartExceptionTableCall(uint8_t *Result, const Function *F,
- uintptr_t ActualSize, uintptr_t ActualSizeResult)
- : Result(Result), F(F), F_dump(DumpFunction(F)),
- ActualSize(ActualSize), ActualSizeResult(ActualSizeResult) {}
- uint8_t *Result;
- const Function *F;
- std::string F_dump;
- uintptr_t ActualSize;
- uintptr_t ActualSizeResult;
- };
- std::vector<StartExceptionTableCall> startExceptionTableCalls;
- virtual uint8_t* startExceptionTable(const Function* F,
- uintptr_t &ActualSize) {
- uintptr_t InitialActualSize = ActualSize;
- uint8_t *Result = Base->startExceptionTable(F, ActualSize);
- startExceptionTableCalls.push_back(
- StartExceptionTableCall(Result, F, InitialActualSize, ActualSize));
- return Result;
- }
- struct EndExceptionTableCall {
- EndExceptionTableCall(const Function *F, uint8_t *TableStart,
- uint8_t *TableEnd, uint8_t* FrameRegister)
- : F(F), F_dump(DumpFunction(F)),
- TableStart(TableStart), TableEnd(TableEnd),
- FrameRegister(FrameRegister) {}
- const Function *F;
- std::string F_dump;
- uint8_t *TableStart;
- uint8_t *TableEnd;
- uint8_t *FrameRegister;
- };
- std::vector<EndExceptionTableCall> endExceptionTableCalls;
- virtual void endExceptionTable(const Function *F, uint8_t *TableStart,
- uint8_t *TableEnd, uint8_t* FrameRegister) {
- endExceptionTableCalls.push_back(
- EndExceptionTableCall(F, TableStart, TableEnd, FrameRegister));
- return Base->endExceptionTable(F, TableStart, TableEnd, FrameRegister);
- }
-};
-
-bool LoadAssemblyInto(Module *M, const char *assembly) {
- SMDiagnostic Error;
- bool success =
- NULL != ParseAssemblyString(assembly, M, Error, M->getContext());
- std::string errMsg;
- raw_string_ostream os(errMsg);
- Error.Print("", os);
- EXPECT_TRUE(success) << os.str();
- return success;
-}
-
-class JITTest : public testing::Test {
- protected:
- virtual void SetUp() {
- M = new Module("<main>", Context);
- RJMM = new RecordingJITMemoryManager;
- RJMM->setPoisonMemory(true);
- std::string Error;
- TheJIT.reset(EngineBuilder(M).setEngineKind(EngineKind::JIT)
- .setJITMemoryManager(RJMM)
- .setErrorStr(&Error).create());
- ASSERT_TRUE(TheJIT.get() != NULL) << Error;
- }
-
- void LoadAssembly(const char *assembly) {
- LoadAssemblyInto(M, assembly);
- }
-
- LLVMContext Context;
- Module *M; // Owned by ExecutionEngine.
- RecordingJITMemoryManager *RJMM;
- OwningPtr<ExecutionEngine> TheJIT;
-};
-
-// Regression test for a bug. The JIT used to allocate globals inside the same
-// memory block used for the function, and when the function code was freed,
-// the global was left in the same place. This test allocates a function
-// that uses and global, deallocates it, and then makes sure that the global
-// stays alive after that.
-TEST(JIT, GlobalInFunction) {
- LLVMContext context;
- Module *M = new Module("<main>", context);
-
- JITMemoryManager *MemMgr = JITMemoryManager::CreateDefaultMemManager();
- // Tell the memory manager to poison freed memory so that accessing freed
- // memory is more easily tested.
- MemMgr->setPoisonMemory(true);
- std::string Error;
- OwningPtr<ExecutionEngine> JIT(EngineBuilder(M)
- .setEngineKind(EngineKind::JIT)
- .setErrorStr(&Error)
- .setJITMemoryManager(MemMgr)
- // The next line enables the fix:
- .setAllocateGVsWithCode(false)
- .create());
- ASSERT_EQ(Error, "");
-
- // Create a global variable.
- const Type *GTy = Type::getInt32Ty(context);
- GlobalVariable *G = new GlobalVariable(
- *M,
- GTy,
- false, // Not constant.
- GlobalValue::InternalLinkage,
- Constant::getNullValue(GTy),
- "myglobal");
-
- // Make a function that points to a global.
- Function *F1 = makeReturnGlobal("F1", G, M);
-
- // Get the pointer to the native code to force it to JIT the function and
- // allocate space for the global.
- void (*F1Ptr)() =
- reinterpret_cast<void(*)()>((intptr_t)JIT->getPointerToFunction(F1));
-
- // Since F1 was codegen'd, a pointer to G should be available.
- int32_t *GPtr = (int32_t*)JIT->getPointerToGlobalIfAvailable(G);
- ASSERT_NE((int32_t*)NULL, GPtr);
- EXPECT_EQ(0, *GPtr);
-
- // F1() should increment G.
- F1Ptr();
- EXPECT_EQ(1, *GPtr);
-
- // Make a second function identical to the first, referring to the same
- // global.
- Function *F2 = makeReturnGlobal("F2", G, M);
- void (*F2Ptr)() =
- reinterpret_cast<void(*)()>((intptr_t)JIT->getPointerToFunction(F2));
-
- // F2() should increment G.
- F2Ptr();
- EXPECT_EQ(2, *GPtr);
-
- // Deallocate F1.
- JIT->freeMachineCodeForFunction(F1);
-
- // F2() should *still* increment G.
- F2Ptr();
- EXPECT_EQ(3, *GPtr);
-}
-
-int PlusOne(int arg) {
- return arg + 1;
-}
-
-TEST_F(JITTest, FarCallToKnownFunction) {
- // x86-64 can only make direct calls to functions within 32 bits of
- // the current PC. To call anything farther away, we have to load
- // the address into a register and call through the register. The
- // current JIT does this by allocating a stub for any far call.
- // There was a bug in which the JIT tried to emit a direct call when
- // the target was already in the JIT's global mappings and lazy
- // compilation was disabled.
-
- Function *KnownFunction = Function::Create(
- TypeBuilder<int(int), false>::get(Context),
- GlobalValue::ExternalLinkage, "known", M);
- TheJIT->addGlobalMapping(KnownFunction, (void*)(intptr_t)PlusOne);
-
- // int test() { return known(7); }
- Function *TestFunction = Function::Create(
- TypeBuilder<int(), false>::get(Context),
- GlobalValue::ExternalLinkage, "test", M);
- BasicBlock *Entry = BasicBlock::Create(Context, "entry", TestFunction);
- IRBuilder<> Builder(Entry);
- Value *result = Builder.CreateCall(
- KnownFunction,
- ConstantInt::get(TypeBuilder<int, false>::get(Context), 7));
- Builder.CreateRet(result);
-
- TheJIT->DisableLazyCompilation(true);
- int (*TestFunctionPtr)() = reinterpret_cast<int(*)()>(
- (intptr_t)TheJIT->getPointerToFunction(TestFunction));
- // This used to crash in trying to call PlusOne().
- EXPECT_EQ(8, TestFunctionPtr());
-}
-
-// Test a function C which calls A and B which call each other.
-TEST_F(JITTest, NonLazyCompilationStillNeedsStubs) {
- TheJIT->DisableLazyCompilation(true);
-
- const FunctionType *Func1Ty =
- cast<FunctionType>(TypeBuilder<void(void), false>::get(Context));
- std::vector<const Type*> arg_types;
- arg_types.push_back(Type::getInt1Ty(Context));
- const FunctionType *FuncTy = FunctionType::get(
- Type::getVoidTy(Context), arg_types, false);
- Function *Func1 = Function::Create(Func1Ty, Function::ExternalLinkage,
- "func1", M);
- Function *Func2 = Function::Create(FuncTy, Function::InternalLinkage,
- "func2", M);
- Function *Func3 = Function::Create(FuncTy, Function::InternalLinkage,
- "func3", M);
- BasicBlock *Block1 = BasicBlock::Create(Context, "block1", Func1);
- BasicBlock *Block2 = BasicBlock::Create(Context, "block2", Func2);
- BasicBlock *True2 = BasicBlock::Create(Context, "cond_true", Func2);
- BasicBlock *False2 = BasicBlock::Create(Context, "cond_false", Func2);
- BasicBlock *Block3 = BasicBlock::Create(Context, "block3", Func3);
- BasicBlock *True3 = BasicBlock::Create(Context, "cond_true", Func3);
- BasicBlock *False3 = BasicBlock::Create(Context, "cond_false", Func3);
-
- // Make Func1 call Func2(0) and Func3(0).
- IRBuilder<> Builder(Block1);
- Builder.CreateCall(Func2, ConstantInt::getTrue(Context));
- Builder.CreateCall(Func3, ConstantInt::getTrue(Context));
- Builder.CreateRetVoid();
-
- // void Func2(bool b) { if (b) { Func3(false); return; } return; }
- Builder.SetInsertPoint(Block2);
- Builder.CreateCondBr(Func2->arg_begin(), True2, False2);
- Builder.SetInsertPoint(True2);
- Builder.CreateCall(Func3, ConstantInt::getFalse(Context));
- Builder.CreateRetVoid();
- Builder.SetInsertPoint(False2);
- Builder.CreateRetVoid();
-
- // void Func3(bool b) { if (b) { Func2(false); return; } return; }
- Builder.SetInsertPoint(Block3);
- Builder.CreateCondBr(Func3->arg_begin(), True3, False3);
- Builder.SetInsertPoint(True3);
- Builder.CreateCall(Func2, ConstantInt::getFalse(Context));
- Builder.CreateRetVoid();
- Builder.SetInsertPoint(False3);
- Builder.CreateRetVoid();
-
- // Compile the function to native code
- void (*F1Ptr)() =
- reinterpret_cast<void(*)()>((intptr_t)TheJIT->getPointerToFunction(Func1));
-
- F1Ptr();
-}
-
-// Regression test for PR5162. This used to trigger an AssertingVH inside the
-// JIT's Function to stub mapping.
-TEST_F(JITTest, NonLazyLeaksNoStubs) {
- TheJIT->DisableLazyCompilation(true);
-
- // Create two functions with a single basic block each.
- const FunctionType *FuncTy =
- cast<FunctionType>(TypeBuilder<int(), false>::get(Context));
- Function *Func1 = Function::Create(FuncTy, Function::ExternalLinkage,
- "func1", M);
- Function *Func2 = Function::Create(FuncTy, Function::InternalLinkage,
- "func2", M);
- BasicBlock *Block1 = BasicBlock::Create(Context, "block1", Func1);
- BasicBlock *Block2 = BasicBlock::Create(Context, "block2", Func2);
-
- // The first function calls the second and returns the result
- IRBuilder<> Builder(Block1);
- Value *Result = Builder.CreateCall(Func2);
- Builder.CreateRet(Result);
-
- // The second function just returns a constant
- Builder.SetInsertPoint(Block2);
- Builder.CreateRet(ConstantInt::get(TypeBuilder<int, false>::get(Context),42));
-
- // Compile the function to native code
- (void)TheJIT->getPointerToFunction(Func1);
-
- // Free the JIT state for the functions
- TheJIT->freeMachineCodeForFunction(Func1);
- TheJIT->freeMachineCodeForFunction(Func2);
-
- // Delete the first function (and show that is has no users)
- EXPECT_EQ(Func1->getNumUses(), 0u);
- Func1->eraseFromParent();
-
- // Delete the second function (and show that it has no users - it had one,
- // func1 but that's gone now)
- EXPECT_EQ(Func2->getNumUses(), 0u);
- Func2->eraseFromParent();
-}
-
-TEST_F(JITTest, ModuleDeletion) {
- TheJIT->DisableLazyCompilation(false);
- LoadAssembly("define void @main() { "
- " call i32 @computeVal() "
- " ret void "
- "} "
- " "
- "define internal i32 @computeVal() { "
- " ret i32 0 "
- "} ");
- Function *func = M->getFunction("main");
- TheJIT->getPointerToFunction(func);
- TheJIT->removeModule(M);
- delete M;
-
- SmallPtrSet<const void*, 2> FunctionsDeallocated;
- for (unsigned i = 0, e = RJMM->deallocateFunctionBodyCalls.size();
- i != e; ++i) {
- FunctionsDeallocated.insert(RJMM->deallocateFunctionBodyCalls[i].Body);
- }
- for (unsigned i = 0, e = RJMM->startFunctionBodyCalls.size(); i != e; ++i) {
- EXPECT_TRUE(FunctionsDeallocated.count(
- RJMM->startFunctionBodyCalls[i].Result))
- << "Function leaked: \n" << RJMM->startFunctionBodyCalls[i].F_dump;
- }
- EXPECT_EQ(RJMM->startFunctionBodyCalls.size(),
- RJMM->deallocateFunctionBodyCalls.size());
-
- SmallPtrSet<const void*, 2> ExceptionTablesDeallocated;
- unsigned NumTablesDeallocated = 0;
- for (unsigned i = 0, e = RJMM->deallocateExceptionTableCalls.size();
- i != e; ++i) {
- ExceptionTablesDeallocated.insert(
- RJMM->deallocateExceptionTableCalls[i].ET);
- if (RJMM->deallocateExceptionTableCalls[i].ET != NULL) {
- // If JITEmitDebugInfo is off, we'll "deallocate" NULL, which doesn't
- // appear in startExceptionTableCalls.
- NumTablesDeallocated++;
- }
- }
- for (unsigned i = 0, e = RJMM->startExceptionTableCalls.size(); i != e; ++i) {
- EXPECT_TRUE(ExceptionTablesDeallocated.count(
- RJMM->startExceptionTableCalls[i].Result))
- << "Function's exception table leaked: \n"
- << RJMM->startExceptionTableCalls[i].F_dump;
- }
- EXPECT_EQ(RJMM->startExceptionTableCalls.size(),
- NumTablesDeallocated);
-}
-
-// ARM and PPC still emit stubs for calls since the target may be too far away
-// to call directly. This #if can probably be removed when
-// http://llvm.org/PR5201 is fixed.
-#if !defined(__arm__) && !defined(__powerpc__) && !defined(__ppc__)
-typedef int (*FooPtr) ();
-
-TEST_F(JITTest, NoStubs) {
- LoadAssembly("define void @bar() {"
- "entry: "
- "ret void"
- "}"
- " "
- "define i32 @foo() {"
- "entry:"
- "call void @bar()"
- "ret i32 undef"
- "}"
- " "
- "define i32 @main() {"
- "entry:"
- "%0 = call i32 @foo()"
- "call void @bar()"
- "ret i32 undef"
- "}");
- Function *foo = M->getFunction("foo");
- uintptr_t tmp = (uintptr_t)(TheJIT->getPointerToFunction(foo));
- FooPtr ptr = (FooPtr)(tmp);
-
- (ptr)();
-
- // We should now allocate no more stubs, we have the code to foo
- // and the existing stub for bar.
- int stubsBefore = RJMM->stubsAllocated;
- Function *func = M->getFunction("main");
- TheJIT->getPointerToFunction(func);
-
- Function *bar = M->getFunction("bar");
- TheJIT->getPointerToFunction(bar);
-
- ASSERT_EQ(stubsBefore, RJMM->stubsAllocated);
-}
-#endif // !ARM && !PPC
-
-TEST_F(JITTest, FunctionPointersOutliveTheirCreator) {
- TheJIT->DisableLazyCompilation(true);
- LoadAssembly("define i8()* @get_foo_addr() { "
- " ret i8()* @foo "
- "} "
- " "
- "define i8 @foo() { "
- " ret i8 42 "
- "} ");
- Function *F_get_foo_addr = M->getFunction("get_foo_addr");
-
- typedef char(*fooT)();
- fooT (*get_foo_addr)() = reinterpret_cast<fooT(*)()>(
- (intptr_t)TheJIT->getPointerToFunction(F_get_foo_addr));
- fooT foo_addr = get_foo_addr();
-
- // Now free get_foo_addr. This should not free the machine code for foo or
- // any call stub returned as foo's canonical address.
- TheJIT->freeMachineCodeForFunction(F_get_foo_addr);
-
- // Check by calling the reported address of foo.
- EXPECT_EQ(42, foo_addr());
-
- // The reported address should also be the same as the result of a subsequent
- // getPointerToFunction(foo).
-#if 0
- // Fails until PR5126 is fixed:
- Function *F_foo = M->getFunction("foo");
- fooT foo = reinterpret_cast<fooT>(
- (intptr_t)TheJIT->getPointerToFunction(F_foo));
- EXPECT_EQ((intptr_t)foo, (intptr_t)foo_addr);
-#endif
-}
-
-// ARM doesn't have an implementation of replaceMachineCodeForFunction(), so
-// recompileAndRelinkFunction doesn't work.
-#if !defined(__arm__)
-TEST_F(JITTest, FunctionIsRecompiledAndRelinked) {
- Function *F = Function::Create(TypeBuilder<int(void), false>::get(Context),
- GlobalValue::ExternalLinkage, "test", M);
- BasicBlock *Entry = BasicBlock::Create(Context, "entry", F);
- IRBuilder<> Builder(Entry);
- Value *Val = ConstantInt::get(TypeBuilder<int, false>::get(Context), 1);
- Builder.CreateRet(Val);
-
- TheJIT->DisableLazyCompilation(true);
- // Compile the function once, and make sure it works.
- int (*OrigFPtr)() = reinterpret_cast<int(*)()>(
- (intptr_t)TheJIT->recompileAndRelinkFunction(F));
- EXPECT_EQ(1, OrigFPtr());
-
- // Now change the function to return a different value.
- Entry->eraseFromParent();
- BasicBlock *NewEntry = BasicBlock::Create(Context, "new_entry", F);
- Builder.SetInsertPoint(NewEntry);
- Val = ConstantInt::get(TypeBuilder<int, false>::get(Context), 2);
- Builder.CreateRet(Val);
- // Recompile it, which should produce a new function pointer _and_ update the
- // old one.
- int (*NewFPtr)() = reinterpret_cast<int(*)()>(
- (intptr_t)TheJIT->recompileAndRelinkFunction(F));
-
- EXPECT_EQ(2, NewFPtr())
- << "The new pointer should call the new version of the function";
- EXPECT_EQ(2, OrigFPtr())
- << "The old pointer's target should now jump to the new version";
-}
-#endif // !defined(__arm__)
-
-} // anonymous namespace
-// This variable is intentionally defined differently in the statically-compiled
-// program from the IR input to the JIT to assert that the JIT doesn't use its
-// definition.
-extern "C" int32_t JITTest_AvailableExternallyGlobal;
-int32_t JITTest_AvailableExternallyGlobal = 42;
-namespace {
-
-TEST_F(JITTest, AvailableExternallyGlobalIsntEmitted) {
- TheJIT->DisableLazyCompilation(true);
- LoadAssembly("@JITTest_AvailableExternallyGlobal = "
- " available_externally global i32 7 "
- " "
- "define i32 @loader() { "
- " %result = load i32* @JITTest_AvailableExternallyGlobal "
- " ret i32 %result "
- "} ");
- Function *loaderIR = M->getFunction("loader");
-
- int32_t (*loader)() = reinterpret_cast<int32_t(*)()>(
- (intptr_t)TheJIT->getPointerToFunction(loaderIR));
- EXPECT_EQ(42, loader()) << "func should return 42 from the external global,"
- << " not 7 from the IR version.";
-}
-
-} // anonymous namespace
-// This function is intentionally defined differently in the statically-compiled
-// program from the IR input to the JIT to assert that the JIT doesn't use its
-// definition.
-extern "C" int32_t JITTest_AvailableExternallyFunction() {
- return 42;
-}
-namespace {
-
-TEST_F(JITTest, AvailableExternallyFunctionIsntCompiled) {
- TheJIT->DisableLazyCompilation(true);
- LoadAssembly("define available_externally i32 "
- " @JITTest_AvailableExternallyFunction() { "
- " ret i32 7 "
- "} "
- " "
- "define i32 @func() { "
- " %result = tail call i32 "
- " @JITTest_AvailableExternallyFunction() "
- " ret i32 %result "
- "} ");
- Function *funcIR = M->getFunction("func");
-
- int32_t (*func)() = reinterpret_cast<int32_t(*)()>(
- (intptr_t)TheJIT->getPointerToFunction(funcIR));
- EXPECT_EQ(42, func()) << "func should return 42 from the static version,"
- << " not 7 from the IR version.";
-}
-
-TEST_F(JITTest, NeedsExactSizeWithManyGlobals) {
- // PR5291: When the JMM needed the exact size of function bodies before
- // starting to emit them, the JITEmitter would modify a set while iterating
- // over it.
- TheJIT->DisableLazyCompilation(true);
- RJMM->setSizeRequired(true);
-
- LoadAssembly("@A = global i32 42 "
- "@B = global i32* @A "
- "@C = global i32** @B "
- "@D = global i32*** @C "
- "@E = global i32**** @D "
- "@F = global i32***** @E "
- "@G = global i32****** @F "
- "@H = global i32******* @G "
- "@I = global i32******** @H "
- "define i32********* @test() { "
- " ret i32********* @I "
- "}");
- Function *testIR = M->getFunction("test");
- int32_t********* (*test)() = reinterpret_cast<int32_t*********(*)()>(
- (intptr_t)TheJIT->getPointerToFunction(testIR));
- EXPECT_EQ(42, *********test());
-}
-
-TEST_F(JITTest, EscapedLazyStubStillCallable) {
- TheJIT->DisableLazyCompilation(false);
- LoadAssembly("define internal i32 @stubbed() { "
- " ret i32 42 "
- "} "
- " "
- "define i32()* @get_stub() { "
- " ret i32()* @stubbed "
- "} ");
- typedef int32_t(*StubTy)();
-
- // Call get_stub() to get the address of @stubbed without actually JITting it.
- Function *get_stubIR = M->getFunction("get_stub");
- StubTy (*get_stub)() = reinterpret_cast<StubTy(*)()>(
- (intptr_t)TheJIT->getPointerToFunction(get_stubIR));
- StubTy stubbed = get_stub();
- // Now get_stubIR is the only reference to stubbed's stub.
- get_stubIR->eraseFromParent();
- // Now there are no references inside the JIT, but we've got a pointer outside
- // it. The stub should be callable and return the right value.
- EXPECT_EQ(42, stubbed());
-}
-
-// Converts the LLVM assembly to bitcode and returns it in a std::string. An
-// empty string indicates an error.
-std::string AssembleToBitcode(LLVMContext &Context, const char *Assembly) {
- Module TempModule("TempModule", Context);
- if (!LoadAssemblyInto(&TempModule, Assembly)) {
- return "";
- }
-
- std::string Result;
- raw_string_ostream OS(Result);
- WriteBitcodeToFile(&TempModule, OS);
- OS.flush();
- return Result;
-}
-
-// Returns a newly-created ExecutionEngine that reads the bitcode in 'Bitcode'
-// lazily. The associated Module (owned by the ExecutionEngine) is returned in
-// M. Both will be NULL on an error. Bitcode must live at least as long as the
-// ExecutionEngine.
-ExecutionEngine *getJITFromBitcode(
- LLVMContext &Context, const std::string &Bitcode, Module *&M) {
- // c_str() is null-terminated like MemoryBuffer::getMemBuffer requires.
- MemoryBuffer *BitcodeBuffer =
- MemoryBuffer::getMemBuffer(Bitcode, "Bitcode for test");
- std::string errMsg;
- M = getLazyBitcodeModule(BitcodeBuffer, Context, &errMsg);
- if (M == NULL) {
- ADD_FAILURE() << errMsg;
- delete BitcodeBuffer;
- return NULL;
- }
- ExecutionEngine *TheJIT = EngineBuilder(M)
- .setEngineKind(EngineKind::JIT)
- .setErrorStr(&errMsg)
- .create();
- if (TheJIT == NULL) {
- ADD_FAILURE() << errMsg;
- delete M;
- M = NULL;
- return NULL;
- }
- return TheJIT;
-}
-
-TEST(LazyLoadedJITTest, MaterializableAvailableExternallyFunctionIsntCompiled) {
- LLVMContext Context;
- const std::string Bitcode =
- AssembleToBitcode(Context,
- "define available_externally i32 "
- " @JITTest_AvailableExternallyFunction() { "
- " ret i32 7 "
- "} "
- " "
- "define i32 @func() { "
- " %result = tail call i32 "
- " @JITTest_AvailableExternallyFunction() "
- " ret i32 %result "
- "} ");
- ASSERT_FALSE(Bitcode.empty()) << "Assembling failed";
- Module *M;
- OwningPtr<ExecutionEngine> TheJIT(getJITFromBitcode(Context, Bitcode, M));
- ASSERT_TRUE(TheJIT.get()) << "Failed to create JIT.";
- TheJIT->DisableLazyCompilation(true);
-
- Function *funcIR = M->getFunction("func");
- Function *availableFunctionIR =
- M->getFunction("JITTest_AvailableExternallyFunction");
-
- // Double-check that the available_externally function is still unmaterialized
- // when getPointerToFunction needs to find out if it's available_externally.
- EXPECT_TRUE(availableFunctionIR->isMaterializable());
-
- int32_t (*func)() = reinterpret_cast<int32_t(*)()>(
- (intptr_t)TheJIT->getPointerToFunction(funcIR));
- EXPECT_EQ(42, func()) << "func should return 42 from the static version,"
- << " not 7 from the IR version.";
-}
-
-TEST(LazyLoadedJITTest, EagerCompiledRecursionThroughGhost) {
- LLVMContext Context;
- const std::string Bitcode =
- AssembleToBitcode(Context,
- "define i32 @recur1(i32 %a) { "
- " %zero = icmp eq i32 %a, 0 "
- " br i1 %zero, label %done, label %notdone "
- "done: "
- " ret i32 3 "
- "notdone: "
- " %am1 = sub i32 %a, 1 "
- " %result = call i32 @recur2(i32 %am1) "
- " ret i32 %result "
- "} "
- " "
- "define i32 @recur2(i32 %b) { "
- " %result = call i32 @recur1(i32 %b) "
- " ret i32 %result "
- "} ");
- ASSERT_FALSE(Bitcode.empty()) << "Assembling failed";
- Module *M;
- OwningPtr<ExecutionEngine> TheJIT(getJITFromBitcode(Context, Bitcode, M));
- ASSERT_TRUE(TheJIT.get()) << "Failed to create JIT.";
- TheJIT->DisableLazyCompilation(true);
-
- Function *recur1IR = M->getFunction("recur1");
- Function *recur2IR = M->getFunction("recur2");
- EXPECT_TRUE(recur1IR->isMaterializable());
- EXPECT_TRUE(recur2IR->isMaterializable());
-
- int32_t (*recur1)(int32_t) = reinterpret_cast<int32_t(*)(int32_t)>(
- (intptr_t)TheJIT->getPointerToFunction(recur1IR));
- EXPECT_EQ(3, recur1(4));
-}
-
-// This code is copied from JITEventListenerTest, but it only runs once for all
-// the tests in this directory. Everything seems fine, but that's strange
-// behavior.
-class JITEnvironment : public testing::Environment {
- virtual void SetUp() {
- // Required to create a JIT.
- InitializeNativeTarget();
- }
-};
-testing::Environment* const jit_env =
- testing::AddGlobalTestEnvironment(new JITEnvironment);
-
-}
diff --git a/contrib/llvm/unittests/ExecutionEngine/JIT/Makefile b/contrib/llvm/unittests/ExecutionEngine/JIT/Makefile
deleted file mode 100644
index f5abe75..0000000
--- a/contrib/llvm/unittests/ExecutionEngine/JIT/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-##===- unittests/ExecutionEngine/JIT/Makefile --------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../../..
-TESTNAME = JIT
-LINK_COMPONENTS := asmparser bitreader bitwriter core jit native support
-
-include $(LEVEL)/Makefile.config
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
-
-# Permit these tests to use the JIT's symbolic lookup.
-LD.Flags += $(RDYNAMIC)
diff --git a/contrib/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp b/contrib/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
deleted file mode 100644
index 8997d39..0000000
--- a/contrib/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-//===- MultiJITTest.cpp - Unit tests for instantiating multiple JITs ------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#include "llvm/Assembly/Parser.h"
-#include "llvm/ExecutionEngine/GenericValue.h"
-#include "llvm/ExecutionEngine/JIT.h"
-#include "llvm/Support/SourceMgr.h"
-#include <vector>
-
-using namespace llvm;
-
-namespace {
-
-bool LoadAssemblyInto(Module *M, const char *assembly) {
- SMDiagnostic Error;
- bool success =
- NULL != ParseAssemblyString(assembly, M, Error, M->getContext());
- std::string errMsg;
- raw_string_ostream os(errMsg);
- Error.Print("", os);
- EXPECT_TRUE(success) << os.str();
- return success;
-}
-
-void createModule1(LLVMContext &Context1, Module *&M1, Function *&FooF1) {
- M1 = new Module("test1", Context1);
- LoadAssemblyInto(M1,
- "define i32 @add1(i32 %ArgX1) { "
- "entry: "
- " %addresult = add i32 1, %ArgX1 "
- " ret i32 %addresult "
- "} "
- " "
- "define i32 @foo1() { "
- "entry: "
- " %add1 = call i32 @add1(i32 10) "
- " ret i32 %add1 "
- "} ");
- FooF1 = M1->getFunction("foo1");
-}
-
-void createModule2(LLVMContext &Context2, Module *&M2, Function *&FooF2) {
- M2 = new Module("test2", Context2);
- LoadAssemblyInto(M2,
- "define i32 @add2(i32 %ArgX2) { "
- "entry: "
- " %addresult = add i32 2, %ArgX2 "
- " ret i32 %addresult "
- "} "
- " "
- "define i32 @foo2() { "
- "entry: "
- " %add2 = call i32 @add2(i32 10) "
- " ret i32 %add2 "
- "} ");
- FooF2 = M2->getFunction("foo2");
-}
-
-TEST(MultiJitTest, EagerMode) {
- LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
- createModule1(Context1, M1, FooF1);
-
- LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
- createModule2(Context2, M2, FooF2);
-
- // Now we create the JIT in eager mode
- OwningPtr<ExecutionEngine> EE1(EngineBuilder(M1).create());
- EE1->DisableLazyCompilation(true);
- OwningPtr<ExecutionEngine> EE2(EngineBuilder(M2).create());
- EE2->DisableLazyCompilation(true);
-
- // Call the `foo' function with no arguments:
- std::vector<GenericValue> noargs;
- GenericValue gv1 = EE1->runFunction(FooF1, noargs);
- GenericValue gv2 = EE2->runFunction(FooF2, noargs);
-
- // Import result of execution:
- EXPECT_EQ(gv1.IntVal, 11);
- EXPECT_EQ(gv2.IntVal, 12);
-
- EE1->freeMachineCodeForFunction(FooF1);
- EE2->freeMachineCodeForFunction(FooF2);
-}
-
-TEST(MultiJitTest, LazyMode) {
- LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
- createModule1(Context1, M1, FooF1);
-
- LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
- createModule2(Context2, M2, FooF2);
-
- // Now we create the JIT in lazy mode
- OwningPtr<ExecutionEngine> EE1(EngineBuilder(M1).create());
- EE1->DisableLazyCompilation(false);
- OwningPtr<ExecutionEngine> EE2(EngineBuilder(M2).create());
- EE2->DisableLazyCompilation(false);
-
- // Call the `foo' function with no arguments:
- std::vector<GenericValue> noargs;
- GenericValue gv1 = EE1->runFunction(FooF1, noargs);
- GenericValue gv2 = EE2->runFunction(FooF2, noargs);
-
- // Import result of execution:
- EXPECT_EQ(gv1.IntVal, 11);
- EXPECT_EQ(gv2.IntVal, 12);
-
- EE1->freeMachineCodeForFunction(FooF1);
- EE2->freeMachineCodeForFunction(FooF2);
-}
-
-extern "C" {
- extern void *getPointerToNamedFunction(const char *Name);
-}
-
-TEST(MultiJitTest, JitPool) {
- LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
- createModule1(Context1, M1, FooF1);
-
- LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
- createModule2(Context2, M2, FooF2);
-
- // Now we create two JITs
- OwningPtr<ExecutionEngine> EE1(EngineBuilder(M1).create());
- OwningPtr<ExecutionEngine> EE2(EngineBuilder(M2).create());
-
- Function *F1 = EE1->FindFunctionNamed("foo1");
- void *foo1 = EE1->getPointerToFunction(F1);
-
- Function *F2 = EE2->FindFunctionNamed("foo2");
- void *foo2 = EE2->getPointerToFunction(F2);
-
- // Function in M1
- EXPECT_EQ(getPointerToNamedFunction("foo1"), foo1);
-
- // Function in M2
- EXPECT_EQ(getPointerToNamedFunction("foo2"), foo2);
-
- // Symbol search
- EXPECT_EQ((intptr_t)getPointerToNamedFunction("getPointerToNamedFunction"),
- (intptr_t)&getPointerToNamedFunction);
-}
-
-} // anonymous namespace
diff --git a/contrib/llvm/unittests/ExecutionEngine/Makefile b/contrib/llvm/unittests/ExecutionEngine/Makefile
deleted file mode 100644
index d4ef92f..0000000
--- a/contrib/llvm/unittests/ExecutionEngine/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-##===- unittests/ExecutionEngine/Makefile ------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../..
-TESTNAME = ExecutionEngine
-LINK_COMPONENTS := engine interpreter
-
-include $(LEVEL)/Makefile.config
-
-PARALLEL_DIRS = JIT
-
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/contrib/llvm/unittests/Makefile b/contrib/llvm/unittests/Makefile
deleted file mode 100644
index 9f377cd..0000000
--- a/contrib/llvm/unittests/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-##===- unittests/Makefile ----------------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ..
-
-PARALLEL_DIRS = ADT ExecutionEngine Support Transforms VMCore
-
-include $(LEVEL)/Makefile.common
-
-clean::
- $(Verb) $(RM) -f *Tests
diff --git a/contrib/llvm/unittests/Makefile.unittest b/contrib/llvm/unittests/Makefile.unittest
deleted file mode 100644
index 8fbcfd2..0000000
--- a/contrib/llvm/unittests/Makefile.unittest
+++ /dev/null
@@ -1,54 +0,0 @@
-##===- unittests/Makefile.unittest -------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-#
-# This file is included by all of the unit test makefiles.
-#
-##===----------------------------------------------------------------------===##
-
-# Set up variables for building a unit test.
-ifdef TESTNAME
-
-include $(LEVEL)/Makefile.common
-
-LLVMUnitTestExe = $(BuildMode)/$(TESTNAME)Tests$(EXEEXT)
-
-# Note that these flags are duplicated when building GoogleTest itself in
-# utils/unittest/googletest/Makefile; ensure that any changes are made to both.
-CPP.Flags += -I$(LLVM_SRC_ROOT)/utils/unittest/googletest/include
-CPP.Flags += $(NO_MISSING_FIELD_INITIALIZERS) $(NO_VARIADIC_MACROS)
-CPP.Flags += -DGTEST_HAS_RTTI=0
-# libstdc++'s TR1 <tuple> header depends on RTTI and uses C++'0x features not
-# supported by Clang, so force googletest to use its own tuple implementation.
-# When we import googletest >=1.4.0, we can drop this line.
-CPP.Flags += -DGTEST_HAS_TR1_TUPLE=0
-
-TESTLIBS = -lGoogleTest -lUnitTestMain
-
-ifeq ($(ENABLE_SHARED), 1)
- # Add the absolute path to the dynamic library. This is ok because
- # we'll never install unittests.
- LD.Flags += $(RPATH) -Wl,$(LibDir)
- # Also set {DYLD,LD}_LIBRARY_PATH because OSX ignores the rpath most
- # of the time.
- Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)"
-endif
-
-$(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
- $(Echo) Linking $(BuildMode) unit test $(TESTNAME) $(StripWarnMsg)
- $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
- $(TESTLIBS) $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
- $(Echo) ======= Finished Linking $(BuildMode) Unit test $(TESTNAME) \
- $(StripWarnMsg)
-
-all:: $(LLVMUnitTestExe)
-
-unitcheck:: $(LLVMUnitTestExe)
- $(Run.Shared) $(LLVMUnitTestExe)
-
-endif
diff --git a/contrib/llvm/unittests/Support/AllocatorTest.cpp b/contrib/llvm/unittests/Support/AllocatorTest.cpp
deleted file mode 100644
index 6c0fca9..0000000
--- a/contrib/llvm/unittests/Support/AllocatorTest.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-//===- llvm/unittest/Support/AllocatorTest.cpp - BumpPtrAllocator tests ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/Allocator.h"
-
-#include "gtest/gtest.h"
-#include <cstdlib>
-
-using namespace llvm;
-
-namespace {
-
-TEST(AllocatorTest, Basics) {
- BumpPtrAllocator Alloc;
- int *a = (int*)Alloc.Allocate(sizeof(int), 0);
- int *b = (int*)Alloc.Allocate(sizeof(int) * 10, 0);
- int *c = (int*)Alloc.Allocate(sizeof(int), 0);
- *a = 1;
- b[0] = 2;
- b[9] = 2;
- *c = 3;
- EXPECT_EQ(1, *a);
- EXPECT_EQ(2, b[0]);
- EXPECT_EQ(2, b[9]);
- EXPECT_EQ(3, *c);
- EXPECT_EQ(1U, Alloc.GetNumSlabs());
-}
-
-// Allocate enough bytes to create three slabs.
-TEST(AllocatorTest, ThreeSlabs) {
- BumpPtrAllocator Alloc(4096, 4096);
- Alloc.Allocate(3000, 0);
- EXPECT_EQ(1U, Alloc.GetNumSlabs());
- Alloc.Allocate(3000, 0);
- EXPECT_EQ(2U, Alloc.GetNumSlabs());
- Alloc.Allocate(3000, 0);
- EXPECT_EQ(3U, Alloc.GetNumSlabs());
-}
-
-// Allocate enough bytes to create two slabs, reset the allocator, and do it
-// again.
-TEST(AllocatorTest, TestReset) {
- BumpPtrAllocator Alloc(4096, 4096);
- Alloc.Allocate(3000, 0);
- EXPECT_EQ(1U, Alloc.GetNumSlabs());
- Alloc.Allocate(3000, 0);
- EXPECT_EQ(2U, Alloc.GetNumSlabs());
- Alloc.Reset();
- EXPECT_EQ(1U, Alloc.GetNumSlabs());
- Alloc.Allocate(3000, 0);
- EXPECT_EQ(1U, Alloc.GetNumSlabs());
- Alloc.Allocate(3000, 0);
- EXPECT_EQ(2U, Alloc.GetNumSlabs());
-}
-
-// Test some allocations at varying alignments.
-TEST(AllocatorTest, TestAlignment) {
- BumpPtrAllocator Alloc;
- uintptr_t a;
- a = (uintptr_t)Alloc.Allocate(1, 2);
- EXPECT_EQ(0U, a & 1);
- a = (uintptr_t)Alloc.Allocate(1, 4);
- EXPECT_EQ(0U, a & 3);
- a = (uintptr_t)Alloc.Allocate(1, 8);
- EXPECT_EQ(0U, a & 7);
- a = (uintptr_t)Alloc.Allocate(1, 16);
- EXPECT_EQ(0U, a & 15);
- a = (uintptr_t)Alloc.Allocate(1, 32);
- EXPECT_EQ(0U, a & 31);
- a = (uintptr_t)Alloc.Allocate(1, 64);
- EXPECT_EQ(0U, a & 63);
- a = (uintptr_t)Alloc.Allocate(1, 128);
- EXPECT_EQ(0U, a & 127);
-}
-
-// Test allocating just over the slab size. This tests a bug where before the
-// allocator incorrectly calculated the buffer end pointer.
-TEST(AllocatorTest, TestOverflow) {
- BumpPtrAllocator Alloc(4096, 4096);
-
- // Fill the slab right up until the end pointer.
- Alloc.Allocate(4096 - sizeof(MemSlab), 0);
- EXPECT_EQ(1U, Alloc.GetNumSlabs());
-
- // If we don't allocate a new slab, then we will have overflowed.
- Alloc.Allocate(1, 0);
- EXPECT_EQ(2U, Alloc.GetNumSlabs());
-}
-
-// Mock slab allocator that returns slabs aligned on 4096 bytes. There is no
-// easy portable way to do this, so this is kind of a hack.
-class MockSlabAllocator : public SlabAllocator {
- MemSlab *LastSlab;
-
-public:
- virtual ~MockSlabAllocator() { }
-
- virtual MemSlab *Allocate(size_t Size) {
- // Allocate space for the alignment, the slab, and a void* that goes right
- // before the slab.
- size_t Alignment = 4096;
- void *MemBase = malloc(Size + Alignment - 1 + sizeof(void*));
-
- // Make the slab.
- MemSlab *Slab = (MemSlab*)(((uintptr_t)MemBase+sizeof(void*)+Alignment-1) &
- ~(uintptr_t)(Alignment - 1));
- Slab->Size = Size;
- Slab->NextPtr = 0;
-
- // Hold a pointer to the base so we can free the whole malloced block.
- ((void**)Slab)[-1] = MemBase;
-
- LastSlab = Slab;
- return Slab;
- }
-
- virtual void Deallocate(MemSlab *Slab) {
- free(((void**)Slab)[-1]);
- }
-
- MemSlab *GetLastSlab() {
- return LastSlab;
- }
-};
-
-// Allocate a large-ish block with a really large alignment so that the
-// allocator will think that it has space, but after it does the alignment it
-// will not.
-TEST(AllocatorTest, TestBigAlignment) {
- MockSlabAllocator SlabAlloc;
- BumpPtrAllocator Alloc(4096, 4096, SlabAlloc);
- uintptr_t Ptr = (uintptr_t)Alloc.Allocate(3000, 2048);
- MemSlab *Slab = SlabAlloc.GetLastSlab();
- EXPECT_LE(Ptr + 3000, ((uintptr_t)Slab) + Slab->Size);
-}
-
-} // anonymous namespace
diff --git a/contrib/llvm/unittests/Support/CommandLineTest.cpp b/contrib/llvm/unittests/Support/CommandLineTest.cpp
deleted file mode 100644
index 72fa24a..0000000
--- a/contrib/llvm/unittests/Support/CommandLineTest.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===- llvm/unittest/Support/CommandLineTest.cpp - CommandLine tests ------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Config/config.h"
-
-#include "gtest/gtest.h"
-
-#include <string>
-#include <stdlib.h>
-
-using namespace llvm;
-
-namespace {
-
-class TempEnvVar {
- public:
- TempEnvVar(const char *name, const char *value)
- : name(name) {
- const char *old_value = getenv(name);
- EXPECT_EQ(NULL, old_value) << old_value;
-#if HAVE_SETENV
- setenv(name, value, true);
-#else
-# define SKIP_ENVIRONMENT_TESTS
-#endif
- }
-
- ~TempEnvVar() {
-#if HAVE_SETENV
- // Assume setenv and unsetenv come together.
- unsetenv(name);
-#endif
- }
-
- private:
- const char *const name;
-};
-
-#ifndef SKIP_ENVIRONMENT_TESTS
-
-const char test_env_var[] = "LLVM_TEST_COMMAND_LINE_FLAGS";
-
-cl::opt<std::string> EnvironmentTestOption("env-test-opt");
-TEST(CommandLineTest, ParseEnvironment) {
- TempEnvVar TEV(test_env_var, "-env-test-opt=hello");
- EXPECT_EQ("", EnvironmentTestOption);
- cl::ParseEnvironmentOptions("CommandLineTest", test_env_var);
- EXPECT_EQ("hello", EnvironmentTestOption);
-}
-
-#endif // SKIP_ENVIRONMENT_TESTS
-
-} // anonymous namespace
diff --git a/contrib/llvm/unittests/Support/ConstantRangeTest.cpp b/contrib/llvm/unittests/Support/ConstantRangeTest.cpp
deleted file mode 100644
index 6b8d01d..0000000
--- a/contrib/llvm/unittests/Support/ConstantRangeTest.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-//===- llvm/unittest/Support/ConstantRangeTest.cpp - ConstantRange tests --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/ConstantRange.h"
-
-#include "gtest/gtest.h"
-
-using namespace llvm;
-
-namespace {
-
-class ConstantRangeTest : public ::testing::Test {
-protected:
- static ConstantRange Full;
- static ConstantRange Empty;
- static ConstantRange One;
- static ConstantRange Some;
- static ConstantRange Wrap;
-};
-
-ConstantRange ConstantRangeTest::Full(16);
-ConstantRange ConstantRangeTest::Empty(16, false);
-ConstantRange ConstantRangeTest::One(APInt(16, 0xa));
-ConstantRange ConstantRangeTest::Some(APInt(16, 0xa), APInt(16, 0xaaa));
-ConstantRange ConstantRangeTest::Wrap(APInt(16, 0xaaa), APInt(16, 0xa));
-
-TEST_F(ConstantRangeTest, Basics) {
- EXPECT_TRUE(Full.isFullSet());
- EXPECT_FALSE(Full.isEmptySet());
- EXPECT_FALSE(Full.isWrappedSet());
- EXPECT_TRUE(Full.contains(APInt(16, 0x0)));
- EXPECT_TRUE(Full.contains(APInt(16, 0x9)));
- EXPECT_TRUE(Full.contains(APInt(16, 0xa)));
- EXPECT_TRUE(Full.contains(APInt(16, 0xaa9)));
- EXPECT_TRUE(Full.contains(APInt(16, 0xaaa)));
-
- EXPECT_FALSE(Empty.isFullSet());
- EXPECT_TRUE(Empty.isEmptySet());
- EXPECT_FALSE(Empty.isWrappedSet());
- EXPECT_FALSE(Empty.contains(APInt(16, 0x0)));
- EXPECT_FALSE(Empty.contains(APInt(16, 0x9)));
- EXPECT_FALSE(Empty.contains(APInt(16, 0xa)));
- EXPECT_FALSE(Empty.contains(APInt(16, 0xaa9)));
- EXPECT_FALSE(Empty.contains(APInt(16, 0xaaa)));
-
- EXPECT_FALSE(One.isFullSet());
- EXPECT_FALSE(One.isEmptySet());
- EXPECT_FALSE(One.isWrappedSet());
- EXPECT_FALSE(One.contains(APInt(16, 0x0)));
- EXPECT_FALSE(One.contains(APInt(16, 0x9)));
- EXPECT_TRUE(One.contains(APInt(16, 0xa)));
- EXPECT_FALSE(One.contains(APInt(16, 0xaa9)));
- EXPECT_FALSE(One.contains(APInt(16, 0xaaa)));
-
- EXPECT_FALSE(Some.isFullSet());
- EXPECT_FALSE(Some.isEmptySet());
- EXPECT_FALSE(Some.isWrappedSet());
- EXPECT_FALSE(Some.contains(APInt(16, 0x0)));
- EXPECT_FALSE(Some.contains(APInt(16, 0x9)));
- EXPECT_TRUE(Some.contains(APInt(16, 0xa)));
- EXPECT_TRUE(Some.contains(APInt(16, 0xaa9)));
- EXPECT_FALSE(Some.contains(APInt(16, 0xaaa)));
-
- EXPECT_FALSE(Wrap.isFullSet());
- EXPECT_FALSE(Wrap.isEmptySet());
- EXPECT_TRUE(Wrap.isWrappedSet());
- EXPECT_TRUE(Wrap.contains(APInt(16, 0x0)));
- EXPECT_TRUE(Wrap.contains(APInt(16, 0x9)));
- EXPECT_FALSE(Wrap.contains(APInt(16, 0xa)));
- EXPECT_FALSE(Wrap.contains(APInt(16, 0xaa9)));
- EXPECT_TRUE(Wrap.contains(APInt(16, 0xaaa)));
-}
-
-TEST_F(ConstantRangeTest, Equality) {
- EXPECT_EQ(Full, Full);
- EXPECT_EQ(Empty, Empty);
- EXPECT_EQ(One, One);
- EXPECT_EQ(Some, Some);
- EXPECT_EQ(Wrap, Wrap);
- EXPECT_NE(Full, Empty);
- EXPECT_NE(Full, One);
- EXPECT_NE(Full, Some);
- EXPECT_NE(Full, Wrap);
- EXPECT_NE(Empty, One);
- EXPECT_NE(Empty, Some);
- EXPECT_NE(Empty, Wrap);
- EXPECT_NE(One, Some);
- EXPECT_NE(One, Wrap);
- EXPECT_NE(Some, Wrap);
-}
-
-TEST_F(ConstantRangeTest, SingleElement) {
- EXPECT_EQ(Full.getSingleElement(), static_cast<APInt *>(NULL));
- EXPECT_EQ(Empty.getSingleElement(), static_cast<APInt *>(NULL));
- EXPECT_EQ(*One.getSingleElement(), APInt(16, 0xa));
- EXPECT_EQ(Some.getSingleElement(), static_cast<APInt *>(NULL));
- EXPECT_EQ(Wrap.getSingleElement(), static_cast<APInt *>(NULL));
-
- EXPECT_FALSE(Full.isSingleElement());
- EXPECT_FALSE(Empty.isSingleElement());
- EXPECT_TRUE(One.isSingleElement());
- EXPECT_FALSE(Some.isSingleElement());
- EXPECT_FALSE(Wrap.isSingleElement());
-}
-
-TEST_F(ConstantRangeTest, GetSetSize) {
- EXPECT_EQ(Full.getSetSize(), APInt(16, 0));
- EXPECT_EQ(Empty.getSetSize(), APInt(16, 0));
- EXPECT_EQ(One.getSetSize(), APInt(16, 1));
- EXPECT_EQ(Some.getSetSize(), APInt(16, 0xaa0));
- EXPECT_EQ(Wrap.getSetSize(), APInt(16, 0x10000 - 0xaa0));
-}
-
-TEST_F(ConstantRangeTest, GetMinsAndMaxes) {
- EXPECT_EQ(Full.getUnsignedMax(), APInt(16, UINT16_MAX));
- EXPECT_EQ(One.getUnsignedMax(), APInt(16, 0xa));
- EXPECT_EQ(Some.getUnsignedMax(), APInt(16, 0xaa9));
- EXPECT_EQ(Wrap.getUnsignedMax(), APInt(16, UINT16_MAX));
-
- EXPECT_EQ(Full.getUnsignedMin(), APInt(16, 0));
- EXPECT_EQ(One.getUnsignedMin(), APInt(16, 0xa));
- EXPECT_EQ(Some.getUnsignedMin(), APInt(16, 0xa));
- EXPECT_EQ(Wrap.getUnsignedMin(), APInt(16, 0));
-
- EXPECT_EQ(Full.getSignedMax(), APInt(16, INT16_MAX));
- EXPECT_EQ(One.getSignedMax(), APInt(16, 0xa));
- EXPECT_EQ(Some.getSignedMax(), APInt(16, 0xaa9));
- EXPECT_EQ(Wrap.getSignedMax(), APInt(16, INT16_MAX));
-
- EXPECT_EQ(Full.getSignedMin(), APInt(16, (uint64_t)INT16_MIN));
- EXPECT_EQ(One.getSignedMin(), APInt(16, 0xa));
- EXPECT_EQ(Some.getSignedMin(), APInt(16, 0xa));
- EXPECT_EQ(Wrap.getSignedMin(), APInt(16, (uint64_t)INT16_MIN));
-
- // Found by Klee
- EXPECT_EQ(ConstantRange(APInt(4, 7), APInt(4, 0)).getSignedMax(),
- APInt(4, 7));
-}
-
-TEST_F(ConstantRangeTest, Trunc) {
- ConstantRange TFull = Full.truncate(10);
- ConstantRange TEmpty = Empty.truncate(10);
- ConstantRange TOne = One.truncate(10);
- ConstantRange TSome = Some.truncate(10);
- ConstantRange TWrap = Wrap.truncate(10);
- EXPECT_TRUE(TFull.isFullSet());
- EXPECT_TRUE(TEmpty.isEmptySet());
- EXPECT_EQ(TOne, ConstantRange(APInt(One.getLower()).trunc(10),
- APInt(One.getUpper()).trunc(10)));
- EXPECT_TRUE(TSome.isFullSet());
-}
-
-TEST_F(ConstantRangeTest, ZExt) {
- ConstantRange ZFull = Full.zeroExtend(20);
- ConstantRange ZEmpty = Empty.zeroExtend(20);
- ConstantRange ZOne = One.zeroExtend(20);
- ConstantRange ZSome = Some.zeroExtend(20);
- ConstantRange ZWrap = Wrap.zeroExtend(20);
- EXPECT_EQ(ZFull, ConstantRange(APInt(20, 0), APInt(20, 0x10000)));
- EXPECT_TRUE(ZEmpty.isEmptySet());
- EXPECT_EQ(ZOne, ConstantRange(APInt(One.getLower()).zext(20),
- APInt(One.getUpper()).zext(20)));
- EXPECT_EQ(ZSome, ConstantRange(APInt(Some.getLower()).zext(20),
- APInt(Some.getUpper()).zext(20)));
- EXPECT_EQ(ZWrap, ConstantRange(APInt(Wrap.getLower()).zext(20),
- APInt(Wrap.getUpper()).zext(20)));
-}
-
-TEST_F(ConstantRangeTest, SExt) {
- ConstantRange SFull = Full.signExtend(20);
- ConstantRange SEmpty = Empty.signExtend(20);
- ConstantRange SOne = One.signExtend(20);
- ConstantRange SSome = Some.signExtend(20);
- ConstantRange SWrap = Wrap.signExtend(20);
- EXPECT_EQ(SFull, ConstantRange(APInt(20, (uint64_t)INT16_MIN, true),
- APInt(20, INT16_MAX + 1, true)));
- EXPECT_TRUE(SEmpty.isEmptySet());
- EXPECT_EQ(SOne, ConstantRange(APInt(One.getLower()).sext(20),
- APInt(One.getUpper()).sext(20)));
- EXPECT_EQ(SSome, ConstantRange(APInt(Some.getLower()).sext(20),
- APInt(Some.getUpper()).sext(20)));
- EXPECT_EQ(SWrap, ConstantRange(APInt(Wrap.getLower()).sext(20),
- APInt(Wrap.getUpper()).sext(20)));
-}
-
-TEST_F(ConstantRangeTest, IntersectWith) {
- EXPECT_EQ(Empty.intersectWith(Full), Empty);
- EXPECT_EQ(Empty.intersectWith(Empty), Empty);
- EXPECT_EQ(Empty.intersectWith(One), Empty);
- EXPECT_EQ(Empty.intersectWith(Some), Empty);
- EXPECT_EQ(Empty.intersectWith(Wrap), Empty);
- EXPECT_EQ(Full.intersectWith(Full), Full);
- EXPECT_EQ(Some.intersectWith(Some), Some);
- EXPECT_EQ(Some.intersectWith(One), One);
- EXPECT_EQ(Full.intersectWith(One), One);
- EXPECT_EQ(Full.intersectWith(Some), Some);
- EXPECT_EQ(Some.intersectWith(Wrap), Empty);
- EXPECT_EQ(One.intersectWith(Wrap), Empty);
- EXPECT_EQ(One.intersectWith(Wrap), Wrap.intersectWith(One));
-
- // Klee generated testcase from PR4545.
- // The intersection of i16 [4, 2) and [6, 5) is disjoint, looking like
- // 01..4.6789ABCDEF where the dots represent values not in the intersection.
- ConstantRange LHS(APInt(16, 4), APInt(16, 2));
- ConstantRange RHS(APInt(16, 6), APInt(16, 5));
- EXPECT_TRUE(LHS.intersectWith(RHS) == LHS);
-}
-
-TEST_F(ConstantRangeTest, UnionWith) {
- EXPECT_EQ(Wrap.unionWith(One),
- ConstantRange(APInt(16, 0xaaa), APInt(16, 0xb)));
- EXPECT_EQ(One.unionWith(Wrap), Wrap.unionWith(One));
- EXPECT_EQ(Empty.unionWith(Empty), Empty);
- EXPECT_EQ(Full.unionWith(Full), Full);
- EXPECT_EQ(Some.unionWith(Wrap), Full);
-
- // PR4545
- EXPECT_EQ(ConstantRange(APInt(16, 14), APInt(16, 1)).unionWith(
- ConstantRange(APInt(16, 0), APInt(16, 8))),
- ConstantRange(APInt(16, 14), APInt(16, 8)));
- EXPECT_EQ(ConstantRange(APInt(16, 6), APInt(16, 4)).unionWith(
- ConstantRange(APInt(16, 4), APInt(16, 0))),
- ConstantRange(16));
- EXPECT_EQ(ConstantRange(APInt(16, 1), APInt(16, 0)).unionWith(
- ConstantRange(APInt(16, 2), APInt(16, 1))),
- ConstantRange(16));
-}
-
-TEST_F(ConstantRangeTest, SubtractAPInt) {
- EXPECT_EQ(Full.subtract(APInt(16, 4)), Full);
- EXPECT_EQ(Empty.subtract(APInt(16, 4)), Empty);
- EXPECT_EQ(Some.subtract(APInt(16, 4)),
- ConstantRange(APInt(16, 0x6), APInt(16, 0xaa6)));
- EXPECT_EQ(Wrap.subtract(APInt(16, 4)),
- ConstantRange(APInt(16, 0xaa6), APInt(16, 0x6)));
- EXPECT_EQ(One.subtract(APInt(16, 4)),
- ConstantRange(APInt(16, 0x6)));
-}
-
-TEST_F(ConstantRangeTest, Add) {
- EXPECT_EQ(Full.add(APInt(16, 4)), Full);
- EXPECT_EQ(Full.add(Full), Full);
- EXPECT_EQ(Full.add(Empty), Empty);
- EXPECT_EQ(Full.add(One), Full);
- EXPECT_EQ(Full.add(Some), Full);
- EXPECT_EQ(Full.add(Wrap), Full);
- EXPECT_EQ(Empty.add(Empty), Empty);
- EXPECT_EQ(Empty.add(One), Empty);
- EXPECT_EQ(Empty.add(Some), Empty);
- EXPECT_EQ(Empty.add(Wrap), Empty);
- EXPECT_EQ(Empty.add(APInt(16, 4)), Empty);
- EXPECT_EQ(Some.add(APInt(16, 4)),
- ConstantRange(APInt(16, 0xe), APInt(16, 0xaae)));
- EXPECT_EQ(Wrap.add(APInt(16, 4)),
- ConstantRange(APInt(16, 0xaae), APInt(16, 0xe)));
- EXPECT_EQ(One.add(APInt(16, 4)),
- ConstantRange(APInt(16, 0xe)));
-}
-
-TEST_F(ConstantRangeTest, Multiply) {
- EXPECT_EQ(Full.multiply(Full), Full);
- EXPECT_EQ(Full.multiply(Empty), Empty);
- EXPECT_EQ(Full.multiply(One), Full);
- EXPECT_EQ(Full.multiply(Some), Full);
- EXPECT_EQ(Full.multiply(Wrap), Full);
- EXPECT_EQ(Empty.multiply(Empty), Empty);
- EXPECT_EQ(Empty.multiply(One), Empty);
- EXPECT_EQ(Empty.multiply(Some), Empty);
- EXPECT_EQ(Empty.multiply(Wrap), Empty);
- EXPECT_EQ(One.multiply(One), ConstantRange(APInt(16, 0xa*0xa),
- APInt(16, 0xa*0xa + 1)));
- EXPECT_EQ(One.multiply(Some), ConstantRange(APInt(16, 0xa*0xa),
- APInt(16, 0xa*0xaa9 + 1)));
- EXPECT_EQ(One.multiply(Wrap), Full);
- EXPECT_EQ(Some.multiply(Some), Full);
- EXPECT_EQ(Some.multiply(Wrap), Full);
- EXPECT_EQ(Wrap.multiply(Wrap), Full);
-
- // http://llvm.org/PR4545
- EXPECT_EQ(ConstantRange(APInt(4, 1), APInt(4, 6)).multiply(
- ConstantRange(APInt(4, 6), APInt(4, 2))),
- ConstantRange(4, /*isFullSet=*/true));
-}
-
-TEST_F(ConstantRangeTest, UMax) {
- EXPECT_EQ(Full.umax(Full), Full);
- EXPECT_EQ(Full.umax(Empty), Empty);
- EXPECT_EQ(Full.umax(Some), ConstantRange(APInt(16, 0xa), APInt(16, 0)));
- EXPECT_EQ(Full.umax(Wrap), Full);
- EXPECT_EQ(Full.umax(Some), ConstantRange(APInt(16, 0xa), APInt(16, 0)));
- EXPECT_EQ(Empty.umax(Empty), Empty);
- EXPECT_EQ(Empty.umax(Some), Empty);
- EXPECT_EQ(Empty.umax(Wrap), Empty);
- EXPECT_EQ(Empty.umax(One), Empty);
- EXPECT_EQ(Some.umax(Some), Some);
- EXPECT_EQ(Some.umax(Wrap), ConstantRange(APInt(16, 0xa), APInt(16, 0)));
- EXPECT_EQ(Some.umax(One), Some);
- // TODO: ConstantRange is currently over-conservative here.
- EXPECT_EQ(Wrap.umax(Wrap), Full);
- EXPECT_EQ(Wrap.umax(One), ConstantRange(APInt(16, 0xa), APInt(16, 0)));
- EXPECT_EQ(One.umax(One), One);
-}
-
-TEST_F(ConstantRangeTest, SMax) {
- EXPECT_EQ(Full.smax(Full), Full);
- EXPECT_EQ(Full.smax(Empty), Empty);
- EXPECT_EQ(Full.smax(Some), ConstantRange(APInt(16, 0xa),
- APInt::getSignedMinValue(16)));
- EXPECT_EQ(Full.smax(Wrap), Full);
- EXPECT_EQ(Full.smax(One), ConstantRange(APInt(16, 0xa),
- APInt::getSignedMinValue(16)));
- EXPECT_EQ(Empty.smax(Empty), Empty);
- EXPECT_EQ(Empty.smax(Some), Empty);
- EXPECT_EQ(Empty.smax(Wrap), Empty);
- EXPECT_EQ(Empty.smax(One), Empty);
- EXPECT_EQ(Some.smax(Some), Some);
- EXPECT_EQ(Some.smax(Wrap), ConstantRange(APInt(16, 0xa),
- APInt(16, (uint64_t)INT16_MIN)));
- EXPECT_EQ(Some.smax(One), Some);
- EXPECT_EQ(Wrap.smax(One), ConstantRange(APInt(16, 0xa),
- APInt(16, (uint64_t)INT16_MIN)));
- EXPECT_EQ(One.smax(One), One);
-}
-
-TEST_F(ConstantRangeTest, UDiv) {
- EXPECT_EQ(Full.udiv(Full), Full);
- EXPECT_EQ(Full.udiv(Empty), Empty);
- EXPECT_EQ(Full.udiv(One), ConstantRange(APInt(16, 0),
- APInt(16, 0xffff / 0xa + 1)));
- EXPECT_EQ(Full.udiv(Some), ConstantRange(APInt(16, 0),
- APInt(16, 0xffff / 0xa + 1)));
- EXPECT_EQ(Full.udiv(Wrap), Full);
- EXPECT_EQ(Empty.udiv(Empty), Empty);
- EXPECT_EQ(Empty.udiv(One), Empty);
- EXPECT_EQ(Empty.udiv(Some), Empty);
- EXPECT_EQ(Empty.udiv(Wrap), Empty);
- EXPECT_EQ(One.udiv(One), ConstantRange(APInt(16, 1)));
- EXPECT_EQ(One.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 2)));
- EXPECT_EQ(One.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xb)));
- EXPECT_EQ(Some.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 0x111)));
- EXPECT_EQ(Some.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa)));
- EXPECT_EQ(Wrap.udiv(Wrap), Full);
-}
-
-} // anonymous namespace
diff --git a/contrib/llvm/unittests/Support/LeakDetectorTest.cpp b/contrib/llvm/unittests/Support/LeakDetectorTest.cpp
deleted file mode 100644
index d198c7a..0000000
--- a/contrib/llvm/unittests/Support/LeakDetectorTest.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//===- llvm/unittest/LeakDetector/LeakDetector.cpp - LeakDetector tests ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/Support/LeakDetector.h"
-
-using namespace llvm;
-
-namespace {
-
-#ifdef GTEST_HAS_DEATH_TEST
-#ifndef NDEBUG
-TEST(LeakDetector, Death1) {
- LeakDetector::addGarbageObject((void*) 1);
- LeakDetector::addGarbageObject((void*) 2);
-
- EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 1),
- ".*Ts.count\\(o\\) == 0 && \"Object already in set!\"");
- EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 2),
- "Cache != o && \"Object already in set!\"");
-}
-#endif
-#endif
-
-}
diff --git a/contrib/llvm/unittests/Support/Makefile b/contrib/llvm/unittests/Support/Makefile
deleted file mode 100644
index 815bdd2..0000000
--- a/contrib/llvm/unittests/Support/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- unittests/ADT/Makefile ------------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../..
-TESTNAME = Support
-LINK_COMPONENTS := core support
-
-include $(LEVEL)/Makefile.config
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/contrib/llvm/unittests/Support/MathExtrasTest.cpp b/contrib/llvm/unittests/Support/MathExtrasTest.cpp
deleted file mode 100644
index 3db1f77..0000000
--- a/contrib/llvm/unittests/Support/MathExtrasTest.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-//===- unittests/Support/MathExtrasTest.cpp - math utils tests ------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/Support/MathExtras.h"
-
-using namespace llvm;
-
-namespace {
-
-TEST(MathExtras, isPowerOf2_32) {
- EXPECT_TRUE(isPowerOf2_32(1 << 6));
- EXPECT_TRUE(isPowerOf2_32(1 << 12));
- EXPECT_FALSE(isPowerOf2_32((1 << 19) + 3));
- EXPECT_FALSE(isPowerOf2_32(0xABCDEF0));
-}
-
-TEST(MathExtras, isPowerOf2_64) {
- EXPECT_TRUE(isPowerOf2_64(1LL << 46));
- EXPECT_TRUE(isPowerOf2_64(1LL << 12));
- EXPECT_FALSE(isPowerOf2_64((1LL << 53) + 3));
- EXPECT_FALSE(isPowerOf2_64(0xABCDEF0ABCDEF0LL));
-}
-
-TEST(MathExtras, ByteSwap_32) {
- EXPECT_EQ(0x44332211u, ByteSwap_32(0x11223344));
- EXPECT_EQ(0xDDCCBBAAu, ByteSwap_32(0xAABBCCDD));
-}
-
-TEST(MathExtras, ByteSwap_64) {
- EXPECT_EQ(0x8877665544332211ULL, ByteSwap_64(0x1122334455667788LL));
- EXPECT_EQ(0x1100FFEEDDCCBBAAULL, ByteSwap_64(0xAABBCCDDEEFF0011LL));
-}
-
-TEST(MathExtras, CountLeadingZeros_32) {
- EXPECT_EQ(8u, CountLeadingZeros_32(0x00F000FF));
- EXPECT_EQ(8u, CountLeadingZeros_32(0x00F12345));
- for (unsigned i = 0; i <= 30; ++i) {
- EXPECT_EQ(31 - i, CountLeadingZeros_32(1 << i));
- }
-}
-
-TEST(MathExtras, CountLeadingZeros_64) {
- EXPECT_EQ(8u, CountLeadingZeros_64(0x00F1234500F12345LL));
- EXPECT_EQ(1u, CountLeadingZeros_64(1LL << 62));
- for (unsigned i = 0; i <= 62; ++i) {
- EXPECT_EQ(63 - i, CountLeadingZeros_64(1LL << i));
- }
-}
-
-TEST(MathExtras, CountLeadingOnes_32) {
- for (int i = 30; i >= 0; --i) {
- // Start with all ones and unset some bit.
- EXPECT_EQ(31u - i, CountLeadingOnes_32(0xFFFFFFFF ^ (1 << i)));
- }
-}
-
-TEST(MathExtras, CountLeadingOnes_64) {
- for (int i = 62; i >= 0; --i) {
- // Start with all ones and unset some bit.
- EXPECT_EQ(63u - i, CountLeadingOnes_64(0xFFFFFFFFFFFFFFFFLL ^ (1LL << i)));
- }
- for (int i = 30; i >= 0; --i) {
- // Start with all ones and unset some bit.
- EXPECT_EQ(31u - i, CountLeadingOnes_32(0xFFFFFFFF ^ (1 << i)));
- }
-}
-
-TEST(MathExtras, FloatBits) {
- static const float kValue = 5632.34;
- EXPECT_FLOAT_EQ(kValue, BitsToFloat(FloatToBits(kValue)));
-}
-
-TEST(MathExtras, DoubleBits) {
- static const double kValue = 87987234.983498;
- EXPECT_FLOAT_EQ(kValue, BitsToDouble(DoubleToBits(kValue)));
-}
-
-TEST(MathExtras, MinAlign) {
- EXPECT_EQ(1u, MinAlign(2, 3));
- EXPECT_EQ(2u, MinAlign(2, 4));
- EXPECT_EQ(1u, MinAlign(17, 64));
- EXPECT_EQ(256u, MinAlign(256, 512));
-}
-
-TEST(MathExtras, NextPowerOf2) {
- EXPECT_EQ(4u, NextPowerOf2(3));
- EXPECT_EQ(16u, NextPowerOf2(15));
- EXPECT_EQ(256u, NextPowerOf2(128));
-}
-
-TEST(MathExtras, RoundUpToAlignment) {
- EXPECT_EQ(8u, RoundUpToAlignment(5, 8));
- EXPECT_EQ(24u, RoundUpToAlignment(17, 8));
- EXPECT_EQ(0u, RoundUpToAlignment(~0LL, 8));
-}
-
-}
diff --git a/contrib/llvm/unittests/Support/RegexTest.cpp b/contrib/llvm/unittests/Support/RegexTest.cpp
deleted file mode 100644
index 65b66c3..0000000
--- a/contrib/llvm/unittests/Support/RegexTest.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-//===- llvm/unittest/Support/RegexTest.cpp - Regex tests --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/Support/Regex.h"
-#include "llvm/ADT/SmallVector.h"
-#include <cstring>
-
-using namespace llvm;
-namespace {
-
-class RegexTest : public ::testing::Test {
-};
-
-TEST_F(RegexTest, Basics) {
- Regex r1("^[0-9]+$");
- EXPECT_TRUE(r1.match("916"));
- EXPECT_TRUE(r1.match("9"));
- EXPECT_FALSE(r1.match("9a"));
-
- SmallVector<StringRef, 1> Matches;
- Regex r2("[0-9]+");
- EXPECT_TRUE(r2.match("aa216b", &Matches));
- EXPECT_EQ(1u, Matches.size());
- EXPECT_EQ("216", Matches[0].str());
-
- Regex r3("[0-9]+([a-f])?:([0-9]+)");
- EXPECT_TRUE(r3.match("9a:513b", &Matches));
- EXPECT_EQ(3u, Matches.size());
- EXPECT_EQ("9a:513", Matches[0].str());
- EXPECT_EQ("a", Matches[1].str());
- EXPECT_EQ("513", Matches[2].str());
-
- EXPECT_TRUE(r3.match("9:513b", &Matches));
- EXPECT_EQ(3u, Matches.size());
- EXPECT_EQ("9:513", Matches[0].str());
- EXPECT_EQ("", Matches[1].str());
- EXPECT_EQ("513", Matches[2].str());
-
- Regex r4("a[^b]+b");
- std::string String="axxb";
- String[2] = '\0';
- EXPECT_FALSE(r4.match("abb"));
- EXPECT_TRUE(r4.match(String, &Matches));
- EXPECT_EQ(1u, Matches.size());
- EXPECT_EQ(String, Matches[0].str());
-
-
- std::string NulPattern="X[0-9]+X([a-f])?:([0-9]+)";
- String="YX99a:513b";
- NulPattern[7] = '\0';
- Regex r5(NulPattern);
- EXPECT_FALSE(r5.match(String));
- EXPECT_FALSE(r5.match("X9"));
- String[3]='\0';
- EXPECT_TRUE(r5.match(String));
-}
-
-TEST_F(RegexTest, Substitution) {
- std::string Error;
-
- EXPECT_EQ("aNUMber", Regex("[0-9]+").sub("NUM", "a1234ber"));
-
- // Standard Escapes
- EXPECT_EQ("a\\ber", Regex("[0-9]+").sub("\\\\", "a1234ber", &Error));
- EXPECT_EQ(Error, "");
- EXPECT_EQ("a\nber", Regex("[0-9]+").sub("\\n", "a1234ber", &Error));
- EXPECT_EQ(Error, "");
- EXPECT_EQ("a\tber", Regex("[0-9]+").sub("\\t", "a1234ber", &Error));
- EXPECT_EQ(Error, "");
- EXPECT_EQ("ajber", Regex("[0-9]+").sub("\\j", "a1234ber", &Error));
- EXPECT_EQ(Error, "");
-
- EXPECT_EQ("aber", Regex("[0-9]+").sub("\\", "a1234ber", &Error));
- EXPECT_EQ(Error, "replacement string contained trailing backslash");
-
- // Backreferences
- EXPECT_EQ("aa1234bber", Regex("a[0-9]+b").sub("a\\0b", "a1234ber", &Error));
- EXPECT_EQ(Error, "");
-
- EXPECT_EQ("a1234ber", Regex("a([0-9]+)b").sub("a\\1b", "a1234ber", &Error));
- EXPECT_EQ(Error, "");
-
- EXPECT_EQ("aber", Regex("a[0-9]+b").sub("a\\100b", "a1234ber", &Error));
- EXPECT_EQ(Error, "invalid backreference string '100'");
-}
-
-}
diff --git a/contrib/llvm/unittests/Support/System.cpp b/contrib/llvm/unittests/Support/System.cpp
deleted file mode 100644
index b3dd17d..0000000
--- a/contrib/llvm/unittests/Support/System.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//===- llvm/unittest/Support/System.cpp - System tests --===//
-#include "gtest/gtest.h"
-#include "llvm/System/TimeValue.h"
-#include <time.h>
-
-using namespace llvm;
-namespace {
-class SystemTest : public ::testing::Test {
-};
-
-TEST_F(SystemTest, TimeValue) {
- sys::TimeValue now = sys::TimeValue::now();
- time_t now_t = time(NULL);
- EXPECT_TRUE(abs(now_t - now.toEpochTime()) < 2);
-}
-}
diff --git a/contrib/llvm/unittests/Support/TypeBuilderTest.cpp b/contrib/llvm/unittests/Support/TypeBuilderTest.cpp
deleted file mode 100644
index e805827..0000000
--- a/contrib/llvm/unittests/Support/TypeBuilderTest.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-//===- llvm/unittest/Support/TypeBuilderTest.cpp - TypeBuilder tests -----===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/TypeBuilder.h"
-#include "llvm/LLVMContext.h"
-
-#include "gtest/gtest.h"
-
-using namespace llvm;
-
-namespace {
-
-TEST(TypeBuilderTest, Void) {
- EXPECT_EQ(Type::getVoidTy(getGlobalContext()), (TypeBuilder<void, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getVoidTy(getGlobalContext()), (TypeBuilder<void, false>::get(getGlobalContext())));
- // Special cases for C compatibility:
- EXPECT_EQ(Type::getInt8PtrTy(getGlobalContext()),
- (TypeBuilder<void*, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8PtrTy(getGlobalContext()),
- (TypeBuilder<const void*, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8PtrTy(getGlobalContext()),
- (TypeBuilder<volatile void*, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8PtrTy(getGlobalContext()),
- (TypeBuilder<const volatile void*, false>::get(
- getGlobalContext())));
-}
-
-TEST(TypeBuilderTest, HostIntegers) {
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()), (TypeBuilder<int8_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()), (TypeBuilder<uint8_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt16Ty(getGlobalContext()), (TypeBuilder<int16_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt16Ty(getGlobalContext()), (TypeBuilder<uint16_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), (TypeBuilder<int32_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), (TypeBuilder<uint32_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt64Ty(getGlobalContext()), (TypeBuilder<int64_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt64Ty(getGlobalContext()), (TypeBuilder<uint64_t, false>::get(getGlobalContext())));
-
- EXPECT_EQ(IntegerType::get(getGlobalContext(), sizeof(size_t) * CHAR_BIT),
- (TypeBuilder<size_t, false>::get(getGlobalContext())));
- EXPECT_EQ(IntegerType::get(getGlobalContext(), sizeof(ptrdiff_t) * CHAR_BIT),
- (TypeBuilder<ptrdiff_t, false>::get(getGlobalContext())));
-}
-
-TEST(TypeBuilderTest, CrossCompilableIntegers) {
- EXPECT_EQ(IntegerType::get(getGlobalContext(), 1), (TypeBuilder<types::i<1>, true>::get(getGlobalContext())));
- EXPECT_EQ(IntegerType::get(getGlobalContext(), 1), (TypeBuilder<types::i<1>, false>::get(getGlobalContext())));
- EXPECT_EQ(IntegerType::get(getGlobalContext(), 72), (TypeBuilder<types::i<72>, true>::get(getGlobalContext())));
- EXPECT_EQ(IntegerType::get(getGlobalContext(), 72), (TypeBuilder<types::i<72>, false>::get(getGlobalContext())));
-}
-
-TEST(TypeBuilderTest, Float) {
- EXPECT_EQ(Type::getFloatTy(getGlobalContext()), (TypeBuilder<float, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getDoubleTy(getGlobalContext()), (TypeBuilder<double, false>::get(getGlobalContext())));
- // long double isn't supported yet.
- EXPECT_EQ(Type::getFloatTy(getGlobalContext()), (TypeBuilder<types::ieee_float, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getFloatTy(getGlobalContext()), (TypeBuilder<types::ieee_float, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getDoubleTy(getGlobalContext()), (TypeBuilder<types::ieee_double, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getDoubleTy(getGlobalContext()), (TypeBuilder<types::ieee_double, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getX86_FP80Ty(getGlobalContext()), (TypeBuilder<types::x86_fp80, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getX86_FP80Ty(getGlobalContext()), (TypeBuilder<types::x86_fp80, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getFP128Ty(getGlobalContext()), (TypeBuilder<types::fp128, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getFP128Ty(getGlobalContext()), (TypeBuilder<types::fp128, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getPPC_FP128Ty(getGlobalContext()), (TypeBuilder<types::ppc_fp128, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getPPC_FP128Ty(getGlobalContext()), (TypeBuilder<types::ppc_fp128, false>::get(getGlobalContext())));
-}
-
-TEST(TypeBuilderTest, Derived) {
- EXPECT_EQ(PointerType::getUnqual(Type::getInt8PtrTy(getGlobalContext())),
- (TypeBuilder<int8_t**, false>::get(getGlobalContext())));
- EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 7),
- (TypeBuilder<int8_t[7], false>::get(getGlobalContext())));
- EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 0),
- (TypeBuilder<int8_t[], false>::get(getGlobalContext())));
-
- EXPECT_EQ(PointerType::getUnqual(Type::getInt8PtrTy(getGlobalContext())),
- (TypeBuilder<types::i<8>**, false>::get(getGlobalContext())));
- EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 7),
- (TypeBuilder<types::i<8>[7], false>::get(getGlobalContext())));
- EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 0),
- (TypeBuilder<types::i<8>[], false>::get(getGlobalContext())));
-
- EXPECT_EQ(PointerType::getUnqual(Type::getInt8PtrTy(getGlobalContext())),
- (TypeBuilder<types::i<8>**, true>::get(getGlobalContext())));
- EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 7),
- (TypeBuilder<types::i<8>[7], true>::get(getGlobalContext())));
- EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 0),
- (TypeBuilder<types::i<8>[], true>::get(getGlobalContext())));
-
-
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<const int8_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<volatile int8_t, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<const volatile int8_t, false>::get(getGlobalContext())));
-
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<const types::i<8>, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<volatile types::i<8>, false>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<const volatile types::i<8>, false>::get(getGlobalContext())));
-
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<const types::i<8>, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<volatile types::i<8>, true>::get(getGlobalContext())));
- EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
- (TypeBuilder<const volatile types::i<8>, true>::get(getGlobalContext())));
-
- EXPECT_EQ(Type::getInt8PtrTy(getGlobalContext()),
- (TypeBuilder<const volatile int8_t*const volatile, false>::get(getGlobalContext())));
-}
-
-TEST(TypeBuilderTest, Functions) {
- std::vector<const Type*> params;
- EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false),
- (TypeBuilder<void(), true>::get(getGlobalContext())));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true),
- (TypeBuilder<int8_t(...), false>::get(getGlobalContext())));
- params.push_back(TypeBuilder<int32_t*, false>::get(getGlobalContext()));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, false),
- (TypeBuilder<int8_t(const int32_t*), false>::get(getGlobalContext())));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true),
- (TypeBuilder<int8_t(const int32_t*, ...), false>::get(getGlobalContext())));
- params.push_back(TypeBuilder<char*, false>::get(getGlobalContext()));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, false),
- (TypeBuilder<int8_t(int32_t*, void*), false>::get(getGlobalContext())));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true),
- (TypeBuilder<int8_t(int32_t*, char*, ...), false>::get(getGlobalContext())));
- params.push_back(TypeBuilder<char, false>::get(getGlobalContext()));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, false),
- (TypeBuilder<int8_t(int32_t*, void*, char), false>::get(getGlobalContext())));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true),
- (TypeBuilder<int8_t(int32_t*, char*, char, ...), false>::get(getGlobalContext())));
- params.push_back(TypeBuilder<char, false>::get(getGlobalContext()));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, false),
- (TypeBuilder<int8_t(int32_t*, void*, char, char), false>::get(getGlobalContext())));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true),
- (TypeBuilder<int8_t(int32_t*, char*, char, char, ...),
- false>::get(getGlobalContext())));
- params.push_back(TypeBuilder<char, false>::get(getGlobalContext()));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, false),
- (TypeBuilder<int8_t(int32_t*, void*, char, char, char),
- false>::get(getGlobalContext())));
- EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true),
- (TypeBuilder<int8_t(int32_t*, char*, char, char, char, ...),
- false>::get(getGlobalContext())));
-}
-
-TEST(TypeBuilderTest, Context) {
- // We used to cache TypeBuilder results in static local variables. This
- // produced the same type for different contexts, which of course broke
- // things.
- LLVMContext context1;
- EXPECT_EQ(&context1,
- &(TypeBuilder<types::i<1>, true>::get(context1))->getContext());
- LLVMContext context2;
- EXPECT_EQ(&context2,
- &(TypeBuilder<types::i<1>, true>::get(context2))->getContext());
-}
-
-class MyType {
- int a;
- int *b;
- void *array[1];
-};
-
-class MyPortableType {
- int32_t a;
- int32_t *b;
- void *array[1];
-};
-
-} // anonymous namespace
-
-namespace llvm {
-template<bool cross> class TypeBuilder<MyType, cross> {
-public:
- static const StructType *get(LLVMContext &Context) {
- // Using the static result variable ensures that the type is
- // only looked up once.
- std::vector<const Type*> st;
- st.push_back(TypeBuilder<int, cross>::get(Context));
- st.push_back(TypeBuilder<int*, cross>::get(Context));
- st.push_back(TypeBuilder<void*[], cross>::get(Context));
- static const StructType *const result = StructType::get(Context, st);
- return result;
- }
-
- // You may find this a convenient place to put some constants
- // to help with getelementptr. They don't have any effect on
- // the operation of TypeBuilder.
- enum Fields {
- FIELD_A,
- FIELD_B,
- FIELD_ARRAY
- };
-};
-
-template<bool cross> class TypeBuilder<MyPortableType, cross> {
-public:
- static const StructType *get(LLVMContext &Context) {
- // Using the static result variable ensures that the type is
- // only looked up once.
- std::vector<const Type*> st;
- st.push_back(TypeBuilder<types::i<32>, cross>::get(Context));
- st.push_back(TypeBuilder<types::i<32>*, cross>::get(Context));
- st.push_back(TypeBuilder<types::i<8>*[], cross>::get(Context));
- static const StructType *const result = StructType::get(Context, st);
- return result;
- }
-
- // You may find this a convenient place to put some constants
- // to help with getelementptr. They don't have any effect on
- // the operation of TypeBuilder.
- enum Fields {
- FIELD_A,
- FIELD_B,
- FIELD_ARRAY
- };
-};
-} // namespace llvm
-namespace {
-
-TEST(TypeBuilderTest, Extensions) {
- EXPECT_EQ(PointerType::getUnqual(StructType::get(getGlobalContext(),
- TypeBuilder<int, false>::get(getGlobalContext()),
- TypeBuilder<int*, false>::get(getGlobalContext()),
- TypeBuilder<void*[], false>::get(getGlobalContext()),
- NULL)),
- (TypeBuilder<MyType*, false>::get(getGlobalContext())));
- EXPECT_EQ(PointerType::getUnqual(StructType::get(getGlobalContext(),
- TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
- TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
- TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
- NULL)),
- (TypeBuilder<MyPortableType*, false>::get(getGlobalContext())));
- EXPECT_EQ(PointerType::getUnqual(StructType::get(getGlobalContext(),
- TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
- TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
- TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
- NULL)),
- (TypeBuilder<MyPortableType*, true>::get(getGlobalContext())));
-}
-
-} // anonymous namespace
diff --git a/contrib/llvm/unittests/Support/ValueHandleTest.cpp b/contrib/llvm/unittests/Support/ValueHandleTest.cpp
deleted file mode 100644
index 6a6528f..0000000
--- a/contrib/llvm/unittests/Support/ValueHandleTest.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-//===- llvm/unittest/Support/ValueHandleTest.cpp - ValueHandle tests --------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/ValueHandle.h"
-
-#include "llvm/Constants.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/ADT/OwningPtr.h"
-
-#include "gtest/gtest.h"
-
-#include <memory>
-
-using namespace llvm;
-
-namespace {
-
-class ValueHandle : public testing::Test {
-protected:
- Constant *ConstantV;
- std::auto_ptr<BitCastInst> BitcastV;
-
- ValueHandle() :
- ConstantV(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 0)),
- BitcastV(new BitCastInst(ConstantV, Type::getInt32Ty(getGlobalContext()))) {
- }
-};
-
-class ConcreteCallbackVH : public CallbackVH {
-public:
- ConcreteCallbackVH() : CallbackVH() {}
- ConcreteCallbackVH(Value *V) : CallbackVH(V) {}
-};
-
-TEST_F(ValueHandle, WeakVH_BasicOperation) {
- WeakVH WVH(BitcastV.get());
- EXPECT_EQ(BitcastV.get(), WVH);
- WVH = ConstantV;
- EXPECT_EQ(ConstantV, WVH);
-
- // Make sure I can call a method on the underlying Value. It
- // doesn't matter which method.
- EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), WVH->getType());
- EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), (*WVH).getType());
-}
-
-TEST_F(ValueHandle, WeakVH_Comparisons) {
- WeakVH BitcastWVH(BitcastV.get());
- WeakVH ConstantWVH(ConstantV);
-
- EXPECT_TRUE(BitcastWVH == BitcastWVH);
- EXPECT_TRUE(BitcastV.get() == BitcastWVH);
- EXPECT_TRUE(BitcastWVH == BitcastV.get());
- EXPECT_FALSE(BitcastWVH == ConstantWVH);
-
- EXPECT_TRUE(BitcastWVH != ConstantWVH);
- EXPECT_TRUE(BitcastV.get() != ConstantWVH);
- EXPECT_TRUE(BitcastWVH != ConstantV);
- EXPECT_FALSE(BitcastWVH != BitcastWVH);
-
- // Cast to Value* so comparisons work.
- Value *BV = BitcastV.get();
- Value *CV = ConstantV;
- EXPECT_EQ(BV < CV, BitcastWVH < ConstantWVH);
- EXPECT_EQ(BV <= CV, BitcastWVH <= ConstantWVH);
- EXPECT_EQ(BV > CV, BitcastWVH > ConstantWVH);
- EXPECT_EQ(BV >= CV, BitcastWVH >= ConstantWVH);
-
- EXPECT_EQ(BV < CV, BitcastV.get() < ConstantWVH);
- EXPECT_EQ(BV <= CV, BitcastV.get() <= ConstantWVH);
- EXPECT_EQ(BV > CV, BitcastV.get() > ConstantWVH);
- EXPECT_EQ(BV >= CV, BitcastV.get() >= ConstantWVH);
-
- EXPECT_EQ(BV < CV, BitcastWVH < ConstantV);
- EXPECT_EQ(BV <= CV, BitcastWVH <= ConstantV);
- EXPECT_EQ(BV > CV, BitcastWVH > ConstantV);
- EXPECT_EQ(BV >= CV, BitcastWVH >= ConstantV);
-}
-
-TEST_F(ValueHandle, WeakVH_FollowsRAUW) {
- WeakVH WVH(BitcastV.get());
- WeakVH WVH_Copy(WVH);
- WeakVH WVH_Recreated(BitcastV.get());
- BitcastV->replaceAllUsesWith(ConstantV);
- EXPECT_EQ(ConstantV, WVH);
- EXPECT_EQ(ConstantV, WVH_Copy);
- EXPECT_EQ(ConstantV, WVH_Recreated);
-}
-
-TEST_F(ValueHandle, WeakVH_NullOnDeletion) {
- WeakVH WVH(BitcastV.get());
- WeakVH WVH_Copy(WVH);
- WeakVH WVH_Recreated(BitcastV.get());
- BitcastV.reset();
- Value *null_value = NULL;
- EXPECT_EQ(null_value, WVH);
- EXPECT_EQ(null_value, WVH_Copy);
- EXPECT_EQ(null_value, WVH_Recreated);
-}
-
-
-TEST_F(ValueHandle, AssertingVH_BasicOperation) {
- AssertingVH<CastInst> AVH(BitcastV.get());
- CastInst *implicit_to_exact_type = AVH;
- implicit_to_exact_type = implicit_to_exact_type; // Avoid warning.
-
- AssertingVH<Value> GenericAVH(BitcastV.get());
- EXPECT_EQ(BitcastV.get(), GenericAVH);
- GenericAVH = ConstantV;
- EXPECT_EQ(ConstantV, GenericAVH);
-
- // Make sure I can call a method on the underlying CastInst. It
- // doesn't matter which method.
- EXPECT_FALSE(AVH->mayWriteToMemory());
- EXPECT_FALSE((*AVH).mayWriteToMemory());
-}
-
-TEST_F(ValueHandle, AssertingVH_Const) {
- const CastInst *ConstBitcast = BitcastV.get();
- AssertingVH<const CastInst> AVH(ConstBitcast);
- const CastInst *implicit_to_exact_type = AVH;
- implicit_to_exact_type = implicit_to_exact_type; // Avoid warning.
-}
-
-TEST_F(ValueHandle, AssertingVH_Comparisons) {
- AssertingVH<Value> BitcastAVH(BitcastV.get());
- AssertingVH<Value> ConstantAVH(ConstantV);
-
- EXPECT_TRUE(BitcastAVH == BitcastAVH);
- EXPECT_TRUE(BitcastV.get() == BitcastAVH);
- EXPECT_TRUE(BitcastAVH == BitcastV.get());
- EXPECT_FALSE(BitcastAVH == ConstantAVH);
-
- EXPECT_TRUE(BitcastAVH != ConstantAVH);
- EXPECT_TRUE(BitcastV.get() != ConstantAVH);
- EXPECT_TRUE(BitcastAVH != ConstantV);
- EXPECT_FALSE(BitcastAVH != BitcastAVH);
-
- // Cast to Value* so comparisons work.
- Value *BV = BitcastV.get();
- Value *CV = ConstantV;
- EXPECT_EQ(BV < CV, BitcastAVH < ConstantAVH);
- EXPECT_EQ(BV <= CV, BitcastAVH <= ConstantAVH);
- EXPECT_EQ(BV > CV, BitcastAVH > ConstantAVH);
- EXPECT_EQ(BV >= CV, BitcastAVH >= ConstantAVH);
-
- EXPECT_EQ(BV < CV, BitcastV.get() < ConstantAVH);
- EXPECT_EQ(BV <= CV, BitcastV.get() <= ConstantAVH);
- EXPECT_EQ(BV > CV, BitcastV.get() > ConstantAVH);
- EXPECT_EQ(BV >= CV, BitcastV.get() >= ConstantAVH);
-
- EXPECT_EQ(BV < CV, BitcastAVH < ConstantV);
- EXPECT_EQ(BV <= CV, BitcastAVH <= ConstantV);
- EXPECT_EQ(BV > CV, BitcastAVH > ConstantV);
- EXPECT_EQ(BV >= CV, BitcastAVH >= ConstantV);
-}
-
-TEST_F(ValueHandle, AssertingVH_DoesNotFollowRAUW) {
- AssertingVH<Value> AVH(BitcastV.get());
- BitcastV->replaceAllUsesWith(ConstantV);
- EXPECT_EQ(BitcastV.get(), AVH);
-}
-
-#ifdef NDEBUG
-
-TEST_F(ValueHandle, AssertingVH_ReducesToPointer) {
- EXPECT_EQ(sizeof(CastInst *), sizeof(AssertingVH<CastInst>));
-}
-
-#else // !NDEBUG
-
-#ifdef GTEST_HAS_DEATH_TEST
-
-TEST_F(ValueHandle, AssertingVH_Asserts) {
- AssertingVH<Value> AVH(BitcastV.get());
- EXPECT_DEATH({BitcastV.reset();},
- "An asserting value handle still pointed to this value!");
- AssertingVH<Value> Copy(AVH);
- AVH = NULL;
- EXPECT_DEATH({BitcastV.reset();},
- "An asserting value handle still pointed to this value!");
- Copy = NULL;
- BitcastV.reset();
-}
-
-#endif // GTEST_HAS_DEATH_TEST
-
-#endif // NDEBUG
-
-TEST_F(ValueHandle, CallbackVH_BasicOperation) {
- ConcreteCallbackVH CVH(BitcastV.get());
- EXPECT_EQ(BitcastV.get(), CVH);
- CVH = ConstantV;
- EXPECT_EQ(ConstantV, CVH);
-
- // Make sure I can call a method on the underlying Value. It
- // doesn't matter which method.
- EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), CVH->getType());
- EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), (*CVH).getType());
-}
-
-TEST_F(ValueHandle, CallbackVH_Comparisons) {
- ConcreteCallbackVH BitcastCVH(BitcastV.get());
- ConcreteCallbackVH ConstantCVH(ConstantV);
-
- EXPECT_TRUE(BitcastCVH == BitcastCVH);
- EXPECT_TRUE(BitcastV.get() == BitcastCVH);
- EXPECT_TRUE(BitcastCVH == BitcastV.get());
- EXPECT_FALSE(BitcastCVH == ConstantCVH);
-
- EXPECT_TRUE(BitcastCVH != ConstantCVH);
- EXPECT_TRUE(BitcastV.get() != ConstantCVH);
- EXPECT_TRUE(BitcastCVH != ConstantV);
- EXPECT_FALSE(BitcastCVH != BitcastCVH);
-
- // Cast to Value* so comparisons work.
- Value *BV = BitcastV.get();
- Value *CV = ConstantV;
- EXPECT_EQ(BV < CV, BitcastCVH < ConstantCVH);
- EXPECT_EQ(BV <= CV, BitcastCVH <= ConstantCVH);
- EXPECT_EQ(BV > CV, BitcastCVH > ConstantCVH);
- EXPECT_EQ(BV >= CV, BitcastCVH >= ConstantCVH);
-
- EXPECT_EQ(BV < CV, BitcastV.get() < ConstantCVH);
- EXPECT_EQ(BV <= CV, BitcastV.get() <= ConstantCVH);
- EXPECT_EQ(BV > CV, BitcastV.get() > ConstantCVH);
- EXPECT_EQ(BV >= CV, BitcastV.get() >= ConstantCVH);
-
- EXPECT_EQ(BV < CV, BitcastCVH < ConstantV);
- EXPECT_EQ(BV <= CV, BitcastCVH <= ConstantV);
- EXPECT_EQ(BV > CV, BitcastCVH > ConstantV);
- EXPECT_EQ(BV >= CV, BitcastCVH >= ConstantV);
-}
-
-TEST_F(ValueHandle, CallbackVH_CallbackOnDeletion) {
- class RecordingVH : public CallbackVH {
- public:
- int DeletedCalls;
- int AURWCalls;
-
- RecordingVH() : DeletedCalls(0), AURWCalls(0) {}
- RecordingVH(Value *V) : CallbackVH(V), DeletedCalls(0), AURWCalls(0) {}
-
- private:
- virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); }
- virtual void allUsesReplacedWith(Value *) { AURWCalls++; }
- };
-
- RecordingVH RVH;
- RVH = BitcastV.get();
- EXPECT_EQ(0, RVH.DeletedCalls);
- EXPECT_EQ(0, RVH.AURWCalls);
- BitcastV.reset();
- EXPECT_EQ(1, RVH.DeletedCalls);
- EXPECT_EQ(0, RVH.AURWCalls);
-}
-
-TEST_F(ValueHandle, CallbackVH_CallbackOnRAUW) {
- class RecordingVH : public CallbackVH {
- public:
- int DeletedCalls;
- Value *AURWArgument;
-
- RecordingVH() : DeletedCalls(0), AURWArgument(NULL) {}
- RecordingVH(Value *V)
- : CallbackVH(V), DeletedCalls(0), AURWArgument(NULL) {}
-
- private:
- virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); }
- virtual void allUsesReplacedWith(Value *new_value) {
- EXPECT_EQ(NULL, AURWArgument);
- AURWArgument = new_value;
- }
- };
-
- RecordingVH RVH;
- RVH = BitcastV.get();
- EXPECT_EQ(0, RVH.DeletedCalls);
- EXPECT_EQ(NULL, RVH.AURWArgument);
- BitcastV->replaceAllUsesWith(ConstantV);
- EXPECT_EQ(0, RVH.DeletedCalls);
- EXPECT_EQ(ConstantV, RVH.AURWArgument);
-}
-
-TEST_F(ValueHandle, CallbackVH_DeletionCanRAUW) {
- class RecoveringVH : public CallbackVH {
- public:
- int DeletedCalls;
- Value *AURWArgument;
- LLVMContext *Context;
-
- RecoveringVH() : DeletedCalls(0), AURWArgument(NULL),
- Context(&getGlobalContext()) {}
- RecoveringVH(Value *V)
- : CallbackVH(V), DeletedCalls(0), AURWArgument(NULL),
- Context(&getGlobalContext()) {}
-
- private:
- virtual void deleted() {
- getValPtr()->replaceAllUsesWith(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())));
- setValPtr(NULL);
- }
- virtual void allUsesReplacedWith(Value *new_value) {
- ASSERT_TRUE(NULL != getValPtr());
- EXPECT_EQ(1U, getValPtr()->getNumUses());
- EXPECT_EQ(NULL, AURWArgument);
- AURWArgument = new_value;
- }
- };
-
- // Normally, if a value has uses, deleting it will crash. However, we can use
- // a CallbackVH to remove the uses before the check for no uses.
- RecoveringVH RVH;
- RVH = BitcastV.get();
- std::auto_ptr<BinaryOperator> BitcastUser(
- BinaryOperator::CreateAdd(RVH,
- Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))));
- EXPECT_EQ(BitcastV.get(), BitcastUser->getOperand(0));
- BitcastV.reset(); // Would crash without the ValueHandler.
- EXPECT_EQ(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())), RVH.AURWArgument);
- EXPECT_EQ(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())),
- BitcastUser->getOperand(0));
-}
-
-TEST_F(ValueHandle, DestroyingOtherVHOnSameValueDoesntBreakIteration) {
- // When a CallbackVH modifies other ValueHandles in its callbacks,
- // that shouldn't interfere with non-modified ValueHandles receiving
- // their appropriate callbacks.
- //
- // We create the active CallbackVH in the middle of a palindromic
- // arrangement of other VHs so that the bad behavior would be
- // triggered in whichever order callbacks run.
-
- class DestroyingVH : public CallbackVH {
- public:
- OwningPtr<WeakVH> ToClear[2];
- DestroyingVH(Value *V) {
- ToClear[0].reset(new WeakVH(V));
- setValPtr(V);
- ToClear[1].reset(new WeakVH(V));
- }
- virtual void deleted() {
- ToClear[0].reset();
- ToClear[1].reset();
- CallbackVH::deleted();
- }
- virtual void allUsesReplacedWith(Value *) {
- ToClear[0].reset();
- ToClear[1].reset();
- }
- };
-
- {
- WeakVH ShouldBeVisited1(BitcastV.get());
- DestroyingVH C(BitcastV.get());
- WeakVH ShouldBeVisited2(BitcastV.get());
-
- BitcastV->replaceAllUsesWith(ConstantV);
- EXPECT_EQ(ConstantV, static_cast<Value*>(ShouldBeVisited1));
- EXPECT_EQ(ConstantV, static_cast<Value*>(ShouldBeVisited2));
- }
-
- {
- WeakVH ShouldBeVisited1(BitcastV.get());
- DestroyingVH C(BitcastV.get());
- WeakVH ShouldBeVisited2(BitcastV.get());
-
- BitcastV.reset();
- EXPECT_EQ(NULL, static_cast<Value*>(ShouldBeVisited1));
- EXPECT_EQ(NULL, static_cast<Value*>(ShouldBeVisited2));
- }
-}
-
-TEST_F(ValueHandle, AssertingVHCheckedLast) {
- // If a CallbackVH exists to clear out a group of AssertingVHs on
- // Value deletion, the CallbackVH should get a chance to do so
- // before the AssertingVHs assert.
-
- class ClearingVH : public CallbackVH {
- public:
- AssertingVH<Value> *ToClear[2];
- ClearingVH(Value *V,
- AssertingVH<Value> &A0, AssertingVH<Value> &A1)
- : CallbackVH(V) {
- ToClear[0] = &A0;
- ToClear[1] = &A1;
- }
-
- virtual void deleted() {
- *ToClear[0] = 0;
- *ToClear[1] = 0;
- CallbackVH::deleted();
- }
- };
-
- AssertingVH<Value> A1, A2;
- A1 = BitcastV.get();
- ClearingVH C(BitcastV.get(), A1, A2);
- A2 = BitcastV.get();
- // C.deleted() should run first, clearing the two AssertingVHs,
- // which should prevent them from asserting.
- BitcastV.reset();
-}
-
-}
diff --git a/contrib/llvm/unittests/Support/raw_ostream_test.cpp b/contrib/llvm/unittests/Support/raw_ostream_test.cpp
deleted file mode 100644
index 2b797b4..0000000
--- a/contrib/llvm/unittests/Support/raw_ostream_test.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//===- llvm/unittest/Support/raw_ostream_test.cpp - raw_ostream tests -----===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/Format.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
-
-namespace {
-
-template<typename T> std::string printToString(const T &Value) {
- std::string res;
- llvm::raw_string_ostream(res) << Value;
- return res;
-}
-
-/// printToString - Print the given value to a stream which only has \arg
-/// BytesLeftInBuffer bytes left in the buffer. This is useful for testing edge
-/// cases in the buffer handling logic.
-template<typename T> std::string printToString(const T &Value,
- unsigned BytesLeftInBuffer) {
- // FIXME: This is relying on internal knowledge of how raw_ostream works to
- // get the buffer position right.
- SmallString<256> SVec;
- assert(BytesLeftInBuffer < 256 && "Invalid buffer count!");
- llvm::raw_svector_ostream OS(SVec);
- unsigned StartIndex = 256 - BytesLeftInBuffer;
- for (unsigned i = 0; i != StartIndex; ++i)
- OS << '?';
- OS << Value;
- return OS.str().substr(StartIndex);
-}
-
-template<typename T> std::string printToStringUnbuffered(const T &Value) {
- std::string res;
- llvm::raw_string_ostream OS(res);
- OS.SetUnbuffered();
- OS << Value;
- return res;
-}
-
-TEST(raw_ostreamTest, Types_Buffered) {
- // Char
- EXPECT_EQ("c", printToString('c'));
-
- // String
- EXPECT_EQ("hello", printToString("hello"));
- EXPECT_EQ("hello", printToString(std::string("hello")));
-
- // Int
- EXPECT_EQ("0", printToString(0));
- EXPECT_EQ("2425", printToString(2425));
- EXPECT_EQ("-2425", printToString(-2425));
-
- // Long long
- EXPECT_EQ("0", printToString(0LL));
- EXPECT_EQ("257257257235709", printToString(257257257235709LL));
- EXPECT_EQ("-257257257235709", printToString(-257257257235709LL));
-
- // Double
- EXPECT_EQ("1.100000e+00", printToString(1.1));
-
- // void*
- EXPECT_EQ("0x0", printToString((void*) 0));
- EXPECT_EQ("0xbeef", printToString((void*) 0xbeef));
- EXPECT_EQ("0xdeadbeef", printToString((void*) 0xdeadbeef));
-
- // Min and max.
- EXPECT_EQ("18446744073709551615", printToString(UINT64_MAX));
- EXPECT_EQ("-9223372036854775808", printToString(INT64_MIN));
-}
-
-TEST(raw_ostreamTest, Types_Unbuffered) {
- // Char
- EXPECT_EQ("c", printToStringUnbuffered('c'));
-
- // String
- EXPECT_EQ("hello", printToStringUnbuffered("hello"));
- EXPECT_EQ("hello", printToStringUnbuffered(std::string("hello")));
-
- // Int
- EXPECT_EQ("0", printToStringUnbuffered(0));
- EXPECT_EQ("2425", printToStringUnbuffered(2425));
- EXPECT_EQ("-2425", printToStringUnbuffered(-2425));
-
- // Long long
- EXPECT_EQ("0", printToStringUnbuffered(0LL));
- EXPECT_EQ("257257257235709", printToStringUnbuffered(257257257235709LL));
- EXPECT_EQ("-257257257235709", printToStringUnbuffered(-257257257235709LL));
-
- // Double
- EXPECT_EQ("1.100000e+00", printToStringUnbuffered(1.1));
-
- // void*
- EXPECT_EQ("0x0", printToStringUnbuffered((void*) 0));
- EXPECT_EQ("0xbeef", printToStringUnbuffered((void*) 0xbeef));
- EXPECT_EQ("0xdeadbeef", printToStringUnbuffered((void*) 0xdeadbeef));
-
- // Min and max.
- EXPECT_EQ("18446744073709551615", printToStringUnbuffered(UINT64_MAX));
- EXPECT_EQ("-9223372036854775808", printToStringUnbuffered(INT64_MIN));
-}
-
-TEST(raw_ostreamTest, BufferEdge) {
- EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 1));
- EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 2));
- EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 3));
- EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 4));
- EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 10));
-}
-
-TEST(raw_ostreamTest, TinyBuffer) {
- std::string Str;
- raw_string_ostream OS(Str);
- OS.SetBufferSize(1);
- OS << "hello";
- OS << 1;
- OS << 'w' << 'o' << 'r' << 'l' << 'd';
- EXPECT_EQ("hello1world", OS.str());
-}
-
-TEST(raw_ostreamTest, WriteEscaped) {
- std::string Str;
-
- Str = "";
- raw_string_ostream(Str).write_escaped("hi");
- EXPECT_EQ("hi", Str);
-
- Str = "";
- raw_string_ostream(Str).write_escaped("\\\t\n\"");
- EXPECT_EQ("\\\\\\t\\n\\\"", Str);
-
- Str = "";
- raw_string_ostream(Str).write_escaped("\1\10\200");
- EXPECT_EQ("\\001\\010\\200", Str);
-}
-
-}
diff --git a/contrib/llvm/unittests/Transforms/Makefile b/contrib/llvm/unittests/Transforms/Makefile
deleted file mode 100644
index 599b18a..0000000
--- a/contrib/llvm/unittests/Transforms/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-##===- unittests/Transforms/Makefile -----------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../..
-
-PARALLEL_DIRS = Utils
-
-include $(LEVEL)/Makefile.common
-
-clean::
- $(Verb) $(RM) -f *Tests
diff --git a/contrib/llvm/unittests/Transforms/Utils/Cloning.cpp b/contrib/llvm/unittests/Transforms/Utils/Cloning.cpp
deleted file mode 100644
index b65ac34..0000000
--- a/contrib/llvm/unittests/Transforms/Utils/Cloning.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-//===- Cloning.cpp - Unit tests for the Cloner ----------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/Argument.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/STLExtras.h"
-
-using namespace llvm;
-
-class CloneInstruction : public ::testing::Test {
-protected:
- virtual void SetUp() {
- V = NULL;
- }
-
- template <typename T>
- T *clone(T *V1) {
- Value *V2 = V1->clone();
- Orig.insert(V1);
- Clones.insert(V2);
- return cast<T>(V2);
- }
-
- void eraseClones() {
- DeleteContainerPointers(Clones);
- }
-
- virtual void TearDown() {
- eraseClones();
- DeleteContainerPointers(Orig);
- delete V;
- }
-
- SmallPtrSet<Value *, 4> Orig; // Erase on exit
- SmallPtrSet<Value *, 4> Clones; // Erase in eraseClones
-
- LLVMContext context;
- Value *V;
-};
-
-TEST_F(CloneInstruction, OverflowBits) {
- V = new Argument(Type::getInt32Ty(context));
-
- BinaryOperator *Add = BinaryOperator::Create(Instruction::Add, V, V);
- BinaryOperator *Sub = BinaryOperator::Create(Instruction::Sub, V, V);
- BinaryOperator *Mul = BinaryOperator::Create(Instruction::Mul, V, V);
-
- BinaryOperator *AddClone = this->clone(Add);
- BinaryOperator *SubClone = this->clone(Sub);
- BinaryOperator *MulClone = this->clone(Mul);
-
- EXPECT_FALSE(AddClone->hasNoUnsignedWrap());
- EXPECT_FALSE(AddClone->hasNoSignedWrap());
- EXPECT_FALSE(SubClone->hasNoUnsignedWrap());
- EXPECT_FALSE(SubClone->hasNoSignedWrap());
- EXPECT_FALSE(MulClone->hasNoUnsignedWrap());
- EXPECT_FALSE(MulClone->hasNoSignedWrap());
-
- eraseClones();
-
- Add->setHasNoUnsignedWrap();
- Sub->setHasNoUnsignedWrap();
- Mul->setHasNoUnsignedWrap();
-
- AddClone = this->clone(Add);
- SubClone = this->clone(Sub);
- MulClone = this->clone(Mul);
-
- EXPECT_TRUE(AddClone->hasNoUnsignedWrap());
- EXPECT_FALSE(AddClone->hasNoSignedWrap());
- EXPECT_TRUE(SubClone->hasNoUnsignedWrap());
- EXPECT_FALSE(SubClone->hasNoSignedWrap());
- EXPECT_TRUE(MulClone->hasNoUnsignedWrap());
- EXPECT_FALSE(MulClone->hasNoSignedWrap());
-
- eraseClones();
-
- Add->setHasNoSignedWrap();
- Sub->setHasNoSignedWrap();
- Mul->setHasNoSignedWrap();
-
- AddClone = this->clone(Add);
- SubClone = this->clone(Sub);
- MulClone = this->clone(Mul);
-
- EXPECT_TRUE(AddClone->hasNoUnsignedWrap());
- EXPECT_TRUE(AddClone->hasNoSignedWrap());
- EXPECT_TRUE(SubClone->hasNoUnsignedWrap());
- EXPECT_TRUE(SubClone->hasNoSignedWrap());
- EXPECT_TRUE(MulClone->hasNoUnsignedWrap());
- EXPECT_TRUE(MulClone->hasNoSignedWrap());
-
- eraseClones();
-
- Add->setHasNoUnsignedWrap(false);
- Sub->setHasNoUnsignedWrap(false);
- Mul->setHasNoUnsignedWrap(false);
-
- AddClone = this->clone(Add);
- SubClone = this->clone(Sub);
- MulClone = this->clone(Mul);
-
- EXPECT_FALSE(AddClone->hasNoUnsignedWrap());
- EXPECT_TRUE(AddClone->hasNoSignedWrap());
- EXPECT_FALSE(SubClone->hasNoUnsignedWrap());
- EXPECT_TRUE(SubClone->hasNoSignedWrap());
- EXPECT_FALSE(MulClone->hasNoUnsignedWrap());
- EXPECT_TRUE(MulClone->hasNoSignedWrap());
-}
-
-TEST_F(CloneInstruction, Inbounds) {
- V = new Argument(Type::getInt32PtrTy(context));
-
- Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
- std::vector<Value *> ops;
- ops.push_back(Z);
- GetElementPtrInst *GEP = GetElementPtrInst::Create(V, ops.begin(), ops.end());
- EXPECT_FALSE(this->clone(GEP)->isInBounds());
-
- GEP->setIsInBounds();
- EXPECT_TRUE(this->clone(GEP)->isInBounds());
-}
-
-TEST_F(CloneInstruction, Exact) {
- V = new Argument(Type::getInt32Ty(context));
-
- BinaryOperator *SDiv = BinaryOperator::Create(Instruction::SDiv, V, V);
- EXPECT_FALSE(this->clone(SDiv)->isExact());
-
- SDiv->setIsExact(true);
- EXPECT_TRUE(this->clone(SDiv)->isExact());
-}
diff --git a/contrib/llvm/unittests/Transforms/Utils/Makefile b/contrib/llvm/unittests/Transforms/Utils/Makefile
deleted file mode 100644
index fdf4be0..0000000
--- a/contrib/llvm/unittests/Transforms/Utils/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- unittests/Transforms/Utils/Makefile -----------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../../..
-TESTNAME = Utils
-LINK_COMPONENTS := core support transformutils
-
-include $(LEVEL)/Makefile.config
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/contrib/llvm/unittests/VMCore/ConstantsTest.cpp b/contrib/llvm/unittests/VMCore/ConstantsTest.cpp
deleted file mode 100644
index 8f28407..0000000
--- a/contrib/llvm/unittests/VMCore/ConstantsTest.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-//===- llvm/unittest/VMCore/ConstantsTest.cpp - Constants unit tests ------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/LLVMContext.h"
-#include "gtest/gtest.h"
-
-namespace llvm {
-namespace {
-
-TEST(ConstantsTest, Integer_i1) {
- const IntegerType* Int1 = IntegerType::get(getGlobalContext(), 1);
- Constant* One = ConstantInt::get(Int1, 1, true);
- Constant* Zero = ConstantInt::get(Int1, 0);
- Constant* NegOne = ConstantInt::get(Int1, static_cast<uint64_t>(-1), true);
- EXPECT_EQ(NegOne, ConstantInt::getSigned(Int1, -1));
- Constant* Undef = UndefValue::get(Int1);
-
- // Input: @b = constant i1 add(i1 1 , i1 1)
- // Output: @b = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getAdd(One, One));
-
- // @c = constant i1 add(i1 -1, i1 1)
- // @c = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getAdd(NegOne, One));
-
- // @d = constant i1 add(i1 -1, i1 -1)
- // @d = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getAdd(NegOne, NegOne));
-
- // @e = constant i1 sub(i1 -1, i1 1)
- // @e = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getSub(NegOne, One));
-
- // @f = constant i1 sub(i1 1 , i1 -1)
- // @f = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getSub(One, NegOne));
-
- // @g = constant i1 sub(i1 1 , i1 1)
- // @g = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getSub(One, One));
-
- // @h = constant i1 shl(i1 1 , i1 1) ; undefined
- // @h = constant i1 undef
- EXPECT_EQ(Undef, ConstantExpr::getShl(One, One));
-
- // @i = constant i1 shl(i1 1 , i1 0)
- // @i = constant i1 true
- EXPECT_EQ(One, ConstantExpr::getShl(One, Zero));
-
- // @j = constant i1 lshr(i1 1, i1 1) ; undefined
- // @j = constant i1 undef
- EXPECT_EQ(Undef, ConstantExpr::getLShr(One, One));
-
- // @m = constant i1 ashr(i1 1, i1 1) ; undefined
- // @m = constant i1 undef
- EXPECT_EQ(Undef, ConstantExpr::getAShr(One, One));
-
- // @n = constant i1 mul(i1 -1, i1 1)
- // @n = constant i1 true
- EXPECT_EQ(One, ConstantExpr::getMul(NegOne, One));
-
- // @o = constant i1 sdiv(i1 -1, i1 1) ; overflow
- // @o = constant i1 true
- EXPECT_EQ(One, ConstantExpr::getSDiv(NegOne, One));
-
- // @p = constant i1 sdiv(i1 1 , i1 -1); overflow
- // @p = constant i1 true
- EXPECT_EQ(One, ConstantExpr::getSDiv(One, NegOne));
-
- // @q = constant i1 udiv(i1 -1, i1 1)
- // @q = constant i1 true
- EXPECT_EQ(One, ConstantExpr::getUDiv(NegOne, One));
-
- // @r = constant i1 udiv(i1 1, i1 -1)
- // @r = constant i1 true
- EXPECT_EQ(One, ConstantExpr::getUDiv(One, NegOne));
-
- // @s = constant i1 srem(i1 -1, i1 1) ; overflow
- // @s = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getSRem(NegOne, One));
-
- // @t = constant i1 urem(i1 -1, i1 1)
- // @t = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getURem(NegOne, One));
-
- // @u = constant i1 srem(i1 1, i1 -1) ; overflow
- // @u = constant i1 false
- EXPECT_EQ(Zero, ConstantExpr::getSRem(One, NegOne));
-}
-
-TEST(ConstantsTest, IntSigns) {
- const IntegerType* Int8Ty = Type::getInt8Ty(getGlobalContext());
- EXPECT_EQ(100, ConstantInt::get(Int8Ty, 100, false)->getSExtValue());
- EXPECT_EQ(100, ConstantInt::get(Int8Ty, 100, true)->getSExtValue());
- EXPECT_EQ(100, ConstantInt::getSigned(Int8Ty, 100)->getSExtValue());
- EXPECT_EQ(-50, ConstantInt::get(Int8Ty, 206)->getSExtValue());
- EXPECT_EQ(-50, ConstantInt::getSigned(Int8Ty, -50)->getSExtValue());
- EXPECT_EQ(206U, ConstantInt::getSigned(Int8Ty, -50)->getZExtValue());
-
- // Overflow is handled by truncation.
- EXPECT_EQ(0x3b, ConstantInt::get(Int8Ty, 0x13b)->getSExtValue());
-}
-
-} // end anonymous namespace
-} // end namespace llvm
diff --git a/contrib/llvm/unittests/VMCore/DerivedTypesTest.cpp b/contrib/llvm/unittests/VMCore/DerivedTypesTest.cpp
deleted file mode 100644
index 2e0450d..0000000
--- a/contrib/llvm/unittests/VMCore/DerivedTypesTest.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-//===- llvm/unittest/VMCore/DerivedTypesTest.cpp - Types unit tests -------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "../lib/VMCore/LLVMContextImpl.h"
-#include "llvm/Type.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/LLVMContext.h"
-using namespace llvm;
-
-namespace {
-
-TEST(OpaqueTypeTest, RegisterWithContext) {
- LLVMContext C;
- LLVMContextImpl *pImpl = C.pImpl;
-
- // 1 refers to the AlwaysOpaqueTy allocated in the Context's constructor and
- // destroyed in the destructor.
- EXPECT_EQ(1u, pImpl->OpaqueTypes.size());
- {
- PATypeHolder Type = OpaqueType::get(C);
- EXPECT_EQ(2u, pImpl->OpaqueTypes.size());
- }
- EXPECT_EQ(1u, pImpl->OpaqueTypes.size());
-}
-
-} // namespace
diff --git a/contrib/llvm/unittests/VMCore/InstructionsTest.cpp b/contrib/llvm/unittests/VMCore/InstructionsTest.cpp
deleted file mode 100644
index c1baa74..0000000
--- a/contrib/llvm/unittests/VMCore/InstructionsTest.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-//===- llvm/unittest/VMCore/InstructionsTest.cpp - Instructions unit tests ===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Instructions.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/ADT/STLExtras.h"
-#include "gtest/gtest.h"
-
-namespace llvm {
-namespace {
-
-TEST(InstructionsTest, ReturnInst) {
- LLVMContext &C(getGlobalContext());
-
- // test for PR6589
- const ReturnInst* r0 = ReturnInst::Create(C);
- EXPECT_EQ(r0->getNumOperands(), 0U);
- EXPECT_EQ(r0->op_begin(), r0->op_end());
-
- const IntegerType* Int1 = IntegerType::get(C, 1);
- Constant* One = ConstantInt::get(Int1, 1, true);
- const ReturnInst* r1 = ReturnInst::Create(C, One);
- EXPECT_EQ(r1->getNumOperands(), 1U);
- User::const_op_iterator b(r1->op_begin());
- EXPECT_NE(b, r1->op_end());
- EXPECT_EQ(*b, One);
- EXPECT_EQ(r1->getOperand(0), One);
- ++b;
- EXPECT_EQ(b, r1->op_end());
-
- // clean up
- delete r0;
- delete r1;
-}
-
-TEST(InstructionsTest, BranchInst) {
- LLVMContext &C(getGlobalContext());
-
- // Make a BasicBlocks
- BasicBlock* bb0 = BasicBlock::Create(C);
- BasicBlock* bb1 = BasicBlock::Create(C);
-
- // Mandatory BranchInst
- const BranchInst* b0 = BranchInst::Create(bb0);
-
- EXPECT_TRUE(b0->isUnconditional());
- EXPECT_FALSE(b0->isConditional());
- EXPECT_EQ(b0->getNumSuccessors(), 1U);
-
- // check num operands
- EXPECT_EQ(b0->getNumOperands(), 1U);
-
- EXPECT_NE(b0->op_begin(), b0->op_end());
- EXPECT_EQ(next(b0->op_begin()), b0->op_end());
-
- EXPECT_EQ(next(b0->op_begin()), b0->op_end());
-
- const IntegerType* Int1 = IntegerType::get(C, 1);
- Constant* One = ConstantInt::get(Int1, 1, true);
-
- // Conditional BranchInst
- BranchInst* b1 = BranchInst::Create(bb0, bb1, One);
-
- EXPECT_FALSE(b1->isUnconditional());
- EXPECT_TRUE(b1->isConditional());
- EXPECT_EQ(b1->getNumSuccessors(), 2U);
-
- // check num operands
- EXPECT_EQ(b1->getNumOperands(), 3U);
-
- User::const_op_iterator b(b1->op_begin());
-
- // check COND
- EXPECT_NE(b, b1->op_end());
- EXPECT_EQ(*b, One);
- EXPECT_EQ(b1->getOperand(0), One);
- EXPECT_EQ(b1->getCondition(), One);
- ++b;
-
- // check ELSE
- EXPECT_EQ(*b, bb1);
- EXPECT_EQ(b1->getOperand(1), bb1);
- EXPECT_EQ(b1->getSuccessor(1), bb1);
- ++b;
-
- // check THEN
- EXPECT_EQ(*b, bb0);
- EXPECT_EQ(b1->getOperand(2), bb0);
- EXPECT_EQ(b1->getSuccessor(0), bb0);
- ++b;
-
- EXPECT_EQ(b, b1->op_end());
-
- // shrink it
- b1->setUnconditionalDest(bb1);
-
- // check num operands
- EXPECT_EQ(b1->getNumOperands(), 1U);
-
- User::const_op_iterator c(b1->op_begin());
- EXPECT_NE(c, b1->op_end());
-
- // check THEN
- EXPECT_EQ(*c, bb1);
- EXPECT_EQ(b1->getOperand(0), bb1);
- EXPECT_EQ(b1->getSuccessor(0), bb1);
- ++c;
-
- EXPECT_EQ(c, b1->op_end());
-
- // clean up
- delete b0;
- delete b1;
-
- delete bb0;
- delete bb1;
-}
-
-} // end anonymous namespace
-} // end namespace llvm
diff --git a/contrib/llvm/unittests/VMCore/Makefile b/contrib/llvm/unittests/VMCore/Makefile
deleted file mode 100644
index 1b2b69c..0000000
--- a/contrib/llvm/unittests/VMCore/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- unittests/VMCore/Makefile ---------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../..
-TESTNAME = VMCore
-LINK_COMPONENTS := core support target ipa
-
-include $(LEVEL)/Makefile.config
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/contrib/llvm/unittests/VMCore/MetadataTest.cpp b/contrib/llvm/unittests/VMCore/MetadataTest.cpp
deleted file mode 100644
index 04db486..0000000
--- a/contrib/llvm/unittests/VMCore/MetadataTest.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-//===- llvm/unittest/VMCore/Metadata.cpp - Metadata unit tests ------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/Constants.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Metadata.h"
-#include "llvm/Module.h"
-#include "llvm/Type.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/ValueHandle.h"
-using namespace llvm;
-
-namespace {
-
-class MetadataTest : public testing::Test {
-protected:
- LLVMContext Context;
-};
-typedef MetadataTest MDStringTest;
-
-// Test that construction of MDString with different value produces different
-// MDString objects, even with the same string pointer and nulls in the string.
-TEST_F(MDStringTest, CreateDifferent) {
- char x[3] = { 'f', 0, 'A' };
- MDString *s1 = MDString::get(Context, StringRef(&x[0], 3));
- x[2] = 'B';
- MDString *s2 = MDString::get(Context, StringRef(&x[0], 3));
- EXPECT_NE(s1, s2);
-}
-
-// Test that creation of MDStrings with the same string contents produces the
-// same MDString object, even with different pointers.
-TEST_F(MDStringTest, CreateSame) {
- char x[4] = { 'a', 'b', 'c', 'X' };
- char y[4] = { 'a', 'b', 'c', 'Y' };
-
- MDString *s1 = MDString::get(Context, StringRef(&x[0], 3));
- MDString *s2 = MDString::get(Context, StringRef(&y[0], 3));
- EXPECT_EQ(s1, s2);
-}
-
-// Test that MDString prints out the string we fed it.
-TEST_F(MDStringTest, PrintingSimple) {
- char *str = new char[13];
- strncpy(str, "testing 1 2 3", 13);
- MDString *s = MDString::get(Context, StringRef(str, 13));
- strncpy(str, "aaaaaaaaaaaaa", 13);
- delete[] str;
-
- std::string Str;
- raw_string_ostream oss(Str);
- s->print(oss);
- EXPECT_STREQ("metadata !\"testing 1 2 3\"", oss.str().c_str());
-}
-
-// Test printing of MDString with non-printable characters.
-TEST_F(MDStringTest, PrintingComplex) {
- char str[5] = {0, '\n', '"', '\\', -1};
- MDString *s = MDString::get(Context, StringRef(str+0, 5));
- std::string Str;
- raw_string_ostream oss(Str);
- s->print(oss);
- EXPECT_STREQ("metadata !\"\\00\\0A\\22\\5C\\FF\"", oss.str().c_str());
-}
-
-typedef MetadataTest MDNodeTest;
-
-// Test the two constructors, and containing other Constants.
-TEST_F(MDNodeTest, Simple) {
- char x[3] = { 'a', 'b', 'c' };
- char y[3] = { '1', '2', '3' };
-
- MDString *s1 = MDString::get(Context, StringRef(&x[0], 3));
- MDString *s2 = MDString::get(Context, StringRef(&y[0], 3));
- ConstantInt *CI = ConstantInt::get(getGlobalContext(), APInt(8, 0));
-
- std::vector<Value *> V;
- V.push_back(s1);
- V.push_back(CI);
- V.push_back(s2);
-
- MDNode *n1 = MDNode::get(Context, &V[0], 3);
- Value *const c1 = n1;
- MDNode *n2 = MDNode::get(Context, &c1, 1);
- MDNode *n3 = MDNode::get(Context, &V[0], 3);
- EXPECT_NE(n1, n2);
-#ifdef ENABLE_MDNODE_UNIQUING
- EXPECT_EQ(n1, n3);
-#else
- (void) n3;
-#endif
-
- EXPECT_EQ(3u, n1->getNumOperands());
- EXPECT_EQ(s1, n1->getOperand(0));
- EXPECT_EQ(CI, n1->getOperand(1));
- EXPECT_EQ(s2, n1->getOperand(2));
-
- EXPECT_EQ(1u, n2->getNumOperands());
- EXPECT_EQ(n1, n2->getOperand(0));
-}
-
-TEST_F(MDNodeTest, Delete) {
- Constant *C = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 1);
- Instruction *I = new BitCastInst(C, Type::getInt32Ty(getGlobalContext()));
-
- Value *const V = I;
- MDNode *n = MDNode::get(Context, &V, 1);
- WeakVH wvh = n;
-
- EXPECT_EQ(n, wvh);
-
- delete I;
-}
-
-TEST(NamedMDNodeTest, Search) {
- LLVMContext Context;
- Constant *C = ConstantInt::get(Type::getInt32Ty(Context), 1);
- Constant *C2 = ConstantInt::get(Type::getInt32Ty(Context), 2);
-
- Value *const V = C;
- Value *const V2 = C2;
- MDNode *n = MDNode::get(Context, &V, 1);
- MDNode *n2 = MDNode::get(Context, &V2, 1);
-
- MDNode *Nodes[2] = { n, n2 };
-
- Module M("MyModule", Context);
- const char *Name = "llvm.NMD1";
- NamedMDNode *NMD = NamedMDNode::Create(Context, Name, &Nodes[0], 2, &M);
- std::string Str;
- raw_string_ostream oss(Str);
- NMD->print(oss);
- EXPECT_STREQ("!llvm.NMD1 = !{!0, !1}\n",
- oss.str().c_str());
-}
-}
diff --git a/contrib/llvm/unittests/VMCore/PassManagerTest.cpp b/contrib/llvm/unittests/VMCore/PassManagerTest.cpp
deleted file mode 100644
index 4b38910..0000000
--- a/contrib/llvm/unittests/VMCore/PassManagerTest.cpp
+++ /dev/null
@@ -1,527 +0,0 @@
-//===- llvm/unittest/VMCore/PassManager.cpp - Constants unit tests ------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Module.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/PassManager.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Pass.h"
-#include "llvm/Analysis/LoopPass.h"
-#include "llvm/CallGraphSCCPass.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Constants.h"
-#include "llvm/GlobalVariable.h"
-#include "llvm/Function.h"
-#include "llvm/CallingConv.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/Instructions.h"
-#include "llvm/InlineAsm.h"
-#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/PassManager.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Assembly/PrintModulePass.h"
-#include "gtest/gtest.h"
-
-namespace llvm {
- namespace {
- // ND = no deps
- // NM = no modifications
- struct ModuleNDNM: public ModulePass {
- public:
- static char run;
- static char ID;
- ModuleNDNM() : ModulePass(&ID) {}
- virtual bool runOnModule(Module &M) {
- run++;
- return false;
- }
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
- }
- };
- char ModuleNDNM::ID=0;
- char ModuleNDNM::run=0;
-
- struct ModuleNDM : public ModulePass {
- public:
- static char run;
- static char ID;
- ModuleNDM() : ModulePass(&ID) {}
- virtual bool runOnModule(Module &M) {
- run++;
- return true;
- }
- };
- char ModuleNDM::ID=0;
- char ModuleNDM::run=0;
- RegisterPass<ModuleNDM> X("mndm","mndm",false,false);
-
- struct ModuleNDM2 : public ModulePass {
- public:
- static char run;
- static char ID;
- ModuleNDM2() : ModulePass(&ID) {}
- virtual bool runOnModule(Module &M) {
- run++;
- return true;
- }
- };
- char ModuleNDM2::ID=0;
- char ModuleNDM2::run=0;
-
- struct ModuleDNM : public ModulePass {
- public:
- static char run;
- static char ID;
- ModuleDNM() : ModulePass(&ID) {}
- virtual bool runOnModule(Module &M) {
- EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
- run++;
- return false;
- }
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired<ModuleNDM>();
- AU.setPreservesAll();
- }
- };
- char ModuleDNM::ID=0;
- char ModuleDNM::run=0;
-
- template<typename P>
- struct PassTestBase : public P {
- protected:
- static int runc;
- static bool initialized;
- static bool finalized;
- int allocated;
- void run() {
- EXPECT_EQ(true, initialized);
- EXPECT_EQ(false, finalized);
- EXPECT_EQ(0, allocated);
- allocated++;
- runc++;
- }
- public:
- static char ID;
- static void finishedOK(int run) {
- EXPECT_GT(runc, 0);
- EXPECT_EQ(true, initialized);
- EXPECT_EQ(true, finalized);
- EXPECT_EQ(run, runc);
- }
- PassTestBase() : P(&ID), allocated(0) {
- initialized = false;
- finalized = false;
- runc = 0;
- }
-
- virtual void releaseMemory() {
- EXPECT_GT(runc, 0);
- EXPECT_GT(allocated, 0);
- allocated--;
- }
- };
- template<typename P> char PassTestBase<P>::ID;
- template<typename P> int PassTestBase<P>::runc;
- template<typename P> bool PassTestBase<P>::initialized;
- template<typename P> bool PassTestBase<P>::finalized;
-
- template<typename T, typename P>
- struct PassTest : public PassTestBase<P> {
- public:
- virtual bool doInitialization(T &t) {
- EXPECT_EQ(false, PassTestBase<P>::initialized);
- PassTestBase<P>::initialized = true;
- return false;
- }
- virtual bool doFinalization(T &t) {
- EXPECT_EQ(false, PassTestBase<P>::finalized);
- PassTestBase<P>::finalized = true;
- EXPECT_EQ(0, PassTestBase<P>::allocated);
- return false;
- }
- };
-
- struct CGPass : public PassTest<CallGraph, CallGraphSCCPass> {
- public:
- virtual bool runOnSCC(CallGraphSCC &SCMM) {
- EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
- run();
- return false;
- }
- };
- RegisterPass<CGPass> X1("cgp","cgp");
-
- struct FPass : public PassTest<Module, FunctionPass> {
- public:
- virtual bool runOnFunction(Function &F) {
- // FIXME: PR4112
- // EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
- run();
- return false;
- }
- };
- RegisterPass<FPass> X2("fp","fp");
-
- struct LPass : public PassTestBase<LoopPass> {
- private:
- static int initcount;
- static int fincount;
- public:
- LPass() {
- initcount = 0; fincount=0;
- EXPECT_EQ(false, initialized);
- }
- static void finishedOK(int run, int finalized) {
- PassTestBase<LoopPass>::finishedOK(run);
- EXPECT_EQ(run, initcount);
- EXPECT_EQ(finalized, fincount);
- }
- virtual bool doInitialization(Loop* L, LPPassManager &LPM) {
- initialized = true;
- initcount++;
- return false;
- }
- virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
- EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
- run();
- return false;
- }
- virtual bool doFinalization() {
- fincount++;
- finalized = true;
- return false;
- }
- };
- int LPass::initcount=0;
- int LPass::fincount=0;
- RegisterPass<LPass> X3("lp","lp");
-
- struct BPass : public PassTestBase<BasicBlockPass> {
- private:
- static int inited;
- static int fin;
- public:
- static void finishedOK(int run, int N) {
- PassTestBase<BasicBlockPass>::finishedOK(run);
- EXPECT_EQ(inited, N);
- EXPECT_EQ(fin, N);
- }
- BPass() {
- inited = 0;
- fin = 0;
- }
- virtual bool doInitialization(Module &M) {
- EXPECT_EQ(false, initialized);
- initialized = true;
- return false;
- }
- virtual bool doInitialization(Function &F) {
- inited++;
- return false;
- }
- virtual bool runOnBasicBlock(BasicBlock &BB) {
- EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
- run();
- return false;
- }
- virtual bool doFinalization(Function &F) {
- fin++;
- return false;
- }
- virtual bool doFinalization(Module &M) {
- EXPECT_EQ(false, finalized);
- finalized = true;
- EXPECT_EQ(0, allocated);
- return false;
- }
- };
- int BPass::inited=0;
- int BPass::fin=0;
- RegisterPass<BPass> X4("bp","bp");
-
- struct OnTheFlyTest: public ModulePass {
- public:
- static char ID;
- OnTheFlyTest() : ModulePass(&ID) {}
- virtual bool runOnModule(Module &M) {
- EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
- for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) {
- Function &F = *I;
- {
- SCOPED_TRACE("Running on the fly function pass");
- getAnalysis<FPass>(F);
- }
- }
- return false;
- }
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired<FPass>();
- }
- };
- char OnTheFlyTest::ID=0;
-
- TEST(PassManager, RunOnce) {
- Module M("test-once", getGlobalContext());
- struct ModuleNDNM *mNDNM = new ModuleNDNM();
- struct ModuleDNM *mDNM = new ModuleDNM();
- struct ModuleNDM *mNDM = new ModuleNDM();
- struct ModuleNDM2 *mNDM2 = new ModuleNDM2();
-
- mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
-
- PassManager Passes;
- Passes.add(new TargetData(&M));
- Passes.add(mNDM2);
- Passes.add(mNDM);
- Passes.add(mNDNM);
- Passes.add(mDNM);
-
- Passes.run(M);
- // each pass must be run exactly once, since nothing invalidates them
- EXPECT_EQ(1, mNDM->run);
- EXPECT_EQ(1, mNDNM->run);
- EXPECT_EQ(1, mDNM->run);
- EXPECT_EQ(1, mNDM2->run);
- }
-
- TEST(PassManager, ReRun) {
- Module M("test-rerun", getGlobalContext());
- struct ModuleNDNM *mNDNM = new ModuleNDNM();
- struct ModuleDNM *mDNM = new ModuleDNM();
- struct ModuleNDM *mNDM = new ModuleNDM();
- struct ModuleNDM2 *mNDM2 = new ModuleNDM2();
-
- mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
-
- PassManager Passes;
- Passes.add(new TargetData(&M));
- Passes.add(mNDM);
- Passes.add(mNDNM);
- Passes.add(mNDM2);// invalidates mNDM needed by mDNM
- Passes.add(mDNM);
-
- Passes.run(M);
- // Some passes must be rerun because a pass that modified the
- // module/function was run inbetween
- EXPECT_EQ(2, mNDM->run);
- EXPECT_EQ(1, mNDNM->run);
- EXPECT_EQ(1, mNDM2->run);
- EXPECT_EQ(1, mDNM->run);
- }
-
- Module* makeLLVMModule();
-
- template<typename T>
- void MemoryTestHelper(int run) {
- OwningPtr<Module> M(makeLLVMModule());
- T *P = new T();
- PassManager Passes;
- Passes.add(new TargetData(M.get()));
- Passes.add(P);
- Passes.run(*M);
- T::finishedOK(run);
- }
-
- template<typename T>
- void MemoryTestHelper(int run, int N) {
- Module *M = makeLLVMModule();
- T *P = new T();
- PassManager Passes;
- Passes.add(new TargetData(M));
- Passes.add(P);
- Passes.run(*M);
- T::finishedOK(run, N);
- delete M;
- }
-
- TEST(PassManager, Memory) {
- // SCC#1: test1->test2->test3->test1
- // SCC#2: test4
- // SCC#3: indirect call node
- {
- SCOPED_TRACE("Callgraph pass");
- MemoryTestHelper<CGPass>(3);
- }
-
- {
- SCOPED_TRACE("Function pass");
- MemoryTestHelper<FPass>(4);// 4 functions
- }
-
- {
- SCOPED_TRACE("Loop pass");
- MemoryTestHelper<LPass>(2, 1); //2 loops, 1 function
- }
- {
- SCOPED_TRACE("Basic block pass");
- MemoryTestHelper<BPass>(7, 4); //9 basic blocks
- }
-
- }
-
- TEST(PassManager, MemoryOnTheFly) {
- Module *M = makeLLVMModule();
- {
- SCOPED_TRACE("Running OnTheFlyTest");
- struct OnTheFlyTest *O = new OnTheFlyTest();
- PassManager Passes;
- Passes.add(new TargetData(M));
- Passes.add(O);
- Passes.run(*M);
-
- FPass::finishedOK(4);
- }
- delete M;
- }
-
- Module* makeLLVMModule() {
- // Module Construction
- Module* mod = new Module("test-mem", getGlobalContext());
- mod->setDataLayout("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
- "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-"
- "a0:0:64-s0:64:64-f80:128:128");
- mod->setTargetTriple("x86_64-unknown-linux-gnu");
-
- // Type Definitions
- std::vector<const Type*>FuncTy_0_args;
- FunctionType* FuncTy_0 = FunctionType::get(
- /*Result=*/IntegerType::get(getGlobalContext(), 32),
- /*Params=*/FuncTy_0_args,
- /*isVarArg=*/false);
-
- std::vector<const Type*>FuncTy_2_args;
- FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1));
- FunctionType* FuncTy_2 = FunctionType::get(
- /*Result=*/Type::getVoidTy(getGlobalContext()),
- /*Params=*/FuncTy_2_args,
- /*isVarArg=*/false);
-
-
- // Function Declarations
-
- Function* func_test1 = Function::Create(
- /*Type=*/FuncTy_0,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"test1", mod);
- func_test1->setCallingConv(CallingConv::C);
- AttrListPtr func_test1_PAL;
- func_test1->setAttributes(func_test1_PAL);
-
- Function* func_test2 = Function::Create(
- /*Type=*/FuncTy_0,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"test2", mod);
- func_test2->setCallingConv(CallingConv::C);
- AttrListPtr func_test2_PAL;
- func_test2->setAttributes(func_test2_PAL);
-
- Function* func_test3 = Function::Create(
- /*Type=*/FuncTy_0,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"test3", mod);
- func_test3->setCallingConv(CallingConv::C);
- AttrListPtr func_test3_PAL;
- func_test3->setAttributes(func_test3_PAL);
-
- Function* func_test4 = Function::Create(
- /*Type=*/FuncTy_2,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"test4", mod);
- func_test4->setCallingConv(CallingConv::C);
- AttrListPtr func_test4_PAL;
- func_test4->setAttributes(func_test4_PAL);
-
- // Global Variable Declarations
-
-
- // Constant Definitions
-
- // Global Variable Definitions
-
- // Function Definitions
-
- // Function: test1 (func_test1)
- {
-
- BasicBlock* label_entry = BasicBlock::Create(getGlobalContext(), "entry",func_test1,0);
-
- // Block entry (label_entry)
- CallInst* int32_3 = CallInst::Create(func_test2, "", label_entry);
- int32_3->setCallingConv(CallingConv::C);
- int32_3->setTailCall(false);AttrListPtr int32_3_PAL;
- int32_3->setAttributes(int32_3_PAL);
-
- ReturnInst::Create(getGlobalContext(), int32_3, label_entry);
-
- }
-
- // Function: test2 (func_test2)
- {
-
- BasicBlock* label_entry_5 = BasicBlock::Create(getGlobalContext(), "entry",func_test2,0);
-
- // Block entry (label_entry_5)
- CallInst* int32_6 = CallInst::Create(func_test3, "", label_entry_5);
- int32_6->setCallingConv(CallingConv::C);
- int32_6->setTailCall(false);AttrListPtr int32_6_PAL;
- int32_6->setAttributes(int32_6_PAL);
-
- ReturnInst::Create(getGlobalContext(), int32_6, label_entry_5);
-
- }
-
- // Function: test3 (func_test3)
- {
-
- BasicBlock* label_entry_8 = BasicBlock::Create(getGlobalContext(), "entry",func_test3,0);
-
- // Block entry (label_entry_8)
- CallInst* int32_9 = CallInst::Create(func_test1, "", label_entry_8);
- int32_9->setCallingConv(CallingConv::C);
- int32_9->setTailCall(false);AttrListPtr int32_9_PAL;
- int32_9->setAttributes(int32_9_PAL);
-
- ReturnInst::Create(getGlobalContext(), int32_9, label_entry_8);
-
- }
-
- // Function: test4 (func_test4)
- {
- Function::arg_iterator args = func_test4->arg_begin();
- Value* int1_f = args++;
- int1_f->setName("f");
-
- BasicBlock* label_entry_11 = BasicBlock::Create(getGlobalContext(), "entry",func_test4,0);
- BasicBlock* label_bb = BasicBlock::Create(getGlobalContext(), "bb",func_test4,0);
- BasicBlock* label_bb1 = BasicBlock::Create(getGlobalContext(), "bb1",func_test4,0);
- BasicBlock* label_return = BasicBlock::Create(getGlobalContext(), "return",func_test4,0);
-
- // Block entry (label_entry_11)
- BranchInst::Create(label_bb, label_entry_11);
-
- // Block bb (label_bb)
- BranchInst::Create(label_bb, label_bb1, int1_f, label_bb);
-
- // Block bb1 (label_bb1)
- BranchInst::Create(label_bb1, label_return, int1_f, label_bb1);
-
- // Block return (label_return)
- ReturnInst::Create(getGlobalContext(), label_return);
-
- }
- return mod;
- }
-
- }
-}
diff --git a/contrib/llvm/unittests/VMCore/VerifierTest.cpp b/contrib/llvm/unittests/VMCore/VerifierTest.cpp
deleted file mode 100644
index 1173b2d..0000000
--- a/contrib/llvm/unittests/VMCore/VerifierTest.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//===- llvm/unittest/VMCore/VerifierTest.cpp - Verifier unit tests --------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/Analysis/Verifier.h"
-#include "gtest/gtest.h"
-
-namespace llvm {
-namespace {
-
-TEST(VerifierTest, Branch_i1) {
- LLVMContext &C = getGlobalContext();
- FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false);
- OwningPtr<Function> F(Function::Create(FTy, GlobalValue::ExternalLinkage));
- BasicBlock *Entry = BasicBlock::Create(C, "entry", F.get());
- BasicBlock *Exit = BasicBlock::Create(C, "exit", F.get());
- ReturnInst::Create(C, Exit);
-
- // To avoid triggering an assertion in BranchInst::Create, we first create
- // a branch with an 'i1' condition ...
-
- Constant *False = ConstantInt::getFalse(C);
- BranchInst *BI = BranchInst::Create(Exit, Exit, False, Entry);
-
- // ... then use setOperand to redirect it to a value of different type.
-
- Constant *Zero32 = ConstantInt::get(IntegerType::get(C, 32), 0);
- BI->setOperand(0, Zero32);
-
- EXPECT_TRUE(verifyFunction(*F, ReturnStatusAction));
-}
-
-}
-}
OpenPOWER on IntegriCloud