Repository navigation
mccode-clangformat: keep preprocessor lines intact - #3124
Merged
Merged
Conversation
Replace %/# lines (and their continuation lines) by short placeholders before running clang-format, so long macros are never reflowed or split. Continuation lines keep their indent relative to the directive. Fixes #3123 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Free-form text area
Fixes #3123.
mccode-clangformathid%/#lines from clang-format by turning them into//comments. clang-format wraps comments longer thanColumnLimit(160), so long one-line macros were split. In the Union dispatch macros this movedbreak;out of the macro (found in #3095).The script now replaces each
%/#line, plus its\continuation lines, by a short placeholder comment. clang-format still sets the placeholder's indent, and the original text is put back unchanged. Continuation lines keep their indent relative to the directive, so they no longer move 2 columns right on every run.Changing
.clang-formatinstead (ReflowComments: false/IndentOnly) also fixed the macros, but reformatted many unrelated files.Tests (clang-format 23.1.4, run over copies of all
mcstas-compsandmcxtrace-comps.comp/.instrfiles):IncoherentPhonon_process.compandInhomogenous_incoherent_process.comp.Elliptic_guide_gravity.comp(\-continued string literal) andIsotropic_Sqw.comp(MPI_MASTER(block) still change because they are not preprocessor lines. This PR leaves them as they are.The script only runs on developer machines, and this PR changes no component code.
Declaration of use of AI-tools
Development OS / boundary conditions
macOS (arm64), clang-format 23.1.4 from the conda
mccode-devenvironment. Not tested with older clang-format versions, Linux or Windows.PR Checklist for contributing to McStas/McXtrace
My PR is meant to fix a specific, existing issue
My contribution contains something else
🤖 Generated with Claude Code