[PATCH] D101192: Add support for #elifdef and #elifndef
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 23 12:19:27 PDT 2021
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall, mibintc, erichkeane.
Herald added subscribers: dexonsmith, arphaman, kbarton, nemanjai.
aaron.ballman requested review of this revision.
Herald added a project: clang.
WG14 adopted N2645 and WG21 EWG has accepted P2334 <https://reviews.llvm.org/P2334> in principle (still subject to full EWG vote + CWG review + plenary vote), which add support for `#elifdef` as shorthand for `#elif defined` and `#elifndef` as shorthand for `#elif !defined`. This patch adds support for the new preprocessor directives.
In this version of the patch, I am supporting the feature in all C and C++ modes. This seems like more useful functionality than diagnosing an unknown preprocessor directive in older language modes, and is a conforming extension in those modes anyway as use of an unknown directive is undefined behavior. However, it was not clear to me whether we want to issue a pedantic warning for this or not or whether we felt it was important to document this behavior explicitly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101192
Files:
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
clang/include/clang/Lex/PPCallbacks.h
clang/include/clang/Lex/PPConditionalDirectiveRecord.h
clang/include/clang/Lex/PreprocessingRecord.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Index/IndexingAction.cpp
clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/PPConditionalDirectiveRecord.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PreprocessingRecord.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/Index/complete-preprocessor.m
clang/test/Preprocessor/elifdef.c
clang/test/Preprocessor/if_warning.c
clang/test/Preprocessor/ifdef-recover.c
clang/test/Preprocessor/macro_misc.c
clang/test/Preprocessor/macro_vaopt_check.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101192.340134.patch
Type: text/x-patch
Size: 24059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210423/1ce15948/attachment-0001.bin>
More information about the cfe-commits
mailing list