Skip to content

Commit 337b952

Browse files
Pangorawkimikage
andauthored
Fix llvm highlighting of variables with : in name (#54405)
This prevents values with `:` in their name to be printed as labels. ### Before ![image](https://github.com/JuliaLang/julia/assets/9824244/2c2eb23f-5f0e-4cb9-aa70-41211c7bc00a) ### After ![image](https://github.com/JuliaLang/julia/assets/9824244/23dd4c5d-13c8-4952-9831-7a028f1f20d7) --------- Co-authored-by: kimikage <kimikage.ceo@gmail.com>
1 parent 9634652 commit 337b952

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

stdlib/InteractiveUtils/src/codeview.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ const llvm_types =
353353
const llvm_cond = r"^(?:[ou]?eq|[ou]?ne|[uso][gl][te]|ord|uno)$" # true|false
354354

355355
function print_llvm_tokens(io, tokens)
356-
m = match(r"^((?:[^\s:]+:)?)(\s*)(.*)", tokens)
356+
m = match(r"^((?:[^\"\s:]+:|\"[^\"]*\":)?)(\s*)(.*)", tokens)
357357
if m !== nothing
358358
label, spaces, tokens = m.captures
359359
printstyled_ll(io, label, :label, spaces)

stdlib/InteractiveUtils/test/highlighting.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ const XU = B * "}" * XB
131131

132132
@test highlight_llvm("L7:\t\t; preds = %top") ==
133133
"$(L)L7:$(XL)\t\t$(C); preds = %top$(XC)\n"
134+
135+
@test highlight_llvm(" %\"box::GenericMemoryRef13\" = add i64 0, 0") ==
136+
" $(V)%\"box::GenericMemoryRef13\"$(XV) $EQU " *
137+
"$(I)add$(XI) $(T)i64$(XT) $(N)0$(XN)$COM $(N)0$(XN)\n"
138+
139+
@test highlight_llvm(" \"label-as-string\":\t\t; preds = %top") ==
140+
" $(L)\"label-as-string\":$(XL)\t\t$(C); preds = %top$(XC)\n"
134141
end
135142
@testset "define" begin
136143
@test highlight_llvm("define double @julia_func_1234(float) {") ==

0 commit comments

Comments
 (0)