Skip to content
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

document that clang-format may clobber javascript #19810

Merged
merged 3 commits into from
Jul 7, 2023
Merged

document that clang-format may clobber javascript #19810

merged 3 commits into from
Jul 7, 2023

Conversation

ad8e
Copy link
Contributor

@ad8e ad8e commented Jul 7, 2023

tone_generator.c failed to compile after running through clang-format, because => changed to = >. clang-format can be disabled by putting comments around it.

I did not build this .rst file, just formatted it manually, so the formatting may have some errors.

tone_generator.c failed to compile after running through clang-format, because => changed to = >. clang-format can be disabled by putting comments around it.
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Thats good to know.

I wonder if there is some way we can embed that in the macro itself? I would guess not.

@ad8e
Copy link
Contributor Author

ad8e commented Jul 7, 2023

Maybe! There's /* clang-format off */. That might fit somewhere in the macro. That would be a better solution if possible.

@ad8e
Copy link
Contributor Author

ad8e commented Jul 7, 2023

I found this while searching: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#whitespacesensitivemacros

WhitespaceSensitiveMacros (List of Strings)

    A vector of macros which are whitespace-sensitive and should not be touched.

    These are expected to be macros of the form:

    STRINGIZE(...)

Maybe it would work, maybe not.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 7, 2023

I found this while searching: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#whitespacesensitivemacros

WhitespaceSensitiveMacros (List of Strings)

    A vector of macros which are whitespace-sensitive and should not be touched.

    These are expected to be macros of the form:

    STRINGIZE(...)

Maybe it would work, maybe not.

Yes, I think that could work, but I think it also requires the modification of the .clang-format file for each project containing EM_ASM.

Shall we just land this change as-is for now, and followup with a recommendation to use WhitespaceSensitiveMacros as well if that works (we should add it to the emscripten .clang-format if it does).

@ad8e
Copy link
Contributor Author

ad8e commented Jul 7, 2023

I added WhitespaceSensitiveMacros: ['EM_ASM', 'EM_JS', 'EM_ASM_INT', 'EM_ASM_DOUBLE', 'EM_ASM_PTR', 'MAIN_THREAD_EM_ASM', 'MAIN_THREAD_EM_ASM_INT', 'MAIN_THREAD_EM_ASM_DOUBLE', 'MAIN_THREAD_EM_ASM_DOUBLE', 'MAIN_THREAD_ASYNC_EM_ASM'] to my .clang-format. Now the => survives, so this works. I like this more than needing to remember // clang-format off after every use.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 7, 2023

Great.. could you add that the doc too?

And maybe add it to our .clang-format here in this repo?

@sbc100 sbc100 enabled auto-merge (squash) July 7, 2023 21:20
@sbc100 sbc100 merged commit 75fc6cd into emscripten-core:main Jul 7, 2023
@ad8e ad8e deleted the patch-1 branch July 7, 2023 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants