[llvm] r300117 - [IR] Assert that we never create an empty AttributeListImpl, NFC
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 12 15:22:02 PDT 2017
Author: rnk
Date: Wed Apr 12 17:22:01 2017
New Revision: 300117
URL: http://llvm.org/viewvc/llvm-project?rev=300117&view=rev
Log:
[IR] Assert that we never create an empty AttributeListImpl, NFC
Delete following conditional that is always true as a result.
Modified:
llvm/trunk/lib/IR/Attributes.cpp
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=300117&r1=300116&r2=300117&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Wed Apr 12 17:22:01 2017
@@ -721,6 +721,7 @@ AttributeListImpl::AttributeListImpl(
LLVMContext &C, ArrayRef<std::pair<unsigned, AttributeSet>> Slots)
: Context(C), NumSlots(Slots.size()), AvailableFunctionAttrs(0) {
#ifndef NDEBUG
+ assert(!Slots.empty() && "pointless AttributeListImpl");
if (Slots.size() >= 2) {
auto &PrevPair = Slots.front();
for (auto &CurPair : Slots.drop_front()) {
@@ -733,19 +734,17 @@ AttributeListImpl::AttributeListImpl(
std::copy(Slots.begin(), Slots.end(), getTrailingObjects<IndexAttrPair>());
// Initialize AvailableFunctionAttrs summary bitset.
- if (NumSlots > 0) {
- static_assert(Attribute::EndAttrKinds <=
- sizeof(AvailableFunctionAttrs) * CHAR_BIT,
- "Too many attributes");
- static_assert(AttributeList::FunctionIndex == ~0u,
- "FunctionIndex should be biggest possible index");
- const auto &Last = Slots.back();
- if (Last.first == AttributeList::FunctionIndex) {
- AttributeSet Node = Last.second;
- for (Attribute I : Node) {
- if (!I.isStringAttribute())
- AvailableFunctionAttrs |= ((uint64_t)1) << I.getKindAsEnum();
- }
+ static_assert(Attribute::EndAttrKinds <=
+ sizeof(AvailableFunctionAttrs) * CHAR_BIT,
+ "Too many attributes");
+ static_assert(AttributeList::FunctionIndex == ~0u,
+ "FunctionIndex should be biggest possible index");
+ const auto &Last = Slots.back();
+ if (Last.first == AttributeList::FunctionIndex) {
+ AttributeSet Node = Last.second;
+ for (Attribute I : Node) {
+ if (!I.isStringAttribute())
+ AvailableFunctionAttrs |= ((uint64_t)1) << I.getKindAsEnum();
}
}
}
More information about the llvm-commits
mailing list