-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 for src/analysis #59691
base: master
Are you sure you want to change the base?
Conversation
71e05d3
to
11fbc01
Compare
11fbc01
to
0a940ed
Compare
This reverts commit 0fe88cf945fd2da710453e2a55a4cdc4e2f82802.
0a940ed
to
c6e6e3c
Compare
This is ready for review and I would like to avoid waiting too long for a merge since rebasing is not funny :) |
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
Not the case for all files it seems, see qgsprocessingparameter for instance. Is it intentionnal ?
That mean that we would have a macro also for MappedType/ConvertFromTypeCode/End/ConvertToTypeCode see qgsattributes. ? I'm not sure about commenting them either as it is IMHO a little bit error prone. Comment followed with % would become SIP instruction and other comment would stay a comment. can we not disable clang-format around given lines like with clang-tidy? |
in this case, the whole TypeHeaderCode is manually generated. This can be switched indeed (I'd prefer leaving this for a follow-up).
indeed, probably a macro
indeed, that's why I plan to move these as macros. But for the sake of simplicity while we still have astyle running on some part of the code, I would keep the comments for now.
no, at least I failed at it. It's not really the formatting of these lines which are problematic but rather what happens after. The following method after a directive are not correctly formatted. In general clang-format seems a bit more picky than astyle and it's not super tolerant with our macros and injected sip code. |
This doesn't work ? |
No. It works for the line in question, but messes up the following |
I'm not in favor of altering sip code either with comment or macros, it makes the whole thing even less readable IMHO. Most of sip code (all?) should not live in header file, it should be in different file included on the fly by sipify, but that's another story. I won't block this PR but I'd rather wait for another contributor opinion. |
We already had to do this for QGIS/src/core/qgstemporalcontroller.h Line 46 in 390ac14
So basically the same, but I get your point of altering the code.
I tend to find it useful to read the expected behavior in a single place, but that's debatable.
Thanks for the feedback, let's wait for more opinions :) |
I'm +1 to this -- I think the choices here look like good pragmatic solutions to a problem which does not have an ideal answer. Regarding:
I'm personally in favour of this code living in the headers. It makes it really obvious when you're editing c++ classes what extra logic is involved in Python. If we siloed it away in a different place then it's very prone to bit rotting/getting out of sync. |
Here are the changes brought to allow using clang-format alongside with our sip code:
TypeHeaderCode
is now achieved by usingSIP_TYPEHEADER_INCLUDE
%MethodCode
and other directives are now commented (I think I would move them to using a macroSIP_MethodCode
when the whole code base has already been moved to clang-format)SIP_SKIP
should be placed before the definition of a method in the header (otherwise it's moved to next line by clang-format)