[llvm] r271848 - [BitCode] Don't allow constants of void type.
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 5 11:43:17 PDT 2016
Author: filcab
Date: Sun Jun 5 13:43:17 2016
New Revision: 271848
URL: http://llvm.org/viewvc/llvm-project?rev=271848&view=rev
Log:
[BitCode] Don't allow constants of void type.
Added:
llvm/trunk/test/Bitcode/Inputs/invalid-void-constant.bc
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/test/Bitcode/invalid.test
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=271848&r1=271847&r2=271848&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sun Jun 5 13:43:17 2016
@@ -2868,6 +2868,7 @@ std::error_code BitcodeReader::parseCons
// Read a record.
Record.clear();
+ Type *VoidType = Type::getVoidTy(Context);
Value *V = nullptr;
unsigned BitCode = Stream.readRecord(Entry.ID, Record);
switch (BitCode) {
@@ -2880,6 +2881,8 @@ std::error_code BitcodeReader::parseCons
return error("Invalid record");
if (Record[0] >= TypeList.size() || !TypeList[Record[0]])
return error("Invalid record");
+ if (TypeList[Record[0]] == VoidType)
+ return error("Invalid constant type");
CurTy = TypeList[Record[0]];
continue; // Skip the ValueList manipulation.
case bitc::CST_CODE_NULL: // NULL
Added: llvm/trunk/test/Bitcode/Inputs/invalid-void-constant.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-void-constant.bc?rev=271848&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/Inputs/invalid-void-constant.bc (added) and llvm/trunk/test/Bitcode/Inputs/invalid-void-constant.bc Sun Jun 5 13:43:17 2016 differ
Modified: llvm/trunk/test/Bitcode/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/invalid.test?rev=271848&r1=271847&r2=271848&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/invalid.test (original)
+++ llvm/trunk/test/Bitcode/invalid.test Sun Jun 5 13:43:17 2016
@@ -212,3 +212,8 @@ RUN: not llvm-dis -disable-output %p/Inp
RUN: FileCheck --check-prefix=NAME-WITH-0 %s
NAME-WITH-0: Invalid value name
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-void-constant.bc 2>&1 | \
+RUN: FileCheck --check-prefix=VOID-CONSTANT-TYPE %s
+
+VOID-CONSTANT-TYPE: Invalid constant type
More information about the llvm-commits
mailing list