[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 27 23:36:19 PDT 2017


NoQ added a comment.

Thanks! Because LLVM's Illinois license is rather permissive than copyleft, we try to avoid stuff copied from GPL/LGPL software (such as Qt or K3B) in our codebase. The code doesn't seem to have been copy-pasted from a copyleft project, but I guess it's better to rename the file to avoid referencing to K3B, and i added inline comments regarding `moc` intro comments.



================
Comment at: lib/Analysis/CloneDetection.cpp:377
+    StringRef Filename = SM.getFilename(D->getLocation());
+    if (Filename.find(StringRef("moc_")) != StringRef::npos ||
+        Filename.find(StringRef("_automoc.")) != StringRef::npos ||
----------------
Maybe `.startswith("moc_")` would be more accurate?

In fact, you could also try to use a single LLVM regex here.


================
Comment at: test/Analysis/copypaste/k3blib_automoc.cpp:5-7
+/* This file is autogenerated, do not edit*/
+
+// clang -E RealMetaObjectCompiler_automoc.cpp > ~/PreprocessedMOC_automoc.cpp
----------------
Other LLVM contributors are free to edit this file, and i doubt it was autogenerated; i believe these comments should be removed.

That said, there should be a comment explaining why the file has no warning. Eg.:
```
// Because files that have `_automoc' in their names are most likely autogenerated,
// we suppress copy-paste warnings here.

// expected-no-diagnostics
```

(same in the other file)


================
Comment at: test/Analysis/copypaste/k3blib_automoc.cpp:16
+  }
+  // Copy-paste above block but careless forget to change something
+  if (p2) {
----------------
My idea regarding the comment above would make this comment unnecessary. (same in the other file)


================
Comment at: test/Analysis/copypaste/moc_k3bactivepipe.cpp:5-13
+/****************************************************************************
+** Meta object code from reading C++ file 'k3bactivepipe.h'
+**
+** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
----------------
This file wasn't in fact created by `moc`, does not seem to be anyhow related to `k3b`; i believe these comments should be removed.


Repository:
  rL LLVM

https://reviews.llvm.org/D31320





More information about the cfe-commits mailing list