-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RemoveDIs] Update syntax highlighting to include debug records #93660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-debuginfo Author: Stephen Tozer (SLTozer) ChangesThis patch updates the vim and vscode syntax highlighters to recognize debug records. I wasn't able to build the vscode extensions locally, so I've only tested this pattern by checking that the pattern works in vscode search. Full diff: https://github.com/llvm/llvm-project/pull/93660.diff 2 Files Affected:
diff --git a/llvm/utils/vim/syntax/llvm.vim b/llvm/utils/vim/syntax/llvm.vim
index d86e3d1ddbc27..c45391477f2c2 100644
--- a/llvm/utils/vim/syntax/llvm.vim
+++ b/llvm/utils/vim/syntax/llvm.vim
@@ -36,6 +36,9 @@ syn keyword llvmStatement sle slt srem store sub switch trunc udiv ueq uge ugt
syn keyword llvmStatement uitofp ule ult umax umin une uno unreachable unwind
syn keyword llvmStatement urem va_arg xchg xor zext
+" Debug records.
+syn match llvmStatement /\v#dbg_(assign|declare|label|value)/
+
" Keywords.
syn keyword llvmKeyword
\ acq_rel
diff --git a/llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml b/llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
index d80c3778bbe78..da07491c9d88d 100644
--- a/llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
+++ b/llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
@@ -34,7 +34,8 @@ patterns:
captures:
1:
name: storage.type.llvm
- - match: "\\badd\\b|\
+ - match: "(?<=\\s|^)#dbg_(assign|declare|label|value)\\b\
+ \\badd\\b|\
\\baddrspacecast\\b|\
\\balloca\\b|\
\\band\\b|\
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there someone else you can add to the review that has edited the file or reviewed a recent edit?
Rather than using "fancy" regex I would rather just have #dbg_assign
#dbg_label
etc checked separately. Less error prone, easier to read (for me!), but I won't push strongly for it.
Any chance we can get emacs too (https://github.com/llvm/llvm-project/blob/main/llvm/utils/emacs/llvm-mode.el) - I can look at adding later if you're not sure about emacs.
@@ -34,7 +34,8 @@ patterns: | |||
captures: | |||
1: | |||
name: storage.type.llvm | |||
- match: "\\badd\\b|\ | |||
- match: "(?<=\\s|^)#dbg_(assign|declare|label|value)\\b\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other lines end |\
- I assume this one should too?
Can you explain what (?<=\\s|^)
is doing please for the uninitiated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other lines end |\ - I assume this one should too?
Yes, it should - I'll fix that.
Can you explain what (?<=\s|^) is doing please for the uninitiated?
Look-behind - it lets us make sure that this is preceded by the start of the line or whitespace without including that whitespace in the match (so if you had a custom background for instructions, it wouldn't highlight the space behind the "#").
@@ -36,6 +36,9 @@ syn keyword llvmStatement sle slt srem store sub switch trunc udiv ueq uge ugt | |||
syn keyword llvmStatement uitofp ule ult umax umin une uno unreachable unwind | |||
syn keyword llvmStatement urem va_arg xchg xor zext | |||
|
|||
" Debug records. | |||
syn match llvmStatement /\v#dbg_(assign|declare|label|value)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's \v
, and why do we need to wrap in /
? (Not familiar with this stuff)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/
is just what you type in vim when you're about to start a search
\v
is to control the "very magic" behaviour of regex spelling:
Vim's default 'magic' setting makes characters have the same meaning as in grep, and \v (very magic) makes them the same as the extended regular expressions used by egrep.
In practice, it means fewer escape sequences for the regex operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vim changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS Code changes look good to me.
Tested the emacs change locally, that LGTM (not super familiar, but it works and looks reasonable). |
This patch updates the vim and vscode syntax highlighters to recognize debug records. I wasn't able to build the vscode extensions locally, so I've only tested this pattern by checking that the pattern works in vscode search.