MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / nativeBoolCast

Function nativeBoolCast

src/DataTypes/Native.cpp:107–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107llvm::Value * nativeBoolCast(llvm::IRBuilderBase & b, const DataTypePtr & from_type, llvm::Value * value)
108{
109 if (from_type->isNullable())
110 {
111 auto * inner = nativeBoolCast(b, removeNullable(from_type), b.CreateExtractValue(value, {0}));
112 return b.CreateAnd(b.CreateNot(b.CreateExtractValue(value, {1})), inner);
113 }
114
115 auto * zero = llvm::Constant::getNullValue(value->getType());
116
117 if (value->getType()->isIntegerTy())
118 return b.CreateICmpNE(value, zero);
119 if (value->getType()->isFloatingPointTy())
120 return b.CreateFCmpUNE(value, zero);
121
122 throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot cast non-number {} to bool", from_type->getName());
123}
124
125llvm::Value * nativeBoolCast(llvm::IRBuilderBase & b, const ValueWithType & value_with_type)
126{

Callers 10

compileMergeMethod · 0.85
compileGetResultMethod · 0.85
compileAddMethod · 0.85
compileAddMethod · 0.85
compileAddMethod · 0.85
compileImplMethod · 0.85
compileImplMethod · 0.85
convertCompileImplFunction · 0.85
compileMethod · 0.85
compileImplMethod · 0.85

Calls 5

removeNullableFunction · 0.70
ExceptionClass · 0.50
isNullableMethod · 0.45
getTypeMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected