diff options
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Bitcode/Inputs/invalid-no-function-block.bc | bin | 0 -> 548 bytes | |||
-rw-r--r-- | llvm/test/Bitcode/invalid.test | 5 |
3 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 74a5553ce6e..c874a84e0cb 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3055,7 +3055,9 @@ std::error_code BitcodeReader::rememberAndSkipFunctionBodies() { if (Stream.AtEndOfStream()) return error("Could not find function in stream"); - assert(SeenFirstFunctionBody); + if (!SeenFirstFunctionBody) + return error("Trying to materialize functions before seeing function blocks"); + // An old bitcode file with the symbol table at the end would have // finished the parse greedily. assert(SeenValueSymbolTable); diff --git a/llvm/test/Bitcode/Inputs/invalid-no-function-block.bc b/llvm/test/Bitcode/Inputs/invalid-no-function-block.bc Binary files differnew file mode 100644 index 00000000000..52b65588e4a --- /dev/null +++ b/llvm/test/Bitcode/Inputs/invalid-no-function-block.bc diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test index 69104046df2..24ccd8bccd5 100644 --- a/llvm/test/Bitcode/invalid.test +++ b/llvm/test/Bitcode/invalid.test @@ -207,3 +207,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-alias-type-mismatch.bc 2>&1 RUN: FileCheck --check-prefix=ALIAS-TYPE-MISMATCH %s ALIAS-TYPE-MISMATCH: Alias and aliasee types don't match + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-function-block.bc 2>&1 | \ +RUN: FileCheck --check-prefix=NO-FUNCTION-BLOCK %s + +NO-FUNCTION-BLOCK: Trying to materialize functions before seeing function blocks |