[clang-tools-extra] [libcxx] [libc] [llvm] [lldb] [compiler-rt] [clang] [flang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 05:16:02 PST 2023


AaronBallman wrote:

> I guess I'd consider the "mental model" here to be that (notionally) `#embed` is preprocessed by expanding to `#embed_base64`, which is handled by the compiler proper, not the preprocessor. Yes, that's not entirely true in the implementation, but it seems like a reasonable way to think about it. (similar in feel to `#pragma` which is also not purely preprocessor, despite starting with `#`.)

I don't see `#pragma` as being similar -- there is no sequence of preprocessed tokens to emit for a pragma, but there is for `#embed`. In fact, it is described specifically in terms of expansion (6.10.3p7):

> The expansion of a #embed directive is a token sequence formed from the list of integer constant
expressions described below. The group of tokens for each integer constant expression in the list
is separated in the token sequence from the group of tokens for the previous integer constant
expression in the list by a comma. The sequence neither begins nor ends in a comma. If the list of
integer constant expressions is empty, the token sequence is empty. The directive is replaced by its
expansion and, with the presence of certain embed parameters, additional or replacement token
sequences.

So it's not so much that it's not actually true in the implementation details, it's that it's not actually true by specification either.

https://github.com/llvm/llvm-project/pull/68620


More information about the cfe-commits mailing list