[PATCH] D119162: [Pseudo] Token/TokenStream, PP directive parser.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 23 04:22:21 PST 2022
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.
Thanks!
================
Comment at: clang/include/clang/Tooling/Syntax/Pseudo/Token.h:81
+};
+static_assert(sizeof(Token) <= sizeof(char *) + 16, "Careful with layout!");
+llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Token &);
----------------
what's the purpose of this static_assert?
================
Comment at: clang/lib/Tooling/Syntax/Pseudo/Preprocess.cpp:60
+ while (Tok->Kind != tok::eof) {
+ while (StartsDirective()) {
+ PPStructure::Directive Directive;
----------------
hokein wrote:
> is there any special reason to use a nested while? it looks like we can replace with an `if`. -- in each iteration, we get a Chunk result (either a Code, or a Directive), something like below should probably work?
>
> ```
> while (Tok->Kind != tok::eof) {
> if (!StartsDirective()) {
> // handle Chunk::Code case
> continue;
> } else {
> // handle directive case.
> }
> }
> ```
>
>
this comment and the one blew seem to be ignored.
================
Comment at: clang/test/Syntax/lex.test:2
+// RUN: clang-pseudo -source %S/Inputs/example.c -print-source | FileCheck %s -check-prefix=SOURCE --strict-whitespace
+ SOURCE: int is_debug() {
+SOURCE-NEXT: #ifndef NDEBUG
----------------
looks like the `example.c` can be moved into this file
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119162/new/
https://reviews.llvm.org/D119162
More information about the cfe-commits
mailing list