klimek added a comment.



================
Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:438-440
@@ +437,5 @@
+  int Count[2] = {0, 0};
+  // Sit[1][0] will tell if there exists any range that is covered by the
+  // first set but not by the second one, Sit[1][1] will tell if there is a
+  // range covered by both sets, etc.
+  bool Sit[2][2] = {{false, false}, {false, false}};
----------------
The description makes it unclear whether the indices stand for the set, or the 
dimensions stand for the sets (I can see it's the dimensions from where it is 
set, and that the indices are bools, but that's unclear without that / hard to 
grasp).
Here's a slightly denormalized way, that uses early-exit and might be easier to 
understand (more opinions would be nice, though).
(note that I probably messed up the FirstInsideSecond setting somewhere :)

  bool Overlaps = false;
  bool FirstInsideSecond = false;

  // In the loop:
  if (Count[0] != 0 && Count[1] != 0) {
    Overlaps = true;
  } else if (Overlaps && ((Count[0] != 0 && FirstInsideSecond) ||
                          (Count[1] != 0 && !FirstInsideSecond)) {
    return OK_Overlap;
  } else if (Count[0] != 0 || Count[1] != 0) {
    FirstInsideSecond = Count[1] != 0;
  }

  // After the loop:
  if (!Overlaps)
    return OK_Disjoint;
  return FirstInsideSecond ? OK_FirstInsideSecond : OK_SecondInsideFirst;



http://reviews.llvm.org/D13516



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to