[PATCH] D106732: Support macro deprecation #pragma clang deprecated
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 29 04:08:22 PDT 2021
aaron.ballman added a comment.
In D106732#2911552 <https://reviews.llvm.org/D106732#2911552>, @beanz wrote:
> Covered taken #elif* directives per @aaron.ballmon's feedback.
Thanks!
> Handling non-taken #elif directives is non-trivial because clang skips parsing the conditionals for non-taken directives. At present clang won't even error on malformed #elif directives if an earlier branch is taken.
Yeah, that's what I was worried about. Can you add some FIXME comments into `Preprocessor::SkipExcludedConditionalBlock()` about wanting to diagnose this situation, and add some test cases with FIXME comments showing we know we don't handle this case perfectly yet?
> Also with this update I refactored the error emitting code out to a function on the Preprocessor, since it is just getting copy and pasted over and over again, and this change would have added another copy.
Thank you, that's a nice cleanup!
================
Comment at: clang/include/clang/Lex/Preprocessor.h:2409
+
+ void emitMacroExpansionWarnings(Token &Identifier);
+
----------------
================
Comment at: clang/lib/Lex/Preprocessor.cpp:1416
+void Preprocessor::emitMacroExpansionWarnings(Token &Identifier) {
+ if (Identifier.getIdentifierInfo()->isDeprecatedMacro()) {
----------------
================
Comment at: clang/test/Lexer/deprecate-macro.c:62
+
+// Test that we diagnose on #elif
+#if 0
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106732/new/
https://reviews.llvm.org/D106732
More information about the cfe-commits
mailing list