[PATCH] D55784: [clang-tidy] Update abseil-duration-comparison to handle macro arguments

Hyrum Wright via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 18 10:44:26 PST 2018


hwright added a comment.

@aaron.ballman I am both grateful and sad that I don't possess the same macro creativity as you do. :)

(I'm also sad that the various clang APIs aren't as well documented as I hoped.  The current solution works well, but it took a while and a bit of consultation with some other llvm'ers to get it right.)



================
Comment at: test/clang-tidy/abseil-duration-comparison.cpp:146
+#define VALUE_IF_2(e) (e)
+#define VALUE_IF(v, e, type) (v ? VALUE_IF_2(absl::To##type##Seconds(e)) : 0)
+  int a3 = VALUE_IF(1, d1, Double);
----------------
aaron.ballman wrote:
> What if this is changed to:
> ```
> #define VALUE_IF(v, e, type) (v ? (5 > VALUE_IF_2(absl::To##type##Seconds(e))) : 0)
> ```
This also doesn't transform.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55784/new/

https://reviews.llvm.org/D55784





More information about the cfe-commits mailing list