SPV: Protect getStorageClass() with a test that the thing is pointer.

This commit is contained in:
John Kessenich
2015-12-08 20:48:49 -07:00
parent 33661450c7
commit e00e72ded1
6 changed files with 128 additions and 5 deletions

View File

@@ -293,7 +293,12 @@ public:
Instruction* getInstruction(Id id) const { return idToInstruction[id]; }
spv::Id getTypeId(Id resultId) const { return idToInstruction[resultId]->getTypeId(); }
StorageClass getStorageClass(Id typeId) const { return (StorageClass)idToInstruction[typeId]->getImmediateOperand(0); }
StorageClass getStorageClass(Id typeId) const
{
assert(idToInstruction[typeId]->getOpCode() == spv::OpTypePointer);
return (StorageClass)idToInstruction[typeId]->getImmediateOperand(0);
}
void dump(std::vector<unsigned int>& out) const
{
for (int f = 0; f < (int)functions.size(); ++f)