[PATCH] D121165: [pseudo] Add crude heuristics to choose taken preprocessor branches.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 7 14:35:18 PST 2022
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang.
In files where different preprocessing paths are possible, our goal is to
choose a preprocessed token sequence which we can parse that pins down as much
of the grammatical structure as possible.
This forms the "primary parse", and the not-taken branches get parsed later,
and are constrained to be compatible with the primary parse.
Concretely:
int x =
#ifdef // TAKEN
2 + 2 + 2 // determined during primary parse to be an expression
#else
2 // constrained to be an expression during a secondary parse
#endif
;
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121165
Files:
clang/include/clang/Tooling/Syntax/Pseudo/DirectiveMap.h
clang/include/clang/Tooling/Syntax/Pseudo/Token.h
clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp
clang/test/Syntax/lex.c
clang/tools/clang-pseudo/ClangPseudo.cpp
clang/unittests/Tooling/Syntax/Pseudo/DirectiveMapTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121165.413636.patch
Type: text/x-patch
Size: 13350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220307/619314e2/attachment-0001.bin>
More information about the cfe-commits
mailing list