[lldb] [libc] [compiler-rt] [libcxx] [llvm] [flang] [clang-tools-extra] [clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
AaronBallman wrote: > @AaronBallman Can you describe your current plan how driver options are going > to behave in the light of `#embed`? I'm flexible with how we proceed, so if others have different ideas, feel free to suggest them! But my initial inclination is: * `--embed-dir=` as a way to specify a search path for `<>` and `""` embedded resources; the quoted form will search the current directory similar to how it behaves for `#include`. I do not envision needing a "system" embedded resources directory, but should such a need arise, we can consider something like `--embed-system=` to support it. * `-E -dE` as a way to preprocess to a file without exploding the contents of the embedded resource into the preprocessed output (that output could become very large). Then the options for determining makefile dependencies can be updated to consider embedded resources are a dependency and tools like distcc can hopefully cope from there. * As a follow-up, I might consider adding a directive `#embed_base64` that holds base64 encoded file contents of the resource to be embedded. Then we can add `-E -dE64` (or some other option name) to preprocess from `#embed ` to `#embed_base64 ` for times when it's not plausible to keep the source and the resource separately. I don't envision that being a directive users would use directly, but instead only for rewriting purposes. Ideally, GCC and Clang can agree on what and how we surface the command line features. https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [llvm] [lldb] [libcxx] [flang] [libc] [clang-tools-extra] [clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
Endilll wrote: @AaronBallman Can you describe your current plan how driver options are going to behave in the light of `#embed`? https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
AaronBallman wrote: > @AaronBallman, hope the WG14 meeting went well? I've essentially done what I > planned to do here, so I was wondering if you're ready to take it from here? > I can try to incorporate the review feedback myself, but it's quite likely > I'd make a mess of it (not familiar with the clang code base at all). Thank you! I hope to pick this up soon-ish (I'm still trying to dig out from under my review backlog at the moment). I'm hoping to have time to dedicate to it so this gets in before the holiday season. As a backup plan, @Fznamznon is also willing to help out if I'm not able to get to it soon enough, but she's currently working on constexpr issues. So this is staying hot on my radar, but it may be a month+ before it gets picked up due to other pressures. https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
h-vetinari wrote: @AaronBallman, hope the WG14 meeting went well? I've essentially done what I planned to do here, so I was wondering if you're ready to take it from here? I can try to incorporate the review feedback myself, but it's quite likely I'd make a mess of it (not familiar with the clang code base at all). https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
@@ -816,6 +821,14 @@ will be ignored}]>; def L : JoinedOrSeparate<["-"], "L">, Flags<[RenderJoined]>, Group, Visibility<[ClangOption, FlangOption]>, MetaVarName<"">, HelpText<"Add directory to library search path">; +def embed_dir : JoinedOrSeparate<["-"], "embed-dir">, +Flags<[RenderJoined]>, Group, +Visibility<[ClangOption, CC1Option, CC1AsOption, FlangOption, FC1Option]>, +MetaVarName<"">, HelpText<"Add directory to embed search path">; +def embed_dir_EQ : JoinedOrSeparate<["-"], "embed-dir=">, MaskRay wrote: `-e` is a driver option, so `-eembed-dir-with-typo` is recognized. Better to use `--embed-dir=`. Please don't support `*Separate<...>` for new options. https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
h-vetinari wrote: JeanHeyd wrote up a [blog post](https://thephd.dev/implementing-embed-c-and-c++) about this implementation, which is probably helpful as background material for any prospective reviewers. :) https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
https://github.com/ThePhD edited https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
h-vetinari wrote: OK, I've got a first rebase going. However, because iterating on a diff with 1000s of lines is extremely hard to review and bound to lead to mistakes and iterations (making it harder still to follow what's going on), I've tried to follow a more structured approach. Basically, I've pushed tags for intermediate milestones during the rebase to my fork, and am documenting below what I've done. That should make it easier to: * understand how the diff evolved * make comparisons between the various different stages (e.g. one can add `/compare/..` on Github) * roll back to intermediate iterations if something goes wrong, without having to start from scratch * validate what I did (for those so inclined) or branch off in a different direction I've used a simple tag scheme `embed_vX[.Y]`, where X increases if exisiting commits were changed, and Y increases if changes happened without rebasing. I did some basic compilation tests to ensure I didn't accidentally drop/introduce changes that break the build, but no more than that. The table is probably busted visually on mobile (sorry...), but I hope it reads alright on a desktop. Where used, equality (`==`) refers to the content of the tree at the commits being compared, not the diffs in those commits. | tag | description | steps to reproduce | compile-tested[^1] | diff toprev. version | |-|-|-|-|-| | [`embed_v0`](https://github.com/h-vetinari/llvm-project/commits/embed_v0) | the state of the PRas opened originally(base 08b20d838549e8ff3939c6793b5067b0d9b36337) | check out [this](https://github.com/ThePhD/llvm-project/tree/thephd/embed-speed) | 32c8097f983a65526516353082268f50a017e27d ✅ (presumably)357bda5d13594bbb47f8a76c935fd6aacbf2f67a ❌ (needs adc973776a526f97b6da2435edf143a10e7e0ad5)dfd638311acb61bab8113c41ddf138199b360dfa ❌adc973776a526f97b6da2435edf143a10e7e0ad5 ✅ | | [`embed_v1`](https://github.com/h-vetinari/llvm-project/commits/embed_v1) | separated superfluousformatting changesfrom first 2 commits(base 08b20d838549e8ff3939c6793b5067b0d9b36337) | Interactive rebase galore(the most painful part) | 0b4b6a654edf6fa2781e1c80983c124a0d0088c5 ✅a05117d39e372e0360655b5da2101f8296bfe5fb ✅ (==v0:[`32c8097`](https://github.com/llvm/llvm-project/commit/32c8097f983a65526516353082268f50a017e27d))8231b72fbe322bef74bba8177a6bc64754b5cede ❌ (needs 36c1a5f04a61dff60d8326906a42c4bf8fdde2f9)0a6f48bbb00552b92401476871386f53cac83512 ❌ (==v0:[`357bda5`](https://github.com/llvm/llvm-project/commit/357bda5d13594bbb47f8a76c935fd6aacbf2f67a))b356860919bd186bf2c340a545e6924dbd9decf0 ❌ (==v0:[`dfd6383`](https://github.com/llvm/llvm-project/commit/dfd638311acb61bab8113c41ddf138199b360dfa))36c1a5f04a61dff60d8326906a42c4bf8fdde2f9 ✅ (==v0:[`adc9737`](https://github.com/llvm/llvm-project/commit/adc973776a526f97b6da2435edf143a10e7e0ad5)) | [empty](https://github.com/h-vetinari/llvm-project/compare/embed_v0..embed_v1) | | [`embed_v1.1`](https://github.com/h-vetinari/llvm-project/commits/embed_v1.1) | added [suggestions](https://github.com/llvm/llvm-project/pull/68620#issuecomment-1753515605) from`git-clang-format`(base 08b20d838549e8ff3939c6793b5067b0d9b36337) | C + `git apply` | v1 + 26c6fcc8d9a85519a4b1d98aa8a0d11fd725855b ✅ | 1 commit;no rebase | | [`embed_v2`](https://github.com/h-vetinari/llvm-project/commits/embed_v2) | undo superfluousformatting changes(base 08b20d838549e8ff3939c6793b5067b0d9b36337) | `git rebase -i ...`; dropa05117d39e372e0360655b5da2101f8296bfe5fb & 0a6f48bbb00552b92401476871386f53cac83512, fixminor conflicts in 26c6fcc8d9a85519a4b1d98aa8a0d11fd725855b | 0b4b6a654edf6fa2781e1c80983c124a0d0088c5 ✅ (same as v1)07795f280fe6727f76fac5028bd5cbe3bc82a662 ❌ (needs 748c3b54e2e3b00d8c7c1a6813886e3f338ae0d4)1179116dac7ccc37a38cb8ae2b37a15f994ebdf5 ❌748c3b54e2e3b00d8c7c1a6813886e3f338ae0d4 ✅ (likely; untested) b6d053e62a8ea9c88c2bd7ffe0e02e75c7abcc0a ✅ | [uninteresting](https://github.com/h-vetinari/llvm-project/compare/embed_v1.1..embed_v2) | | [`embed_v3`](https://github.com/h-vetinari/llvm-project/commits/embed_v3) | squash small commits(base 08b20d838549e8ff3939c6793b5067b0d9b36337) | `git rebase -i ...`; squash | 0b4b6a654edf6fa2781e1c80983c124a0d0088c5 ✅ (same as v1)a6f134d30f0007efa339fd434ac109749c30bb11 ✅ | [empty](https://github.com/h-vetinari/llvm-project/compare/embed_v2..embed_v3) | | [`embed_v4`](https://github.com/h-vetinari/llvm-project/commits/embed_v4) | rebase (cleanly) on main(base 7060422265902f11a13f785a1a0ba246eff96114) | `git rebase -i ...` | 7050c932f63f9cb9e94636b287887f8241083117 ❔ (untested) 5956fc215c905fa8520ded8368ceb6b1fab1f996 ❔ (untested) | [uninteresting](https://github.com/h-vetinari/llvm-project/compare/embed_v3..embed_v4) | Since the rebase from v3 to v4 went cleanly, I haven't run the compilation tests. I will push v4 now, and hope that this is a good enough jumping off point for further review and iteration. [^1]: `cmake -G Ninja
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
h-vetinari wrote: > @h-vetinari -- would you mind doing some initial cleanup on the patch for > things like rebasing, removing spurious formatting changes, naming, and the > likes? I'll try to do that! https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
AaronBallman wrote: > > > Because I don't know of any better way to commandeer a patch in GitHub > > > > > > As a maintainer, you can push into this branch > > I had reached out to @ThePhD with an offer to help on this before they opened > this PR, and I now have push access to their fork, which means I could change > the state of this PR. > > To be clear, I cannot offer to defend the content (semantically) in the face > of review, but - if desired - I'd be happy to help with some more routine > operations like rebasing, formatting, or chopping off pieces into separate > PRs (all while keeping @ThePhD's authorship, of course). Oh, that's excellent! @ThePhD also gave me push access to his repo. If we're going to tag-team efforts on this and we both have access, it probably makes sense to just leave it in his repo and work from there. If he finds the notifications too distracting, we can always move the work elsewhere at that point. @h-vetinari -- would you mind doing some initial cleanup on the patch for things like rebasing, removing spurious formatting changes, naming, and the likes? I have WG14 meetings coming up next week (they should hopefully go quickly though), so it is likely going to be ~a week before I have the chance to work on this more heavily. > So just to clarify, we should wait till you post a follow-up review before > commenting, to avoid fragmenting the discussion. Given the above, I'd say we can keep the review going here. https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
h-vetinari wrote: > > Because I don't know of any better way to commandeer a patch in GitHub > > As a maintainer, you can push into this branch I had reached out to @ThePhD with an offer to help on this before they opened this PR, and I now have push access to their fork, which means I could change the state of this PR. To be clear, I cannot offer to defend the content (semantically) in the face of review, but - if desired - I'd be happy to help with some more routine operations like rebasing, formatting, or chopping off pieces into separate PRs (all while keeping @ThePhD's authorship, of course). https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
shafik wrote: > FWIW, I spoke offline with the original author of the PR and he said that > he's fine with me picking up the changes and carrying the review forward. > > Because I don't know of any better way to commandeer a patch in GitHub, I'll > probably grab the changes, get them into my own fork, and then recreate the > PR to get the review started. Whenever we get ready to land the PR, @ThePhD > will be credited as a co-author. So just to clarify, we should wait till you post a follow-up review before commenting, to avoid fragmenting the discussion. https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
jyknight wrote: > This pull request implements the entirety of the now-accepted N3017 - > Preprocessor Embed. Amazing! I had started to think about looking into getting this implemented recently, so it's really nice to see an implementation uploaded now! > I have no intention of following up on this PR. I am too tired to carry it to > fruition. Pick this apart, take from it what you want, or reimplement it > entirely. I'm very sorry to hear that, but thank you for the contribution regardless! https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
h-vetinari wrote: > Because I don't know of any better way to commandeer a patch in GitHub As a maintainer, you can push into this branch (unless @ThePhD unchecked the default setting when creating the PR), including forcefully. For example (you could also use the github CLI, but I'm using vanilla git to demo): ``` git remote add ThePhD https://github.com/ThePhD/llvm-project git fetch ThePhD git checkout thephd/embed-speed # git will tell you you've got this branch, tracking the ThePhD remote # do changes git push ThePhD # add `-f` if you've modified the existing commits, e.g. via rebase ``` https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
AaronBallman wrote: FWIW, I spoke offline with the original author of the PR and he said that he's fine with me picking up the changes and carrying the review forward. Because I don't know of any better way to commandeer a patch in GitHub, I'll probably grab the changes, get them into my own fork, and then recreate the PR to get the review started. Whenever we get ready to land the PR, @ThePhD will be credited as a co-author. https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
@@ -1464,6 +1467,21 @@ class AnnotatingParser { } } + void parseEmbedDirective() { +if (CurrentToken && CurrentToken->is(tok::less)) { + next(); + while (CurrentToken) { +// Mark tokens up to the trailing line comments as implicit string +// literals. +if (CurrentToken->isNot(tok::comment) && +!CurrentToken->TokenText.startswith("//")) { + CurrentToken->setType(TT_ImplicitStringLiteral); workingjubilee wrote: just fyi > I have no intention of following up on this PR. I am too tired to carry it to > fruition. Pick this apart, take from it what you want, or reimplement it > entirely. (I will be unsubscribing from this immediately after posting.) so the "you" you are addressing might indeed be *you*. https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
@@ -1464,6 +1467,21 @@ class AnnotatingParser { } } + void parseEmbedDirective() { +if (CurrentToken && CurrentToken->is(tok::less)) { + next(); + while (CurrentToken) { +// Mark tokens up to the trailing line comments as implicit string +// literals. +if (CurrentToken->isNot(tok::comment) && +!CurrentToken->TokenText.startswith("//")) { + CurrentToken->setType(TT_ImplicitStringLiteral); HazardyKnusperkeks wrote: Can you please add tests in `TokenAnnotatorTest.cpp`? https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
@@ -1500,6 +1518,14 @@ class AnnotatingParser { next(); // ')' } + void parseHasEmbed() { +if (!CurrentToken || CurrentToken->isNot(tok::l_paren)) + return; +next(); // '(' +parseEmbedDirective(); +next(); // ')' HazardyKnusperkeks wrote: What if it isn't a `r_paren`? https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
@@ -1464,6 +1467,21 @@ class AnnotatingParser { } } + void parseEmbedDirective() { +if (CurrentToken && CurrentToken->is(tok::less)) { + next(); + while (CurrentToken) { +// Mark tokens up to the trailing line comments as implicit string +// literals. +if (CurrentToken->isNot(tok::comment) && +!CurrentToken->TokenText.startswith("//")) { + CurrentToken->setType(TT_ImplicitStringLiteral); HazardyKnusperkeks wrote: ```suggestion CurrentToken->setFinalizedType(TT_ImplicitStringLiteral); ``` https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 67b675ee55cce183b93874a38ab94eee00aedbcc adc973776a526f97b6da2435edf143a10e7e0ad5 -- clang/include/clang/Lex/PPDirectiveParameter.h clang/include/clang/Lex/PPEmbedParameters.h clang/test/Preprocessor/embed___has_embed.c clang/test/Preprocessor/embed___has_embed_supported.c clang/test/Preprocessor/embed_art.c clang/test/Preprocessor/embed_feature_test.cpp clang/test/Preprocessor/embed_file_not_found.c clang/test/Preprocessor/embed_init.c clang/test/Preprocessor/embed_parameter_if_empty.c clang/test/Preprocessor/embed_parameter_limit.c clang/test/Preprocessor/embed_parameter_offset.c clang/test/Preprocessor/embed_parameter_prefix.c clang/test/Preprocessor/embed_parameter_suffix.c clang/test/Preprocessor/embed_parameter_unrecognized.c clang/test/Preprocessor/embed_path_chevron.c clang/test/Preprocessor/embed_path_quote.c clang/test/Preprocessor/embed_single_entity.c clang/test/Preprocessor/embed_weird.cpp clang/include/clang/AST/Expr.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/FileManager.h clang/include/clang/Frontend/PreprocessorOutputOptions.h clang/include/clang/Lex/PPCallbacks.h clang/include/clang/Lex/Preprocessor.h clang/include/clang/Lex/PreprocessorOptions.h clang/include/clang/Lex/Token.h clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/Expr.cpp clang/lib/AST/ExprClassification.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/FileManager.cpp clang/lib/Basic/IdentifierTable.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Format/FormatToken.h clang/lib/Format/TokenAnnotator.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/DependencyFile.cpp clang/lib/Frontend/DependencyGraph.cpp clang/lib/Frontend/InitPreprocessor.cpp clang/lib/Frontend/PrintPreprocessedOutput.cpp clang/lib/Frontend/Rewrite/InclusionRewriter.cpp clang/lib/Interpreter/Interpreter.cpp clang/lib/Lex/Lexer.cpp clang/lib/Lex/PPCallbacks.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPExpressions.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Parse/ParseDeclCXX.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseInit.cpp clang/lib/Parse/ParseTemplate.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExceptionSpec.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/lib/StaticAnalyzer/Core/ExprEngine.cpp llvm/include/llvm/Support/Base64.h `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 9303307fd..d3fba205c 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -4818,14 +4818,13 @@ public: FoundOne, Expanded, }; - - PPEmbedExpr(const ASTContext , QualType ResultTy, StringLiteral* Filename, StringLiteral* BinaryData, -SourceLocation BLoc, SourceLocation RParenLoc, -DeclContext *Context); + + PPEmbedExpr(const ASTContext , QualType ResultTy, StringLiteral *Filename, + StringLiteral *BinaryData, SourceLocation BLoc, + SourceLocation RParenLoc, DeclContext *Context); /// Build an empty call expression. - explicit PPEmbedExpr(EmptyShell Empty) - : Expr(SourceLocExprClass, Empty) {} + explicit PPEmbedExpr(EmptyShell Empty) : Expr(SourceLocExprClass, Empty) {} /// If the PPEmbedExpr has been resolved return the subexpression /// representing the resolved value. Otherwise return null. diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index c757f8775..cbfcb2927 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -282,8 +282,9 @@ public: getBufferForFile(StringRef Filename, bool isVolatile = false, bool RequiresNullTerminator = true, std::optional MaybeLimit = std::nullopt) { -return getBufferForFileImpl(Filename, /*FileSize=*/(MaybeLimit ? *MaybeLimit : -1), isVolatile, -RequiresNullTerminator); +return getBufferForFileImpl(Filename, +/*FileSize=*/(MaybeLimit ? *MaybeLimit : -1), +isVolatile, RequiresNullTerminator); } private: diff --git a/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/clang/include/clang/Frontend/PreprocessorOutputOptions.h index 3e36db3f8..0bc32c65a 100644 ---
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
llvmbot wrote: @llvm/pr-subscribers-llvm-support Changes This pull request implements the entirety of the now-accepted [N3017 - Preprocessor Embed](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3017.htm) and its sister C++ paper [p1967](https://wg21.link/p1967). It implements everything in the specification, and includes an implementation that drastically improves the time it takes to embed data in specific scenarios (the initialization of character type arrays). The mechanisms used to do this are used under the "as-if" rule, and in general when the system cannot detect it is initializing an array object in a variable declaration, will simply expand the list out to a sequence of numbers. There are likely places where the `__builtin_pp_embed` intrinsic fails to compile properly and triggers ICEs. However, we have covered what we feel are the vast majority of cases where users would want or need the speedup. Images are a dry run of a recently built clang and LLVM on Release mode (not RelWithDebInfo) on Windows, under the following properties: OS Name: Microsoft Windows 10 Pro Version: 10.0.19045 Build 19045 System Type: x64-based PC Processor: AMD Ryzen 9 5950X 16-Core Processor, 3401 Mhz, 16 Core(s), 32 Logical Processor(s) Installed Physical Memory (RAM): 32.0 GB Total Physical Memory: 31.9 GB Total Virtual Memory: 36.7 GB All of the added tests pass under the above machine properties. I have no intention of following up on this PR. I am too tired to carry it to fruition. Pick this apart, take from it what you want, or reimplement it entirely. (I will be unsubscribing from this immediately after posting.) Good luck ✌! ![1](https://github.com/llvm/llvm-project/assets/2886436/3b1c2d1d-4db5-49d1-a8d6-0d07492ee4b1) ![2](https://github.com/llvm/llvm-project/assets/2886436/d9150d42-5b73-413e-927d-e1cd1de5bfce) ![3](https://github.com/llvm/llvm-project/assets/2886436/e0fa380e-7433-4fe9-9185-c9bec33ae41d) ![4](https://github.com/llvm/llvm-project/assets/2886436/f59f7758-29c3-4646-9e50-1871b2fbcd2f) --- Patch is 1.33 MiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/68620.diff 82 Files Affected: - (modified) clang/CMakeLists.txt (+2-1) - (modified) clang/include/clang/AST/Expr.h (+52) - (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+1) - (modified) clang/include/clang/Basic/Builtins.def (+3) - (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (+6) - (modified) clang/include/clang/Basic/DiagnosticGroups.td (+7) - (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (+23-1) - (modified) clang/include/clang/Basic/FileManager.h (+5-3) - (modified) clang/include/clang/Basic/StmtNodes.td (+1) - (modified) clang/include/clang/Basic/TokenKinds.def (+5) - (modified) clang/include/clang/Driver/Options.td (+16) - (modified) clang/include/clang/Frontend/PreprocessorOutputOptions.h (+2) - (modified) clang/include/clang/Lex/PPCallbacks.h (+118-82) - (added) clang/include/clang/Lex/PPDirectiveParameter.h (+32) - (added) clang/include/clang/Lex/PPEmbedParameters.h (+78) - (modified) clang/include/clang/Lex/Preprocessor.h (+191-128) - (modified) clang/include/clang/Lex/PreprocessorOptions.h (+7) - (modified) clang/include/clang/Lex/Token.h (+1-1) - (modified) clang/include/clang/Sema/Sema.h (+1124-1441) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3) - (modified) clang/lib/AST/Expr.cpp (+17) - (modified) clang/lib/AST/ExprClassification.cpp (+4) - (modified) clang/lib/AST/ExprConstant.cpp (+8) - (modified) clang/lib/AST/ItaniumMangle.cpp (+1) - (modified) clang/lib/AST/StmtPrinter.cpp (+7) - (modified) clang/lib/AST/StmtProfile.cpp (+4) - (modified) clang/lib/Basic/FileManager.cpp (+41-35) - (modified) clang/lib/Basic/IdentifierTable.cpp (+2-1) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+4-1) - (modified) clang/lib/Format/FormatToken.h (+2) - (modified) clang/lib/Format/TokenAnnotator.cpp (+28) - (modified) clang/lib/Frontend/CompilerInvocation.cpp (+21) - (modified) clang/lib/Frontend/DependencyFile.cpp (+29) - (modified) clang/lib/Frontend/DependencyGraph.cpp (+51-15) - (modified) clang/lib/Frontend/InitPreprocessor.cpp (+7) - (modified) clang/lib/Frontend/PrintPreprocessedOutput.cpp (+50-32) - (modified) clang/lib/Frontend/Rewrite/InclusionRewriter.cpp (+98-85) - (modified) clang/lib/Interpreter/Interpreter.cpp (+1) - (modified) clang/lib/Lex/Lexer.cpp (+8) - (modified) clang/lib/Lex/PPCallbacks.cpp (-11) - (modified) clang/lib/Lex/PPDirectives.cpp (+942-174) - (modified) clang/lib/Lex/PPExpressions.cpp (+137-88) - (modified) clang/lib/Lex/PPMacroExpansion.cpp (+124) - (modified) clang/lib/Lex/Preprocessor.cpp (+3-2) - (modified) clang/lib/Parse/ParseDeclCXX.cpp (-1) - (modified) clang/lib/Parse/ParseExpr.cpp (+361-308) - (modified) clang/lib/Parse/ParseInit.cpp (+3-3) - (modified) clang/lib/Parse/ParseTemplate.cpp (+2) - (modified)
[clang] [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
https://github.com/ThePhD edited https://github.com/llvm/llvm-project/pull/68620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits