[PATCH] D23555: [analyzer] CloneDetector now checks template arguments of function calls.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 16 12:25:10 PDT 2016


NoQ added inline comments.

================
Comment at: lib/Analysis/CloneDetection.cpp:154
@@ -153,2 +153,3 @@
     // Function pointers don't have a callee and we just skip hashing it.
-    if (S->getDirectCallee())
+    if (S->getDirectCallee()) {
+      // If the function is a template instantiation, we also need to handle
----------------
Maybe `if (const FunctionDecl *D = S->getDirectCallee())` here, and then use `D` everywhere inside the `if`?

================
Comment at: lib/Analysis/CloneDetection.cpp:164
@@ +163,3 @@
+        for (unsigned i = 0; i < Args->size(); ++i) {
+          Args->get(i).print(Context.getLangOpts(), OS);
+        }
----------------
We don't discriminate between `foo<A, AA>()` and `foo<AA, A>()` here, because in both cases the stuff we hash gets concatenated to `AAA`. Just thought that we might be having this common problem everywhere, even though it barely shows up "in real life".

================
Comment at: test/Analysis/copypaste/call.cpp:41
@@ +40,3 @@
+template<typename T, unsigned N>
+bool tempFunc() { unsigned i = N; return false; }
+
----------------
"temp" feels a lot more like "temporary" than like "template" (?)


https://reviews.llvm.org/D23555





More information about the cfe-commits mailing list