[PATCH] D33627: Fix Crashes when 'AttributeList::get'ing with an ArrayRef<AttributeList> where all pImpl are null
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 31 07:24:31 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304300: Fix assertion when merging multiple empty AttributeLists (authored by rnk).
Changed prior to commit:
https://reviews.llvm.org/D33627?vs=100544&id=100862#toc
Repository:
rL LLVM
https://reviews.llvm.org/D33627
Files:
llvm/trunk/lib/IR/Attributes.cpp
llvm/trunk/unittests/IR/AttributesTest.cpp
Index: llvm/trunk/lib/IR/Attributes.cpp
===================================================================
--- llvm/trunk/lib/IR/Attributes.cpp
+++ llvm/trunk/lib/IR/Attributes.cpp
@@ -1006,6 +1006,10 @@
for (AttributeList List : Attrs)
MaxSize = std::max(MaxSize, List.getNumAttrSets());
+ // If every list was empty, there is no point in merging the lists.
+ if (MaxSize == 0)
+ return AttributeList();
+
SmallVector<AttributeSet, 8> NewAttrSets(MaxSize);
for (unsigned I = 0; I < MaxSize; ++I) {
AttrBuilder CurBuilder;
Index: llvm/trunk/unittests/IR/AttributesTest.cpp
===================================================================
--- llvm/trunk/unittests/IR/AttributesTest.cpp
+++ llvm/trunk/unittests/IR/AttributesTest.cpp
@@ -82,4 +82,11 @@
EXPECT_TRUE(AL.hasParamAttribute(0, Attribute::NonNull));
}
+TEST(Attributes, EmptyGet) {
+ LLVMContext C;
+ AttributeList EmptyLists[] = {AttributeList(), AttributeList()};
+ AttributeList AL = AttributeList::get(C, EmptyLists);
+ EXPECT_TRUE(AL.isEmpty());
+}
+
} // end anonymous namespace
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33627.100862.patch
Type: text/x-patch
Size: 1085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170531/6fe43070/attachment.bin>
More information about the llvm-commits
mailing list