Returns a constants with the value NaN of the given type. Only works for 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs.
| 26 | // Returns a constants with the value NaN of the given type. Only works for |
| 27 | // 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs. |
| 28 | const analysis::Constant* GetNan(const analysis::Type* type, |
| 29 | analysis::ConstantManager* const_mgr) { |
| 30 | const analysis::Float* float_type = type->AsFloat(); |
| 31 | if (float_type == nullptr) { |
| 32 | return nullptr; |
| 33 | } |
| 34 | |
| 35 | switch (float_type->width()) { |
| 36 | case 32: |
| 37 | return const_mgr->GetFloatConst(std::numeric_limits<float>::quiet_NaN()); |
| 38 | case 64: |
| 39 | return const_mgr->GetDoubleConst( |
| 40 | std::numeric_limits<double>::quiet_NaN()); |
| 41 | default: |
| 42 | return nullptr; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // Returns a constants with the value INF of the given type. Only works for |
| 47 | // 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs. |
no test coverage detected