diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-04-28 05:38:52 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-04-28 05:38:52 +0000 |
| commit | 19651c77b204c504a245f2017d8544e0e9304933 (patch) | |
| tree | e90e664f85b7942943848a8d1cc9d98214defa34 /llvm/lib | |
| parent | 089e35cc57cd723f55e2aa6cbd539c347b79ff9c (diff) | |
| download | bcm5719-llvm-19651c77b204c504a245f2017d8544e0e9304933.tar.gz bcm5719-llvm-19651c77b204c504a245f2017d8544e0e9304933.zip | |
add a way to make this less brittle
llvm-svn: 36528
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/ValueTypes.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/ValueTypes.cpp b/llvm/lib/VMCore/ValueTypes.cpp index ccbd29771de..52d8549201d 100644 --- a/llvm/lib/VMCore/ValueTypes.cpp +++ b/llvm/lib/VMCore/ValueTypes.cpp @@ -113,16 +113,20 @@ const Type *MVT::getTypeForValueType(MVT::ValueType VT) { /// MVT::getValueType - Return the value type corresponding to the specified /// type. This returns all vectors as MVT::Vector and all pointers as -/// MVT::iPTR. -MVT::ValueType MVT::getValueType(const Type *Ty) { +/// MVT::iPTR. If HandleUnknown is true, unknown types are returned as Other, +/// otherwise they are invalid. +MVT::ValueType MVT::getValueType(const Type *Ty, bool HandleUnknown) { switch (Ty->getTypeID()) { - default: assert(0 && "Unknown type!"); + default: + if (HandleUnknown) return MVT::Other; + assert(0 && "Unknown type!"); case Type::VoidTyID: return MVT::isVoid; case Type::IntegerTyID: switch (cast<IntegerType>(Ty)->getBitWidth()) { default: // FIXME: Return MVT::iANY. + if (HandleUnknown) return MVT::Other; assert(0 && "Invalid width for value type"); case 1: return MVT::i1; case 8: return MVT::i8; |

