[Bitcode] Don't assert on invalid attribute group record

Report an error instead.
This commit is contained in:
Nikita Popov
2022-02-07 11:15:43 +01:00
parent 3c86642edd
commit 89017772d9
3 changed files with 8 additions and 3 deletions

View File

@@ -1647,9 +1647,7 @@ Error BitcodeReader::parseAttributeGroupBlock() {
}
B.addAttribute(KindStr.str(), ValStr.str());
} else {
assert((Record[i] == 5 || Record[i] == 6) &&
"Invalid attribute group entry");
} else if (Record[i] == 5 || Record[i] == 6) {
bool HasType = Record[i] == 6;
Attribute::AttrKind Kind;
if (Error Err = parseAttrKind(Record[++i], &Kind))
@@ -1658,6 +1656,8 @@ Error BitcodeReader::parseAttributeGroupBlock() {
return error("Not a type attribute");
B.addTypeAttr(Kind, HasType ? getTypeByID(Record[++i]) : nullptr);
} else {
return error("Invalid attribute group entry");
}
}