[PATCH] D117522: [clang-tidy] Add modernize-macro-to-enum check
Richard via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 19 07:52:03 PST 2022
LegalizeAdulthood added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:182
+ MD->getMacroInfo()->isUsedForHeaderGuard() ||
+ MD->getMacroInfo()->isBuiltinMacro() || ConditionScope > 0)
+ return;
----------------
LegalizeAdulthood wrote:
> LegalizeAdulthood wrote:
> > njames93 wrote:
> > > This `ConditionScope` checks looks like it would prevent warning in header files that use a header guard(instead of pragma once) to prevent multiple inclusion.
> > Oh, good catch, you're probably right. I'll test that manually.
> >
> > (Gee, another case where we need `check_clang_tidy.py` to validate
> > changes to header files! This keeps coming up! My implementation
> > of this from several years ago died in review hell and was never born.)
> Any ideas for an algorithm that detects a header guard condition
> from some other condition? I don't see anything obvious.
So I created a little state machine and that covers my test cases,
but I worry that it might be too fragile, so I'm open to suggestions
for improvement on my state machine algorithm and/or test cases
that could break the algorithm.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117522/new/
https://reviews.llvm.org/D117522
More information about the cfe-commits
mailing list