[PATCH] D54349: [clang-tidy] new check 'readability-redundant-preprocessor'

Miklos Vajna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 11 05:24:31 PST 2018


vmiklos marked an inline comment as done.
vmiklos added a comment.

> As it stands, I feel like this check is a bit too simplistic to have much value, but if you covered some of these other cases, it would alleviate that worry for me.

I've now added support for detecting inverted conditions when it comes to `#ifdef` and `#ifndef` (see extended documentation and testcases). I'll also check what can I do for `#if`. I think it would not be too hard to detect just repeated conditions. if I have the full range, then I can look for end of the first line that does not end with `\`, and that would be a poor man's way to get the `#if` condition. Let's see if that works in practice.



================
Comment at: clang-tidy/readability/RedundantPreprocessorCheck.cpp:19-22
+struct Entry {
+  SourceLocation Loc;
+  std::string MacroName;
+};
----------------
Szelethus wrote:
> vmiklos wrote:
> > Szelethus wrote:
> > > This is a way too general name in my opinion. Either include comments that describe it, or rename it (preferably both).
> > Renamed to `PreprocessorCondition`, hope it helps. :-)
> I actually meant it for `Entry`, if you hover your mouse over an inline comment, you can see which lines it applies to. Sorry for the confusing communication :D
Done now. Nah, it's more about I'm not so fluent with phabricator. :-)


https://reviews.llvm.org/D54349





More information about the cfe-commits mailing list