/// Helper to read the header common to all bitcode files.
static bool hasValidBitcodeHeader(BitstreamCursor &Stream) {
// Sniff for the signature.
- if (Stream.Read(8) != 'B' ||
+ if (!Stream.canSkipToPos(4) ||
+ Stream.Read(8) != 'B' ||
Stream.Read(8) != 'C' ||
Stream.Read(4) != 0x0 ||
Stream.Read(4) != 0xC ||
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-empty.bc 2>&1 | \
+RUN: FileCheck --check-prefix=INVALID-EMPTY %s
RUN: not llvm-dis -disable-output %p/Inputs/invalid-pr20485.bc 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-ENCODING %s
RUN: not llvm-dis -disable-output %p/Inputs/invalid-abbrev.bc 2>&1 | \
RUN: not llvm-dis -disable-output %p/Inputs/invalid-invoke-non-function-explicit-type.bc 2>&1 | \
RUN: FileCheck --check-prefix=NON-FUNCTION-EXPLICIT-INVOKE %s
+INVALID-EMPTY: Invalid bitcode signature
INVALID-ENCODING: Invalid encoding
BAD-ABBREV: Abbreviation starts with an Array or a Blob
UNEXPECTED-EOF: Unexpected end of file