Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class DebugValueUser {
/// `resetDebugValue(Idx, NewDebugValue)` should be used instead.
LLVM_ABI void handleChangedValue(void *Old, Metadata *NewDebugValue);
DebugValueUser() = default;
explicit DebugValueUser(std::array<Metadata *, 3> DebugValues)
explicit DebugValueUser(const std::array<Metadata *, 3> &DebugValues)
: DebugValues(DebugValues) {
trackDebugValues();
}
Expand Down
25 changes: 25 additions & 0 deletions llvm/unittests/IR/MetadataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5497,4 +5497,29 @@ TEST_F(MDTupleAllocationDeathTest, ResizeRejected) {
}
#endif

typedef MetadataTest DebugValueUserTest;

namespace {
struct DebugValueUserTestHelper: public llvm::DebugValueUser {
using llvm::DebugValueUser::DebugValueUser;
using llvm::DebugValueUser::getDebugValues;
};
}

TEST_F(DebugValueUserTest, GetDebugValues) {
auto *V = getConstantAsMetadata();
auto *V2 = getConstantAsMetadata();
auto *V3 = getConstantAsMetadata();
std::array<Metadata *, 3> Debugs = {V, V2, V3};
DebugValueUserTestHelper User(Debugs);
ArrayRef<Metadata *> Result = User.getDebugValues();

// Verify the size of the returned array is correct,
// and each element is correctly stored and returned.
EXPECT_EQ(Result.size(), 3u);
EXPECT_EQ(Result[0], V);
EXPECT_EQ(Result[1], V2);
EXPECT_EQ(Result[2], V3);
}

} // end namespace