Skip to content

Commit 3ffa17f

Browse files
authored
Merge pull request #216 from maleadt/tb/undef_constant
Undef is a Constant.
2 parents 1f5d8d0 + 3c3d2e6 commit 3ffa17f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/core/value/constant.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ all_ones(typ::LLVMType) = Value(API.LLVMConstAllOnes(typ))
77
isnull(val::Value) = convert(Core.Bool, API.LLVMIsNull(val))
88

99

10-
@checked struct UndefValue <: User
11-
ref::API.LLVMValueRef
12-
end
13-
identify(::Type{Value}, ::Val{API.LLVMUndefValueValueKind}) = UndefValue
14-
15-
UndefValue(typ::LLVMType) = UndefValue(API.LLVMGetUndef(typ))
16-
17-
1810
abstract type Constant <: User end
1911

2012
# forward declarations
@@ -32,6 +24,14 @@ identify(::Type{Value}, ::Val{API.LLVMConstantPointerNullValueKind}) = PointerNu
3224
PointerNull(typ::PointerType) = PointerNull(API.LLVMConstPointerNull(typ))
3325

3426

27+
@checked struct UndefValue <: Constant
28+
ref::API.LLVMValueRef
29+
end
30+
identify(::Type{Value}, ::Val{API.LLVMUndefValueValueKind}) = UndefValue
31+
32+
UndefValue(typ::LLVMType) = UndefValue(API.LLVMGetUndef(typ))
33+
34+
3535
## scalar
3636

3737
export ConstantInt, ConstantFP

test/core.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ Context() do ctx
312312

313313
let val = UndefValue(typ)
314314
@test isundef(val)
315+
@test val isa LLVM.Constant
315316
end
316317

317318
end

0 commit comments

Comments
 (0)