[llvm] 8901777 - [Bitcode] Don't assert on invalid attribute group record
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 7 03:16:23 PST 2022
Author: Nikita Popov
Date: 2022-02-07T12:16:12+01:00
New Revision: 89017772d9a7dc66398227fe23a9f8a1f5fabda3
URL: https://github.com/llvm/llvm-project/commit/89017772d9a7dc66398227fe23a9f8a1f5fabda3
DIFF: https://github.com/llvm/llvm-project/commit/89017772d9a7dc66398227fe23a9f8a1f5fabda3.diff
LOG: [Bitcode] Don't assert on invalid attribute group record
Report an error instead.
Added:
llvm/test/Bitcode/Inputs/invalid-attribute-group-entry.bc
Modified:
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/test/Bitcode/invalid.test
Removed:
################################################################################
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 51159c60227a..308986a588f4 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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");
}
}
diff --git a/llvm/test/Bitcode/Inputs/invalid-attribute-group-entry.bc b/llvm/test/Bitcode/Inputs/invalid-attribute-group-entry.bc
new file mode 100644
index 000000000000..5f063f9d1cd4
Binary files /dev/null and b/llvm/test/Bitcode/Inputs/invalid-attribute-group-entry.bc
diff er
diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test
index ef229de32018..e3e2f5981cd8 100644
--- a/llvm/test/Bitcode/invalid.test
+++ b/llvm/test/Bitcode/invalid.test
@@ -256,3 +256,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/size-not-plausible.bc 2>&1 | \
RUN: FileCheck --check-prefix=SIZE-NOT-PLAUSIBLE %s
SIZE-NOT-PLAUSIBLE: Size is not plausible
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-attribute-group-entry.bc 2>&1 | \
+RUN: FileCheck --check-prefix=INVALID-ATTRIBUTE-GROUP-ENTRY %s
+
+INVALID-ATTRIBUTE-GROUP-ENTRY: Invalid attribute group entry
More information about the llvm-commits
mailing list