From a9f0a8d32563e7f87dab56c5b371dcf618dc7f29 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 19 Feb 2015 23:25:21 +0000 Subject: [PATCH] IR: Add missing null operand to MDSubroutineType Add missing `nullptr` from `MDSubroutineType`'s operands for `MDCompositeTypeBase::getIdentifier()` (and add tests for all the other unused fields). This highlights just how crazy it is that `MDSubroutineType` inherits from `MDCompositeTypeBase`. llvm-svn: 229926 --- llvm/lib/IR/DebugInfoMetadata.cpp | 2 +- llvm/unittests/IR/MetadataTest.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index ab79a71..a2f5d55 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -200,7 +200,7 @@ MDSubroutineType *MDSubroutineType::getImpl(LLVMContext &Context, bool ShouldCreate) { DEFINE_GETIMPL_LOOKUP(MDSubroutineType, (Flags, TypeArray)); Metadata *Ops[] = {nullptr, nullptr, nullptr, nullptr, - TypeArray, nullptr, nullptr}; + TypeArray, nullptr, nullptr, nullptr}; DEFINE_GETIMPL_STORE(MDSubroutineType, (Flags), Ops); } diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index ea49880..0c1ef82 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -964,6 +964,15 @@ TEST_F(MDSubroutineTypeTest, get) { TempMDSubroutineType Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); + + // Test always-empty operands. + EXPECT_EQ(nullptr, N->getScope()); + EXPECT_EQ(nullptr, N->getFile()); + EXPECT_EQ("", N->getName()); + EXPECT_EQ(nullptr, N->getBaseType()); + EXPECT_EQ(nullptr, N->getVTableHolder()); + EXPECT_EQ(nullptr, N->getTemplateParams()); + EXPECT_EQ("", N->getIdentifier()); } typedef MetadataTest MDFileTest; -- 2.7.4