Don't let clang-format reorder Fiddle #includes#7887
Merged
expipiplus1 merged 2 commits intomasterfrom Aug 18, 2025
Merged
Conversation
csyonghe
reviewed
Jul 24, 2025
|
|
||
| #include "slang-ast-base.h" | ||
|
|
||
| // |
Collaborator
There was a problem hiding this comment.
Isn't an empty line sufficient? The // line shouldn't be needed?
Contributor
Author
There was a problem hiding this comment.
@csyonghe no, I tried that when writing this PR and it didn't work; e.g. if you write this in source/slang/slang-ast-modifier.h:
#include "slang-ast-base.h"
#include "slang-ir-insts-enum.h"
#include "slang-ast-modifier.h.fiddle"then clang-format rewrites it as this:
#include "slang-ast-base.h"
#include "slang-ast-modifier.h.fiddle"
#include "slang-ir-insts-enum.h"which is incorrect.
This is because we use Regroup for the IncludeBlocks setting:
Lines 8 to 10 in 2d23a96
Your suggestion would work if we were using IncludeBlocks: Preserve, but the // lines here make that unnecessary.
expipiplus1
approved these changes
Aug 18, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 18, 2025
Similar to #7887, this PR improves the Fiddle docs a bit by showing how the `FIDDLE TEMPLATE` example would actually need to include `FIDDLE END` at some point after `FIDDLE OUTPUT`.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The documentation added by #6844 included instructions to make sure that the Fiddle
#includein a file comes after all the other#includes, but it's easy to accidentally violate this viaclang-format, as happened forsource/slang/slang-ast-modifier.hin #7559. This PR guards against this sort of violation by separating all Fiddle#includes from other#includes via a blank line followed by a//line (as we already do in most cases), and also adds a sentence about this intools/slang-fiddle/README.md.As a bonus, I also enabled Markdown syntax highlighting for all the code blocks in that doc file.