[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
Wed Aug 3 08:05:01 PDT 2016


NoQ accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: lib/Analysis/CloneDetection.cpp:99
@@ +98,3 @@
+  /// Every item in this list is unique.
+  std::vector<const VarDecl *> Variables;
+
----------------
NoQ wrote:
> 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.
Discussed that we're going to have lookups in both directions in the next patch.

================
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) {
----------------
NoQ wrote:
> Because your code uses a lot of fancy C++11, i'd probably suggest to make it even prettier with `std::all_of()`.
Uhm, never mind, iterating two arrays here.


https://reviews.llvm.org/D22982





More information about the cfe-commits mailing list