[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

George Burgess IV via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 2 12:50:51 PDT 2018


george.burgess.iv added inline comments.


================
Comment at: clang-tidy/bugprone/ComparisonInTempFailureRetryCheck.cpp:78
+
+  diag(RHS.getOperatorLoc(),
+       "Top-level comparisons should be moved out of TEMP_FAILURE_RETRY");
----------------
JonasToth wrote:
> You could even provide a fixit to do this. But this can be done in later patches, too.
I initially tried this, but a complete solution appears to be nontrivial when nested macros start to happen. Added a FIXME nonetheless. :)


================
Comment at: test/clang-tidy/bugprone-comparison-in-temp-failure-retry.c:1
+// RUN: %check_clang_tidy %s bugprone-comparison-in-temp-failure-retry %t
+
----------------
JonasToth wrote:
> Could you please add a test with control structures, like loops you used in your example?
Added the `control_flow` function


================
Comment at: test/clang-tidy/bugprone-comparison-in-temp-failure-retry.c:5
+  ({                                                                           \
+    typeof(x) __z;                                                             \
+    do                                                                         \
----------------
JonasToth wrote:
> I think you could add one test, that shows using `long int` instead of `typeof` is diagnosed, given glibc uses this approach (or even copy there macro)
Added a variant with `long int` near the bottom.


https://reviews.llvm.org/D45059





More information about the cfe-commits mailing list