-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[clang-format] Don't split "DPI"/"DPI-C" in Verilog imports #66951
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't we handle
export
as well? Also, I don't think this is Verilog specific.Edit: let’s just fix Verilog for now.
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.
isOneOf
won't work here, since the token has the type ofidentifier
rather than a keyword:We should leave
Current.getPreviousNonComment()
to handle comments in the middle of the statement (something likeimport /*"DPI"*/ "DPI-C" ...
comes to mind).Indeed,
export "DPI-C"
is also a valid construct, and thus, string literals afterexport
should be exempt from breaking too.I'd suggest to address known cases with targeted exemptions to avoid surprises in random places.
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.
Have you tried it? It does work because not only is
import
atok::identifier
, it's also aKeywords.kw_import
.I was aware of that, but we usually don't call
getPreviousNonComment()
unless a comment before a token makes sense in practice. Otherwise, we would have to write ugly and inefficient code to handle things like the following:I think this is also relevant to (at least) C++ import statements, e.g.:
I still prefer that we make a general fix here but will leave it to @sstwcw.
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.
Can we please have any of the resolutions sooner?
This blocks quite a bit of testing.
For example, can we have this as a workaround, then let @sstwcw fix it cleanly?
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.
Please see my update in #66951 (comment).
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.
For C++, it is already handled on lines 261 and 2166. I prefer fixing the Verilog problem by annotating the import lines instead of implementing said lines again. But if you think it is too much work for you, then I am also fine with your current fix.
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.
I've taken the suggestion and added a FIXME to use the C++ import infra
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.
Ah, right, I had tried it with
tok::kw_import
(and I missed the difference between this and your suggestion). Thanks for the clarification!I don't think it would add a lot of overhead (one branch on a happy path) or hinder readability of the code a lot (
getPreviousNonComment()
vsPrev
), but I also don't think it's super important here.