Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/unittests/IR/DebugInfoTest.cpp
//===- llvm/unittest/IR/DebugInfo.cpp - DebugInfo tests -------------------===// | //===- llvm/unittest/IR/DebugInfo.cpp - DebugInfo tests -------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "llvm/IR/DebugInfo.h" | #include "llvm/IR/DebugInfo.h" | ||||
#include "llvm/IR/DIBuilder.h" | |||||
#include "llvm/AsmParser/Parser.h" | #include "llvm/AsmParser/Parser.h" | ||||
#include "llvm/IR/DebugInfoMetadata.h" | #include "llvm/IR/DebugInfoMetadata.h" | ||||
#include "llvm/IR/IntrinsicInst.h" | #include "llvm/IR/IntrinsicInst.h" | ||||
#include "llvm/IR/LLVMContext.h" | #include "llvm/IR/LLVMContext.h" | ||||
#include "llvm/IR/Module.h" | #include "llvm/IR/Module.h" | ||||
#include "llvm/IR/Verifier.h" | #include "llvm/IR/Verifier.h" | ||||
#include "llvm/Support/SourceMgr.h" | #include "llvm/Support/SourceMgr.h" | ||||
#include "llvm/Transforms/Utils/Local.h" | #include "llvm/Transforms/Utils/Local.h" | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | )"); | ||||
SmallVector<DbgValueInst *, 1> DVIs; | SmallVector<DbgValueInst *, 1> DVIs; | ||||
findDbgValues(DVIs, &I); | findDbgValues(DVIs, &I); | ||||
// Delete %b. The dbg.value should now point to undef. | // Delete %b. The dbg.value should now point to undef. | ||||
I.eraseFromParent(); | I.eraseFromParent(); | ||||
EXPECT_TRUE(isa<UndefValue>(DVIs[0]->getValue())); | EXPECT_TRUE(isa<UndefValue>(DVIs[0]->getValue())); | ||||
} | } | ||||
TEST(DIBuilder, CreateFortranArrayTypeWithAttributes) { | |||||
LLVMContext Ctx; | |||||
std::unique_ptr<Module> M(new Module("MyModule", Ctx)); | |||||
DIBuilder DIB(*M); | |||||
DISubrange *Subrange = DIB.getOrCreateSubrange(1,1); | |||||
SmallVector<Metadata*, 4> Subranges; | |||||
Subranges.push_back(Subrange); | |||||
DINodeArray Subscripts = DIB.getOrCreateArray(Subranges); | |||||
auto getDIExpression = [&DIB](int offset) { | |||||
SmallVector<uint64_t, 4> ops; | |||||
ops.push_back(llvm::dwarf::DW_OP_push_object_address); | |||||
DIExpression::appendOffset(ops, offset); | |||||
ops.push_back(llvm::dwarf::DW_OP_deref); | |||||
return DIB.createExpression(ops); | |||||
}; | |||||
Metadata *DataLocation = getDIExpression(0); | |||||
Metadata *Associated = getDIExpression(1); | |||||
Metadata *Allocated = getDIExpression(2); | |||||
DICompositeType *ArrayType = DIB.createArrayType(0, 0, nullptr, Subscripts, | |||||
DataLocation, Associated, | |||||
Allocated); | |||||
EXPECT_TRUE(isa_and_nonnull<DICompositeType>(ArrayType)); | |||||
EXPECT_EQ(ArrayType->getRawDataLocation(), DataLocation); | |||||
EXPECT_EQ(ArrayType->getRawAssociated(), Associated); | |||||
EXPECT_EQ(ArrayType->getRawAllocated(), Allocated); | |||||
} | |||||
} // end namespace | } // end namespace |