Skip to content

Commit da5b897

Browse files
authored
Merge pull request #310 from maleadt/tb/unnamed_struct
Support querying an unnamed struct's name.
2 parents 1c32b3e + a24c7b4 commit da5b897

File tree

3 files changed

+48
-40
lines changed

3 files changed

+48
-40
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,63 @@ on:
66
pull_request:
77
workflow_dispatch:
88
jobs:
9-
test:
10-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.libLLVMExtra }} libLLVMExtra - assertions=${{ matrix.assertions }}
9+
binary_test:
10+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
fail-fast: false
1414
matrix:
1515
version: ['1.6', '1.7', '^1.8.0-beta3', 'nightly']
1616
os: [ubuntu-latest, macOS-latest, windows-latest]
1717
arch: [x64]
18-
libLLVMExtra: [packaged]
19-
assertions: [false]
20-
include:
21-
# special test with a locally-built libLLVMExtra
22-
- os: ubuntu-latest
23-
arch: x64
24-
libLLVMExtra: local
25-
version: '1.7'
26-
assertions: true
27-
# special test with LLVM assertions enabled
28-
# TODO: enable this across all versions
29-
# (needs LLVM.jl fixes, and julia-actions/setup-julia support)
30-
- os: ubuntu-latest
31-
arch: x64
32-
libLLVMExtra: packaged
33-
version: '1.7'
34-
assertions: true
35-
- os: ubuntu-latest
36-
arch: x64
37-
libLLVMExtra: packaged
38-
version: '1.8'
39-
assertions: true
4018
steps:
4119
- uses: actions/checkout@v2
42-
# install Julia
4320
- uses: julia-actions/setup-julia@v1
44-
if: ${{ ! matrix.assertions }}
4521
with:
4622
version: ${{ matrix.version }}
4723
arch: ${{ matrix.arch }}
48-
- name: Download Julia with assertions
49-
if: ${{ matrix.assertions }}
24+
- uses: actions/cache@v1
5025
env:
51-
version: ${{ matrix.version }}
52-
arch: ${{ matrix.arch }}
26+
cache-name: cache-artifacts
27+
with:
28+
path: ~/.julia/artifacts
29+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
30+
restore-keys: |
31+
${{ runner.os }}-test-${{ env.cache-name }}-
32+
${{ runner.os }}-test-
33+
${{ runner.os }}-
34+
- uses: julia-actions/julia-buildpkg@v1
35+
- name: Run tests
36+
run: |
37+
julia --project -e 'using Pkg; Pkg.test(; coverage=true, julia_args=`-g2`)'
38+
- uses: julia-actions/julia-processcoverage@v1
39+
- uses: codecov/codecov-action@v1
40+
with:
41+
file: lcov.info
42+
43+
# development versions of Julia, built with assertions enabled.
44+
# we also build LLVMExtra from source here.
45+
source_test:
46+
name: Julia ${{ matrix.branch }} - ${{ matrix.os }} - ${{ matrix.arch }}
47+
runs-on: ${{ matrix.os }}
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
branch: ['release-1.7', 'release-1.8', 'master']
52+
os: [ubuntu-latest, macOS-latest]
53+
arch: [x64]
54+
assertions: [false]
55+
steps:
56+
- uses: actions/checkout@v2
57+
- uses: actions/checkout@v2
58+
with:
59+
repository: 'JuliaLang/julia'
60+
ref: ${{ matrix.branch }}
61+
path: 'julia'
62+
- name: Compile Julia
5363
run: |
54-
wget https://julialangnightlies.s3.amazonaws.com/assert_bin/linux/$arch/$version/julia-latest-linux64.tar.gz
55-
tar -xvzf julia-latest-linux64.tar.gz
56-
rm -rf julia-latest-linux64.tar.gz
57-
echo $PWD/julia-*/bin >> $GITHUB_PATH
58-
# prepare
64+
make -C julia -j $(nproc) FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 JULIA_PRECOMPILE=0
65+
echo $PWD/julia/usr/bin >> $GITHUB_PATH
5966
- uses: actions/cache@v1
6067
env:
6168
cache-name: cache-artifacts
@@ -68,19 +75,17 @@ jobs:
6875
${{ runner.os }}-
6976
- uses: julia-actions/julia-buildpkg@v1
7077
- name: Build libLLVMExtra
71-
if: ${{ matrix.libLLVMExtra == 'local' }}
7278
run: |
7379
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
7480
julia --project=deps deps/build_local.jl
75-
# test
7681
- name: Run tests
7782
run: |
7883
julia --project -e 'using Pkg; Pkg.test(; coverage=true, julia_args=`-g2`)'
79-
# process results
8084
- uses: julia-actions/julia-processcoverage@v1
8185
- uses: codecov/codecov-action@v1
8286
with:
8387
file: lcov.info
88+
8489
docs:
8590
name: Documentation
8691
runs-on: ubuntu-latest

src/core/type.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ end
193193
StructType(elems::Vector{<:LLVMType}; packed::Core.Bool=false, ctx::Context) =
194194
StructType(API.LLVMStructTypeInContext(ctx, elems, length(elems), convert(Bool, packed)))
195195

196-
name(structtyp::StructType) =
197-
unsafe_string(API.LLVMGetStructName(structtyp))
196+
function name(structtyp::StructType)
197+
cstr = API.LLVMGetStructName(structtyp)
198+
cstr == C_NULL ? nothing : unsafe_string(cstr)
199+
end
198200
ispacked(structtyp::StructType) =
199201
convert(Core.Bool, API.LLVMIsPackedStruct(structtyp))
200202
isopaque(structtyp::StructType) =

test/core.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ end
122122
@test context(st) == ctx
123123
@test !ispacked(st)
124124
@test !isopaque(st)
125+
@test name(st) === nothing
125126

126127
let elem_it = elements(st)
127128
@test eltype(elem_it) == LLVMType

0 commit comments

Comments
 (0)