[PATCH] D72703: Add a warning, flags and pragmas to limit the number of pre-processor tokens in a translation unit

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 22 09:09:13 PST 2020


hans added a comment.

In D72703#1832678 <https://reviews.llvm.org/D72703#1832678>, @rnk wrote:

> I waited to see if there was any other feedback, but I'm in favor of this.
>
> Should we try to come up with better pragma names? `clang max_tokens` doesn't seem to call to mind what it does: warn if there have been more than this many tokens so far in the translation unit. `max_file_tokens` has to do with the number of tokens in the translation unit overall, but it uses the terminology "file" instead of "translation unit". The user could interpret that as being in the current source file, ignoring includes.


Thanks for thinking about the names. I agree they are not ideal.

> Some ideas for the immediate version:
> 
> - clang max_tokens_so_far
> - clang max_tokens_lexed
> - clang max_tokens_here

I went with max_tokens because it's shorter, and I figured maybe the "here" could be implicit as most things happen where the pragma is. But since we'll also have the per-tu variant, maybe it makes sense to have a longer name. Of your alternatives I like max_tokens_here best.

> Some ideas for end-of-tu:
> 
> - clang max_translation_unit_tokens
> - clang max_tu_tokens
> - clang global_max_tokens

I went with "file" because tu is such a technical term and I'm not sure we generally use it in clang's interface. What do you think about max_tokens_total?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72703/new/

https://reviews.llvm.org/D72703





More information about the cfe-commits mailing list