[PATCH] D23316: [analyzer] Fixed the false-positives caused by macro generated code.

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 9 13:31:21 PDT 2016


v.g.vassilev added inline comments.

================
Comment at: lib/Analysis/CloneDetection.cpp:431
@@ +430,3 @@
+    // level of it's containing clone. This prevents false-positives caused by
+    // complex macros. For example 'assert(false)' could be reported as a clone
+    // if the assert macro is implemented as a expression that would
----------------
What are complex macros? Could you clarify?

================
Comment at: test/Analysis/copypaste/macro-complexity.cpp:19
@@ +18,3 @@
+// Prevents that this tests won't accidentially pass because the code inside
+// the macro isn't complex enough.
+int foo(int a, int b) {  // expected-warning{{Detected code clone.}}
----------------
I am not sure I understand this comment. Could you reword?

================
Comment at: test/Analysis/copypaste/macros.cpp:11
@@ +10,3 @@
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  return a > b ? a : b;
+}
----------------
Wouldn't it be a good idea to have a fixit hint, saying "Did you mean to use ABS(a,b)". If the suggestion is applied, it would make the code more consistent, however it would encourage using preprocessor tricks (which is not always considered as good practice).


https://reviews.llvm.org/D23316





More information about the cfe-commits mailing list