[PATCH] D22982: [CloneDetector] No longer reporting clones that don't have a common referenced variable pattern.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 03:46:20 PDT 2016


NoQ added a comment.

Looks good, minor comments :)


================
Comment at: lib/Analysis/CloneDetection.cpp:99
@@ +98,3 @@
+  /// Every item in this list is unique.
+  std::vector<const VarDecl *> Variables;
+
----------------
I've a feeling this is essentially a `map<const VarDecl *, size_t>`, because that harmonizes with our access patterns (lookup number by variable, insert the new value `Variables.size()` if not found). So i think a map would express the intention more clearly.

================
Comment at: lib/Analysis/CloneDetection.cpp:168
@@ +167,3 @@
+    assert(Other.Occurences.size() == Occurences.size());
+    for (unsigned i = 0; i < Occurences.size(); ++i) {
+      if (Occurences[i].KindID != Other.Occurences[i].KindID) {
----------------
Because your code uses a lot of fancy C++11, i'd probably suggest to make it even prettier with `std::all_of()`.


https://reviews.llvm.org/D22982





More information about the cfe-commits mailing list