aboutsummaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2015-05-06 11:46:36 -0700
committerPirama Arumuga Nainar <pirama@google.com>2015-05-18 10:52:30 -0700
commit2c3e0051c31c3f5b2328b447eadf1cf9c4427442 (patch)
treec0104029af14e9f47c2ef58ca60e6137691f3c9b /unittests
parente1bc145815f4334641be19f1c45ecf85d25b6e5a (diff)
downloadexternal_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.zip
external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.gz
external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.bz2
Update aosp/master LLVM for rebase to r235153
Change-Id: I9bf53792f9fc30570e81a8d80d296c681d005ea7 (cherry picked from commit 0c7f116bb6950ef819323d855415b2f2b0aad987)
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/DAGDeltaAlgorithmTest.cpp2
-rw-r--r--unittests/ADT/DeltaAlgorithmTest.cpp2
-rw-r--r--unittests/ADT/SmallVectorTest.cpp5
-rw-r--r--unittests/Analysis/AliasAnalysisTest.cpp94
-rw-r--r--unittests/Analysis/CFGTest.cpp4
-rw-r--r--unittests/Analysis/CMakeLists.txt1
-rw-r--r--unittests/Analysis/ScalarEvolutionTest.cpp2
-rw-r--r--unittests/ExecutionEngine/ExecutionEngineTest.cpp3
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp28
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp4
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITTest.cpp2
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITTestBase.h5
-rw-r--r--unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp10
-rw-r--r--unittests/IR/ConstantsTest.cpp8
-rw-r--r--unittests/IR/DebugInfoTest.cpp128
-rw-r--r--unittests/IR/DominatorTreeTest.cpp32
-rw-r--r--unittests/IR/IRBuilderTest.cpp15
-rw-r--r--unittests/IR/MetadataTest.cpp526
-rw-r--r--unittests/IR/ValueHandleTest.cpp24
-rw-r--r--unittests/IR/ValueMapTest.cpp3
-rw-r--r--unittests/LineEditor/LineEditor.cpp2
-rw-r--r--unittests/Linker/LinkModulesTest.cpp4
-rw-r--r--unittests/Support/AlignOfTest.cpp42
-rw-r--r--unittests/Support/CMakeLists.txt1
-rw-r--r--unittests/Support/CommandLineTest.cpp4
-rw-r--r--unittests/Support/MemoryBufferTest.cpp2
-rw-r--r--unittests/Support/Path.cpp6
-rw-r--r--unittests/Support/raw_pwrite_stream_test.cpp25
-rw-r--r--unittests/Transforms/Utils/Cloning.cpp83
29 files changed, 621 insertions, 446 deletions
diff --git a/unittests/ADT/DAGDeltaAlgorithmTest.cpp b/unittests/ADT/DAGDeltaAlgorithmTest.cpp
index 370b7c2..190df7f 100644
--- a/unittests/ADT/DAGDeltaAlgorithmTest.cpp
+++ b/unittests/ADT/DAGDeltaAlgorithmTest.cpp
@@ -22,7 +22,7 @@ class FixedDAGDeltaAlgorithm : public DAGDeltaAlgorithm {
unsigned NumTests;
protected:
- virtual bool ExecuteOneTest(const changeset_ty &Changes) {
+ bool ExecuteOneTest(const changeset_ty &Changes) override {
++NumTests;
return std::includes(Changes.begin(), Changes.end(),
FailingSet.begin(), FailingSet.end());
diff --git a/unittests/ADT/DeltaAlgorithmTest.cpp b/unittests/ADT/DeltaAlgorithmTest.cpp
index a33f2b4..bed57b1 100644
--- a/unittests/ADT/DeltaAlgorithmTest.cpp
+++ b/unittests/ADT/DeltaAlgorithmTest.cpp
@@ -37,7 +37,7 @@ class FixedDeltaAlgorithm final : public DeltaAlgorithm {
unsigned NumTests;
protected:
- virtual bool ExecuteOneTest(const changeset_ty &Changes) {
+ bool ExecuteOneTest(const changeset_ty &Changes) override {
++NumTests;
return std::includes(Changes.begin(), Changes.end(),
FailingSet.begin(), FailingSet.end());
diff --git a/unittests/ADT/SmallVectorTest.cpp b/unittests/ADT/SmallVectorTest.cpp
index 97ff90b..46f7021 100644
--- a/unittests/ADT/SmallVectorTest.cpp
+++ b/unittests/ADT/SmallVectorTest.cpp
@@ -156,10 +156,7 @@ LLVM_ATTRIBUTE_USED void CompileTest() {
class SmallVectorTestBase : public testing::Test {
protected:
-
- void SetUp() {
- Constructable::reset();
- }
+ void SetUp() override { Constructable::reset(); }
template <typename VectorT>
void assertEmpty(VectorT & v) {
diff --git a/unittests/Analysis/AliasAnalysisTest.cpp b/unittests/Analysis/AliasAnalysisTest.cpp
new file mode 100644
index 0000000..1ba396c
--- /dev/null
+++ b/unittests/Analysis/AliasAnalysisTest.cpp
@@ -0,0 +1,94 @@
+//===--- AliasAnalysisTest.cpp - Mixed TBAA 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/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/Passes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/Support/CommandLine.h"
+#include "gtest/gtest.h"
+
+namespace llvm {
+namespace {
+
+class AliasAnalysisTest : public testing::Test {
+protected:
+ AliasAnalysisTest() : M("AliasAnalysisTBAATest", C) {}
+
+ // This is going to check that calling getModRefInfo without a location, and
+ // with a default location, first, doesn't crash, and second, gives the right
+ // answer.
+ void CheckModRef(Instruction *I, AliasAnalysis::ModRefResult Result) {
+ static char ID;
+ class CheckModRefTestPass : public FunctionPass {
+ public:
+ CheckModRefTestPass(Instruction *I, AliasAnalysis::ModRefResult Result)
+ : FunctionPass(ID), ExpectResult(Result), I(I) {}
+ static int initialize() {
+ PassInfo *PI = new PassInfo("CheckModRef testing pass", "", &ID,
+ nullptr, true, true);
+ PassRegistry::getPassRegistry()->registerPass(*PI, false);
+ initializeAliasAnalysisAnalysisGroup(*PassRegistry::getPassRegistry());
+ initializeBasicAliasAnalysisPass(*PassRegistry::getPassRegistry());
+ return 0;
+ }
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesAll();
+ AU.addRequiredTransitive<AliasAnalysis>();
+ }
+ bool runOnFunction(Function &) override {
+ AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
+ EXPECT_EQ(AA.getModRefInfo(I, AliasAnalysis::Location()), ExpectResult);
+ EXPECT_EQ(AA.getModRefInfo(I), ExpectResult);
+ return false;
+ }
+ AliasAnalysis::ModRefResult ExpectResult;
+ Instruction *I;
+ };
+ static int initialize = CheckModRefTestPass::initialize();
+ (void)initialize;
+ CheckModRefTestPass *P = new CheckModRefTestPass(I, Result);
+ legacy::PassManager PM;
+ PM.add(createBasicAliasAnalysisPass());
+ PM.add(P);
+ PM.run(M);
+ }
+
+ LLVMContext C;
+ Module M;
+};
+
+TEST_F(AliasAnalysisTest, getModRefInfo) {
+ // Setup function.
+ FunctionType *FTy =
+ FunctionType::get(Type::getVoidTy(C), std::vector<Type *>(), false);
+ auto *F = cast<Function>(M.getOrInsertFunction("f", FTy));
+ auto *BB = BasicBlock::Create(C, "entry", F);
+ auto IntType = Type::getInt32Ty(C);
+ auto PtrType = Type::getInt32PtrTy(C);
+ auto *Value = ConstantInt::get(IntType, 42);
+ auto *Addr = ConstantPointerNull::get(PtrType);
+
+ auto *Store1 = new StoreInst(Value, Addr, BB);
+ auto *Load1 = new LoadInst(Addr, "load", BB);
+ auto *Add1 = BinaryOperator::CreateAdd(Value, Value, "add", BB);
+
+ ReturnInst::Create(C, nullptr, BB);
+
+ // Check basic results
+ CheckModRef(Store1, AliasAnalysis::ModRefResult::Mod);
+ CheckModRef(Load1, AliasAnalysis::ModRefResult::Ref);
+ CheckModRef(Add1, AliasAnalysis::ModRefResult::NoModRef);
+}
+
+} // end anonymous namspace
+} // end llvm namespace
diff --git a/unittests/Analysis/CFGTest.cpp b/unittests/Analysis/CFGTest.cpp
index 4b4ebb6..b29c168 100644
--- a/unittests/Analysis/CFGTest.cpp
+++ b/unittests/Analysis/CFGTest.cpp
@@ -78,13 +78,13 @@ protected:
return 0;
}
- void getAnalysisUsage(AnalysisUsage &AU) const {
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
AU.addRequired<LoopInfoWrapperPass>();
AU.addRequired<DominatorTreeWrapperPass>();
}
- bool runOnFunction(Function &F) {
+ bool runOnFunction(Function &F) override {
if (!F.hasName() || F.getName() != "test")
return false;
diff --git a/unittests/Analysis/CMakeLists.txt b/unittests/Analysis/CMakeLists.txt
index baf0c28..35a6d92 100644
--- a/unittests/Analysis/CMakeLists.txt
+++ b/unittests/Analysis/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
)
add_llvm_unittest(AnalysisTests
+ AliasAnalysisTest.cpp
CallGraphTest.cpp
CFGTest.cpp
LazyCallGraphTest.cpp
diff --git a/unittests/Analysis/ScalarEvolutionTest.cpp b/unittests/Analysis/ScalarEvolutionTest.cpp
index 876a264..6ce7ff4 100644
--- a/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -25,7 +25,7 @@ namespace {
class ScalarEvolutionsTest : public testing::Test {
protected:
ScalarEvolutionsTest() : M("", Context), SE(*new ScalarEvolution) {}
- ~ScalarEvolutionsTest() {
+ ~ScalarEvolutionsTest() override {
// Manually clean up, since we allocated new SCEV objects after the
// pass was finished.
SE.releaseMemory();
diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp
index 8ffc1c8..bb47c4c 100644
--- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp
+++ b/unittests/ExecutionEngine/ExecutionEngineTest.cpp
@@ -33,7 +33,7 @@ protected:
Engine.reset(EngineBuilder(std::move(Owner)).setErrorStr(&Error).create());
}
- virtual void SetUp() {
+ void SetUp() override {
ASSERT_TRUE(Engine.get() != nullptr) << "EngineBuilder returned error: '"
<< Error << "'";
}
@@ -54,6 +54,7 @@ TEST_F(ExecutionEngineTest, ForwardGlobalMapping) {
int32_t Mem1 = 3;
Engine->addGlobalMapping(G1, &Mem1);
EXPECT_EQ(&Mem1, Engine->getPointerToGlobalIfAvailable(G1));
+ EXPECT_EQ(&Mem1, Engine->getPointerToGlobalIfAvailable("Global1"));
int32_t Mem2 = 4;
Engine->updateGlobalMapping(G1, &Mem2);
EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1));
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
index f2a3000..a7c9ae0 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
@@ -85,13 +85,11 @@ public:
ReservedCodeSize(0), UsedCodeSize(0), ReservedDataSizeRO(0),
UsedDataSizeRO(0), ReservedDataSizeRW(0), UsedDataSizeRW(0) {
}
-
- virtual bool needsToReserveAllocationSpace() {
- return true;
- }
- virtual void reserveAllocationSpace(
- uintptr_t CodeSize, uintptr_t DataSizeRO, uintptr_t DataSizeRW) {
+ bool needsToReserveAllocationSpace() override { return true; }
+
+ void reserveAllocationSpace(uintptr_t CodeSize, uintptr_t DataSizeRO,
+ uintptr_t DataSizeRW) override {
ReservedCodeSize = CodeSize;
ReservedDataSizeRO = DataSizeRO;
ReservedDataSizeRW = DataSizeRW;
@@ -103,15 +101,17 @@ public:
*UsedSize = AlignedBegin + AlignedSize;
}
- virtual uint8_t* allocateDataSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID, StringRef SectionName, bool IsReadOnly) {
+ uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
+ unsigned SectionID, StringRef SectionName,
+ bool IsReadOnly) override {
useSpace(IsReadOnly ? &UsedDataSizeRO : &UsedDataSizeRW, Size, Alignment);
return SectionMemoryManager::allocateDataSection(Size, Alignment,
SectionID, SectionName, IsReadOnly);
}
- uint8_t* allocateCodeSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID, StringRef SectionName) {
+ uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
+ unsigned SectionID,
+ StringRef SectionName) override {
useSpace(&UsedCodeSize, Size, Alignment);
return SectionMemoryManager::allocateCodeSection(Size, Alignment,
SectionID, SectionName);
@@ -141,8 +141,8 @@ protected:
// that they will fail the MCJIT C API tests.
UnsupportedEnvironments.push_back(Triple::Cygnus);
}
-
- virtual void SetUp() {
+
+ void SetUp() override {
didCallAllocateCodeSection = false;
didAllocateCompactUnwindSection = false;
didCallYield = false;
@@ -151,8 +151,8 @@ protected:
Engine = nullptr;
Error = nullptr;
}
-
- virtual void TearDown() {
+
+ void TearDown() override {
if (Engine)
LLVMDisposeExecutionEngine(Engine);
else if (Module)
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
index 2e38dd8..ff5b6e3 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
@@ -33,7 +33,7 @@ public:
ObjMap[ModuleID] = copyBuffer(Obj);
}
- virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) override {
+ std::unique_ptr<MemoryBuffer> getObject(const Module *M) override {
const MemoryBuffer* BufferFound = getObjectInternal(M);
ModulesLookedUp.insert(M->getModuleIdentifier());
if (!BufferFound)
@@ -84,7 +84,7 @@ protected:
ReplacementRC = 7
};
- virtual void SetUp() {
+ void SetUp() override {
M.reset(createEmptyModule("<main>"));
Main = insertMainFunction(M.get(), OriginalRC);
}
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
index 64d8c2f..94b9a69 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
@@ -22,7 +22,7 @@ namespace {
class MCJITTest : public testing::Test, public MCJITTestBase {
protected:
- virtual void SetUp() { M.reset(createEmptyModule("<main>")); }
+ void SetUp() override { M.reset(createEmptyModule("<main>")); }
};
// FIXME: Ensure creating an execution engine does not crash when constructed
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h b/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
index 35af417..901f142 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
+++ b/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
@@ -308,11 +308,6 @@ protected:
SupportedSubArchs.push_back("armv6");
SupportedSubArchs.push_back("armv7");
- // The operating systems below are known to be incompatible with MCJIT as
- // they are copied from the test/ExecutionEngine/MCJIT/lit.local.cfg and
- // should be kept in sync.
- UnsupportedOSs.push_back(Triple::Darwin);
-
UnsupportedEnvironments.push_back(Triple::Cygnus);
}
diff --git a/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp b/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
index b0ff127..a495766 100644
--- a/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
+++ b/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
@@ -14,9 +14,11 @@ namespace {
struct MockBaseLayer {
typedef int ModuleSetHandleT;
- ModuleSetHandleT addModuleSet(std::list<std::unique_ptr<llvm::Module>>,
- std::unique_ptr<llvm::RTDyldMemoryManager> x) {
- EXPECT_FALSE(x);
+ ModuleSetHandleT addModuleSet(
+ std::list<std::unique_ptr<llvm::Module>>,
+ std::unique_ptr<llvm::RuntimeDyld::MemoryManager> MemMgr,
+ std::unique_ptr<llvm::RuntimeDyld::SymbolResolver> Resolver) {
+ EXPECT_FALSE(MemMgr);
return 42;
}
};
@@ -24,7 +26,7 @@ struct MockBaseLayer {
TEST(LazyEmittingLayerTest, Empty) {
MockBaseLayer M;
llvm::orc::LazyEmittingLayer<MockBaseLayer> L(M);
- L.addModuleSet(std::list<std::unique_ptr<llvm::Module>>(), nullptr);
+ L.addModuleSet(std::list<std::unique_ptr<llvm::Module>>(), nullptr, nullptr);
}
}
diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp
index 0e040bc..0c7777d 100644
--- a/unittests/IR/ConstantsTest.cpp
+++ b/unittests/IR/ConstantsTest.cpp
@@ -249,7 +249,8 @@ TEST(ConstantsTest, AsInstructionsTest) {
// not a normal one!
//CHECK(ConstantExpr::getGetElementPtr(Global, V, false),
// "getelementptr i32*, i32** @dummy, i32 1");
- CHECK(ConstantExpr::getInBoundsGetElementPtr(Global, V),
+ CHECK(ConstantExpr::getInBoundsGetElementPtr(PointerType::getUnqual(Int32Ty),
+ Global, V),
"getelementptr inbounds i32*, i32** @dummy, i32 1");
CHECK(ConstantExpr::getExtractElement(P6, One), "extractelement <2 x i16> "
@@ -266,7 +267,8 @@ TEST(ConstantsTest, ReplaceWithConstantTest) {
Constant *Global =
M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty));
- Constant *GEP = ConstantExpr::getGetElementPtr(Global, One);
+ Constant *GEP = ConstantExpr::getGetElementPtr(
+ PointerType::getUnqual(Int32Ty), Global, One);
EXPECT_DEATH(Global->replaceAllUsesWith(GEP),
"this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!");
}
@@ -333,7 +335,7 @@ TEST(ConstantsTest, GEPReplaceWithConstant) {
auto *C1 = ConstantInt::get(IntTy, 1);
auto *Placeholder = new GlobalVariable(
*M, IntTy, false, GlobalValue::ExternalWeakLinkage, nullptr);
- auto *GEP = ConstantExpr::getGetElementPtr(Placeholder, C1);
+ auto *GEP = ConstantExpr::getGetElementPtr(IntTy, Placeholder, C1);
ASSERT_EQ(GEP->getOperand(0), Placeholder);
auto *Ref =
diff --git a/unittests/IR/DebugInfoTest.cpp b/unittests/IR/DebugInfoTest.cpp
index a957b99..534663a 100644
--- a/unittests/IR/DebugInfoTest.cpp
+++ b/unittests/IR/DebugInfoTest.cpp
@@ -7,127 +7,75 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
#include "gtest/gtest.h"
using namespace llvm;
-namespace llvm {
-
-static void PrintTo(const StringRef &S, ::std::ostream *os) {
- *os << "(" << (const void *)S.data() << "," << S.size() << ") = '";
- for (auto C : S)
- if (C)
- *os << C;
- else
- *os << "\\00";
- *os << "'";
-}
-static void PrintTo(const DIHeaderFieldIterator &I, ::std::ostream *os) {
- PrintTo(I.getCurrent(), os);
- *os << " in ";
- PrintTo(I.getHeader(), os);
-}
-
-} // end namespace llvm
-
namespace {
-#define MAKE_FIELD_ITERATOR(S) \
- DIHeaderFieldIterator(StringRef(S, sizeof(S) - 1))
-TEST(DebugInfoTest, DIHeaderFieldIterator) {
- ASSERT_EQ(DIHeaderFieldIterator(), DIHeaderFieldIterator());
-
- ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR(""));
- ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR(""));
- ASSERT_EQ("", *DIHeaderFieldIterator(""));
-
- ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff"));
- ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff"));
- ASSERT_EQ("stuff", *DIHeaderFieldIterator("stuff"));
-
- ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("st\0uff"));
- ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("st\0uff"));
- ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("st\0uff"));
- ASSERT_EQ("st", *MAKE_FIELD_ITERATOR("st\0uff"));
- ASSERT_EQ("uff", *++MAKE_FIELD_ITERATOR("st\0uff"));
-
- ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff\0"));
- ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff\0"));
- ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("stuff\0"));
- ASSERT_EQ("stuff", *MAKE_FIELD_ITERATOR("stuff\0"));
- ASSERT_EQ("", *++MAKE_FIELD_ITERATOR("stuff\0"));
-
- ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("\0stuff"));
- ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("\0stuff"));
- ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("\0stuff"));
- ASSERT_EQ("", *MAKE_FIELD_ITERATOR("\0stuff"));
- ASSERT_EQ("stuff", *++MAKE_FIELD_ITERATOR("\0stuff"));
-}
-
-TEST(DIDescriptorTest, getFlag) {
+TEST(DebugNodeTest, getFlag) {
// Some valid flags.
- EXPECT_EQ(DIDescriptor::FlagPublic, DIDescriptor::getFlag("DIFlagPublic"));
- EXPECT_EQ(DIDescriptor::FlagProtected,
- DIDescriptor::getFlag("DIFlagProtected"));
- EXPECT_EQ(DIDescriptor::FlagPrivate, DIDescriptor::getFlag("DIFlagPrivate"));
- EXPECT_EQ(DIDescriptor::FlagVector, DIDescriptor::getFlag("DIFlagVector"));
- EXPECT_EQ(DIDescriptor::FlagRValueReference,
- DIDescriptor::getFlag("DIFlagRValueReference"));
+ EXPECT_EQ(DebugNode::FlagPublic, DebugNode::getFlag("DIFlagPublic"));
+ EXPECT_EQ(DebugNode::FlagProtected, DebugNode::getFlag("DIFlagProtected"));
+ EXPECT_EQ(DebugNode::FlagPrivate, DebugNode::getFlag("DIFlagPrivate"));
+ EXPECT_EQ(DebugNode::FlagVector, DebugNode::getFlag("DIFlagVector"));
+ EXPECT_EQ(DebugNode::FlagRValueReference,
+ DebugNode::getFlag("DIFlagRValueReference"));
// FlagAccessibility shouldn't work.
- EXPECT_EQ(0u, DIDescriptor::getFlag("DIFlagAccessibility"));
+ EXPECT_EQ(0u, DebugNode::getFlag("DIFlagAccessibility"));
// Some other invalid strings.
- EXPECT_EQ(0u, DIDescriptor::getFlag("FlagVector"));
- EXPECT_EQ(0u, DIDescriptor::getFlag("Vector"));
- EXPECT_EQ(0u, DIDescriptor::getFlag("other things"));
- EXPECT_EQ(0u, DIDescriptor::getFlag("DIFlagOther"));
+ EXPECT_EQ(0u, DebugNode::getFlag("FlagVector"));
+ EXPECT_EQ(0u, DebugNode::getFlag("Vector"));
+ EXPECT_EQ(0u, DebugNode::getFlag("other things"));
+ EXPECT_EQ(0u, DebugNode::getFlag("DIFlagOther"));
}
-TEST(DIDescriptorTest, getFlagString) {
+TEST(DebugNodeTest, getFlagString) {
// Some valid flags.
EXPECT_EQ(StringRef("DIFlagPublic"),
- DIDescriptor::getFlagString(DIDescriptor::FlagPublic));
+ DebugNode::getFlagString(DebugNode::FlagPublic));
EXPECT_EQ(StringRef("DIFlagProtected"),
- DIDescriptor::getFlagString(DIDescriptor::FlagProtected));
+ DebugNode::getFlagString(DebugNode::FlagProtected));
EXPECT_EQ(StringRef("DIFlagPrivate"),
- DIDescriptor::getFlagString(DIDescriptor::FlagPrivate));
+ DebugNode::getFlagString(DebugNode::FlagPrivate));
EXPECT_EQ(StringRef("DIFlagVector"),
- DIDescriptor::getFlagString(DIDescriptor::FlagVector));
+ DebugNode::getFlagString(DebugNode::FlagVector));
EXPECT_EQ(StringRef("DIFlagRValueReference"),
- DIDescriptor::getFlagString(DIDescriptor::FlagRValueReference));
+ DebugNode::getFlagString(DebugNode::FlagRValueReference));
// FlagAccessibility actually equals FlagPublic.
EXPECT_EQ(StringRef("DIFlagPublic"),
- DIDescriptor::getFlagString(DIDescriptor::FlagAccessibility));
+ DebugNode::getFlagString(DebugNode::FlagAccessibility));
// Some other invalid flags.
- EXPECT_EQ(StringRef(), DIDescriptor::getFlagString(DIDescriptor::FlagPublic |
- DIDescriptor::FlagVector));
- EXPECT_EQ(StringRef(),
- DIDescriptor::getFlagString(DIDescriptor::FlagFwdDecl |
- DIDescriptor::FlagArtificial));
- EXPECT_EQ(StringRef(), DIDescriptor::getFlagString(0xffff));
+ EXPECT_EQ(StringRef(), DebugNode::getFlagString(DebugNode::FlagPublic |
+ DebugNode::FlagVector));
+ EXPECT_EQ(StringRef(), DebugNode::getFlagString(DebugNode::FlagFwdDecl |
+ DebugNode::FlagArtificial));
+ EXPECT_EQ(StringRef(), DebugNode::getFlagString(0xffff));
}
-TEST(DIDescriptorTest, splitFlags) {
- // Some valid flags.
+TEST(DebugNodeTest, splitFlags) {
+// Some valid flags.
#define CHECK_SPLIT(FLAGS, VECTOR, REMAINDER) \
{ \
SmallVector<unsigned, 8> V; \
- EXPECT_EQ(REMAINDER, DIDescriptor::splitFlags(FLAGS, V)); \
- EXPECT_TRUE(makeArrayRef(V).equals(VECTOR)); \
+ EXPECT_EQ(REMAINDER, DebugNode::splitFlags(FLAGS, V)); \
+ EXPECT_TRUE(makeArrayRef(V).equals(VECTOR)); \
}
- CHECK_SPLIT(DIDescriptor::FlagPublic, {DIDescriptor::FlagPublic}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagProtected, {DIDescriptor::FlagProtected}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagPrivate, {DIDescriptor::FlagPrivate}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagVector, {DIDescriptor::FlagVector}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagRValueReference, {DIDescriptor::FlagRValueReference}, 0u);
- unsigned Flags[] = {DIDescriptor::FlagFwdDecl, DIDescriptor::FlagVector};
- CHECK_SPLIT(DIDescriptor::FlagFwdDecl | DIDescriptor::FlagVector, Flags, 0u);
+ CHECK_SPLIT(DebugNode::FlagPublic, {DebugNode::FlagPublic}, 0u);
+ CHECK_SPLIT(DebugNode::FlagProtected, {DebugNode::FlagProtected}, 0u);
+ CHECK_SPLIT(DebugNode::FlagPrivate, {DebugNode::FlagPrivate}, 0u);
+ CHECK_SPLIT(DebugNode::FlagVector, {DebugNode::FlagVector}, 0u);
+ CHECK_SPLIT(DebugNode::FlagRValueReference, {DebugNode::FlagRValueReference},
+ 0u);
+ unsigned Flags[] = {DebugNode::FlagFwdDecl, DebugNode::FlagVector};
+ CHECK_SPLIT(DebugNode::FlagFwdDecl | DebugNode::FlagVector, Flags, 0u);
CHECK_SPLIT(0x100000u, {}, 0x100000u);
- CHECK_SPLIT(0x100000u | DIDescriptor::FlagVector, {DIDescriptor::FlagVector},
+ CHECK_SPLIT(0x100000u | DebugNode::FlagVector, {DebugNode::FlagVector},
0x100000u);
#undef CHECK_SPLIT
}
diff --git a/unittests/IR/DominatorTreeTest.cpp b/unittests/IR/DominatorTreeTest.cpp
index 8d2dc41..6a5838e 100644
--- a/unittests/IR/DominatorTreeTest.cpp
+++ b/unittests/IR/DominatorTreeTest.cpp
@@ -10,6 +10,7 @@
#include "llvm/IR/Dominators.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/AsmParser/Parser.h"
+#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
@@ -25,7 +26,7 @@ namespace llvm {
namespace {
struct DPass : public FunctionPass {
static char ID;
- virtual bool runOnFunction(Function &F) {
+ bool runOnFunction(Function &F) override {
DominatorTree *DT =
&getAnalysis<DominatorTreeWrapperPass>().getDomTree();
PostDominatorTree *PDT = &getAnalysis<PostDominatorTree>();
@@ -174,9 +175,36 @@ namespace llvm {
EXPECT_EQ(DominatedBBs.size(), 0UL);
EXPECT_EQ(PostDominatedBBs.size(), 0UL);
+ // Check DFS Numbers before
+ EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL);
+ EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 7UL);
+ EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL);
+ EXPECT_EQ(DT->getNode(BB1)->getDFSNumOut(), 2UL);
+ EXPECT_EQ(DT->getNode(BB2)->getDFSNumIn(), 5UL);
+ EXPECT_EQ(DT->getNode(BB2)->getDFSNumOut(), 6UL);
+ EXPECT_EQ(DT->getNode(BB4)->getDFSNumIn(), 3UL);
+ EXPECT_EQ(DT->getNode(BB4)->getDFSNumOut(), 4UL);
+
+ // Reattach block 3 to block 1 and recalculate
+ BB1->getTerminator()->eraseFromParent();
+ BranchInst::Create(BB4, BB3, ConstantInt::getTrue(F.getContext()), BB1);
+ DT->recalculate(F);
+
+ // Check DFS Numbers after
+ EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL);
+ EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 9UL);
+ EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL);
+ EXPECT_EQ(DT->getNode(BB1)->getDFSNumOut(), 4UL);
+ EXPECT_EQ(DT->getNode(BB2)->getDFSNumIn(), 7UL);
+ EXPECT_EQ(DT->getNode(BB2)->getDFSNumOut(), 8UL);
+ EXPECT_EQ(DT->getNode(BB3)->getDFSNumIn(), 2UL);
+ EXPECT_EQ(DT->getNode(BB3)->getDFSNumOut(), 3UL);
+ EXPECT_EQ(DT->getNode(BB4)->getDFSNumIn(), 5UL);
+ EXPECT_EQ(DT->getNode(BB4)->getDFSNumOut(), 6UL);
+
return false;
}
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<PostDominatorTree>();
}
diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp
index ca378a3..9fe241c 100644
--- a/unittests/IR/IRBuilderTest.cpp
+++ b/unittests/IR/IRBuilderTest.cpp
@@ -17,6 +17,7 @@
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/NoFolder.h"
+#include "llvm/IR/Verifier.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -25,7 +26,7 @@ namespace {
class IRBuilderTest : public testing::Test {
protected:
- virtual void SetUp() {
+ void SetUp() override {
M.reset(new Module("MyModule", Ctx));
FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
/*isVarArg=*/false);
@@ -35,7 +36,7 @@ protected:
GlobalValue::ExternalLinkage, nullptr);
}
- virtual void TearDown() {
+ void TearDown() override {
BB = nullptr;
M.reset();
}
@@ -295,14 +296,14 @@ TEST_F(IRBuilderTest, DIBuilder) {
auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
"llvm-cobol74", true, "", 0);
auto Type = DIB.createSubroutineType(File, DIB.getOrCreateTypeArray(None));
- auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type,
- false, true, 1, 0, true, F);
- EXPECT_TRUE(SP.Verify());
+ DIB.createFunction(CU, "foo", "", File, 1, Type, false, true, 1, 0, true, F);
AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty());
- auto BadScope = DIB.createLexicalBlockFile(DIDescriptor(), File, 0);
+ auto BarSP = DIB.createFunction(CU, "bar", "", File, 1, Type, false, true, 1,
+ 0, true, nullptr);
+ auto BadScope = DIB.createLexicalBlockFile(BarSP, File, 0);
I->setDebugLoc(DebugLoc::get(2, 0, BadScope));
- EXPECT_FALSE(SP.Verify());
DIB.finalize();
+ EXPECT_TRUE(verifyModule(*M));
}
diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp
index 51a9e0b..8b4c5db 100644
--- a/unittests/IR/MetadataTest.cpp
+++ b/unittests/IR/MetadataTest.cpp
@@ -61,8 +61,14 @@ TEST(ContextAndReplaceableUsesTest, takeReplaceableUses) {
}
class MetadataTest : public testing::Test {
+public:
+ MetadataTest() : M("test", Context), Counter(0) {}
+
protected:
LLVMContext Context;
+ Module M;
+ int Counter;
+
MDNode *getNode() { return MDNode::get(Context, None); }
MDNode *getNode(Metadata *MD) { return MDNode::get(Context, MD); }
MDNode *getNode(Metadata *MD1, Metadata *MD2) {
@@ -70,11 +76,45 @@ protected:
return MDNode::get(Context, MDs);
}
+ MDTuple *getTuple() { return MDTuple::getDistinct(Context, None); }
+ MDSubroutineType *getSubroutineType() {
+ return MDSubroutineType::getDistinct(Context, 0, getNode(nullptr));
+ }
MDSubprogram *getSubprogram() {
return MDSubprogram::getDistinct(Context, nullptr, "", "", nullptr, 0,
nullptr, false, false, 0, nullptr, 0, 0, 0,
0);
}
+ MDScopeRef getSubprogramRef() { return getSubprogram()->getRef(); }
+ MDFile *getFile() {
+ return MDFile::getDistinct(Context, "file.c", "/path/to/dir");
+ }
+ MDTypeRef getBasicType(StringRef Name) {
+ return MDBasicType::get(Context, dwarf::DW_TAG_unspecified_type, Name)
+ ->getRef();
+ }
+ MDTypeRef getDerivedType() {
+ return MDDerivedType::getDistinct(Context, dwarf::DW_TAG_pointer_type, "",
+ nullptr, 0, nullptr,
+ getBasicType("basictype"), 1, 2, 0, 0)
+ ->getRef();
+ }
+ Constant *getConstant() {
+ return ConstantInt::get(Type::getInt32Ty(Context), Counter++);
+ }
+ ConstantAsMetadata *getConstantAsMetadata() {
+ return ConstantAsMetadata::get(getConstant());
+ }
+ MDTypeRef getCompositeType() {
+ return MDCompositeType::getDistinct(
+ Context, dwarf::DW_TAG_structure_type, "", nullptr, 0, nullptr,
+ nullptr, 32, 32, 0, 0, nullptr, 0, nullptr, nullptr, "")
+ ->getRef();
+ }
+ Function *getFunction(StringRef Name) {
+ return cast<Function>(M.getOrInsertFunction(
+ Name, FunctionType::get(Type::getVoidTy(Context), None, false)));
+ }
};
typedef MetadataTest MDStringTest;
@@ -593,6 +633,48 @@ TEST_F(MDNodeTest, replaceWithUniqued) {
}
}
+TEST_F(MDNodeTest, replaceWithUniquedResolvingOperand) {
+ // temp !{}
+ MDTuple *Op = MDTuple::getTemporary(Context, None).release();
+ EXPECT_FALSE(Op->isResolved());
+
+ // temp !{temp !{}}
+ Metadata *Ops[] = {Op};
+ MDTuple *N = MDTuple::getTemporary(Context, Ops).release();
+ EXPECT_FALSE(N->isResolved());
+
+ // temp !{temp !{}} => !{temp !{}}
+ ASSERT_EQ(N, MDNode::replaceWithUniqued(TempMDTuple(N)));
+ EXPECT_FALSE(N->isResolved());
+
+ // !{temp !{}} => !{!{}}
+ ASSERT_EQ(Op, MDNode::replaceWithUniqued(TempMDTuple(Op)));
+ EXPECT_TRUE(Op->isResolved());
+ EXPECT_TRUE(N->isResolved());
+}
+
+TEST_F(MDNodeTest, replaceWithUniquedChangingOperand) {
+ // i1* @GV
+ Type *Ty = Type::getInt1PtrTy(Context);
+ std::unique_ptr<GlobalVariable> GV(
+ new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
+ ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get());
+
+ // temp !{i1* @GV}
+ Metadata *Ops[] = {Op};
+ MDTuple *N = MDTuple::getTemporary(Context, Ops).release();
+
+ // temp !{i1* @GV} => !{i1* @GV}
+ ASSERT_EQ(N, MDNode::replaceWithUniqued(TempMDTuple(N)));
+ ASSERT_TRUE(N->isUniqued());
+
+ // !{i1* @GV} => !{null}
+ GV.reset();
+ ASSERT_TRUE(N->isUniqued());
+ Metadata *NullOps[] = {nullptr};
+ ASSERT_EQ(N, MDTuple::get(Context, NullOps));
+}
+
TEST_F(MDNodeTest, replaceWithDistinct) {
{
auto *Empty = MDTuple::get(Context, None);
@@ -768,7 +850,7 @@ TEST_F(MDSubrangeTest, get) {
auto *N = MDSubrange::get(Context, 5, 7);
EXPECT_EQ(dwarf::DW_TAG_subrange_type, N->getTag());
EXPECT_EQ(5, N->getCount());
- EXPECT_EQ(7, N->getLo());
+ EXPECT_EQ(7, N->getLowerBound());
EXPECT_EQ(N, MDSubrange::get(Context, 5, 7));
EXPECT_EQ(MDSubrange::get(Context, 5, 0), MDSubrange::get(Context, 5));
@@ -780,7 +862,7 @@ TEST_F(MDSubrangeTest, getEmptyArray) {
auto *N = MDSubrange::get(Context, -1, 0);
EXPECT_EQ(dwarf::DW_TAG_subrange_type, N->getTag());
EXPECT_EQ(-1, N->getCount());
- EXPECT_EQ(0, N->getLo());
+ EXPECT_EQ(0, N->getLowerBound());
EXPECT_EQ(N, MDSubrange::get(Context, -1, 0));
}
@@ -865,15 +947,15 @@ TEST_F(MDTypeTest, setFlags) {
MDType *D = MDSubroutineType::getDistinct(Context, 0u, Types);
EXPECT_EQ(0u, D->getFlags());
- D->setFlags(DIDescriptor::FlagRValueReference);
- EXPECT_EQ(DIDescriptor::FlagRValueReference, D->getFlags());
+ D->setFlags(DebugNode::FlagRValueReference);
+ EXPECT_EQ(DebugNode::FlagRValueReference, D->getFlags());
D->setFlags(0u);
EXPECT_EQ(0u, D->getFlags());
TempMDType T = MDSubroutineType::getTemporary(Context, 0u, Types);
EXPECT_EQ(0u, T->getFlags());
- T->setFlags(DIDescriptor::FlagRValueReference);
- EXPECT_EQ(DIDescriptor::FlagRValueReference, T->getFlags());
+ T->setFlags(DebugNode::FlagRValueReference);
+ EXPECT_EQ(DebugNode::FlagRValueReference, T->getFlags());
T->setFlags(0u);
EXPECT_EQ(0u, T->getFlags());
}
@@ -881,10 +963,10 @@ TEST_F(MDTypeTest, setFlags) {
typedef MetadataTest MDDerivedTypeTest;
TEST_F(MDDerivedTypeTest, get) {
- Metadata *File = MDTuple::getDistinct(Context, None);
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *BaseType = MDTuple::getDistinct(Context, None);
- Metadata *ExtraData = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
+ MDScopeRef Scope = getSubprogramRef();
+ MDTypeRef BaseType = getBasicType("basic");
+ MDTuple *ExtraData = getTuple();
auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
File, 1, Scope, BaseType, 2, 3, 4, 5, ExtraData);
@@ -910,17 +992,17 @@ TEST_F(MDDerivedTypeTest, get) {
File, 1, Scope, BaseType, 2, 3, 4, 5,
ExtraData));
EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
- "something", Scope, 1, Scope, BaseType, 2, 3,
- 4, 5, ExtraData));
+ "something", getFile(), 1, Scope, BaseType, 2,
+ 3, 4, 5, ExtraData));
EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
"something", File, 2, Scope, BaseType, 2, 3,
4, 5, ExtraData));
- EXPECT_NE(N,
- MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
- File, 1, File, BaseType, 2, 3, 4, 5, ExtraData));
- EXPECT_NE(N,
- MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
- File, 1, Scope, File, 2, 3, 4, 5, ExtraData));
+ EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
+ "something", File, 1, getSubprogramRef(),
+ BaseType, 2, 3, 4, 5, ExtraData));
+ EXPECT_NE(N, MDDerivedType::get(
+ Context, dwarf::DW_TAG_pointer_type, "something", File, 1,
+ Scope, getBasicType("basic2"), 2, 3, 4, 5, ExtraData));
EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
"something", File, 1, Scope, BaseType, 3, 3,
4, 5, ExtraData));
@@ -933,19 +1015,19 @@ TEST_F(MDDerivedTypeTest, get) {
EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
"something", File, 1, Scope, BaseType, 2, 3,
4, 4, ExtraData));
- EXPECT_NE(N,
- MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
- File, 1, Scope, BaseType, 2, 3, 4, 5, File));
+ EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
+ "something", File, 1, Scope, BaseType, 2, 3,
+ 4, 5, getTuple()));
TempMDDerivedType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
TEST_F(MDDerivedTypeTest, getWithLargeValues) {
- Metadata *File = MDTuple::getDistinct(Context, None);
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *BaseType = MDTuple::getDistinct(Context, None);
- Metadata *ExtraData = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
+ MDScopeRef Scope = getSubprogramRef();
+ MDTypeRef BaseType = getBasicType("basic");
+ MDTuple *ExtraData = getTuple();
auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
File, 1, Scope, BaseType, UINT64_MAX,
@@ -960,18 +1042,18 @@ typedef MetadataTest MDCompositeTypeTest;
TEST_F(MDCompositeTypeTest, get) {
unsigned Tag = dwarf::DW_TAG_structure_type;
StringRef Name = "some name";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 1;
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *BaseType = MDTuple::getDistinct(Context, None);
+ MDScopeRef Scope = getSubprogramRef();
+ MDTypeRef BaseType = getCompositeType();
uint64_t SizeInBits = 2;
uint64_t AlignInBits = 3;
uint64_t OffsetInBits = 4;
unsigned Flags = 5;
- Metadata *Elements = MDTuple::getDistinct(Context, None);
+ MDTuple *Elements = getTuple();
unsigned RuntimeLang = 6;
- Metadata *VTableHolder = MDTuple::getDistinct(Context, None);
- Metadata *TemplateParams = MDTuple::getDistinct(Context, None);
+ MDTypeRef VTableHolder = getCompositeType();
+ MDTuple *TemplateParams = getTuple();
StringRef Identifier = "some id";
auto *N = MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
@@ -988,10 +1070,10 @@ TEST_F(MDCompositeTypeTest, get) {
EXPECT_EQ(AlignInBits, N->getAlignInBits());
EXPECT_EQ(OffsetInBits, N->getOffsetInBits());
EXPECT_EQ(Flags, N->getFlags());
- EXPECT_EQ(Elements, N->getElements());
+ EXPECT_EQ(Elements, N->getElements().get());
EXPECT_EQ(RuntimeLang, N->getRuntimeLang());
EXPECT_EQ(VTableHolder, N->getVTableHolder());
- EXPECT_EQ(TemplateParams, N->getTemplateParams());
+ EXPECT_EQ(TemplateParams, N->getTemplateParams().get());
EXPECT_EQ(Identifier, N->getIdentifier());
EXPECT_EQ(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
@@ -1007,7 +1089,7 @@ TEST_F(MDCompositeTypeTest, get) {
BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams, Identifier));
- EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, Scope, Line, Scope,
+ EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, getFile(), Line, Scope,
BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams, Identifier));
@@ -1015,14 +1097,14 @@ TEST_F(MDCompositeTypeTest, get) {
BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams, Identifier));
- EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, File,
- BaseType, SizeInBits, AlignInBits,
- OffsetInBits, Flags, Elements, RuntimeLang,
- VTableHolder, TemplateParams, Identifier));
- EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, File,
- SizeInBits, AlignInBits, OffsetInBits,
- Flags, Elements, RuntimeLang, VTableHolder,
- TemplateParams, Identifier));
+ EXPECT_NE(N, MDCompositeType::get(
+ Context, Tag, Name, File, Line, getSubprogramRef(), BaseType,
+ SizeInBits, AlignInBits, OffsetInBits, Flags, Elements,
+ RuntimeLang, VTableHolder, TemplateParams, Identifier));
+ EXPECT_NE(N, MDCompositeType::get(
+ Context, Tag, Name, File, Line, Scope, getBasicType("other"),
+ SizeInBits, AlignInBits, OffsetInBits, Flags, Elements,
+ RuntimeLang, VTableHolder, TemplateParams, Identifier));
EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
BaseType, SizeInBits + 1, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang,
@@ -1039,22 +1121,22 @@ TEST_F(MDCompositeTypeTest, get) {
Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags + 1, Elements, RuntimeLang,
VTableHolder, TemplateParams, Identifier));
- EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
- BaseType, SizeInBits, AlignInBits,
- OffsetInBits, Flags, File, RuntimeLang,
- VTableHolder, TemplateParams, Identifier));
+ EXPECT_NE(N, MDCompositeType::get(
+ Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
+ AlignInBits, OffsetInBits, Flags, getTuple(), RuntimeLang,
+ VTableHolder, TemplateParams, Identifier));
EXPECT_NE(N, MDCompositeType::get(
Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang + 1,
VTableHolder, TemplateParams, Identifier));
+ EXPECT_NE(N, MDCompositeType::get(
+ Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
+ AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
+ getCompositeType(), TemplateParams, Identifier));
EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang,
- File, TemplateParams, Identifier));
- EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
- BaseType, SizeInBits, AlignInBits,
- OffsetInBits, Flags, Elements, RuntimeLang,
- VTableHolder, File, Identifier));
+ VTableHolder, getTuple(), Identifier));
EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang,
@@ -1077,18 +1159,18 @@ TEST_F(MDCompositeTypeTest, get) {
TEST_F(MDCompositeTypeTest, getWithLargeValues) {
unsigned Tag = dwarf::DW_TAG_structure_type;
StringRef Name = "some name";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 1;
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *BaseType = MDTuple::getDistinct(Context, None);
+ MDScopeRef Scope = getSubprogramRef();
+ MDTypeRef BaseType = getCompositeType();
uint64_t SizeInBits = UINT64_MAX;
uint64_t AlignInBits = UINT64_MAX - 1;
uint64_t OffsetInBits = UINT64_MAX - 2;
unsigned Flags = 5;
- Metadata *Elements = MDTuple::getDistinct(Context, None);
+ MDTuple *Elements = getTuple();
unsigned RuntimeLang = 6;
- Metadata *VTableHolder = MDTuple::getDistinct(Context, None);
- Metadata *TemplateParams = MDTuple::getDistinct(Context, None);
+ MDTypeRef VTableHolder = getCompositeType();
+ MDTuple *TemplateParams = getTuple();
StringRef Identifier = "some id";
auto *N = MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
@@ -1103,10 +1185,10 @@ TEST_F(MDCompositeTypeTest, getWithLargeValues) {
TEST_F(MDCompositeTypeTest, replaceOperands) {
unsigned Tag = dwarf::DW_TAG_structure_type;
StringRef Name = "some name";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 1;
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *BaseType = MDTuple::getDistinct(Context, None);
+ MDScopeRef Scope = getSubprogramRef();
+ MDTypeRef BaseType = getCompositeType();
uint64_t SizeInBits = 2;
uint64_t AlignInBits = 3;
uint64_t OffsetInBits = 4;
@@ -1120,13 +1202,13 @@ TEST_F(MDCompositeTypeTest, replaceOperands) {
nullptr, nullptr, Identifier);
auto *Elements = MDTuple::getDistinct(Context, None);
- EXPECT_EQ(nullptr, N->getElements());
+ EXPECT_EQ(nullptr, N->getElements().get());
N->replaceElements(Elements);
- EXPECT_EQ(Elements, N->getElements());
+ EXPECT_EQ(Elements, N->getElements().get());
N->replaceElements(nullptr);
- EXPECT_EQ(nullptr, N->getElements());
+ EXPECT_EQ(nullptr, N->getElements().get());
- auto *VTableHolder = MDTuple::getDistinct(Context, None);
+ MDTypeRef VTableHolder = getCompositeType();
EXPECT_EQ(nullptr, N->getVTableHolder());
N->replaceVTableHolder(VTableHolder);
EXPECT_EQ(VTableHolder, N->getVTableHolder());
@@ -1134,28 +1216,27 @@ TEST_F(MDCompositeTypeTest, replaceOperands) {
EXPECT_EQ(nullptr, N->getVTableHolder());
auto *TemplateParams = MDTuple::getDistinct(Context, None);
- EXPECT_EQ(nullptr, N->getTemplateParams());
+ EXPECT_EQ(nullptr, N->getTemplateParams().get());
N->replaceTemplateParams(TemplateParams);
- EXPECT_EQ(TemplateParams, N->getTemplateParams());
+ EXPECT_EQ(TemplateParams, N->getTemplateParams().get());
N->replaceTemplateParams(nullptr);
- EXPECT_EQ(nullptr, N->getTemplateParams());
+ EXPECT_EQ(nullptr, N->getTemplateParams().get());
}
typedef MetadataTest MDSubroutineTypeTest;
TEST_F(MDSubroutineTypeTest, get) {
unsigned Flags = 1;
- Metadata *TypeArray = MDTuple::getDistinct(Context, None);
+ MDTuple *TypeArray = getTuple();
auto *N = MDSubroutineType::get(Context, Flags, TypeArray);
EXPECT_EQ(dwarf::DW_TAG_subroutine_type, N->getTag());
EXPECT_EQ(Flags, N->getFlags());
- EXPECT_EQ(TypeArray, N->getTypeArray());
+ EXPECT_EQ(TypeArray, N->getTypeArray().get());
EXPECT_EQ(N, MDSubroutineType::get(Context, Flags, TypeArray));
EXPECT_NE(N, MDSubroutineType::get(Context, Flags + 1, TypeArray));
- EXPECT_NE(N, MDSubroutineType::get(Context, Flags,
- MDTuple::getDistinct(Context, None)));
+ EXPECT_NE(N, MDSubroutineType::get(Context, Flags, getTuple()));
TempMDSubroutineType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1166,7 +1247,7 @@ TEST_F(MDSubroutineTypeTest, get) {
EXPECT_EQ("", N->getName());
EXPECT_EQ(nullptr, N->getBaseType());
EXPECT_EQ(nullptr, N->getVTableHolder());
- EXPECT_EQ(nullptr, N->getTemplateParams());
+ EXPECT_EQ(nullptr, N->getTemplateParams().get());
EXPECT_EQ("", N->getIdentifier());
}
@@ -1199,18 +1280,18 @@ typedef MetadataTest MDCompileUnitTest;
TEST_F(MDCompileUnitTest, get) {
unsigned SourceLanguage = 1;
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
StringRef Producer = "some producer";
bool IsOptimized = false;
StringRef Flags = "flag after flag";
unsigned RuntimeVersion = 2;
StringRef SplitDebugFilename = "another/file";
unsigned EmissionKind = 3;
- Metadata *EnumTypes = MDTuple::getDistinct(Context, None);
- Metadata *RetainedTypes = MDTuple::getDistinct(Context, None);
- Metadata *Subprograms = MDTuple::getDistinct(Context, None);
- Metadata *GlobalVariables = MDTuple::getDistinct(Context, None);
- Metadata *ImportedEntities = MDTuple::getDistinct(Context, None);
+ MDTuple *EnumTypes = getTuple();
+ MDTuple *RetainedTypes = getTuple();
+ MDTuple *Subprograms = getTuple();
+ MDTuple *GlobalVariables = getTuple();
+ MDTuple *ImportedEntities = getTuple();
auto *N = MDCompileUnit::get(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
@@ -1225,11 +1306,11 @@ TEST_F(MDCompileUnitTest, get) {
EXPECT_EQ(RuntimeVersion, N->getRuntimeVersion());
EXPECT_EQ(SplitDebugFilename, N->getSplitDebugFilename());
EXPECT_EQ(EmissionKind, N->getEmissionKind());
- EXPECT_EQ(EnumTypes, N->getEnumTypes());
- EXPECT_EQ(RetainedTypes, N->getRetainedTypes());
- EXPECT_EQ(Subprograms, N->getSubprograms());
- EXPECT_EQ(GlobalVariables, N->getGlobalVariables());
- EXPECT_EQ(ImportedEntities, N->getImportedEntities());
+ EXPECT_EQ(EnumTypes, N->getEnumTypes().get());
+ EXPECT_EQ(RetainedTypes, N->getRetainedTypes().get());
+ EXPECT_EQ(Subprograms, N->getSubprograms().get());
+ EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get());
+ EXPECT_EQ(ImportedEntities, N->getImportedEntities().get());
EXPECT_EQ(N, MDCompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
@@ -1241,7 +1322,7 @@ TEST_F(MDCompileUnitTest, get) {
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
ImportedEntities));
- EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, EnumTypes, Producer,
+ EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, getFile(), Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
@@ -1278,25 +1359,26 @@ TEST_F(MDCompileUnitTest, get) {
GlobalVariables, ImportedEntities));
EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, Flags, RuntimeVersion,
- SplitDebugFilename, EmissionKind, File,
+ SplitDebugFilename, EmissionKind, getTuple(),
RetainedTypes, Subprograms, GlobalVariables,
ImportedEntities));
EXPECT_NE(N, MDCompileUnit::get(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- File, Subprograms, GlobalVariables, ImportedEntities));
- EXPECT_NE(N, MDCompileUnit::get(
- Context, SourceLanguage, File, Producer, IsOptimized, Flags,
- RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, File, GlobalVariables, ImportedEntities));
+ getTuple(), Subprograms, GlobalVariables, ImportedEntities));
+ EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, File, Producer,
+ IsOptimized, Flags, RuntimeVersion,
+ SplitDebugFilename, EmissionKind, EnumTypes,
+ RetainedTypes, getTuple(), GlobalVariables,
+ ImportedEntities));
EXPECT_NE(N, MDCompileUnit::get(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, Subprograms, File, ImportedEntities));
+ RetainedTypes, Subprograms, getTuple(), ImportedEntities));
EXPECT_NE(N, MDCompileUnit::get(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, Subprograms, GlobalVariables, File));
+ RetainedTypes, Subprograms, GlobalVariables, getTuple()));
TempMDCompileUnit Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1304,57 +1386,57 @@ TEST_F(MDCompileUnitTest, get) {
TEST_F(MDCompileUnitTest, replaceArrays) {
unsigned SourceLanguage = 1;
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
StringRef Producer = "some producer";
bool IsOptimized = false;
StringRef Flags = "flag after flag";
unsigned RuntimeVersion = 2;
StringRef SplitDebugFilename = "another/file";
unsigned EmissionKind = 3;
- Metadata *EnumTypes = MDTuple::getDistinct(Context, None);
- Metadata *RetainedTypes = MDTuple::getDistinct(Context, None);
- Metadata *ImportedEntities = MDTuple::getDistinct(Context, None);
+ MDTuple *EnumTypes = MDTuple::getDistinct(Context, None);
+ MDTuple *RetainedTypes = MDTuple::getDistinct(Context, None);
+ MDTuple *ImportedEntities = MDTuple::getDistinct(Context, None);
auto *N = MDCompileUnit::get(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, nullptr, nullptr, ImportedEntities);
auto *Subprograms = MDTuple::getDistinct(Context, None);
- EXPECT_EQ(nullptr, N->getSubprograms());
+ EXPECT_EQ(nullptr, N->getSubprograms().get());
N->replaceSubprograms(Subprograms);
- EXPECT_EQ(Subprograms, N->getSubprograms());
+ EXPECT_EQ(Subprograms, N->getSubprograms().get());
N->replaceSubprograms(nullptr);
- EXPECT_EQ(nullptr, N->getSubprograms());
+ EXPECT_EQ(nullptr, N->getSubprograms().get());
auto *GlobalVariables = MDTuple::getDistinct(Context, None);
- EXPECT_EQ(nullptr, N->getGlobalVariables());
+ EXPECT_EQ(nullptr, N->getGlobalVariables().get());
N->replaceGlobalVariables(GlobalVariables);
- EXPECT_EQ(GlobalVariables, N->getGlobalVariables());
+ EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get());
N->replaceGlobalVariables(nullptr);
- EXPECT_EQ(nullptr, N->getGlobalVariables());
+ EXPECT_EQ(nullptr, N->getGlobalVariables().get());
}
typedef MetadataTest MDSubprogramTest;
TEST_F(MDSubprogramTest, get) {
- Metadata *Scope = MDTuple::getDistinct(Context, None);
+ MDScopeRef Scope = getCompositeType();
StringRef Name = "name";
StringRef LinkageName = "linkage";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 2;
- Metadata *Type = MDTuple::getDistinct(Context, None);
+ MDSubroutineType *Type = getSubroutineType();
bool IsLocalToUnit = false;
bool IsDefinition = true;
unsigned ScopeLine = 3;
- Metadata *ContainingType = MDTuple::getDistinct(Context, None);
+ MDTypeRef ContainingType = getCompositeType();
unsigned Virtuality = 4;
unsigned VirtualIndex = 5;
unsigned Flags = 6;
bool IsOptimized = false;
- Metadata *Function = MDTuple::getDistinct(Context, None);
- Metadata *TemplateParams = MDTuple::getDistinct(Context, None);
- Metadata *Declaration = MDTuple::getDistinct(Context, None);
- Metadata *Variables = MDTuple::getDistinct(Context, None);
+ llvm::Function *Function = getFunction("foo");
+ MDTuple *TemplateParams = getTuple();
+ MDSubprogram *Declaration = getSubprogram();
+ MDTuple *Variables = getTuple();
auto *N = MDSubprogram::get(
Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
@@ -1377,20 +1459,20 @@ TEST_F(MDSubprogramTest, get) {
EXPECT_EQ(Flags, N->getFlags());
EXPECT_EQ(IsOptimized, N->isOptimized());
EXPECT_EQ(Function, N->getFunction());
- EXPECT_EQ(TemplateParams, N->getTemplateParams());
+ EXPECT_EQ(TemplateParams, N->getTemplateParams().get());
EXPECT_EQ(Declaration, N->getDeclaration());
- EXPECT_EQ(Variables, N->getVariables());
+ EXPECT_EQ(Variables, N->getVariables().get());
EXPECT_EQ(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex,
Flags, IsOptimized, Function, TemplateParams,
Declaration, Variables));
- EXPECT_NE(N, MDSubprogram::get(Context, File, Name, LinkageName, File, Line,
- Type, IsLocalToUnit, IsDefinition, ScopeLine,
- ContainingType, Virtuality, VirtualIndex,
- Flags, IsOptimized, Function, TemplateParams,
- Declaration, Variables));
+ EXPECT_NE(N, MDSubprogram::get(Context, getCompositeType(), Name, LinkageName,
+ File, Line, Type, IsLocalToUnit, IsDefinition,
+ ScopeLine, ContainingType, Virtuality,
+ VirtualIndex, Flags, IsOptimized, Function,
+ TemplateParams, Declaration, Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, "other", LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality,
@@ -1401,21 +1483,21 @@ TEST_F(MDSubprogramTest, get) {
ContainingType, Virtuality, VirtualIndex,
Flags, IsOptimized, Function, TemplateParams,
Declaration, Variables));
- EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, Scope, Line,
- Type, IsLocalToUnit, IsDefinition, ScopeLine,
- ContainingType, Virtuality, VirtualIndex,
- Flags, IsOptimized, Function, TemplateParams,
- Declaration, Variables));
+ EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, getFile(),
+ Line, Type, IsLocalToUnit, IsDefinition,
+ ScopeLine, ContainingType, Virtuality,
+ VirtualIndex, Flags, IsOptimized, Function,
+ TemplateParams, Declaration, Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File,
Line + 1, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality,
VirtualIndex, Flags, IsOptimized, Function,
TemplateParams, Declaration, Variables));
- EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
- Scope, IsLocalToUnit, IsDefinition, ScopeLine,
- ContainingType, Virtuality, VirtualIndex,
- Flags, IsOptimized, Function, TemplateParams,
- Declaration, Variables));
+ EXPECT_NE(N, MDSubprogram::get(
+ Context, Scope, Name, LinkageName, File, Line,
+ getSubroutineType(), IsLocalToUnit, IsDefinition, ScopeLine,
+ ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized,
+ Function, TemplateParams, Declaration, Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, !IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex,
@@ -1433,8 +1515,8 @@ TEST_F(MDSubprogramTest, get) {
TemplateParams, Declaration, Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, ScopeLine,
- Type, Virtuality, VirtualIndex, Flags,
- IsOptimized, Function, TemplateParams,
+ getCompositeType(), Virtuality, VirtualIndex,
+ Flags, IsOptimized, Function, TemplateParams,
Declaration, Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, ScopeLine,
@@ -1459,46 +1541,46 @@ TEST_F(MDSubprogramTest, get) {
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex,
- Flags, IsOptimized, Type, TemplateParams,
- Declaration, Variables));
+ Flags, IsOptimized, getFunction("bar"),
+ TemplateParams, Declaration, Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex,
- Flags, IsOptimized, Function, Type,
+ Flags, IsOptimized, Function, getTuple(),
Declaration, Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex,
Flags, IsOptimized, Function, TemplateParams,
- Type, Variables));
+ getSubprogram(), Variables));
EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex,
Flags, IsOptimized, Function, TemplateParams,
- Declaration, Type));
+ Declaration, getTuple()));
TempMDSubprogram Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
TEST_F(MDSubprogramTest, replaceFunction) {
- Metadata *Scope = MDTuple::getDistinct(Context, None);
+ MDScopeRef Scope = getCompositeType();
StringRef Name = "name";
StringRef LinkageName = "linkage";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 2;
- Metadata *Type = MDTuple::getDistinct(Context, None);
+ MDSubroutineType *Type = getSubroutineType();
bool IsLocalToUnit = false;
bool IsDefinition = true;
unsigned ScopeLine = 3;
- Metadata *ContainingType = MDTuple::getDistinct(Context, None);
+ MDTypeRef ContainingType = getCompositeType();
unsigned Virtuality = 4;
unsigned VirtualIndex = 5;
unsigned Flags = 6;
bool IsOptimized = false;
- Metadata *TemplateParams = MDTuple::getDistinct(Context, None);
- Metadata *Declaration = MDTuple::getDistinct(Context, None);
- Metadata *Variables = MDTuple::getDistinct(Context, None);
+ MDTuple *TemplateParams = getTuple();
+ MDSubprogram *Declaration = getSubprogram();
+ MDTuple *Variables = getTuple();
auto *N = MDSubprogram::get(
Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
@@ -1511,7 +1593,7 @@ TEST_F(MDSubprogramTest, replaceFunction) {
Function::Create(FunctionType::get(Type::getVoidTy(Context), false),
GlobalValue::ExternalLinkage));
N->replaceFunction(F.get());
- EXPECT_EQ(ConstantAsMetadata::get(F.get()), N->getFunction());
+ EXPECT_EQ(F.get(), N->getFunction());
N->replaceFunction(nullptr);
EXPECT_EQ(nullptr, N->getFunction());
@@ -1520,8 +1602,8 @@ TEST_F(MDSubprogramTest, replaceFunction) {
typedef MetadataTest MDLexicalBlockTest;
TEST_F(MDLexicalBlockTest, get) {
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDLocalScope *Scope = getSubprogram();
+ MDFile *File = getFile();
unsigned Line = 5;
unsigned Column = 8;
@@ -1534,8 +1616,9 @@ TEST_F(MDLexicalBlockTest, get) {
EXPECT_EQ(Column, N->getColumn());
EXPECT_EQ(N, MDLexicalBlock::get(Context, Scope, File, Line, Column));
- EXPECT_NE(N, MDLexicalBlock::get(Context, File, File, Line, Column));
- EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, Scope, Line, Column));
+ EXPECT_NE(N,
+ MDLexicalBlock::get(Context, getSubprogram(), File, Line, Column));
+ EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, getFile(), Line, Column));
EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, File, Line + 1, Column));
EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, File, Line, Column + 1));
@@ -1546,8 +1629,8 @@ TEST_F(MDLexicalBlockTest, get) {
typedef MetadataTest MDLexicalBlockFileTest;
TEST_F(MDLexicalBlockFileTest, get) {
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDLocalScope *Scope = getSubprogram();
+ MDFile *File = getFile();
unsigned Discriminator = 5;
auto *N = MDLexicalBlockFile::get(Context, Scope, File, Discriminator);
@@ -1558,8 +1641,10 @@ TEST_F(MDLexicalBlockFileTest, get) {
EXPECT_EQ(Discriminator, N->getDiscriminator());
EXPECT_EQ(N, MDLexicalBlockFile::get(Context, Scope, File, Discriminator));
- EXPECT_NE(N, MDLexicalBlockFile::get(Context, File, File, Discriminator));
- EXPECT_NE(N, MDLexicalBlockFile::get(Context, Scope, Scope, Discriminator));
+ EXPECT_NE(N, MDLexicalBlockFile::get(Context, getSubprogram(), File,
+ Discriminator));
+ EXPECT_NE(N,
+ MDLexicalBlockFile::get(Context, Scope, getFile(), Discriminator));
EXPECT_NE(N,
MDLexicalBlockFile::get(Context, Scope, File, Discriminator + 1));
@@ -1570,8 +1655,8 @@ TEST_F(MDLexicalBlockFileTest, get) {
typedef MetadataTest MDNamespaceTest;
TEST_F(MDNamespaceTest, get) {
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDScope *Scope = getFile();
+ MDFile *File = getFile();
StringRef Name = "namespace";
unsigned Line = 5;
@@ -1584,8 +1669,8 @@ TEST_F(MDNamespaceTest, get) {
EXPECT_EQ(Line, N->getLine());
EXPECT_EQ(N, MDNamespace::get(Context, Scope, File, Name, Line));
- EXPECT_NE(N, MDNamespace::get(Context, File, File, Name, Line));
- EXPECT_NE(N, MDNamespace::get(Context, Scope, Scope, Name, Line));
+ EXPECT_NE(N, MDNamespace::get(Context, getFile(), File, Name, Line));
+ EXPECT_NE(N, MDNamespace::get(Context, Scope, getFile(), Name, Line));
EXPECT_NE(N, MDNamespace::get(Context, Scope, File, "other", Line));
EXPECT_NE(N, MDNamespace::get(Context, Scope, File, Name, Line + 1));
@@ -1597,8 +1682,7 @@ typedef MetadataTest MDTemplateTypeParameterTest;
TEST_F(MDTemplateTypeParameterTest, get) {
StringRef Name = "template";
- Metadata *Type = MDTuple::getDistinct(Context, None);
- Metadata *Other = MDTuple::getDistinct(Context, None);
+ MDTypeRef Type = getBasicType("basic");
auto *N = MDTemplateTypeParameter::get(Context, Name, Type);
@@ -1608,7 +1692,8 @@ TEST_F(MDTemplateTypeParameterTest, get) {
EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Name, Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, "other", Type));
- EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Name, Other));
+ EXPECT_NE(N,
+ MDTemplateTypeParameter::get(Context, Name, getBasicType("other")));
TempMDTemplateTypeParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1619,9 +1704,8 @@ typedef MetadataTest MDTemplateValueParameterTest;
TEST_F(MDTemplateValueParameterTest, get) {
unsigned Tag = dwarf::DW_TAG_template_value_parameter;
StringRef Name = "template";
- Metadata *Type = MDTuple::getDistinct(Context, None);
- Metadata *Value = MDTuple::getDistinct(Context, None);
- Metadata *Other = MDTuple::getDistinct(Context, None);
+ MDTypeRef Type = getBasicType("basic");
+ Metadata *Value = getConstantAsMetadata();
auto *N = MDTemplateValueParameter::get(Context, Tag, Name, Type, Value);
EXPECT_EQ(Tag, N->getTag());
@@ -1635,9 +1719,10 @@ TEST_F(MDTemplateValueParameterTest, get) {
Type, Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, "other", Type,
Value));
- EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Other,
- Value));
- EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Type, Other));
+ EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name,
+ getBasicType("other"), Value));
+ EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Type,
+ getConstantAsMetadata()));
TempMDTemplateValueParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1646,16 +1731,17 @@ TEST_F(MDTemplateValueParameterTest, get) {
typedef MetadataTest MDGlobalVariableTest;
TEST_F(MDGlobalVariableTest, get) {
- Metadata *Scope = MDTuple::getDistinct(Context, None);
+ MDScope *Scope = getSubprogram();
StringRef Name = "name";
StringRef LinkageName = "linkage";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 5;
- Metadata *Type = MDTuple::getDistinct(Context, None);
+ MDTypeRef Type = getDerivedType();
bool IsLocalToUnit = false;
bool IsDefinition = true;
- Metadata *Variable = MDTuple::getDistinct(Context, None);
- Metadata *StaticDataMemberDeclaration = MDTuple::getDistinct(Context, None);
+ Constant *Variable = getConstant();
+ MDDerivedType *StaticDataMemberDeclaration =
+ cast<MDDerivedType>(getDerivedType());
auto *N = MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, Variable,
@@ -1675,37 +1761,42 @@ TEST_F(MDGlobalVariableTest, get) {
Line, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
- EXPECT_NE(N, MDGlobalVariable::get(Context, File, Name, LinkageName, File,
- Line, Type, IsLocalToUnit, IsDefinition,
- Variable, StaticDataMemberDeclaration));
+ EXPECT_NE(N,
+ MDGlobalVariable::get(Context, getSubprogram(), Name, LinkageName,
+ File, Line, Type, IsLocalToUnit, IsDefinition,
+ Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, "other", LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, "other", File, Line,
Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
- EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, Scope,
- Line, Type, IsLocalToUnit, IsDefinition,
- Variable, StaticDataMemberDeclaration));
+ EXPECT_NE(N,
+ MDGlobalVariable::get(Context, Scope, Name, LinkageName, getFile(),
+ Line, Type, IsLocalToUnit, IsDefinition,
+ Variable, StaticDataMemberDeclaration));
EXPECT_NE(N,
MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line + 1, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
- EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
- Line, Scope, IsLocalToUnit, IsDefinition,
- Variable, StaticDataMemberDeclaration));
+ EXPECT_NE(N,
+ MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
+ getDerivedType(), IsLocalToUnit, IsDefinition,
+ Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, !IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, !IsDefinition,
Variable, StaticDataMemberDeclaration));
- EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
- Line, Type, IsLocalToUnit, IsDefinition,
- Type, StaticDataMemberDeclaration));
- EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
- Line, Type, IsLocalToUnit, IsDefinition,
- Variable, Type));
+ EXPECT_NE(N,
+ MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
+ Type, IsLocalToUnit, IsDefinition,
+ getConstant(), StaticDataMemberDeclaration));
+ EXPECT_NE(N,
+ MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
+ Type, IsLocalToUnit, IsDefinition, Variable,
+ cast<MDDerivedType>(getDerivedType())));
TempMDGlobalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1715,19 +1806,16 @@ typedef MetadataTest MDLocalVariableTest;
TEST_F(MDLocalVariableTest, get) {
unsigned Tag = dwarf::DW_TAG_arg_variable;
- Metadata *Scope = MDTuple::getDistinct(Context, None);
+ MDLocalScope *Scope = getSubprogram();
StringRef Name = "name";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 5;
- Metadata *Type = MDTuple::getDistinct(Context, None);
+ MDTypeRef Type = getDerivedType();
unsigned Arg = 6;
unsigned Flags = 7;
- Metadata *InlinedAtScope = MDTuple::getDistinct(Context, None);
- Metadata *InlinedAt =
- MDLocation::getDistinct(Context, 10, 20, InlinedAtScope);
auto *N = MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, Flags, InlinedAt);
+ Arg, Flags);
EXPECT_EQ(Tag, N->getTag());
EXPECT_EQ(Scope, N->getScope());
EXPECT_EQ(Name, N->getName());
@@ -1736,45 +1824,28 @@ TEST_F(MDLocalVariableTest, get) {
EXPECT_EQ(Type, N->getType());
EXPECT_EQ(Arg, N->getArg());
EXPECT_EQ(Flags, N->getFlags());
- EXPECT_EQ(InlinedAt, N->getInlinedAt());
EXPECT_EQ(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, Flags, InlinedAt));
+ Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, dwarf::DW_TAG_auto_variable, Scope,
- Name, File, Line, Type, Arg, Flags,
- InlinedAt));
- EXPECT_NE(N, MDLocalVariable::get(Context, Tag, File, Name, File, Line,
- Type, Arg, Flags, InlinedAt));
+ Name, File, Line, Type, Arg, Flags));
+ EXPECT_NE(N, MDLocalVariable::get(Context, Tag, getSubprogram(), Name, File,
+ Line, Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, "other", File, Line,
- Type, Arg, Flags, InlinedAt));
- EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, Scope, Line,
- Type, Arg, Flags, InlinedAt));
+ Type, Arg, Flags));
+ EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, getFile(), Line,
+ Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line + 1,
- Type, Arg, Flags, InlinedAt));
+ Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line,
- Scope, Arg, Flags, InlinedAt));
- EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg + 1, Flags, InlinedAt));
+ getDerivedType(), Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, ~Flags, InlinedAt));
+ Arg + 1, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, Flags, Scope));
+ Arg, ~Flags));
TempMDLocalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
-
- auto *Inlined = N->withoutInline();
- EXPECT_NE(N, Inlined);
- EXPECT_EQ(N->getTag(), Inlined->getTag());
- EXPECT_EQ(N->getScope(), Inlined->getScope());
- EXPECT_EQ(N->getName(), Inlined->getName());
- EXPECT_EQ(N->getFile(), Inlined->getFile());
- EXPECT_EQ(N->getLine(), Inlined->getLine());
- EXPECT_EQ(N->getType(), Inlined->getType());
- EXPECT_EQ(N->getArg(), Inlined->getArg());
- EXPECT_EQ(N->getFlags(), Inlined->getFlags());
- EXPECT_EQ(nullptr, Inlined->getInlinedAt());
- EXPECT_EQ(N, Inlined->withInline(cast<MDLocation>(InlinedAt)));
}
typedef MetadataTest MDExpressionTest;
@@ -1836,12 +1907,12 @@ typedef MetadataTest MDObjCPropertyTest;
TEST_F(MDObjCPropertyTest, get) {
StringRef Name = "name";
- Metadata *File = MDTuple::getDistinct(Context, None);
+ MDFile *File = getFile();
unsigned Line = 5;
StringRef GetterName = "getter";
StringRef SetterName = "setter";
unsigned Attributes = 7;
- Metadata *Type = MDTuple::getDistinct(Context, None);
+ MDType *Type = cast<MDBasicType>(getBasicType("basic"));
auto *N = MDObjCProperty::get(Context, Name, File, Line, GetterName,
SetterName, Attributes, Type);
@@ -1859,7 +1930,7 @@ TEST_F(MDObjCPropertyTest, get) {
EXPECT_NE(N, MDObjCProperty::get(Context, "other", File, Line, GetterName,
SetterName, Attributes, Type));
- EXPECT_NE(N, MDObjCProperty::get(Context, Name, Type, Line, GetterName,
+ EXPECT_NE(N, MDObjCProperty::get(Context, Name, getFile(), Line, GetterName,
SetterName, Attributes, Type));
EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line + 1, GetterName,
SetterName, Attributes, Type));
@@ -1870,7 +1941,8 @@ TEST_F(MDObjCPropertyTest, get) {
EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName,
SetterName, Attributes + 1, Type));
EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName,
- SetterName, Attributes, File));
+ SetterName, Attributes,
+ cast<MDBasicType>(getBasicType("other"))));
TempMDObjCProperty Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1880,8 +1952,8 @@ typedef MetadataTest MDImportedEntityTest;
TEST_F(MDImportedEntityTest, get) {
unsigned Tag = dwarf::DW_TAG_imported_module;
- Metadata *Scope = MDTuple::getDistinct(Context, None);
- Metadata *Entity = MDTuple::getDistinct(Context, None);
+ MDScope *Scope = getSubprogram();
+ DebugNodeRef Entity = getCompositeType();
unsigned Line = 5;
StringRef Name = "name";
@@ -1897,8 +1969,10 @@ TEST_F(MDImportedEntityTest, get) {
EXPECT_NE(N,
MDImportedEntity::get(Context, dwarf::DW_TAG_imported_declaration,
Scope, Entity, Line, Name));
- EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Entity, Entity, Line, Name));
- EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Scope, Scope, Line, Name));
+ EXPECT_NE(N, MDImportedEntity::get(Context, Tag, getSubprogram(), Entity,
+ Line, Name));
+ EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Scope, getCompositeType(),
+ Line, Name));
EXPECT_NE(N,
MDImportedEntity::get(Context, Tag, Scope, Entity, Line + 1, Name));
EXPECT_NE(N,
diff --git a/unittests/IR/ValueHandleTest.cpp b/unittests/IR/ValueHandleTest.cpp
index 403d2bc..6000c4a 100644
--- a/unittests/IR/ValueHandleTest.cpp
+++ b/unittests/IR/ValueHandleTest.cpp
@@ -244,8 +244,11 @@ TEST_F(ValueHandle, CallbackVH_CallbackOnDeletion) {
RecordingVH(Value *V) : CallbackVH(V), DeletedCalls(0), AURWCalls(0) {}
private:
- virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); }
- virtual void allUsesReplacedWith(Value *) { AURWCalls++; }
+ void deleted() override {
+ DeletedCalls++;
+ CallbackVH::deleted();
+ }
+ void allUsesReplacedWith(Value *) override { AURWCalls++; }
};
RecordingVH RVH;
@@ -268,8 +271,11 @@ TEST_F(ValueHandle, CallbackVH_CallbackOnRAUW) {
: CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr) {}
private:
- virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); }
- virtual void allUsesReplacedWith(Value *new_value) {
+ void deleted() override {
+ DeletedCalls++;
+ CallbackVH::deleted();
+ }
+ void allUsesReplacedWith(Value *new_value) override {
EXPECT_EQ(nullptr, AURWArgument);
AURWArgument = new_value;
}
@@ -298,11 +304,11 @@ TEST_F(ValueHandle, CallbackVH_DeletionCanRAUW) {
Context(&getGlobalContext()) {}
private:
- virtual void deleted() {
+ void deleted() override {
getValPtr()->replaceAllUsesWith(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())));
setValPtr(nullptr);
}
- virtual void allUsesReplacedWith(Value *new_value) {
+ void allUsesReplacedWith(Value *new_value) override {
ASSERT_TRUE(nullptr != getValPtr());
EXPECT_EQ(1U, getValPtr()->getNumUses());
EXPECT_EQ(nullptr, AURWArgument);
@@ -341,12 +347,12 @@ TEST_F(ValueHandle, DestroyingOtherVHOnSameValueDoesntBreakIteration) {
setValPtr(V);
ToClear[1].reset(new WeakVH(V));
}
- virtual void deleted() {
+ void deleted() override {
ToClear[0].reset();
ToClear[1].reset();
CallbackVH::deleted();
}
- virtual void allUsesReplacedWith(Value *) {
+ void allUsesReplacedWith(Value *) override {
ToClear[0].reset();
ToClear[1].reset();
}
@@ -388,7 +394,7 @@ TEST_F(ValueHandle, AssertingVHCheckedLast) {
ToClear[1] = &A1;
}
- virtual void deleted() {
+ void deleted() override {
*ToClear[0] = nullptr;
*ToClear[1] = nullptr;
CallbackVH::deleted();
diff --git a/unittests/IR/ValueMapTest.cpp b/unittests/IR/ValueMapTest.cpp
index a6bad71..1431a8d 100644
--- a/unittests/IR/ValueMapTest.cpp
+++ b/unittests/IR/ValueMapTest.cpp
@@ -194,7 +194,8 @@ struct LockMutex : ValueMapConfig<KeyT, MutexT> {
}
static MutexT *getMutex(const ExtraData &Data) { return Data.M; }
};
-#if LLVM_ENABLE_THREADS
+// FIXME: These tests started failing on Windows.
+#if LLVM_ENABLE_THREADS && !defined(LLVM_ON_WIN32)
TYPED_TEST(ValueMapTest, LocksMutex) {
sys::Mutex M(false); // Not recursive.
bool CalledRAUW = false, CalledDeleted = false;
diff --git a/unittests/LineEditor/LineEditor.cpp b/unittests/LineEditor/LineEditor.cpp
index 26053c0..4d9081f 100644
--- a/unittests/LineEditor/LineEditor.cpp
+++ b/unittests/LineEditor/LineEditor.cpp
@@ -29,7 +29,7 @@ public:
LE = new LineEditor("test", HistPath);
}
- ~LineEditorTest() {
+ ~LineEditorTest() override {
delete LE;
sys::fs::remove(HistPath.str());
}
diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp
index fbd0363..b4689cb 100644
--- a/unittests/Linker/LinkModulesTest.cpp
+++ b/unittests/Linker/LinkModulesTest.cpp
@@ -23,7 +23,7 @@ namespace {
class LinkModuleTest : public testing::Test {
protected:
- virtual void SetUp() {
+ void SetUp() override {
M.reset(new Module("MyModule", Ctx));
FunctionType *FTy = FunctionType::get(
Type::getInt8PtrTy(Ctx), Type::getInt32Ty(Ctx), false /*=isVarArg*/);
@@ -56,7 +56,7 @@ protected:
GV->setInitializer(ConstantArray::get(AT, Init));
}
- virtual void TearDown() { M.reset(); }
+ void TearDown() override { M.reset(); }
LLVMContext Ctx;
std::unique_ptr<Module> M;
diff --git a/unittests/Support/AlignOfTest.cpp b/unittests/Support/AlignOfTest.cpp
index d209086..e0859fc 100644
--- a/unittests/Support/AlignOfTest.cpp
+++ b/unittests/Support/AlignOfTest.cpp
@@ -39,24 +39,10 @@ namespace {
#endif
// Define some fixed alignment types to use in these tests.
-#if __has_feature(cxx_alignas)
-struct alignas(1) A1 { };
-struct alignas(2) A2 { };
-struct alignas(4) A4 { };
-struct alignas(8) A8 { };
-#elif defined(__GNUC__)
-struct A1 { } __attribute__((aligned(1)));
-struct A2 { } __attribute__((aligned(2)));
-struct A4 { } __attribute__((aligned(4)));
-struct A8 { } __attribute__((aligned(8)));
-#elif defined(_MSC_VER)
-__declspec(align(1)) struct A1 { };
-__declspec(align(2)) struct A2 { };
-__declspec(align(4)) struct A4 { };
-__declspec(align(8)) struct A8 { };
-#else
-# error No supported align as directive.
-#endif
+struct LLVM_ALIGNAS(1) A1 {};
+struct LLVM_ALIGNAS(2) A2 {};
+struct LLVM_ALIGNAS(4) A4 {};
+struct LLVM_ALIGNAS(8) A8 {};
struct S1 {};
struct S2 { char a; };
@@ -75,12 +61,22 @@ struct D8 : S1, D4, D5 { double x[2]; };
struct D9 : S1, D1 { S1 s1; };
struct V1 { virtual ~V1(); };
struct V2 { int x; virtual ~V2(); };
-struct V3 : V1 { virtual ~V3(); };
-struct V4 : virtual V2 { int y; virtual ~V4(); };
-struct V5 : V4, V3 { double z; virtual ~V5(); };
+struct V3 : V1 {
+ ~V3() override;
+};
+struct V4 : virtual V2 { int y;
+ ~V4() override;
+};
+struct V5 : V4, V3 { double z;
+ ~V5() override;
+};
struct V6 : S1 { virtual ~V6(); };
-struct V7 : virtual V2, virtual V6 { virtual ~V7(); };
-struct V8 : V5, virtual V6, V7 { double zz; virtual ~V8(); };
+struct V7 : virtual V2, virtual V6 {
+ ~V7() override;
+};
+struct V8 : V5, virtual V6, V7 { double zz;
+ ~V8() override;
+};
double S6::f() { return 0.0; }
float D2::g() { return 0.0f; }
diff --git a/unittests/Support/CMakeLists.txt b/unittests/Support/CMakeLists.txt
index f3b55c3..3c8a090 100644
--- a/unittests/Support/CMakeLists.txt
+++ b/unittests/Support/CMakeLists.txt
@@ -44,6 +44,7 @@ add_llvm_unittest(SupportTests
YAMLParserTest.cpp
formatted_raw_ostream_test.cpp
raw_ostream_test.cpp
+ raw_pwrite_stream_test.cpp
)
# ManagedStatic.cpp uses <pthread>.
diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp
index 9d7679d..328c4b7 100644
--- a/unittests/Support/CommandLineTest.cpp
+++ b/unittests/Support/CommandLineTest.cpp
@@ -65,9 +65,7 @@ public:
StackOption(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3)
: Base(M0, M1, M2, M3) {}
- ~StackOption() {
- this->removeArgument();
- }
+ ~StackOption() override { this->removeArgument(); }
};
diff --git a/unittests/Support/MemoryBufferTest.cpp b/unittests/Support/MemoryBufferTest.cpp
index 1cdd6ad..ffb809a 100644
--- a/unittests/Support/MemoryBufferTest.cpp
+++ b/unittests/Support/MemoryBufferTest.cpp
@@ -26,7 +26,7 @@ protected:
: data("this is some data")
{ }
- virtual void SetUp() { }
+ void SetUp() override {}
/// Common testing for different modes of getOpenFileSlice.
/// Creates a temporary file with known contents, and uses
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index 479812c..262d272 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -308,7 +308,7 @@ protected:
/// be placed. It is removed at the end of each test (must be empty).
SmallString<128> TestDirectory;
- virtual void SetUp() {
+ void SetUp() override {
ASSERT_NO_ERROR(
fs::createUniqueDirectory("file-system-test", TestDirectory));
// We don't care about this specific file.
@@ -316,9 +316,7 @@ protected:
errs().flush();
}
- virtual void TearDown() {
- ASSERT_NO_ERROR(fs::remove(TestDirectory.str()));
- }
+ void TearDown() override { ASSERT_NO_ERROR(fs::remove(TestDirectory.str())); }
};
TEST_F(FileSystemTest, Unique) {
diff --git a/unittests/Support/raw_pwrite_stream_test.cpp b/unittests/Support/raw_pwrite_stream_test.cpp
new file mode 100644
index 0000000..bcbb29b
--- /dev/null
+++ b/unittests/Support/raw_pwrite_stream_test.cpp
@@ -0,0 +1,25 @@
+//===- raw_pwrite_stream_test.cpp - raw_pwrite_stream 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/raw_ostream.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(raw_pwrite_ostreamTest, TestSVector) {
+ SmallString<64> Buffer;
+ raw_svector_ostream OS(Buffer);
+ StringRef Test = "test";
+ OS.pwrite(Test.data(), Test.size(), 0);
+ EXPECT_EQ(Test, OS.str());
+}
+}
diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp
index 8374099..636cb3c 100644
--- a/unittests/Transforms/Utils/Cloning.cpp
+++ b/unittests/Transforms/Utils/Cloning.cpp
@@ -22,6 +22,7 @@
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/Verifier.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -30,9 +31,7 @@ namespace {
class CloneInstruction : public ::testing::Test {
protected:
- virtual void SetUp() {
- V = nullptr;
- }
+ void SetUp() override { V = nullptr; }
template <typename T>
T *clone(T *V1) {
@@ -46,7 +45,7 @@ protected:
DeleteContainerPointers(Clones);
}
- virtual void TearDown() {
+ void TearDown() override {
eraseClones();
DeleteContainerPointers(Orig);
delete V;
@@ -205,16 +204,14 @@ TEST_F(CloneInstruction, CallingConvention) {
class CloneFunc : public ::testing::Test {
protected:
- virtual void SetUp() {
+ void SetUp() override {
SetupModule();
CreateOldFunc();
CreateNewFunc();
SetupFinder();
}
- virtual void TearDown() {
- delete Finder;
- }
+ void TearDown() override { delete Finder; }
void SetupModule() {
M = new Module("", C);
@@ -233,7 +230,8 @@ protected:
// Function DI
DIFile File = DBuilder.createFile("filename.c", "/file/dir/");
DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
- DICompositeType FuncType = DBuilder.createSubroutineType(File, ParamTypes);
+ MDSubroutineType *FuncType =
+ DBuilder.createSubroutineType(File, ParamTypes);
DICompileUnit CU = DBuilder.createCompileUnit(dwarf::DW_LANG_C99,
"filename.c", "/file/dir", "CloneFunc", false, "", 0);
@@ -258,8 +256,10 @@ protected:
DIExpression E = DBuilder.createExpression();
DIVariable Variable = DBuilder.createLocalVariable(
dwarf::DW_TAG_auto_variable, Subprogram, "x", File, 5, IntType, true);
- DBuilder.insertDeclare(Alloca, Variable, E, Store);
- DBuilder.insertDbgValueIntrinsic(AllocaContent, 0, Variable, E, Terminator);
+ auto *DL = MDLocation::get(Subprogram->getContext(), 5, 0, Subprogram);
+ DBuilder.insertDeclare(Alloca, Variable, E, DL, Store);
+ DBuilder.insertDbgValueIntrinsic(AllocaContent, 0, Variable, E, DL,
+ Terminator);
// Finalize the debug info
DBuilder.finalize();
@@ -297,38 +297,41 @@ TEST_F(CloneFunc, NewFunctionCreated) {
// Test that a new subprogram entry was added and is pointing to the new
// function, while the original subprogram still points to the old one.
TEST_F(CloneFunc, Subprogram) {
+ EXPECT_FALSE(verifyModule(*M));
+
unsigned SubprogramCount = Finder->subprogram_count();
EXPECT_EQ(2U, SubprogramCount);
auto Iter = Finder->subprograms().begin();
- DISubprogram Sub1(*Iter);
- EXPECT_TRUE(Sub1.Verify());
+ DISubprogram Sub1 = cast<MDSubprogram>(*Iter);
Iter++;
- DISubprogram Sub2(*Iter);
- EXPECT_TRUE(Sub2.Verify());
+ DISubprogram Sub2 = cast<MDSubprogram>(*Iter);
- EXPECT_TRUE((Sub1.getFunction() == OldFunc && Sub2.getFunction() == NewFunc)
- || (Sub1.getFunction() == NewFunc && Sub2.getFunction() == OldFunc));
+ EXPECT_TRUE(
+ (Sub1->getFunction() == OldFunc && Sub2->getFunction() == NewFunc) ||
+ (Sub1->getFunction() == NewFunc && Sub2->getFunction() == OldFunc));
}
// Test that the new subprogram entry was not added to the CU which doesn't
// contain the old subprogram entry.
TEST_F(CloneFunc, SubprogramInRightCU) {
+ EXPECT_FALSE(verifyModule(*M));
+
EXPECT_EQ(2U, Finder->compile_unit_count());
auto Iter = Finder->compile_units().begin();
- DICompileUnit CU1(*Iter);
- EXPECT_TRUE(CU1.Verify());
+ DICompileUnit CU1 = cast<MDCompileUnit>(*Iter);
Iter++;
- DICompileUnit CU2(*Iter);
- EXPECT_TRUE(CU2.Verify());
- EXPECT_TRUE(CU1.getSubprograms().getNumElements() == 0
- || CU2.getSubprograms().getNumElements() == 0);
+ DICompileUnit CU2 = cast<MDCompileUnit>(*Iter);
+ EXPECT_TRUE(CU1->getSubprograms().size() == 0 ||
+ CU2->getSubprograms().size() == 0);
}
// Test that instructions in the old function still belong to it in the
// metadata, while instruction in the new function belong to the new one.
TEST_F(CloneFunc, InstructionOwnership) {
+ EXPECT_FALSE(verifyModule(*M));
+
inst_iterator OldIter = inst_begin(OldFunc);
inst_iterator OldEnd = inst_end(OldFunc);
inst_iterator NewIter = inst_begin(NewFunc);
@@ -346,14 +349,12 @@ TEST_F(CloneFunc, InstructionOwnership) {
// Verify that the debug location data is the same
EXPECT_EQ(OldDL.getLine(), NewDL.getLine());
EXPECT_EQ(OldDL.getCol(), NewDL.getCol());
-
+
// But that they belong to different functions
- DISubprogram OldSubprogram(OldDL.getScope(C));
- DISubprogram NewSubprogram(NewDL.getScope(C));
- EXPECT_TRUE(OldSubprogram.Verify());
- EXPECT_TRUE(NewSubprogram.Verify());
- EXPECT_EQ(OldFunc, OldSubprogram.getFunction());
- EXPECT_EQ(NewFunc, NewSubprogram.getFunction());
+ auto *OldSubprogram = cast<MDSubprogram>(OldDL.getScope());
+ auto *NewSubprogram = cast<MDSubprogram>(NewDL.getScope());
+ EXPECT_EQ(OldFunc, OldSubprogram->getFunction());
+ EXPECT_EQ(NewFunc, NewSubprogram->getFunction());
}
++OldIter;
@@ -366,6 +367,8 @@ TEST_F(CloneFunc, InstructionOwnership) {
// Test that the arguments for debug intrinsics in the new function were
// properly cloned
TEST_F(CloneFunc, DebugIntrinsics) {
+ EXPECT_FALSE(verifyModule(*M));
+
inst_iterator OldIter = inst_begin(OldFunc);
inst_iterator OldEnd = inst_end(OldFunc);
inst_iterator NewIter = inst_begin(NewFunc);
@@ -385,21 +388,25 @@ TEST_F(CloneFunc, DebugIntrinsics) {
getParent()->getParent());
// Old variable must belong to the old function
- EXPECT_EQ(OldFunc, DISubprogram(DIVariable(OldIntrin->getVariable())
- .getContext()).getFunction());
+ EXPECT_EQ(OldFunc,
+ cast<MDSubprogram>(OldIntrin->getVariable()->getScope())
+ ->getFunction());
// New variable must belong to the New function
- EXPECT_EQ(NewFunc, DISubprogram(DIVariable(NewIntrin->getVariable())
- .getContext()).getFunction());
+ EXPECT_EQ(NewFunc,
+ cast<MDSubprogram>(NewIntrin->getVariable()->getScope())
+ ->getFunction());
} else if (DbgValueInst* OldIntrin = dyn_cast<DbgValueInst>(&OldI)) {
DbgValueInst* NewIntrin = dyn_cast<DbgValueInst>(&NewI);
EXPECT_TRUE(NewIntrin);
// Old variable must belong to the old function
- EXPECT_EQ(OldFunc, DISubprogram(DIVariable(OldIntrin->getVariable())
- .getContext()).getFunction());
+ EXPECT_EQ(OldFunc,
+ cast<MDSubprogram>(OldIntrin->getVariable()->getScope())
+ ->getFunction());
// New variable must belong to the New function
- EXPECT_EQ(NewFunc, DISubprogram(DIVariable(NewIntrin->getVariable())
- .getContext()).getFunction());
+ EXPECT_EQ(NewFunc,
+ cast<MDSubprogram>(NewIntrin->getVariable()->getScope())
+ ->getFunction());
}
++OldIter;